[ 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 * Check for image existence in themes orelse 13 * use the common one. 14 */ 15 // Let us create cache to improve performance 16 if(!isset($__cache_vtiger_imagepath)) { 17 $__cache_vtiger_imagepath = Array(); 18 } 19 function vtiger_imageurl($imagename, $themename) { 20 global $__cache_vtiger_imagepath; 21 if($__cache_vtiger_imagepath[$imagename]) { 22 $imagepath = $__cache_vtiger_imagepath[$imagename]; 23 } else { 24 $imagepath = false; 25 // Check in theme specific folder 26 if(file_exists("themes/$themename/images/$imagename")) { 27 $imagepath = "themes/$themename/images/$imagename"; 28 } else if(file_exists("themes/images/$imagename")) { 29 // Search in common image folder 30 $imagepath = "themes/images/$imagename"; 31 } else { 32 // Not found anywhere? Return whatever is sent 33 $imagepath = $imagename; 34 } 35 $__cache_vtiger_imagepath[$imagename] = $imagepath; 36 } 37 return $imagepath; 38 } 39 40 /** 41 * Get module name by id. 42 */ 43 function vtlib_getModuleNameById($tabid) { 44 global $adb; 45 $sqlresult = $adb->pquery("SELECT name FROM vtiger_tab WHERE tabid = ?",array($tabid)); 46 if($adb->num_rows($sqlresult)) return $adb->query_result($sqlresult, 0, 'name'); 47 return null; 48 } 49 50 /** 51 * Get module names for which sharing access can be controlled. 52 * NOTE: Ignore the standard modules which is already handled. 53 */ 54 function vtlib_getModuleNameForSharing() { 55 global $adb; 56 $std_modules = array('Calendar','Leads','Accounts','Contacts','Potentials', 57 'HelpDesk','Campaigns','Quotes','PurchaseOrder','SalesOrder','Invoice','Events'); 58 $modulesList = getSharingModuleList($std_modules); 59 return $modulesList; 60 } 61 62 /** 63 * Cache the module active information for performance 64 */ 65 $__cache_module_activeinfo = Array(); 66 67 /** 68 * Fetch module active information at one shot, but return all the information fetched. 69 */ 70 function vtlib_prefetchModuleActiveInfo($force = true) { 71 global $__cache_module_activeinfo; 72 73 // Look up if cache has information 74 $tabrows = VTCacheUtils::lookupAllTabsInfo(); 75 76 // Initialize from DB if cache information is not available or force flag is set 77 if($tabrows === false || $force) { 78 global $adb; 79 $tabres = $adb->query("SELECT * FROM vtiger_tab"); 80 $tabrows = array(); 81 if($tabres) { 82 while($tabresrow = $adb->fetch_array($tabres)) { 83 $tabrows[] = $tabresrow; 84 $__cache_module_activeinfo[$tabresrow['name']] = $tabresrow['presence']; 85 } 86 // Update cache for further re-use 87 VTCacheUtils::updateAllTabsInfo($tabrows); 88 } 89 } 90 91 return $tabrows; 92 } 93 94 /** 95 * Check if module is set active (or enabled) 96 */ 97 function vtlib_isModuleActive($module) { 98 global $adb, $__cache_module_activeinfo; 99 100 if(in_array($module, vtlib_moduleAlwaysActive())){ 101 return true; 102 } 103 104 if(!isset($__cache_module_activeinfo[$module])) { 105 include 'tabdata.php'; 106 $tabId = $tab_info_array[$module]; 107 $presence = $tab_seq_array[$tabId]; 108 $__cache_module_activeinfo[$module] = $presence; 109 } else { 110 $presence = $__cache_module_activeinfo[$module]; 111 } 112 113 $active = false; 114 //Fix for http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/7991 115 if($presence === 0 || $presence==='0') $active = true; 116 117 return $active; 118 } 119 120 /** 121 * Recreate user privileges files. 122 */ 123 function vtlib_RecreateUserPrivilegeFiles() { 124 global $adb; 125 $userres = $adb->query('SELECT id FROM vtiger_users WHERE deleted = 0'); 126 if($userres && $adb->num_rows($userres)) { 127 while($userrow = $adb->fetch_array($userres)) { 128 createUserPrivilegesfile($userrow['id']); 129 } 130 } 131 } 132 133 /** 134 * Get list module names which are always active (cannot be disabled) 135 */ 136 function vtlib_moduleAlwaysActive() { 137 $modules = Array ( 138 'Administration', 'CustomView', 'Settings', 'Users', 'Migration', 139 'Utilities', 'uploads', 'Import', 'System', 'com_vtiger_workflow', 'PickList' 140 ); 141 return $modules; 142 } 143 144 /** 145 * Toggle the module (enable/disable) 146 */ 147 function vtlib_toggleModuleAccess($module, $enable_disable) { 148 global $adb, $__cache_module_activeinfo; 149 150 include_once ('vtlib/Vtiger/Module.php'); 151 152 $event_type = false; 153 154 if($enable_disable === true) { 155 $enable_disable = 0; 156 $event_type = Vtiger_Module::EVENT_MODULE_ENABLED; 157 } else if($enable_disable === false) { 158 $enable_disable = 1; 159 $event_type = Vtiger_Module::EVENT_MODULE_DISABLED; 160 } 161 162 $adb->pquery("UPDATE vtiger_tab set presence = ? WHERE name = ?", array($enable_disable,$module)); 163 164 $__cache_module_activeinfo[$module] = $enable_disable; 165 166 create_tab_data_file(); 167 create_parenttab_data_file(); 168 169 // UserPrivilege file needs to be regenerated if module state is changed from 170 // vtiger 5.1.0 onwards 171 global $vtiger_current_version; 172 if(version_compare($vtiger_current_version, '5.0.4', '>')) { 173 vtlib_RecreateUserPrivilegeFiles(); 174 } 175 176 Vtiger_Module::fireEvent($module, $event_type); 177 } 178 179 /** 180 * Get list of module with current status which can be controlled. 181 */ 182 function vtlib_getToggleModuleInfo() { 183 global $adb; 184 185 $modinfo = Array(); 186 187 $sqlresult = $adb->query("SELECT name, presence, customized, isentitytype FROM vtiger_tab WHERE name NOT IN ('Users','Home') AND presence IN (0,1) ORDER BY name"); 188 $num_rows = $adb->num_rows($sqlresult); 189 for($idx = 0; $idx < $num_rows; ++$idx) { 190 $module = $adb->query_result($sqlresult, $idx, 'name'); 191 $presence=$adb->query_result($sqlresult, $idx, 'presence'); 192 $customized=$adb->query_result($sqlresult, $idx, 'customized'); 193 $isentitytype=$adb->query_result($sqlresult, $idx, 'isentitytype'); 194 $hassettings=file_exists("modules/$module/Settings.php"); 195 196 $modinfo[$module] = Array( 'customized'=>$customized, 'presence'=>$presence, 'hassettings'=>$hassettings, 'isentitytype' => $isentitytype ); 197 } 198 return $modinfo; 199 } 200 201 /** 202 * Get list of language and its current status. 203 */ 204 function vtlib_getToggleLanguageInfo() { 205 global $adb; 206 207 // The table might not exists! 208 $old_dieOnError = $adb->dieOnError; 209 $adb->dieOnError = false; 210 211 $langinfo = Array(); 212 $sqlresult = $adb->query("SELECT * FROM vtiger_language"); 213 if($sqlresult) { 214 for($idx = 0; $idx < $adb->num_rows($sqlresult); ++$idx) { 215 $row = $adb->fetch_array($sqlresult); 216 $langinfo[$row['prefix']] = Array( 'label'=>$row['label'], 'active'=>$row['active'] ); 217 } 218 } 219 $adb->dieOnError = $old_dieOnError; 220 return $langinfo; 221 } 222 223 /** 224 * Toggle the language (enable/disable) 225 */ 226 function vtlib_toggleLanguageAccess($langprefix, $enable_disable) { 227 global $adb; 228 229 // The table might not exists! 230 $old_dieOnError = $adb->dieOnError; 231 $adb->dieOnError = false; 232 233 if($enable_disable === true) $enable_disable = 1; 234 else if($enable_disable === false) $enable_disable = 0; 235 236 $adb->pquery('UPDATE vtiger_language set active = ? WHERE prefix = ?', Array($enable_disable, $langprefix)); 237 238 $adb->dieOnError = $old_dieOnError; 239 } 240 241 /** 242 * Get help information set for the module fields. 243 */ 244 function vtlib_getFieldHelpInfo($module) { 245 global $adb; 246 $fieldhelpinfo = Array(); 247 if(in_array('helpinfo', $adb->getColumnNames('vtiger_field'))) { 248 $result = $adb->pquery('SELECT fieldname,helpinfo FROM vtiger_field WHERE tabid=?', Array(getTabid($module))); 249 if($result && $adb->num_rows($result)) { 250 while($fieldrow = $adb->fetch_array($result)) { 251 $helpinfo = decode_html($fieldrow['helpinfo']); 252 if(!empty($helpinfo)) { 253 $fieldhelpinfo[$fieldrow['fieldname']] = getTranslatedString($helpinfo, $module); 254 } 255 } 256 } 257 } 258 return $fieldhelpinfo; 259 } 260 261 /** 262 * Setup mandatory (requried) module variable values in the module class. 263 */ 264 function vtlib_setup_modulevars($module, $focus) { 265 266 $checkfor = Array('table_name', 'table_index', 'related_tables', 'popup_fields', 'IsCustomModule'); 267 foreach($checkfor as $check) { 268 if(!isset($focus->$check)) $focus->$check = __vtlib_get_modulevar_value($module, $check); 269 } 270 } 271 function __vtlib_get_modulevar_value($module, $varname) { 272 $mod_var_mapping = 273 Array( 274 'Accounts' => 275 Array( 276 'IsCustomModule'=>false, 277 'table_name' => 'vtiger_account', 278 'table_index' => 'accountid', 279 // related_tables variable should define the association (relation) between dependent tables 280 // FORMAT: related_tablename => Array ( related_tablename_column[, base_tablename, base_tablename_column] ) 281 // Here base_tablename_column should establish relation with related_tablename_column 282 // NOTE: If base_tablename and base_tablename_column are not specified, it will default to modules (table_name, related_tablename_column) 283 'related_tables' => Array( 284 'vtiger_accountbillads' => Array ('accountaddressid', 'vtiger_account', 'accountid'), 285 'vtiger_accountshipads' => Array ('accountaddressid', 'vtiger_account', 'accountid'), 286 'vtiger_accountscf' => Array ('accountid', 'vtiger_account', 'accountid'), 287 ), 288 'popup_fields' => Array('accountname'), // TODO: Add this initialization to all the standard module 289 ), 290 'Contacts' => 291 Array( 292 'IsCustomModule'=>false, 293 'table_name' => 'vtiger_contactdetails', 294 'table_index' => 'contactid', 295 'related_tables'=> Array( 296 'vtiger_account' => Array ('accountid' ), 297 //REVIEW: Added these tables for displaying the data into relatedlist (based on configurable fields) 298 'vtiger_contactaddress' => Array('contactaddressid', 'vtiger_contactdetails', 'contactid'), 299 'vtiger_contactsubdetails' => Array('contactsubscriptionid', 'vtiger_contactdetails', 'contactid'), 300 'vtiger_customerdetails' => Array('customerid', 'vtiger_contactdetails', 'contactid'), 301 'vtiger_contactscf' => Array('contactid', 'vtiger_contactdetails', 'contactid') 302 ), 303 'popup_fields' => Array ('lastname'), 304 ), 305 'Leads' => 306 Array( 307 'IsCustomModule'=>false, 308 'table_name' => 'vtiger_leaddetails', 309 'table_index' => 'leadid', 310 'related_tables' => Array ( 311 'vtiger_leadsubdetails' => Array ( 'leadsubscriptionid', 'vtiger_leaddetails', 'leadid' ), 312 'vtiger_leadaddress' => Array ( 'leadaddressid', 'vtiger_leaddetails', 'leadid' ), 313 'vtiger_leadscf' => Array ( 'leadid', 'vtiger_leaddetails', 'leadid' ), 314 ), 315 'popup_fields'=> Array ('lastname'), 316 ), 317 'Campaigns' => 318 Array( 319 'IsCustomModule'=>false, 320 'table_name' => 'vtiger_campaign', 321 'table_index' => 'campaignid', 322 'popup_fields' => Array ('campaignname'), 323 ), 324 'Potentials' => 325 Array( 326 'IsCustomModule'=>false, 327 'table_name' => 'vtiger_potential', 328 'table_index'=> 'potentialid', 329 // NOTE: UIType 10 is being used instead of direct relationship from 5.1.0 330 //'related_tables' => Array ('vtiger_account' => Array('accountid')), 331 'popup_fields'=> Array('potentialname'), 332 'related_tables' => Array ( 333 'vtiger_potentialscf' => Array ( 'potentialid', 'vtiger_potential', 'potentialid' ), 334 ), 335 ), 336 'Quotes' => 337 Array( 338 'IsCustomModule'=>false, 339 'table_name' => 'vtiger_quotes', 340 'table_index'=> 'quoteid', 341 'related_tables' => Array ('vtiger_account' => Array('accountid')), 342 'popup_fields'=>Array('subject'), 343 ), 344 'SalesOrder'=> 345 Array( 346 'IsCustomModule'=>false, 347 'table_name' => 'vtiger_salesorder', 348 'table_index'=> 'salesorderid', 349 'related_tables'=> Array ('vtiger_account' => Array('accountid')), 350 'popup_fields'=>Array('subject'), 351 ), 352 'PurchaseOrder'=> 353 Array( 354 'IsCustomModule'=>false, 355 'table_name' => 'vtiger_purchaseorder', 356 'table_index'=> 'purchaseorderid', 357 'popup_fields'=>Array('subject'), 358 ), 359 'Invoice'=> 360 Array( 361 'IsCustomModule'=>false, 362 'table_name' => 'vtiger_invoice', 363 'table_index'=> 'invoiceid', 364 'popup_fields'=> Array('subject'), 365 'related_tables'=> Array( 366 'vtiger_invoicecf' => Array('invoiceid', 'vtiger_invoice', 'invoiceid') 367 ), 368 ), 369 'HelpDesk'=> 370 Array( 371 'IsCustomModule'=>false, 372 'table_name' => 'vtiger_troubletickets', 373 'table_index'=> 'ticketid', 374 'related_tables'=> Array ('vtiger_ticketcf' => Array('ticketid')), 375 'popup_fields'=> Array('ticket_title') 376 ), 377 'Faq'=> 378 Array( 379 'IsCustomModule'=>false, 380 'table_name' => 'vtiger_faq', 381 'table_index'=> 'id', 382 ), 383 'Documents'=> 384 Array( 385 'IsCustomModule'=>false, 386 'table_name' => 'vtiger_notes', 387 'table_index'=> 'notesid', 388 ), 389 'Products'=> 390 Array( 391 'IsCustomModule'=>false, 392 'table_name' => 'vtiger_products', 393 'table_index'=> 'productid', 394 'popup_fields'=> Array('productname'), 395 ), 396 'PriceBooks'=> 397 Array( 398 'IsCustomModule'=>false, 399 'table_name' => 'vtiger_pricebook', 400 'table_index'=> 'pricebookid', 401 ), 402 'Vendors'=> 403 Array( 404 'IsCustomModule'=>false, 405 'table_name' => 'vtiger_vendor', 406 'table_index'=> 'vendorid', 407 'popup_fields'=>Array('vendorname'), 408 ), 409 'Project' => 410 Array( 411 'IsCustomModule'=>false, 412 'table_name' => 'vtiger_project', 413 'table_index'=> 'projectid', 414 'related_tables'=> Array( 415 'vtiger_projectcf' => Array('projectid', 'vtiger_project', 'projectid') 416 ), 417 ), 418 'ProjectMilestone' => 419 Array( 420 'IsCustomModule'=>false, 421 'table_name' => 'vtiger_projectmilestone', 422 'table_index'=> 'projectmilestoneid', 423 'related_tables'=> Array( 424 'vtiger_projectmilestonecf' => Array('projectmilestoneid', 'vtiger_projectmilestone', 'projectmilestoneid') 425 ), 426 ), 427 'ProjectTask' => 428 Array( 429 'IsCustomModule'=>false, 430 'table_name' => 'vtiger_projecttask', 431 'table_index'=> 'projecttaskid', 432 'related_tables'=> Array( 433 'vtiger_projecttaskcf' => Array('projecttaskid', 'vtiger_projecttask', 'projecttaskid') 434 ), 435 ), 436 'Services' => 437 Array( 438 'IsCustomModule'=>false, 439 'table_name' => 'vtiger_service', 440 'table_index'=> 'serviceid', 441 'related_tables'=> Array( 442 'vtiger_servicecf' => Array('serviceid') 443 ), 444 ), 445 'ServiceContracts' => 446 Array( 447 'IsCustomModule'=>false, 448 'table_name' => 'vtiger_servicecontracts', 449 'table_index'=> 'servicecontractsid', 450 'related_tables'=> Array( 451 'vtiger_servicecontractscf' => Array('servicecontractsid') 452 ), 453 ), 454 'Assets' => 455 Array( 456 'IsCustomModule'=>false, 457 'table_name' => 'vtiger_assets', 458 'table_index'=> 'assetsid', 459 'related_tables'=> Array( 460 'vtiger_assetscf' => Array('assetsid') 461 ), 462 ) 463 ); 464 return $mod_var_mapping[$module][$varname]; 465 } 466 467 /** 468 * Convert given text input to singular. 469 */ 470 function vtlib_tosingular($text) { 471 $lastpos = strripos($text, 's'); 472 if($lastpos == strlen($text)-1) 473 return substr($text, 0, -1); 474 return $text; 475 } 476 477 /** 478 * Get picklist values that is accessible by all roles. 479 */ 480 function vtlib_getPicklistValues_AccessibleToAll($field_columnname) { 481 global $adb; 482 483 $columnname = $adb->sql_escape_string($field_columnname); 484 $tablename = "vtiger_$columnname"; 485 486 // Gather all the roles (except H1 which is organization role) 487 $roleres = $adb->query("SELECT roleid FROM vtiger_role WHERE roleid != 'H1'"); 488 $roleresCount= $adb->num_rows($roleres); 489 $allroles = Array(); 490 if($roleresCount) { 491 for($index = 0; $index < $roleresCount; ++$index) 492 $allroles[] = $adb->query_result($roleres, $index, 'roleid'); 493 } 494 sort($allroles); 495 496 // Get all the picklist values associated to roles (except H1 - organization role). 497 $picklistres = $adb->query( 498 "SELECT $columnname as pickvalue, roleid FROM $tablename 499 INNER JOIN vtiger_role2picklist ON $tablename.picklist_valueid=vtiger_role2picklist.picklistvalueid 500 WHERE roleid != 'H1'"); 501 502 $picklistresCount = $adb->num_rows($picklistres); 503 504 $picklistval_roles = Array(); 505 if($picklistresCount) { 506 for($index = 0; $index < $picklistresCount; ++$index) { 507 $picklistval = $adb->query_result($picklistres, $index, 'pickvalue'); 508 $pickvalroleid=$adb->query_result($picklistres, $index, 'roleid'); 509 $picklistval_roles[$picklistval][] = $pickvalroleid; 510 } 511 } 512 // Collect picklist value which is associated to all the roles. 513 $allrolevalues = Array(); 514 foreach($picklistval_roles as $picklistval => $pickvalroles) { 515 sort($pickvalroles); 516 $diff = array_diff($pickvalroles,$allroles); 517 if(empty($diff)) $allrolevalues[] = $picklistval; 518 } 519 520 return $allrolevalues; 521 } 522 523 /** 524 * Get all picklist values for a non-standard picklist type. 525 */ 526 function vtlib_getPicklistValues($field_columnname) { 527 global $adb; 528 529 $columnname = $adb->sql_escape_string($field_columnname); 530 $tablename = "vtiger_$columnname"; 531 532 $picklistres = $adb->query("SELECT $columnname as pickvalue FROM $tablename"); 533 534 $picklistresCount = $adb->num_rows($picklistres); 535 536 $picklistvalues = Array(); 537 if($picklistresCount) { 538 for($index = 0; $index < $picklistresCount; ++$index) { 539 $picklistvalues[] = $adb->query_result($picklistres, $index, 'pickvalue'); 540 } 541 } 542 return $picklistvalues; 543 } 544 545 /** 546 * Check for custom module by its name. 547 */ 548 function vtlib_isCustomModule($moduleName) { 549 $moduleFile = "modules/$moduleName/$moduleName.php"; 550 if(file_exists($moduleFile)) { 551 if(function_exists('checkFileAccessForInclusion')) { 552 checkFileAccessForInclusion($moduleFile); 553 } 554 include_once($moduleFile); 555 $focus = new $moduleName(); 556 return (isset($focus->IsCustomModule) && $focus->IsCustomModule); 557 } 558 return false; 559 } 560 561 /** 562 * Get module specific smarty template path. 563 */ 564 function vtlib_getModuleTemplate($module, $templateName) { 565 return ("modules/$module/$templateName"); 566 } 567 568 /** 569 * Check if give path is writeable. 570 */ 571 function vtlib_isWriteable($path) { 572 if(is_dir($path)) { 573 return vtlib_isDirWriteable($path); 574 } else { 575 return is_writable($path); 576 } 577 } 578 579 /** 580 * Check if given directory is writeable. 581 * NOTE: The check is made by trying to create a random file in the directory. 582 */ 583 function vtlib_isDirWriteable($dirpath) { 584 if(is_dir($dirpath)) { 585 do { 586 $tmpfile = 'vtiger' . time() . '-' . rand(1,1000) . '.tmp'; 587 // Continue the loop unless we find a name that does not exists already. 588 $usefilename = "$dirpath/$tmpfile"; 589 if(!file_exists($usefilename)) break; 590 } while(true); 591 $fh = @fopen($usefilename,'a'); 592 if($fh) { 593 fclose($fh); 594 unlink($usefilename); 595 return true; 596 } 597 } 598 return false; 599 } 600 601 /** HTML Purifier global instance */ 602 $__htmlpurifier_instance = false; 603 /** 604 * Purify (Cleanup) malicious snippets of code from the input 605 * 606 * @param String $value 607 * @param Boolean $ignore Skip cleaning of the input 608 * @return String 609 */ 610 function vtlib_purify($input, $ignore=false) { 611 global $__htmlpurifier_instance, $root_directory, $default_charset; 612 613 static $purified_cache = array(); 614 $value = $input; 615 616 if(!is_array($input)) { 617 $md5OfInput = md5($input); 618 if (array_key_exists($md5OfInput, $purified_cache)) { 619 $value = $purified_cache[$md5OfInput]; 620 //to escape cleaning up again 621 $ignore = true; 622 } 623 } 624 $use_charset = $default_charset; 625 $use_root_directory = $root_directory; 626 627 628 if(!$ignore) { 629 // Initialize the instance if it has not yet done 630 if($__htmlpurifier_instance == false) { 631 if(empty($use_charset)) $use_charset = 'UTF-8'; 632 if(empty($use_root_directory)) $use_root_directory = dirname(__FILE__) . '/../..'; 633 634 include_once ('libraries/htmlpurifier/library/HTMLPurifier.auto.php'); 635 636 $config = HTMLPurifier_Config::createDefault(); 637 $config->set('Core', 'Encoding', $use_charset); 638 $config->set('Cache', 'SerializerPath', "$use_root_directory/test/vtlib"); 639 640 $__htmlpurifier_instance = new HTMLPurifier($config); 641 } 642 if($__htmlpurifier_instance) { 643 // Composite type 644 if (is_array($input)) { 645 $value = array(); 646 foreach ($input as $k => $v) { 647 $value[$k] = vtlib_purify($v, $ignore); 648 } 649 } else { // Simple type 650 $value = $__htmlpurifier_instance->purify($input); 651 } 652 } 653 $purified_cache[$md5OfInput] = $value; 654 } 655 $value = str_replace('&','&',$value); 656 return $value; 657 } 658 659 /** 660 * Function to return the valid SQl input. 661 * @param <String> $string 662 * @param <Boolean> $skipEmpty Skip the check if string is empty. 663 * @return <String> $string/false 664 */ 665 function vtlib_purifyForSql($string, $skipEmpty=true) { 666 $pattern = "/^[_a-zA-Z0-9.]+$/"; 667 if ((empty($string) && $skipEmpty) || preg_match($pattern, $string)) { 668 return $string; 669 } 670 return false; 671 } 672 673 /** 674 * Process the UI Widget requested 675 * @param Vtiger_Link $widgetLinkInfo 676 * @param Current Smarty Context $context 677 * @return 678 */ 679 function vtlib_process_widget($widgetLinkInfo, $context = false) { 680 if (preg_match("/^block:\/\/(.*)/", $widgetLinkInfo->linkurl, $matches)) { 681 list($widgetControllerClass, $widgetControllerClassFile) = explode(':', $matches[1]); 682 if (!class_exists($widgetControllerClass)) { 683 checkFileAccessForInclusion($widgetControllerClassFile); 684 include_once $widgetControllerClassFile; 685 } 686 if (class_exists($widgetControllerClass)) { 687 $widgetControllerInstance = new $widgetControllerClass; 688 $widgetInstance = $widgetControllerInstance->getWidget($widgetLinkInfo->linklabel); 689 if ($widgetInstance) { 690 return $widgetInstance->process($context); 691 } 692 } 693 } 694 return ""; 695 } 696 697 function vtlib_module_icon($modulename){ 698 if($modulename == 'Events'){ 699 return "modules/Calendar/Events.png"; 700 } 701 if(file_exists("modules/$modulename/$modulename.png")){ 702 return "modules/$modulename/$modulename.png"; 703 } 704 return "modules/Vtiger/Vtiger.png"; 705 } 706 707 ?>
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 |