Files
crm.clientright.ru/modules/VDNotifierPro/VDNotifierProHandler.php
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

141 lines
5.9 KiB
PHP

<?php
/* * *******************************************************************************
* The content of this file is subject to the VD VDNotifier Pro license.
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is http://www.vordoom.net
* Portions created by Vordoom.net are Copyright(C) Vordoom.net
* All Rights Reserved.
* ****************************************************************************** */
class VDNotifierProHandler extends VTEventHandler{
private static $oldEntity;
private static $newEntity;
private static $entityDelta;
function handleEvent($eventName, $data) {
global $log, $current_module, $adb, $current_user;
if (!vtlib_isModuleActive('VDNotifierPro')) {
return true;
}
$moduleName = $data->getModuleName();
$setting = VDNotifierPro_Module_Model::getSetting($moduleName);
$VDNotifier = new VDNotifierPro_Record_Model();
$item_summary = false;
if ($setting['status']==0) return;
if($eventName == 'vtiger.entity.aftersave') {
if ($data->isNew()){
if ($setting['newentity']==1) {
$VDNotifier->action = 'CREATED';
}
}
else {
if ($setting['updateentity']==1) {
$VDNotifier->action = 'UPDATED';
}
}
}
elseif ($eventName == 'vtiger.entity.beforedelete'){
$VDNotifier->action = 'DELETED';
$item_summary = true;
}
elseif ($eventName == 'vtiger.entity.afterrestore'){
$VDNotifier->action = 'RESTORED';
$item_summary = true;
}
$VDNotifier->modiuserid = $data->get('modifiedby');
$recordId = $data->getId();
$crmentity = VDNotifierPro_Record_Model::findCrmid($recordId);
$vtEntityDelta = new VTEntityDelta();
$delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
$VDNotifier->modifiedtime = $delta['modifiedtime']['currentValue'];
$recordModel = Vtiger_Record_Model::getInstanceById( $recordId, $moduleName);
$link = $recordModel->getDetailViewUrl();
$focus = CRMEntity::getInstance($moduleName);
$VDNotifier->title = $recordModel->getName();;
$VDNotifier->link = str_replace('index.php?', '', $link);;
$item_summary = false;
$notifUserId = self::chekVDNotifier($crmentity,$setting,$delta,$data->get('modifiedby'));
if (!count($notifUserId)) return;
$VDNotifier->crmid = $recordId = $data->getId();
$VDNotifier->modulename = $moduleName;
if (!$item_summary){
$arrayDelta = array();
$i=0;
foreach ($delta as $fieldName=>$field){
if ($fieldName != 'modifiedtime' && $fieldName != 'modifiedby'){
if (empty($field['oldValue'])) $arrayDelta[$i]['type'] = 'new';
elseif (empty($field['currentValue'])) $arrayDelta[$i]['type'] = 'delete';
else $arrayDelta[$i]['type'] = 'change';
$arrayDelta[$i]['oldValue'] = $field['oldValue'];
$arrayDelta[$i]['currentValue'] = $field['currentValue'];
$arrayDelta[$i]['fieldName'] = $fieldName;
$i++;
}
}
if (count($arrayDelta)){
$item_summary = true;
$VDNotifier->item_summary = Zend_Json::encode($arrayDelta);
}
}
if ($item_summary){
foreach ($notifUserId as $userId){
$VDNotifier->userid = $userId;
$VDNotifier->save($adb);
}
}
return;
}
function getAction($moduleName, $recordId) {
$moduleModel = Vtiger_DetailView_Model::getInstance($moduleName, $recordId);
$recordModel = $moduleModel->getRecord();
$link = $recordModel->getDetailViewUrl();
$label = $recordModel->getName();
$link = str_replace('index.php?', '', $link);
return array('link'=>$link,'title'=>$label);
}
function chekVDNotifier($crmentity,$setting,$delta,$curen_user_id){
$notifUserId = array();
if ($curen_user_id != $crmentity['smcreatorid'] && $setting['creator']==1){
$notifUserId[] = $crmentity['smcreatorid'];
}
if ($curen_user_id != $crmentity['smownerid'] && $setting['owner']==1){
$notifUserId[] = $crmentity['smownerid'];
}
if ($setting['modif'] == 1 && isset($delta['modifiedby'])){
if ($delta['modifiedby']['oldValue'] != $crmentity['smcreatorid'] && $delta['modifiedby']['oldValue'] != $crmentity['smownerid']){
$notifUserId[] = $delta['modifiedby']['oldValue'];
}
}
return array_unique($notifUserId);
}
}