- 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.
266 lines
9.3 KiB
PHP
266 lines
9.3 KiB
PHP
<?php
|
|
/*+**********************************************************************************
|
|
* The content of this file is subject to the ITS4GoogleCalendarSync license.
|
|
* ("License"); You may not use this file except in compliance with the License
|
|
* The Initial Developer of the Original Code is IT-Solutions4You s.r.o.
|
|
* Portions created by IT-Solutions4You s.r.o. are Copyright(C) IT-Solutions4You s.r.o.
|
|
* All Rights Reserved.
|
|
************************************************************************************/
|
|
|
|
require_once 'modules/Webforms/model/WebformsModel.php';
|
|
require_once 'include/Webservices/DescribeObject.php';
|
|
|
|
vimport('~~/modules/WSAPP/Utils.php');
|
|
|
|
class ITS4YouGoogleCalendarSync
|
|
{
|
|
public $moduleName = 'ITS4YouGoogleCalendarSync';
|
|
public $parentName = 'Tools';
|
|
protected static $moduleDescribeCache = array();
|
|
public $list_fields_name = [];
|
|
public $list_fields = [];
|
|
public $LBL_SETTINGS_NAME = 'ITS4You Google Cal Sync';
|
|
public $LBL_MODULE_NAME = 'Google Calendar Synchronization';
|
|
|
|
// Cache to speed up describe information store
|
|
public $LBL_MODULE_NAME_OLD = 'Google Calendar Synchronization';
|
|
|
|
/**
|
|
* [module, type, label, url, icon, sequence, handlerInfo]
|
|
* @return array
|
|
*/
|
|
public $registerCustomLinks = [
|
|
['ITS4YouGoogleCalendarSync', 'HEADERSCRIPT', 'LBL_CALENDAR_SYNC', 'layouts/v7/modules/ITS4YouGoogleCalendarSync/resources/ITS4YouGoogleCalendarSyncHeader.js',],
|
|
['Calendar', 'EXTENSIONLINK', 'ITS4YouGoogleCalendarSync', 'index.php?module=ITS4YouGoogleCalendarSync&view=CalendarSettings',],
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
* [events, file, class, condition, dependOn, modules]
|
|
*/
|
|
public $registerEventHandler = [
|
|
[
|
|
['vtiger.entity.aftersave', 'vtiger.entity.beforedelete', 'vtiger.entity.afterdelete'],
|
|
'modules/ITS4YouGoogleCalendarSync/handlers/EventHandler.php',
|
|
'ITS4YouGoogleCalendarSync_EventHandler_Handler',
|
|
],
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
* [name, handler, frequency, module, sequence, description]
|
|
*/
|
|
public $registerCron = array(
|
|
[
|
|
'Schedule ITS4YouGoogleCalendarSync',
|
|
'modules/ITS4YouGoogleCalendarSync/cron/SheduleITS4YouGoogleCalendarSync.service',
|
|
900,
|
|
'ITS4YouGoogleCalendarSync',
|
|
0,
|
|
'Recommended frequency for Calendar Synchronization is 15 mins'
|
|
],
|
|
);
|
|
/**
|
|
* @var PearDatabase
|
|
*/
|
|
public $db;
|
|
|
|
/**
|
|
* @var Logger|object
|
|
*/
|
|
public $log;
|
|
|
|
public function __construct()
|
|
{
|
|
global $log, $currentModule;
|
|
|
|
$this->db = PearDatabase::getInstance();
|
|
$this->log = $log;
|
|
}
|
|
|
|
public static function checkAdminAccess($user)
|
|
{
|
|
}
|
|
|
|
public static function getModuleDescribe($module)
|
|
{
|
|
}
|
|
|
|
public static function getFieldInfo($module, $fieldname)
|
|
{
|
|
}
|
|
|
|
public static function getFieldInfos($module)
|
|
{
|
|
}
|
|
|
|
public function retrieveDeleteCustomLinks()
|
|
{
|
|
$this->registerCustomLinks[] = ['ITS4YouGoogleCalendarSync', 'HEADERSCRIPT', 'LBL_CALENDAR_SYNC', 'layouts/v7/modules/ITS4YouGoogleCalendarSync/resources/ITS4YouGoogleCalendarSyncHeader.js',];
|
|
$this->registerCustomLinks[] = ['Calendar', 'EXTENSIONLINK', 'ITS4YouGoogleCalendarSync', 'index.php?module=ITS4YouGoogleCalendarSync&view=CalendarSettings',];
|
|
|
|
$this->registerCustomLinks[] = ['Calendar', 'EXTENSIONLINK', 'ITS4YouGoogleCalendarSync', 'index.php?module=ITS4YouGoogleCalendarSync&view=CalendarSettings',];
|
|
$this->registerCustomLinks[] = ['Calendar', 'HEADERSCRIPT', 'LBL_CALENDAR_SYNC', 'layouts/v7/modules/ITS4YouGoogleCalendarSync/resources/ITS4YouGoogleCalendarSyncHeader.js',];
|
|
$this->registerCustomLinks[] = ['Calendar', 'SIDEBARWIDGET', 'Google Synchronization', 'module=ITS4YouGoogleCalendarSync&view=List',];
|
|
$this->registerCustomLinks[] = ['Calendar', 'HEADERSCRIPT', 'LBL_CALENDAR_SYNC', 'layouts/vlayout/modules/ITS4YouGoogleCalendarSync/resources/CalendarSidebarWidget.js',];
|
|
}
|
|
|
|
/**
|
|
* @param string $moduleName
|
|
* @param string $eventType
|
|
* @return void
|
|
* @throws Exception
|
|
*/
|
|
public function vtlib_handler($moduleName, $eventType)
|
|
{
|
|
/** @var ITS4YouGoogleCalendarSync_Module_Model $moduleModel */
|
|
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
|
|
|
|
switch ($eventType) {
|
|
case 'module.postinstall':
|
|
case 'module.postupdate':
|
|
case 'module.enabled':
|
|
$moduleModel->addCustomLinks();
|
|
$this->addCustomLinks();
|
|
break;
|
|
case 'module.disabled':
|
|
case 'module.preupdate':
|
|
case 'module.preuninstall':
|
|
$moduleModel->deleteCustomLinks();
|
|
$this->deleteCustomLinks();
|
|
break;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function addCustomLinks()
|
|
{
|
|
$this->updateSettings();
|
|
$this->updateCron();
|
|
$this->updateCustomLinks();
|
|
$this->updateEventHandler();
|
|
|
|
Settings_MenuEditor_Module_Model::addModuleToApp($this->moduleName, $this->parentName);
|
|
}
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function updateSettings($enabled = true)
|
|
{
|
|
$name = $this->LBL_SETTINGS_NAME;
|
|
$image = '';
|
|
$description = '';
|
|
$linkTo = 'index.php?module=ITS4YouGoogleCalendarSync&parent=Settings&view=List';
|
|
|
|
$result1 = $this->db->pquery('SELECT 1 FROM vtiger_settings_field WHERE name=?', array($name));
|
|
if (!$this->db->num_rows($result1)) {
|
|
if ($enabled) {
|
|
$fieldId = $this->db->getUniqueID('vtiger_settings_field');
|
|
$blockId = getSettingsBlockId('LBL_INTEGRATION');
|
|
$seq_res = $this->db->pquery(
|
|
'SELECT max(sequence) AS max_seq FROM vtiger_settings_field WHERE blockid = ?',
|
|
[$blockId]
|
|
);
|
|
$sequence = intval($this->db->query_result($seq_res, 0, 'max_seq')) + 1;
|
|
|
|
$this->db->pquery(
|
|
'INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence) VALUES (?,?,?,?,?,?,?)',
|
|
[$fieldId, $blockId, $name, $image, $description, $linkTo, $sequence]
|
|
);
|
|
}
|
|
} else {
|
|
$this->db->pquery(
|
|
'UPDATE vtiger_settings_field SET active= ? WHERE name= ?',
|
|
[($enabled ? '0' : '1'), $name]
|
|
);
|
|
}
|
|
}
|
|
|
|
public function updateCron($register = true)
|
|
{
|
|
$this->db->pquery('ALTER TABLE vtiger_cron_task MODIFY COLUMN id INT auto_increment ');
|
|
|
|
foreach ($this->registerCron as $cronInfo) {
|
|
list($name, $handler, $frequency, $module, $sequence, $description) = $cronInfo;
|
|
|
|
Vtiger_Cron::deregister($name);
|
|
|
|
if ($register) {
|
|
Vtiger_Cron::register($name, $handler, $frequency, $module, 1, $sequence, $description);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param bool $register
|
|
*/
|
|
public function updateCustomLinks($register = true)
|
|
{
|
|
foreach ($this->registerCustomLinks as $customLink) {
|
|
$module = Vtiger_Module::getInstance($customLink[0]);
|
|
$type = $customLink[1];
|
|
$label = $customLink[2];
|
|
$url = str_replace('$LAYOUT$', Vtiger_Viewer::getDefaultLayoutName(), $customLink[3]);
|
|
|
|
if ($module) {
|
|
$module->deleteLink($type, $label);
|
|
|
|
if ($register) {
|
|
$module->addLink($type, $label, $url, $customLink[4], $customLink[5], $customLink[6]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param bool $register
|
|
*/
|
|
public function updateEventHandler($register = true)
|
|
{
|
|
$eventsManager = new VTEventsManager($this->db);
|
|
|
|
foreach ($this->registerEventHandler as $data) {
|
|
list($events, $fileName, $className, $condition, $dependOn, $modules) = $data;
|
|
|
|
$eventsManager->unregisterHandler($className);
|
|
|
|
if ($register) {
|
|
$condition = !empty($condition) ? $condition : '';
|
|
$dependOn = !empty($dependOn) ? $dependOn : '[]';
|
|
|
|
foreach ((array)$events as $event) {
|
|
$eventsManager->registerHandler($event, $fileName, $className, $condition, $dependOn);
|
|
|
|
foreach ((array)$modules as $module) {
|
|
$eventsManager->setModuleForHandler($module, $className);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function deleteCustomLinks()
|
|
{
|
|
$this->updateSettings(false);
|
|
$this->updateSettings(false);
|
|
$this->updateCron(false);
|
|
|
|
$this->retrieveDeleteCustomLinks();
|
|
$this->updateCustomLinks(false);
|
|
$this->updateEventHandler(false);
|
|
}
|
|
|
|
public function removeSettings()
|
|
{
|
|
$this->db->pquery(
|
|
'DELETE FROM vtiger_settings_field WHERE name= ?',
|
|
[$this->LBL_SETTINGS_NAME]
|
|
);
|
|
}
|
|
} |