Files
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

105 lines
3.2 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 Import_Map_Model extends Vtiger_Base_Model {
static $tableName = 'vtiger_import_maps';
var $map;
var $user;
public function __construct($map, $user) {
$this->map = $map;
$this->user = $user;
}
public static function getInstanceFromDb($row, $user) {
$map = array();
foreach($row as $key=>$value) {
if($key == 'content') {
$content = array();
$pairs = explode("&", decode_html($value));
foreach($pairs as $pair) {
list($mappedName, $sequence) = explode("=", $pair);
$mappedName = str_replace('/eq/', '=', $mappedName);
$mappedName = str_replace('/amp/', '&', $mappedName);
$content["$mappedName"] = $sequence;
}
$map[$key] = $content;
} else {
$map[$key] = $value;
}
}
return new Import_Map_Model($map, $user);
}
public static function markAsDeleted($mapId) {
$db = PearDatabase::getInstance();
$db->pquery('UPDATE vtiger_import_maps SET deleted=1 WHERE id=?', array($mapId));
}
public function getId() {
$map = $this->map;
return $map['id'];
}
public function getAllValues() {
return $this->map;
}
public function getValue($key) {
$map = $this->map;
return $map[$key];
}
public function getStringifiedContent() {
if(empty($this->map['content'])) return;
$content = $this->map['content'];
$keyValueStrings = array();
foreach($content as $key => $value) {
$key = str_replace('=', '/eq/', $key);
$key = str_replace('&', '/amp/', $key);
$keyValueStrings[] = $key.'='.$value;
}
$stringifiedContent = implode('&', $keyValueStrings);
return $stringifiedContent;
}
public function save() {
$db = PearDatabase::getInstance();
$map = $this->getAllValues();
$map['content'] = "".$db->getEmptyBlob()."";
$columnNames = array_keys($map);
$columnValues = array_values($map);
if(count($map) > 0) {
$db->pquery('INSERT INTO '.self::$tableName.' ('. implode(',',$columnNames).') VALUES ('. generateQuestionMarks($columnValues).')', array($columnValues));
$db->updateBlob(self::$tableName,"content","name='". $db->sql_escape_string($this->getValue('name')).
"' AND module='".$db->sql_escape_string($this->getValue('module'))."'",$this->getStringifiedContent());
}
}
public static function getAllByModule($moduleName) {
global $current_user;
$db = PearDatabase::getInstance();
$result = $db->pquery('SELECT * FROM '.self::$tableName.' WHERE deleted=0 AND module=?', array($moduleName));
$noOfMaps = $db->num_rows($result);
$savedMaps = array();
for($i=0; $i<$noOfMaps; ++$i) {
$importMap = Import_Map_Model::getInstanceFromDb($db->query_result_rowdata($result, $i), $current_user);
$savedMaps[$importMap->getId()] = $importMap;
}
return $savedMaps;
}
}