- 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.
191 lines
6.5 KiB
PHP
191 lines
6.5 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.
|
|
************************************************************************************/
|
|
|
|
class ITS4YouGoogleCalendarSync_GoogleToVtigerMapping_Model extends ITS4YouGoogleCalendarSync_VtigerToGoogleMapping_Model
|
|
{
|
|
protected $usedCalendarIds = array();
|
|
|
|
public function __construct(array $values = array())
|
|
{
|
|
parent::__construct($values);
|
|
}
|
|
|
|
public static function getInstance($user = false)
|
|
{
|
|
$adb = PearDatabase::getInstance();
|
|
|
|
if (!$user) {
|
|
$user = Users_Record_Model::getCurrentUserModel();
|
|
}
|
|
|
|
$sql = "SELECT * FROM its4you_google_googleVtigerMap WHERE userid= ?";
|
|
$res = $adb->pquery($sql, array($user->getId()));
|
|
$tableValues = array();
|
|
$usedCalendars = array();
|
|
if ($adb->getRowCount($res) > 0) {
|
|
while ($row = $adb->fetchByAssoc($res)) {
|
|
$tableValues[$row['google_calendarid']] = $row['activitytype'];
|
|
$usedCalendars[$row['google_calendarid']] = $row['google_calendarid'];
|
|
}
|
|
|
|
$instance = new self();
|
|
$instance->setData($tableValues);
|
|
$instance->setUsedCalendarIds($usedCalendars);
|
|
|
|
return $instance;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static function getActivityTypeByCalendarId($calendarId, $user = false)
|
|
{
|
|
$adb = PearDatabase::getInstance();
|
|
if (!$user) {
|
|
$user = Users_Record_Model::getCurrentUserModel();
|
|
}
|
|
|
|
$sql = "SELECT activitytype FROM its4you_google_googleVtigerMap WHERE google_calendarid=? AND userid= ?";
|
|
$res = $adb->pquery($sql, array($calendarId, $user->getId()));
|
|
|
|
$activityType = null;
|
|
if ($adb->getRowCount($res) > 0) {
|
|
while ($row = $adb->fetchByAssoc($res)) {
|
|
$activityType = $row['activitytype'];
|
|
}
|
|
}
|
|
|
|
return $activityType;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getUsedCalendarIds()
|
|
{
|
|
return $this->usedCalendarIds;
|
|
}
|
|
|
|
/**
|
|
* @param array $usedCalendarIds
|
|
*/
|
|
public function setUsedCalendarIds($usedCalendarIds)
|
|
{
|
|
$this->usedCalendarIds = $usedCalendarIds;
|
|
}
|
|
|
|
public function initializeData()
|
|
{
|
|
$adb = PearDatabase::getInstance();
|
|
|
|
$sql = "SELECT * FROM its4you_google_googleVtigerMap WHERE userid = ?";
|
|
$result = $adb->pquery($sql, array($this->getCurrentUserModel()->getId()));
|
|
|
|
while ($row = $adb->fetchByAssoc($result)) {
|
|
$this->set($row['google_calendarid'], $row['activitytype']);
|
|
$this->usedCalendarIds[$row['google_calendarid']] = $row['google_calendarid'];
|
|
}
|
|
}
|
|
|
|
//TODO rename to getCalendarsFromGoogle()
|
|
|
|
public function existVtigerToGoogleMapping($userId = null)
|
|
{
|
|
if (empty($userId)) {
|
|
$userId = $this->getCurrentUserModel()->getId();
|
|
}
|
|
|
|
$adb = PearDatabase::getInstance();
|
|
$sql = "SELECT 1 FROM its4you_google_vtigerGoogleMap WHERE userid = ?";
|
|
$result = $adb->pquery($sql, array($userId));
|
|
|
|
return ($adb->getRowCount($result) > 0) ? true : false;
|
|
}
|
|
|
|
/**
|
|
* @param $client ITS4YouGoogleCalendarSync_GoogleClient_Model
|
|
* @param null $userId
|
|
* @return array
|
|
*/
|
|
public function getCalendarList($client, $userId = null)
|
|
{
|
|
$calendarList = $client->getCalendarList();
|
|
$usedCalendars = $this->getUsedCalendarsInVtigerToGoogleMapping();
|
|
|
|
if (empty($userId)) {
|
|
$userId = $this->getCurrentUserModel()->getId();
|
|
}
|
|
|
|
$result = array();
|
|
/**
|
|
* @var $calendar Google_Service_Calendar_Calendar
|
|
*/
|
|
foreach ($calendarList as $calendar) {
|
|
$myCalendar = ITS4YouGoogleCalendarSync_GoogleCalendar_Model::getInstanceFromGoogleCalendarInstace($calendar);
|
|
if (in_array($calendar->getId(), $usedCalendars)) {
|
|
$myCalendar->initializePicklistValuesForUser($userId);
|
|
}
|
|
|
|
$result[$myCalendar->getId()] = $myCalendar;
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function getUsedCalendarsInVtigerToGoogleMapping()
|
|
{
|
|
$adb = PearDatabase::getInstance();
|
|
$currentUser = parent::getCurrentUserModel();
|
|
|
|
$sql = "SELECT google_calendarid FROM " . parent::getTableName() . " WHERE userid = ?";
|
|
$result = $adb->pquery($sql, array($currentUser->getId()));
|
|
|
|
$usedCalendars = array();
|
|
if ($adb->num_rows($result) > 0) {
|
|
while ($row = $adb->fetchByAssoc($result)) {
|
|
if ($row['google_calendarid'] != 'none') {
|
|
$usedCalendars[$row['google_calendarid']] = $row['google_calendarid'];
|
|
}
|
|
}
|
|
}
|
|
|
|
return $usedCalendars;
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$adb = PearDatabase::getInstance();
|
|
|
|
$currentUser = $this->getCurrentUserModel();
|
|
|
|
$delete = 'DELETE FROM its4you_google_googleVtigerMap WHERE userid=?';
|
|
$adb->pquery($delete, array($currentUser->getId()));
|
|
|
|
foreach ($this->getData() as $key => $value) {
|
|
$insert = 'INSERT INTO its4you_google_googleVtigerMap (activitytype, google_calendarid, userid) VALUES (?,?,?)';
|
|
$adb->pquery($insert, array($value, $key, $currentUser->getId()));
|
|
}
|
|
}
|
|
|
|
public function remove($calendarId)
|
|
{
|
|
$adb = PearDatabase::getInstance();
|
|
$adb->setDebug(true);
|
|
|
|
$currentUser = $this->getCurrentUserModel();
|
|
|
|
$select = "SELECT 1 FROM its4you_google_googleVtigerMap WHERE google_calendarid=? AND userid=?";
|
|
$result = $adb->pquery($select, array($calendarId, $currentUser->getId()));
|
|
|
|
if ($adb->getRowCount($result) > 0) {
|
|
$delete = "DELETE FROM its4you_google_googleVtigerMap WHERE google_calendarid=? and userid=?";
|
|
$adb->pquery($delete, array($calendarId, $currentUser->getId()));
|
|
}
|
|
}
|
|
} |