🚀 CRM Files Migration & Real-time Features

 Features:
- Migrated ALL files to new S3 structure (Projects, Contacts, Accounts, HelpDesk, Invoice, etc.)
- Added Nextcloud folder buttons to ALL modules
- Fixed Nextcloud editor integration
- WebSocket server for real-time updates
- Redis Pub/Sub integration
- File path manager for organized storage
- Redis caching for performance (Functions.php)

📁 New Structure:
Documents/Project/ProjectName_ID/file_docID.ext
Documents/Contacts/FirstName_LastName_ID/file_docID.ext
Documents/Accounts/AccountName_ID/file_docID.ext

🔧 Technical:
- FilePathManager for standardized paths
- S3StorageService integration
- WebSocket server (Node.js + Docker)
- Redis cache for getBasicModuleInfo()
- Predis library for Redis connectivity

📝 Scripts:
- Migration scripts for all modules
- Test pages for WebSocket/SSE/Polling
- Documentation (MIGRATION_*.md, REDIS_*.md)

🎯 Result: 15,000+ files migrated successfully!
This commit is contained in:
Fedor
2025-10-24 19:59:28 +03:00
parent 3fb2ad5f60
commit 9245768987
1062 changed files with 161778 additions and 16212 deletions

View File

@@ -15,6 +15,9 @@
class Vtiger_Functions {
const LINK_TO_ANCHOR_TEXT_SYMBOL = '#';
// Redis кеш для ускорения
protected static $redisCache = null;
static function userIsAdministrator($user) {
return (isset($user->is_admin) && $user->is_admin == 'on');
@@ -113,25 +116,70 @@ class Vtiger_Functions {
protected static $moduleIdNameCache = array();
protected static $moduleNameIdCache = array();
protected static $moduleIdDataCache = array();
/**
* Инициализация Redis кеша
*/
protected static function getRedisCache() {
if (self::$redisCache === null) {
try {
require_once __DIR__ . '/../../crm_extensions/RedisCache.php';
self::$redisCache = new RedisCache();
} catch (Exception $e) {
// Redis недоступен - работаем без кеша
self::$redisCache = false;
}
}
return self::$redisCache;
}
protected static function getBasicModuleInfo($mixed) {
$id = $name = NULL;
if (is_numeric($mixed)) $id = $mixed;
else $name = $mixed;
// Сначала проверяем статический кеш (память)
$reload = false;
if ($name) {
if (!isset(self::$moduleNameIdCache[$name])) {$reload = true;}
} else if ($id) {
if (!isset(self::$moduleIdNameCache[$id])) {$reload = true;}
}
if ($reload) {
global $adb;
$result = $adb->pquery('SELECT tabid, name, ownedby FROM vtiger_tab', array());
while ($row = $adb->fetch_array($result)) {
self::$moduleIdNameCache[$row['tabid']] = $row;
self::$moduleNameIdCache[$row['name']] = $row;
// Пробуем Redis кеш
$cache = self::getRedisCache();
if ($cache && $cache->isEnabled()) {
$allModules = $cache->get('all_modules_info');
if ($allModules) {
// Загружаем из Redis в статический кеш
foreach ($allModules as $row) {
self::$moduleIdNameCache[$row['tabid']] = $row;
self::$moduleNameIdCache[$row['name']] = $row;
}
$reload = false;
}
}
// Если Redis не помог - загружаем из БД
if ($reload) {
global $adb;
$result = $adb->pquery('SELECT tabid, name, ownedby FROM vtiger_tab', array());
$allModules = [];
while ($row = $adb->fetch_array($result)) {
self::$moduleIdNameCache[$row['tabid']] = $row;
self::$moduleNameIdCache[$row['name']] = $row;
$allModules[] = $row;
}
// Сохраняем в Redis на 24 часа
if ($cache && $cache->isEnabled()) {
$cache->set('all_modules_info', $allModules, 86400);
}
}
}
return $id ? self::$moduleIdNameCache[$id] : self::$moduleNameIdCache[$name];
}