- 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.
160 lines
6.0 KiB
PHP
160 lines
6.0 KiB
PHP
<?php
|
|
/*+***********************************************************************************
|
|
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
|
* ("License"); You may not use this file except in compliance with the License
|
|
* The Original Code is: vtiger CRM Open Source
|
|
* The Initial Developer of the Original Code is vtiger.
|
|
* Portions created by vtiger are Copyright (C) vtiger.
|
|
* All Rights Reserved.
|
|
*************************************************************************************/
|
|
|
|
class RecycleBin_ListView_Model extends Vtiger_ListView_Model {
|
|
|
|
/**
|
|
* Static Function to get the Instance of Vtiger ListView model for a given module and custom view
|
|
* @param <String> $moduleName - Module Name
|
|
* @param <Number> $viewId - Custom View Id
|
|
* @return Vtiger_ListView_Model instance
|
|
*/
|
|
public static function getInstance($moduleName, $sourceModule) {
|
|
$db = PearDatabase::getInstance();
|
|
$currentUser = vglobal('current_user');
|
|
|
|
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $moduleName);
|
|
$instance = new $modelClassName();
|
|
|
|
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
|
|
$queryGenerator = new EnhancedQueryGenerator($sourceModuleModel->get('name'), $currentUser);
|
|
$cvidObj = CustomView_Record_Model::getAllFilterByModule($sourceModuleModel->get('name'));
|
|
$cvid = $cvidObj->getId('cvid');
|
|
$queryGenerator->initForCustomViewById($cvid);
|
|
|
|
$controller = new ListViewController($db, $currentUser, $queryGenerator);
|
|
|
|
return $instance->set('module', $sourceModuleModel)->set('query_generator', $queryGenerator)->set('listview_controller', $controller);
|
|
}
|
|
|
|
/**
|
|
* Function to get the list view entries
|
|
* @param Vtiger_Paging_Model $pagingModel
|
|
* @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
|
|
*/
|
|
public function getListViewEntries($pagingModel) {
|
|
$db = PearDatabase::getInstance();
|
|
$moduleName = $this->getModule()->get('name');
|
|
$moduleFocus = CRMEntity::getInstance($moduleName);
|
|
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
|
|
|
|
$queryGenerator = $this->get('query_generator');
|
|
$listViewContoller = $this->get('listview_controller');
|
|
|
|
$orderBy = $this->get('orderby');
|
|
$sortOrder = $this->get('sortorder');
|
|
|
|
$searchParams = $this->get('search_params');
|
|
if(empty($searchParams)) {
|
|
$searchParams = array();
|
|
}
|
|
$glue = "";
|
|
if(count($queryGenerator->getWhereFields()) > 0 && (count($searchParams)) > 0) {
|
|
$glue = QueryGenerator::$AND;
|
|
}
|
|
$queryGenerator->parseAdvFilterList($searchParams, $glue);
|
|
|
|
if(!empty($orderBy)){
|
|
$queryGenerator = $this->get('query_generator');
|
|
$fieldModels = $queryGenerator->getModuleFields();
|
|
$orderByFieldModel = $fieldModels[$orderBy];
|
|
if($orderByFieldModel && ($orderByFieldModel->getFieldDataType() == Vtiger_Field_Model::REFERENCE_TYPE ||
|
|
$orderByFieldModel->getFieldDataType() == Vtiger_Field_Model::OWNER_TYPE)){
|
|
$queryGenerator->addWhereField($orderBy);
|
|
}
|
|
}
|
|
if($moduleName == 'Documents'){
|
|
//Document source required in list view for managing delete
|
|
$listViewFields = $queryGenerator->getFields();
|
|
if(!in_array('document_source', $listViewFields)){
|
|
$listViewFields[] = 'document_source';
|
|
}
|
|
$queryGenerator->setFields($listViewFields);
|
|
}
|
|
|
|
$listQuery = $this->getQuery();
|
|
$listQuery = preg_replace("/vtiger_crmentity.deleted\s*=\s*0/i", 'vtiger_crmentity.deleted = 1', $listQuery);
|
|
|
|
$startIndex = $pagingModel->getStartIndex();
|
|
$pageLimit = $pagingModel->getPageLimit();
|
|
|
|
if(!empty($orderBy) && $orderByFieldModel) {
|
|
$listQuery .= ' ORDER BY '.$queryGenerator->getOrderByColumn($orderBy).' '.$sortOrder;
|
|
} else if(empty($orderBy) && empty($sortOrder)){
|
|
//List view will be displayed on recently created/modified records
|
|
$listQuery .= ' ORDER BY vtiger_crmentity.modifiedtime DESC';
|
|
}
|
|
$listQuery .= " LIMIT $startIndex,".($pageLimit+1);
|
|
|
|
$listResult = $db->pquery($listQuery, array());
|
|
$listViewRecordModels = array();
|
|
$listViewEntries = $listViewContoller->getListViewRecords($moduleFocus,$moduleName, $listResult);
|
|
$pagingModel->calculatePageRange($listViewEntries);
|
|
|
|
if($db->num_rows($listResult) > $pageLimit){
|
|
array_pop($listViewEntries);
|
|
$pagingModel->set('nextPageExists', true);
|
|
}else{
|
|
$pagingModel->set('nextPageExists', false);
|
|
}
|
|
|
|
$index = 0;
|
|
foreach($listViewEntries as $recordId => $record) {
|
|
$rawData = $db->query_result_rowdata($listResult, $index++);
|
|
$record['id'] = $recordId;
|
|
$listViewRecordModels[$recordId] = $moduleModel->getRecordFromArray($record, $rawData);
|
|
}
|
|
return $listViewRecordModels;
|
|
}
|
|
|
|
/**
|
|
* Function to get the list view entries
|
|
* @param Vtiger_Paging_Model $pagingModel
|
|
* @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
|
|
*/
|
|
public function getListViewCount() {
|
|
$db = PearDatabase::getInstance();
|
|
|
|
$queryGenerator = $this->get('query_generator');
|
|
|
|
$searchParams = $this->get('search_params');
|
|
if(empty($searchParams)) {
|
|
$searchParams = array();
|
|
}
|
|
|
|
$glue = "";
|
|
if(count($queryGenerator->getWhereFields()) > 0 && (count($searchParams)) > 0) {
|
|
$glue = QueryGenerator::$AND;
|
|
}
|
|
$queryGenerator->parseAdvFilterList($searchParams, $glue);
|
|
|
|
$listQuery = $queryGenerator->getQuery();
|
|
$listQuery = preg_replace("/vtiger_crmentity.deleted\s*=\s*0/i", 'vtiger_crmentity.deleted = 1', $listQuery);
|
|
|
|
$position = stripos($listQuery, ' from ');
|
|
if ($position) {
|
|
$split = preg_split('/ from /i', $listQuery);
|
|
$splitCount = count($split);
|
|
$listQuery = 'SELECT count(*) AS count ';
|
|
for ($i=1; $i<$splitCount; $i++) {
|
|
$listQuery = $listQuery. ' FROM ' .$split[$i];
|
|
}
|
|
}
|
|
|
|
if($this->getModule()->get('name') == 'Calendar'){
|
|
$listQuery .= ' AND activitytype <> "Emails"';
|
|
}
|
|
|
|
$listResult = $db->pquery($listQuery, array());
|
|
$listViewCount = $db->query_result($listResult, 0, 'count');
|
|
return $listViewCount;
|
|
}
|
|
|
|
} |