- 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.
121 lines
4.9 KiB
PHP
121 lines
4.9 KiB
PHP
<?php
|
|
/* ********************************************************************************
|
|
* The content of this file is subject to the Mobile App 4 You 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.
|
|
* ****************************************************************************** */
|
|
|
|
include_once('modules/CustomView/CustomView.php');
|
|
|
|
class ITS4YouMobileApp_ListView_Model extends Vtiger_Base_Model
|
|
{
|
|
public static function getInstance($moduleName, $viewId = '0', $listHeaders = array())
|
|
{
|
|
$db = PearDatabase::getInstance();
|
|
$currentUser = vglobal('current_user');
|
|
|
|
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $moduleName);
|
|
$instance = new $modelClassName();
|
|
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
|
|
$queryGenerator = new EnhancedQueryGenerator($moduleModel->get('name'), $currentUser);
|
|
|
|
if (!empty($viewId) && $viewId != "0") {
|
|
$queryGenerator->initForCustomViewById($viewId);
|
|
|
|
} else {
|
|
$viewId = self::getDefaultViewId($moduleName);
|
|
|
|
if (!empty($viewId) && $viewId != 0) {
|
|
$queryGenerator->initForDefaultCustomView();
|
|
} else {
|
|
$entityInstance = CRMEntity::getInstance($moduleName);
|
|
$listFields = $entityInstance->list_fields_name;
|
|
$listFields[] = 'id';
|
|
$queryGenerator->setFields($listFields);
|
|
}
|
|
}
|
|
|
|
$fieldsList = $queryGenerator->getFields();
|
|
|
|
if (!empty($listHeaders) && is_array($listHeaders) && self::php7_count($listHeaders) > 0) {
|
|
$fieldsList = $listHeaders;
|
|
$fieldsList[] = 'id';
|
|
}
|
|
|
|
$fieldsList[] = 'starred';
|
|
$queryGenerator->setFields($fieldsList);
|
|
$moduleSpecificControllerPath = 'modules/' . $moduleName . '/controllers/ListViewController.php';
|
|
|
|
if (file_exists($moduleSpecificControllerPath)) {
|
|
include_once $moduleSpecificControllerPath;
|
|
$moduleSpecificControllerClassName = $moduleName . 'ListViewController';
|
|
$controller = new $moduleSpecificControllerClassName($db, $currentUser, $queryGenerator);
|
|
} else {
|
|
$controller = new ListViewController($db, $currentUser, $queryGenerator);
|
|
}
|
|
|
|
return $instance->set('module', $moduleModel)->set('query_generator', $queryGenerator)->set('listview_controller', $controller);
|
|
}
|
|
|
|
public static function getInstanceForPopup($value)
|
|
{
|
|
$db = PearDatabase::getInstance();
|
|
$currentUser = vglobal('current_user');
|
|
|
|
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $value);
|
|
$instance = new $modelClassName();
|
|
$moduleModel = Vtiger_Module_Model::getInstance($value);
|
|
|
|
$queryGenerator = new EnhancedQueryGenerator($moduleModel->get('name'), $currentUser);
|
|
|
|
$listFields = $moduleModel->getPopupViewFieldsList();
|
|
|
|
$listFields[] = 'id';
|
|
$queryGenerator->setFields($listFields);
|
|
|
|
$controller = new ListViewController($db, $currentUser, $queryGenerator);
|
|
|
|
return $instance->set('module', $moduleModel)->set('query_generator', $queryGenerator)->set('listview_controller', $controller);
|
|
}
|
|
|
|
protected static function getDefaultViewId($moduleName)
|
|
{
|
|
global $adb, $current_user;
|
|
|
|
$defCVResult = $adb->pquery(
|
|
'select default_cvid from vtiger_user_module_preferences where userid = ? and tabid =?',
|
|
[$current_user->id, getTabid($moduleName)]
|
|
);
|
|
|
|
if (0 < $adb->num_rows($defCVResult)) {
|
|
$viewId = $adb->query_result($defCVResult, 0, 'default_cvid');
|
|
} else {
|
|
$viewId = '';
|
|
$query = 'select cvid from vtiger_customview where setdefault=1 and entitytype=?';
|
|
$cvResult = $adb->pquery($query, [$moduleName]);
|
|
|
|
if (0 < $adb->num_rows($cvResult)) {
|
|
$viewId = $adb->query_result($cvResult, 0, 'cvid');
|
|
}
|
|
}
|
|
|
|
$customView = new CustomView($moduleName);
|
|
|
|
if (!empty($viewId) || 'yes' !== $customView->isPermittedCustomView($viewId, '', $moduleName)) {
|
|
$query = "select cvid from vtiger_customview where viewname='All' and entitytype=?";
|
|
$cvResult = $adb->pquery($query, [$moduleName]);
|
|
$viewId = $adb->query_result($cvResult, 0, 'cvid');
|
|
}
|
|
|
|
return $viewId;
|
|
}
|
|
|
|
protected static function php7_count($value) {
|
|
// PHP 8.x does not allow count(null) or count(string)
|
|
if (is_null($value)) return 0;
|
|
if (!is_array($value)) return 1;
|
|
return count($value);
|
|
}
|
|
} |