[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare SiteMgr - Web Content Management * 4 * http://www.egroupware.org * 5 * Rewritten with the new db-functions by RalfBecker-AT-outdoor-training.de * 6 * -------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \**************************************************************************/ 12 13 /* $Id: class.Modules_SO.inc.php 20295 2006-02-15 12:31:25Z $ */ 14 15 class Modules_SO 16 { 17 var $db; 18 var $properties_table,$modules_table,$active_modules_table; 19 20 function Modules_SO() 21 { 22 $this->db = clone($GLOBALS['egw']->db); 23 $this->db->set_app('sitemgr'); 24 foreach(array('properties','modules','active_modules') as $name) 25 { 26 $var = $name.'_table'; 27 $this->$var = 'egw_sitemgr_'.$name; // only reference to the db-prefix 28 } 29 } 30 31 function savemoduleproperties($module_id,$data,$contentarea,$cat_id) 32 { 33 $this->db->insert($this->properties_table,array( 34 'properties'=> serialize($data), 35 ),array( 36 'area' => $contentarea, 37 'cat_id' => $cat_id, 38 'module_id' => $module_id, 39 ),__LINE__,__FILE__); 40 } 41 42 function deletemoduleproperties($module_id,$contentarea,$cat_id) 43 { 44 $this->db->delete($this->properties_table,array( 45 'area' => $contentarea, 46 'cat_id' => $cat_id, 47 'module_id' => $module_id, 48 ),__LINE__,__FILE__); 49 } 50 51 function getmoduleproperties($module_id,$contentarea,$cat_id,$modulename) 52 { 53 if ($module_id) 54 { 55 $this->db->select($this->properties_table,'properties',array( 56 'area' => $contentarea, 57 'cat_id' => $cat_id, 58 'module_id' => $module_id, 59 ),__LINE__,__FILE__); 60 } 61 else 62 { 63 $this->db->query("SELECT properties FROM $this->properties_table AS t1". 64 " LEFT JOIN $this->modules_table AS t2 ON t1.module_id=t2.module_id". 65 " WHERE ".$this->db->expression($this->properties_table,array( 66 'area' => $contentarea, 67 'cat_id' => $cat_id, 68 )).' AND '.$this->db->expression($this->modules_table,array( 69 'module_name' => $modulename 70 )),__LINE__,__FILE__); 71 } 72 if ($this->db->next_record()) 73 { 74 return unserialize($this->db->f('properties')); 75 } 76 return false; 77 } 78 79 function registermodule($modulename,$description) 80 { 81 $newly = !$this->getmoduleid($modulename); 82 83 $this->db->insert($this->modules_table,array( 84 'description' => $description 85 ),array( 86 'module_name' => $modulename 87 ),__LINE__,__FILE__); 88 89 return $newly; // returns True on a new insert 90 } 91 92 function getallmodules() 93 { 94 $this->db->select($this->modules_table,'*',false,__LINE__,__FILE__,false,'ORDER BY module_name'); 95 96 return $this->constructmodulearray(); 97 } 98 99 function getmoduleid($modulename) 100 { 101 $this->db->select($this->modules_table,'module_id',array( 102 'module_name' => $modulename 103 ),__LINE__,__FILE__); 104 105 return $this->db->next_record() ? $this->db->f('module_id') : False; 106 } 107 108 function getmodule($module_id) 109 { 110 $this->db->select($this->modules_table,'*',array( 111 'module_id' => $module_id 112 ),__LINE__,__FILE__); 113 114 if ($this->db->next_record()) 115 { 116 return array( 117 'id' => $this->db->f('module_id'), 118 'module_name' => $this->db->f('module_name'), 119 'description' => stripslashes($this->db->f('description')), 120 ); 121 } 122 return false; 123 } 124 125 function constructmodulearray() 126 { 127 $result = array(); 128 while ($this->db->next_record()) 129 { 130 $id = $this->db->f('module_id'); 131 $result[$id]['module_name'] = $this->db->f('module_name'); 132 $result[$id]['description'] = stripslashes($this->db->f('description')); 133 } 134 return $result; 135 } 136 137 function savemodulepermissions($contentarea,$cat_id,$modules) 138 { 139 $this->db->delete($this->active_modules_table,array( 140 'area' => $contentarea, 141 'cat_id'=> $cat_id, 142 ),__LINE__,__FILE__); 143 144 if (!is_array($modules)) return; 145 146 foreach($modules as $module_id) 147 { 148 $this->db->insert($this->active_modules_table,array( 149 'module_id' => $module_id, 150 'area' => $contentarea, 151 'cat_id'=> $cat_id, 152 ),False,__LINE__,__FILE__); 153 } 154 } 155 156 function getpermittedmodules($contentarea,$cat_id) 157 { 158 $this->db->query("SELECT * from $this->modules_table AS t1". 159 " LEFT JOIN $this->active_modules_table AS t2 ON t1.module_id=t2.module_id". 160 " WHERE ".$this->db->expression($this->active_modules_table,array( 161 'area' => $contentarea, 162 'cat_id'=> $cat_id, 163 )),__LINE__,__FILE__); 164 165 return $this->constructmodulearray(); 166 } 167 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |