[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare SiteMgr - Web Content Management * 4 * http://www.egroupware.org * 5 * -------------------------------------------- * 6 * This program is free software; you can redistribute it and/or modify it * 7 * under the terms of the GNU General Public License as published by the * 8 * Free Software Foundation; either version 2 of the License, or (at your * 9 * option) any later version. * 10 \**************************************************************************/ 11 12 /* $Id: class.Modules_BO.inc.php 20295 2006-02-15 12:31:25Z $ */ 13 14 require_once (EGW_INCLUDE_ROOT . '/sitemgr/inc/class.module.inc.php'); 15 16 class Modules_BO 17 { 18 var $so; 19 20 function Modules_BO() 21 { 22 //all sitemgr BOs should be instantiated via a globalized Common_BO object, 23 $this->so =& CreateObject('sitemgr.Modules_SO', true); 24 } 25 26 function getmoduleid($modulename) 27 { 28 return $this->so->getmoduleid($modulename); 29 } 30 31 function getmodule($module_id) 32 { 33 return $this->so->getmodule($module_id); 34 } 35 36 function savemoduleproperties($module_id,$element,$contentarea,$cat_id) 37 { 38 $module = $this->getmodule($module_id); 39 $moduleobject =& $this->createmodule($module['module_name']); 40 if ($moduleobject->validate_properties($element)) 41 { 42 $this->so->savemoduleproperties($module_id,$element,$contentarea,$cat_id); 43 } 44 } 45 46 function deletemoduleproperties($module_id,$contentarea,$cat_id) 47 { 48 $this->so->deletemoduleproperties($module_id,$contentarea,$cat_id); 49 } 50 51 /** 52 * instanciates the sitemgr module $modulename 53 * 54 * The module is stored either in sitemgr/modules or in $app/sitemgr in class.modules_$modulename.inc.php 55 * The appname is the modulename (eg. 'calendar') or the first part of the modulename (eg. 'calendar_day'). 56 * 57 * @param string $modulename 58 * @return object/boolean reference to the instanciated class, or false on error 59 */ 60 function &createmodule($modulename) 61 { 62 $obj = false; 63 $classname = 'module_' . $modulename; 64 list($app) = explode('_',$modulename); 65 66 if (@file_exists($file = EGW_INCLUDE_ROOT.'/sitemgr/modules/class.'.$classname.'.inc.php') || 67 @file_exists($file = EGW_INCLUDE_ROOT.'/'.$app.'/sitemgr/class.'.$classname.'.inc.php')) 68 { 69 include_once($file); 70 71 $obj =& new $classname; 72 } 73 return $obj; 74 } 75 76 77 function getallmodules() 78 { 79 return $this->so->getallmodules(); 80 } 81 82 /** 83 * Searches sitemgr/modules and $app/sitemgr dirs for new modules 84 * 85 * @return array with modulename => modulename: description pairs 86 */ 87 function findmodules() 88 { 89 $new_modules = array(); 90 foreach($GLOBALS['egw_info']['apps'] as $app => $data) 91 { 92 $moddir = EGW_SERVER_ROOT . '/' . $app . ($app == 'sitemgr' ? '/modules' : '/sitemgr'); 93 if (is_dir($moddir)) 94 { 95 $d = dir($moddir); 96 while ($file = $d->read()) 97 { 98 if (preg_match ("/class\.module_(.*)\.inc\.php$/", $file, $module)) 99 { 100 $modulename = $module[1]; 101 102 $moduleobject =& $this->createmodule($modulename); 103 if ($moduleobject) 104 { 105 $description = ''; 106 // we grab the description direct from the module source, as we need the untranslated one 107 if (ereg('\$this->description = lang\(\'([^'."\n".']*)\'\);',implode("\n",file($moddir.'/'.$file)),$parts)) 108 { 109 $description = str_replace("\\'","'",$parts[1]); 110 } 111 if ($this->so->registermodule($modulename,$description ? $description : $moduleobject->description)) 112 { 113 $new_modules[$modulename] = $modulename.': '.$moduleobject->description; 114 } 115 } 116 //echo "<p>Modules_BO::findmodules() found $modulename: $moduleobject->description</p>\n"; 117 } 118 } 119 $d->close(); 120 } 121 } 122 return $new_modules; 123 } 124 125 function savemodulepermissions($contentarea,$cat_id,$modules) 126 { 127 $this->so->savemodulepermissions($contentarea,$cat_id,$modules); 128 } 129 130 //this function looks for a configured value for the combination contentareara,cat_id 131 function getpermittedmodules($contentarea,$cat_id) 132 { 133 return $this->so->getpermittedmodules($contentarea,$cat_id); 134 } 135 136 //this function looks for a module's configured propertiese for the combination contentareara,cat_id 137 //if module_id is 0 the fourth argument should provide modulename 138 function getmoduleproperties($module_id,$contentarea,$cat_id,$modulename=False) 139 { 140 return $this->so->getmoduleproperties($module_id,$contentarea,$cat_id,$modulename); 141 } 142 143 //this function calculates the permitted modules by asking first for a value contentarea/cat_id 144 //if it does not find one, climbing up the category hierarchy until the site wide value for the same contentarea 145 //and if it still does not find a value, looking for __PAGE__/cat_id, and again climbing up until the master list 146 function getcascadingmodulepermissions($contentarea,$cat_id) 147 { 148 $cat_ancestorlist = ($cat_id != CURRENT_SITE_ID) ? $GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id) : array(); 149 $cat_ancestorlist[] = CURRENT_SITE_ID; 150 151 $cat_ancestorlist_temp = $cat_ancestorlist; 152 153 do 154 { 155 $cat_id = array_shift($cat_ancestorlist_temp); 156 157 while($cat_id !== NULL) 158 { 159 $permitted = $this->so->getpermittedmodules($contentarea,$cat_id); 160 if ($permitted) 161 { 162 return $permitted; 163 } 164 $cat_id = array_shift($cat_ancestorlist_temp); 165 } 166 $contentarea = ($contentarea != "__PAGE__") ? "__PAGE__" : False; 167 $cat_ancestorlist_temp = $cat_ancestorlist; 168 } while($contentarea); 169 return array(); 170 } 171 172 //this function calculates the properties by climbing up the hierarchy tree in the same way as 173 //getcascadingmodulepermissions does 174 function getcascadingmoduleproperties($module_id,$contentarea,$cat_id,$modulename=False) 175 { 176 $cat_ancestorlist = ($cat_id != CURRENT_SITE_ID) ? $GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id) : array(); 177 $cat_ancestorlist[] = CURRENT_SITE_ID; 178 179 $cat_ancestorlist_temp = $cat_ancestorlist; 180 181 do 182 { 183 $cat_id = array_shift($cat_ancestorlist_temp); 184 185 while($cat_id !== NULL) 186 { 187 $properties = $this->so->getmoduleproperties($module_id,$contentarea,$cat_id,$modulename); 188 //we have to check for type identity since properties can be NULL in case of unchecked checkbox 189 if ($properties !== false) 190 { 191 return $properties; 192 } 193 $cat_id = array_shift($cat_ancestorlist_temp); 194 } 195 $contentarea = ($contentarea != "__PAGE__") ? "__PAGE__" : False; 196 $cat_ancestorlist_temp = $cat_ancestorlist; 197 } while($contentarea); 198 } 199 }
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 |