[ 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 include_once ('vtlib/Vtiger/Utils.php'); 11 12 /** 13 * Provides API to work with vtiger CRM Menu 14 * @package vtlib 15 */ 16 class Vtiger_Menu { 17 /** ID of this menu instance */ 18 var $id = false; 19 var $label = false; 20 var $sequence = false; 21 var $visible = 0; 22 23 /** 24 * Constructor 25 */ 26 function __construct() { 27 } 28 29 /** 30 * Initialize this instance 31 * @param Array Map 32 * @access private 33 */ 34 function initialize($valuemap) { 35 $this->id = $valuemap[parenttabid]; 36 $this->label = $valuemap[parenttab_label]; 37 $this->sequence = $valuemap[sequence]; 38 $this->visible = $valuemap[visible]; 39 } 40 41 /** 42 * Get relation sequence to use 43 * @access private 44 */ 45 function __getNextRelSequence() { 46 global $adb; 47 $result = $adb->pquery("SELECT MAX(sequence) AS max_seq FROM vtiger_parenttabrel WHERE parenttabid=?", 48 Array($this->id)); 49 $maxseq = $adb->query_result($result, 0, 'max_seq'); 50 return ++$maxseq; 51 } 52 53 /** 54 * Add module to this menu instance 55 * @param Vtiger_Module Instance of the module 56 */ 57 function addModule($moduleInstance) { 58 if($this->id) { 59 global $adb; 60 $relsequence = $this->__getNextRelSequence(); 61 $adb->pquery("INSERT INTO vtiger_parenttabrel (parenttabid,tabid,sequence) VALUES(?,?,?)", 62 Array($this->id, $moduleInstance->id, $relsequence)); 63 self::log("Added to menu $this->label ... DONE"); 64 } else { 65 self::log("Menu could not be found!"); 66 } 67 self::syncfile(); 68 } 69 70 /** 71 * Remove module from this menu instance. 72 * @param Vtiger_Module Instance of the module 73 */ 74 function removeModule($moduleInstance) { 75 if(empty($moduleInstance) || empty($moduleInstance)) { 76 self::log("Module instance is not set!"); 77 return; 78 } 79 if($this->id) { 80 global $adb; 81 $adb->pquery("DELETE FROM vtiger_parenttabrel WHERE parenttabid = ? AND tabid = ?", 82 Array($this->id, $moduleInstance->id)); 83 self::log("Removed $moduleInstance->name from menu $this->label ... DONE"); 84 } else { 85 self::log("Menu could not be found!"); 86 } 87 self::syncfile(); 88 } 89 90 /** 91 * Detach module from menu 92 * @param Vtiger_Module Instance of the module 93 */ 94 static function detachModule($moduleInstance) { 95 global $adb; 96 $adb->pquery("DELETE FROM vtiger_parenttabrel WHERE tabid=?", Array($moduleInstance->id)); 97 self::log("Detaching from menu ... DONE"); 98 self::syncfile(); 99 } 100 101 /** 102 * Get instance of menu by label 103 * @param String Menu label 104 */ 105 static function getInstance($value) { 106 global $adb; 107 $query = false; 108 $instance = false; 109 if(Vtiger_Utils::isNumber($value)) { 110 $query = "SELECT * FROM vtiger_parenttab WHERE parenttabid=?"; 111 } else { 112 $query = "SELECT * FROM vtiger_parenttab WHERE parenttab_label=?"; 113 } 114 $result = $adb->pquery($query, Array($value)); 115 if($adb->num_rows($result)) { 116 $instance = new self(); 117 $instance->initialize($adb->fetch_array($result)); 118 } 119 return $instance; 120 } 121 122 /** 123 * Helper function to log messages 124 * @param String Message to log 125 * @param Boolean true appends linebreak, false to avoid it 126 * @access private 127 */ 128 static function log($message, $delim=true) { 129 Vtiger_Utils::Log($message, $delim); 130 } 131 132 /** 133 * Synchronize the menu information to flat file 134 * @access private 135 */ 136 static function syncfile() { 137 self::log("Updating parent_tabdata file ... STARTED"); 138 create_parenttab_data_file(); 139 self::log("Updating parent_tabdata file ... DONE"); 140 } 141 } 142 ?>
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 |