[ 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 * Settings Menu Model Class 13 */ 14 class Settings_Vtiger_Menu_Model extends Vtiger_Base_Model { 15 16 protected static $menusTable = 'vtiger_settings_blocks'; 17 protected static $menuId = 'blockid'; 18 19 /** 20 * Function to get the Id of the Menu Model 21 * @return <Number> - Menu Id 22 */ 23 public function getId() { 24 return $this->get(self::$menuId); 25 } 26 27 /** 28 * Function to get the menu label 29 * @return <String> - Menu Label 30 */ 31 public function getLabel() { 32 return $this->get('label'); 33 } 34 35 /** 36 * Function to get the url to list the items of the Menu 37 * @return <String> - List url 38 */ 39 public function getListUrl() { 40 return 'index.php?module=Vtiger&parent=Settings&view=ListMenu&block='.$this->getId(); 41 } 42 43 /** 44 * Function to get all the menu items of the current menu 45 * @return <Array> - List of Settings_Vtiger_MenuItem_Model instances 46 */ 47 public function getItems() { 48 return Settings_Vtiger_MenuItem_Model::getAll($this); 49 } 50 51 /** 52 * Static function to get the list of all the Settings Menus 53 * @return <Array> - List of Settings_Vtiger_Menu_Model instances 54 */ 55 public static function getAll() { 56 $db = PearDatabase::getInstance(); 57 $restrictBlock = array('LBL_MODULE_MANAGER'); 58 59 $sql = 'SELECT * FROM '.self::$menusTable. ' WHERE label NOT IN ('.generateQuestionMarks($restrictBlock).') 60 ORDER BY sequence'; 61 $params = array($restrictBlock); 62 63 $result = $db->pquery($sql, $params); 64 $noOfMenus = $db->num_rows($result); 65 66 $menuModels = array(); 67 for($i=0; $i<$noOfMenus; ++$i) { 68 $blockId = $db->query_result($result, $i, self::$menuId); 69 $rowData = $db->query_result_rowdata($result, $i); 70 $menuModels[$blockId] = Settings_Vtiger_Menu_Model::getInstanceFromArray($rowData); 71 } 72 return $menuModels; 73 } 74 75 /** 76 * Static Function to get the instance of Settings Menu model with the given value map array 77 * @param <Array> $valueMap 78 * @return Settings_Vtiger_Menu_Model instance 79 */ 80 public static function getInstanceFromArray($valueMap) { 81 return new self($valueMap); 82 } 83 84 /** 85 * Static Function to get the instance of Settings Menu model for given menu id 86 * @param <Number> $id - Menu Id 87 * @return Settings_Vtiger_Menu_Model instance 88 */ 89 public static function getInstanceById($id) { 90 $db = PearDatabase::getInstance(); 91 92 $sql = 'SELECT * FROM '.self::$menusTable. ' WHERE ' .self::$menuId. ' = ?'; 93 $params = array($id); 94 95 $result = $db->pquery($sql, $params); 96 97 if($db->num_rows($result) > 0) { 98 $rowData = $db->query_result_rowdata($result, 0); 99 return Settings_Vtiger_Menu_Model::getInstanceFromArray($rowData); 100 } 101 return false; 102 } 103 104 /** 105 * Static Function to get the instance of Settings Menu model for the given menu name 106 * @param <String> $name - Menu Name 107 * @return Settings_Vtiger_Menu_Model instance 108 */ 109 public static function getInstance($name) { 110 $db = PearDatabase::getInstance(); 111 112 $sql = 'SELECT * FROM '.self::$menusTable. ' WHERE label = ?'; 113 $params = array($name); 114 115 $result = $db->pquery($sql, $params); 116 117 if($db->num_rows($result) > 0) { 118 $rowData = $db->query_result_rowdata($result, 0); 119 return Settings_Vtiger_Menu_Model::getInstanceFromArray($rowData); 120 } 121 return false; 122 } 123 124 /** 125 * Function returns menu items for the current menu 126 * @return <Settings_Vtiger_MenuItem_Model> 127 */ 128 public function getMenuItems() { 129 return Settings_Vtiger_MenuItem_Model::getAll($this); 130 } 131 132 }
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 |