[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+********************************************************************************** 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 ************************************************************************************/ 10 11 /** 12 * Class to handle Caching Mechanism and re-use information. 13 */ 14 require_once 'includes/runtime/Cache.php'; 15 class VTCacheUtils { 16 17 /** Tab information caching */ 18 static $_tabidinfo_cache = array(); 19 static function lookupTabid($module) { 20 $flip_cache = array_flip(self::$_tabidinfo_cache); 21 22 if(isset($flip_cache[$module])) { 23 return $flip_cache[$module]; 24 } 25 return false; 26 } 27 28 static function lookupModulename($tabid) { 29 if(isset(self::$_tabidinfo_cache[$tabid])) { 30 return self::$_tabidinfo_cache[$tabid]; 31 } 32 return false; 33 } 34 35 static function updateTabidInfo($tabid, $module) { 36 if(!empty($tabid) && !empty($module)) { 37 self::$_tabidinfo_cache[$tabid] = $module; 38 } 39 } 40 41 /** All tab information caching */ 42 static $_alltabrows_cache = false; 43 static function lookupAllTabsInfo() { 44 return self::$_alltabrows_cache; 45 } 46 static function updateAllTabsInfo($tabrows) { 47 self::$_alltabrows_cache = $tabrows; 48 } 49 50 /** Block information caching */ 51 static $_blocklabel_cache = array(); 52 static function updateBlockLabelWithId($label, $id) { 53 self::$_blocklabel_cache[$id] = $label; 54 } 55 static function lookupBlockLabelWithId($id) { 56 if (isset(self::$_blocklabel_cache[$id])) { 57 return self::$_blocklabel_cache[$id]; 58 } 59 return false; 60 } 61 62 /** Field information caching */ 63 static $_fieldinfo_cache = array(); 64 static function updateFieldInfo($tabid, $fieldname, $fieldid, $fieldlabel, 65 $columnname, $tablename, $uitype, $typeofdata, $presence) { 66 67 self::$_fieldinfo_cache[$tabid][$fieldname] = array( 68 'tabid' => $tabid, 69 'fieldid' => $fieldid, 70 'fieldname' => $fieldname, 71 'fieldlabel'=> $fieldlabel, 72 'columnname'=> $columnname, 73 'tablename' => $tablename, 74 'uitype' => $uitype, 75 'typeofdata'=> $typeofdata, 76 'presence' => $presence, 77 ); 78 Vtiger_Cache::set('fieldInfo', $tabid, self::$_fieldinfo_cache[$tabid]); 79 } 80 static function lookupFieldInfo($tabid, $fieldname) { 81 $fieldInfo = Vtiger_Cache::get('fieldInfo', $tabid); 82 if($fieldInfo && isset($fieldInfo[$fieldname])){ 83 return $fieldInfo[$fieldname]; 84 }else if(isset(self::$_fieldinfo_cache[$tabid]) && isset(self::$_fieldinfo_cache[$tabid][$fieldname])) { 85 return self::$_fieldinfo_cache[$tabid][$fieldname]; 86 } 87 88 $field = Vtiger_Cache::get('field-'.$tabid,$fieldname); 89 if($field){ 90 $cacheField = array( 91 'tabid' => $tabid, 92 'fieldid' => $field->getId(), 93 'fieldname' => $field->getName(), 94 'fieldlabel' => $field->get('label'), 95 'columnname' => $field->get('column'), 96 'tablename' => $field->get('table'), 97 'uitype' => $field->get('uitype'), 98 'typeofdata' => $field->get('typeofdata'), 99 'presence' => $field->get('presence'), 100 ); 101 return $cacheField; 102 } 103 return false; 104 } 105 static function lookupFieldInfo_Module($module, $presencein = array('0', '2')) { 106 $tabid = getTabid($module); 107 $modulefields = false; 108 $fieldInfo = Vtiger_Cache::get('fieldInfo', $tabid); 109 if($fieldInfo){ 110 $fldcache =$fieldInfo; 111 }else if(isset(self::$_fieldinfo_cache[$tabid])) { 112 $fldcache = self::$_fieldinfo_cache[$tabid]; 113 } 114 115 if($fldcache){ 116 $modulefields = array(); 117 118 foreach($fldcache as $fieldname=>$fieldinfo) { 119 if(in_array($fieldinfo['presence'], $presencein)) { 120 $modulefields[] = $fieldinfo; 121 } 122 } 123 } 124 125 $fieldInfo = Vtiger_Cache::get('ModuleFields',$tabid); 126 if($fieldInfo){ 127 foreach($fieldInfo as $block => $blockFields){ 128 foreach ($blockFields as $field){ 129 if(in_array($field->get('presence'), $presencein)) { 130 $cacheField = array( 131 'tabid' => $tabid, 132 'fieldid' => $field->getId(), 133 'fieldname' => $field->getName(), 134 'fieldlabel' => $field->get('label'), 135 'columnname' => $field->get('column'), 136 'tablename' => $field->get('table'), 137 'uitype' => $field->get('uitype'), 138 'typeofdata' => $field->get('typeofdata'), 139 'presence' => $field->get('presence'), 140 ); 141 $modulefields[] = $cacheField; 142 } 143 } 144 } 145 } 146 return $modulefields; 147 } 148 149 static function lookupFieldInfoByColumn($tabid, $columnname) { 150 151 if(isset(self::$_fieldinfo_cache[$tabid])) { 152 foreach(self::$_fieldinfo_cache[$tabid] as $fieldname=>$fieldinfo) { 153 if($fieldinfo['columnname'] == $columnname) { 154 return $fieldinfo; 155 } 156 } 157 } 158 159 $fieldInfo = Vtiger_Cache::get('ModuleFields',$tabid); 160 if($fieldInfo){ 161 foreach($fieldInfo as $block => $blockFields){ 162 foreach ($blockFields as $field){ 163 if($field->get('column') == $columnname) { 164 $cacheField = array( 165 'tabid' => $tabid, 166 'fieldid' => $field->getId(), 167 'fieldname' => $field->getName(), 168 'fieldlabel' => $field->get('label'), 169 'columnname' => $field->get('column'), 170 'tablename' => $field->get('table'), 171 'uitype' => $field->get('uitype'), 172 'typeofdata' => $field->get('typeofdata'), 173 'presence' => $field->get('presence'), 174 ); 175 return $cacheField; 176 } 177 } 178 } 179 } 180 return false; 181 } 182 183 /** Entityname information */ 184 static $_module_entityname_cache = array(); 185 static function updateEntityNameInfo($module, $data) { 186 self::$_module_entityname_cache[$module] = $data; 187 Vtiger_Cache::set('EntityInfo', $module, self::$_module_entityname_cache[$module]); 188 } 189 static function lookupEntityNameInfo($module) { 190 $entityNames = Vtiger_Cache::get('EntityInfo', $module); 191 if($entityNames){ 192 return $entityNames; 193 }else if (isset(self::$_module_entityname_cache[$module])) { 194 return self::$_module_entityname_cache[$module]; 195 } 196 return false; 197 } 198 199 /** Module active column fields caching */ 200 static $_module_columnfields_cache = array(); 201 static function updateModuleColumnFields($module, $column_fields) { 202 self::$_module_columnfields_cache[$module] = $column_fields; 203 } 204 static function lookupModuleColumnFields($module) { 205 if(isset(self::$_module_columnfields_cache[$module])) { 206 return self::$_module_columnfields_cache[$module]; 207 } 208 return false; 209 } 210 211 /** User currency id caching */ 212 static $_usercurrencyid_cache = array(); 213 static function lookupUserCurrenyId($userid) { 214 global $current_user; 215 if(isset($current_user) && $current_user->id == $userid) { 216 return array( 217 'currencyid' => $current_user->column_fields['currency_id'] 218 ); 219 } 220 221 if(isset(self::$_usercurrencyid_cache[$userid])) { 222 return self::$_usercurrencyid_cache[$userid]; 223 } 224 225 return false; 226 } 227 static function updateUserCurrencyId($userid, $currencyid) { 228 self::$_usercurrencyid_cache[$userid] = array( 229 'currencyid' => $currencyid 230 ); 231 } 232 233 /** Currency information caching */ 234 static $_currencyinfo_cache = array(); 235 static function lookupCurrencyInfo($currencyid) { 236 if(isset(self::$_currencyinfo_cache[$currencyid])) { 237 return self::$_currencyinfo_cache[$currencyid]; 238 } 239 return false; 240 } 241 static function updateCurrencyInfo($currencyid, $name, $code, $symbol, $rate) { 242 self::$_currencyinfo_cache[$currencyid] = array( 243 'currencyid' => $currencyid, 244 'name' => $name, 245 'code' => $code, 246 'symbol' => $symbol, 247 'rate' => $rate 248 ); 249 } 250 251 252 /** ProfileId information caching */ 253 static $_userprofileid_cache = array(); 254 static function updateUserProfileId($userid, $profileid) { 255 self::$_userprofileid_cache[$userid] = $profileid; 256 } 257 static function lookupUserProfileId($userid) { 258 if(isset(self::$_userprofileid_cache[$userid])) { 259 return self::$_userprofileid_cache[$userid]; 260 } 261 return false; 262 } 263 264 /** Profile2Field information caching */ 265 static $_profile2fieldpermissionlist_cache = array(); 266 static function lookupProfile2FieldPermissionList($module, $profileid) { 267 $pro2fld_perm = self::$_profile2fieldpermissionlist_cache; 268 if(isset($pro2fld_perm[$module]) && isset($pro2fld_perm[$module][$profileid])) { 269 return $pro2fld_perm[$module][$profileid]; 270 } 271 return false; 272 } 273 static function updateProfile2FieldPermissionList($module, $profileid, $value) { 274 self::$_profile2fieldpermissionlist_cache[$module][$profileid] = $value; 275 } 276 277 /** Role information */ 278 static $_subroles_roleid_cache = array(); 279 static function lookupRoleSubordinates($roleid) { 280 if(isset(self::$_subroles_roleid_cache[$roleid])) { 281 return self::$_subroles_roleid_cache[$roleid]; 282 } 283 return false; 284 } 285 static function updateRoleSubordinates($roleid, $roles) { 286 self::$_subroles_roleid_cache[$roleid] = $roles; 287 } 288 static function clearRoleSubordinates($roleid = false) { 289 if($roleid === false) { 290 self::$_subroles_roleid_cache = array(); 291 } else if(isset(self::$_subroles_roleid_cache[$roleid])) { 292 unset(self::$_subroles_roleid_cache[$roleid]); 293 } 294 } 295 296 /** Record Owner Id */ 297 static $_record_ownerid_cache = array(); 298 static function lookupRecordOwner($record) { 299 if(isset(self::$_record_ownerid_cache[$record])) { 300 return self::$_record_ownerid_cache[$record]; 301 } 302 return false; 303 } 304 305 static function updateRecordOwner($record, $ownerId) { 306 self::$_record_ownerid_cache[$record] = $ownerId; 307 } 308 309 310 /** Record Owner Type */ 311 static $_record_ownertype_cache = array(); 312 static function lookupOwnerType($ownerId) { 313 if(isset(self::$_record_ownertype_cache[$ownerId])) { 314 return self::$_record_ownertype_cache[$ownerId]; 315 } 316 return false; 317 } 318 319 static function updateOwnerType($ownerId, $count) { 320 self::$_record_ownertype_cache[$ownerId] = $count; 321 } 322 323 /** Related module information for Report */ 324 static $_report_listofmodules_cache = false; 325 static function lookupReport_ListofModuleInfos() { 326 return self::$_report_listofmodules_cache; 327 } 328 static function updateReport_ListofModuleInfos($module_list, $related_modules) { 329 if(self::$_report_listofmodules_cache === false) { 330 self::$_report_listofmodules_cache = array( 331 'module_list' => $module_list, 332 'related_modules' => $related_modules 333 ); 334 } 335 } 336 337 /** Report module information based on used. */ 338 static $_reportmodule_infoperuser_cache = array(); 339 static function lookupReport_Info($userid, $reportid) { 340 341 if(isset(self::$_reportmodule_infoperuser_cache[$userid])) { 342 if(isset(self::$_reportmodule_infoperuser_cache[$userid][$reportid])) { 343 return self::$_reportmodule_infoperuser_cache[$userid][$reportid]; 344 } 345 } 346 return false; 347 } 348 static function updateReport_Info($userid, $reportid, $primarymodule, $secondarymodules, $reporttype, 349 $reportname, $description, $folderid, $owner) { 350 if(!isset(self::$_reportmodule_infoperuser_cache[$userid])) { 351 self::$_reportmodule_infoperuser_cache[$userid] = array(); 352 } 353 if(!isset(self::$_reportmodule_infoperuser_cache[$userid][$reportid])) { 354 self::$_reportmodule_infoperuser_cache[$userid][$reportid] = array ( 355 'reportid' => $reportid, 356 'primarymodule' => $primarymodule, 357 'secondarymodules'=> $secondarymodules, 358 'reporttype' => $reporttype, 359 'reportname' => $reportname, 360 'description' => $description, 361 'folderid' => $folderid, 362 'owner' => $owner 363 ); 364 } 365 } 366 367 /** Report module sub-ordinate users information. */ 368 static $_reportmodule_subordinateuserid_cache = array(); 369 static function lookupReport_SubordinateUsers($reportid) { 370 if(isset(self::$_reportmodule_subordinateuserid_cache[$reportid])) { 371 return self::$_reportmodule_subordinateuserid_cache[$reportid]; 372 } 373 return false; 374 } 375 static function updateReport_SubordinateUsers($reportid, $userids) { 376 self::$_reportmodule_subordinateuserid_cache[$reportid] = $userids; 377 } 378 379 /** Report module information based on used. */ 380 static $_reportmodule_scheduledinfoperuser_cache = array(); 381 static function lookupReport_ScheduledInfo($userid, $reportid) { 382 383 if(isset(self::$_reportmodule_scheduledinfoperuser_cache[$userid])) { 384 if(isset(self::$_reportmodule_scheduledinfoperuser_cache[$userid][$reportid])) { 385 return self::$_reportmodule_scheduledinfoperuser_cache[$userid][$reportid]; 386 } 387 } 388 return false; 389 } 390 static function updateReport_ScheduledInfo($userid, $reportid, $isScheduled, $scheduledFormat, $scheduledInterval, $scheduledRecipients, $scheduledTime) { 391 if(!isset(self::$_reportmodule_scheduledinfoperuser_cache[$userid])) { 392 self::$_reportmodule_scheduledinfoperuser_cache[$userid] = array(); 393 } 394 if(!isset(self::$_reportmodule_scheduledinfoperuser_cache[$userid][$reportid])) { 395 self::$_reportmodule_scheduledinfoperuser_cache[$userid][$reportid] = array ( 396 'reportid' => $reportid, 397 'isScheduled' => $isScheduled, 398 'scheduledFormat' => $scheduledFormat, 399 'scheduledInterval' => $scheduledInterval, 400 'scheduledRecipients' => $scheduledRecipients, 401 'scheduledTime' => $scheduledTime, 402 ); 403 } 404 } 405 406 static $_outgoingMailFromEmailAddress; 407 public static function setOutgoingMailFromEmailAddress($email) { 408 self::$_outgoingMailFromEmailAddress = $email; 409 } 410 public static function getOutgoingMailFromEmailAddress() { 411 return self::$_outgoingMailFromEmailAddress; 412 } 413 414 static $_userSignature = array(); 415 public static function setUserSignature($userName, $signature) { 416 self::$_userSignature[$userName] = $signature; 417 } 418 public static function getUserSignature($userName) { 419 return self::$_userSignature[$userName]; 420 } 421 422 static $_userFullName = array(); 423 public static function setUserFullName($userName, $fullName) { 424 self::$_userFullName[$userName] = $fullName; 425 } 426 public static function getUserFullName($userName) { 427 return self::$_userFullName[$userName]; 428 } 429 430 static $_report_field_bylabel = array(); 431 public static function getReportFieldByLabel($module, $label) { 432 return self::$_report_field_bylabel[$module][$label]; 433 } 434 435 public static function setReportFieldByLabel($module, $label, $fieldInfo) { 436 self::$_report_field_bylabel[$module][$label] = $fieldInfo; 437 } 438 } 439 440 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |