[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> 4 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 5 * Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * 21 * $Id: modules.php,v 1.65 2005/10/22 13:48:19 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/admin/modules.php,v $ 23 */ 24 25 /** 26 \file htdocs/admin/modules.php 27 \brief Page de configuration et activation des modules 28 \version $Revision: 1.65 $ 29 */ 30 31 require ("./pre.inc.php"); 32 33 if (!$user->admin) 34 accessforbidden(); 35 36 /* 37 * Actions 38 */ 39 40 if ($_GET["action"] == 'set' && $user->admin) 41 { 42 $result=Activate($_GET["value"]); 43 $mesg=''; 44 if ($result) $mesg=$result; 45 Header("Location: modules.php?spe=".$_GET["spe"]."&mesg=".urlencode($mesg)); 46 } 47 48 if ($_GET["action"] == 'reset' && $user->admin) 49 { 50 $result=UnActivate($_GET["value"]); 51 $mesg=''; 52 if ($result) $mesg=$result; 53 Header("Location: modules.php?spe=".$_GET["spe"]."&mesg=".urlencode($mesg)); 54 } 55 56 57 /** \brief Active un module 58 \param value Nom du module a activer 59 \param withdeps Active/désactive aussi les dépendances 60 */ 61 function Activate($value,$withdeps=1) 62 { 63 global $db, $modules, $langs; 64 65 $modName = $value; 66 67 // Activation du module 68 if ($modName) 69 { 70 $file = $modName . ".class.php"; 71 include_once(DOL_DOCUMENT_ROOT."/includes/modules/$file"); 72 $objMod = new $modName($db); 73 74 // Test si version PHP ok 75 $verphp=versionphp(); 76 $vermin=$objMod->phpmin; 77 if (is_array($vermin) && versioncompare($verphp,$vermin) < 0) 78 { 79 return $langs->trans("ErrorModuleRequirePHPVersion",versiontostring($vermin)); 80 } 81 82 $objMod->init(); 83 } 84 85 if ($withdeps) 86 { 87 // Activation des modules dont le module dépend 88 for ($i = 0; $i < sizeof($objMod->depends); $i++) 89 { 90 Activate($objMod->depends[$i]); 91 } 92 93 // Desactivation des modules qui entrent en conflit 94 for ($i = 0; $i < sizeof($objMod->conflictwith); $i++) 95 { 96 UnActivate($objMod->conflictwith[$i],0); 97 } 98 } 99 100 return 0; 101 } 102 103 104 /** \brief Désactive un module 105 \param value Nom du module a désactiver 106 \param requiredby 1=Desactive aussi modules dépendants 107 */ 108 function UnActivate($value,$requiredby=1) 109 { 110 global $db, $modules; 111 112 $modName = $value; 113 114 // Desactivation du module 115 if ($modName) 116 { 117 $file = $modName . ".class.php"; 118 include_once(DOL_DOCUMENT_ROOT."/includes/modules/$file"); 119 $objMod = new $modName($db); 120 $objMod->remove(); 121 } 122 123 // Desactivation des modules qui dependent de lui 124 if ($requiredby) 125 { 126 for ($i = 0; $i < sizeof($objMod->requiredby); $i++) 127 { 128 UnActivate($objMod->requiredby[$i]); 129 } 130 } 131 132 return 0; 133 } 134 135 136 /* 137 * Affichage page 138 */ 139 140 llxHeader("",""); 141 142 $h = 0; 143 144 $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?spe=0"; 145 $head[$h][1] = $langs->trans("ModulesCommon"); 146 if (!$_GET["spe"]) $hselected=$h; 147 $h++; 148 149 $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?spe=1"; 150 $head[$h][1] = $langs->trans("ModulesSpecial"); 151 if ($_GET["spe"]) $hselected=$h; 152 $h++; 153 154 dolibarr_fiche_head($head, $hselected, $langs->trans("Modules")); 155 156 157 if (!$_GET["spe"]) 158 { 159 print $langs->trans("ModulesDesc")."<br>\n"; 160 } 161 else 162 { 163 print $langs->trans("ModulesSpecialDesc")."<br>\n"; 164 } 165 166 if ($_GET["mesg"]) 167 { 168 $mesg=urldecode($_GET["mesg"]); 169 print '<div class="error">'.$mesg.'</div>'; 170 } 171 172 print "<br>\n"; 173 print "<table class=\"noborder\" width=\"100%\">\n"; 174 print "<tr class=\"liste_titre\">\n"; 175 print " <td>".$langs->trans("Family")."</td>\n"; 176 print " <td colspan=\"2\">".$langs->trans("Module")."</td>\n"; 177 print " <td>".$langs->trans("Description")."</td>\n"; 178 print " <td align=\"center\">".$langs->trans("Version")."</td>\n"; 179 print " <td align=\"center\">".$langs->trans("DbVersion")."</td>\n"; 180 print " <td align=\"center\">".$langs->trans("Activated")."</td>\n"; 181 print " <td align=\"center\">".$langs->trans("Action")."</td>\n"; 182 print " <td>".$langs->trans("SetupShort")."</td>\n"; 183 print "</tr>\n"; 184 185 186 $dir = DOL_DOCUMENT_ROOT . "/includes/modules/"; 187 188 // Charge tableaux modules, nom, numero, orders depuis répertoire dir 189 $handle=opendir($dir); 190 $modules = array(); 191 $orders = array(); 192 $i = 0; 193 $j = 0; 194 while (($file = readdir($handle))!==false) 195 { 196 if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, strlen($file) - 10) == '.class.php') 197 { 198 $modName = substr($file, 0, strlen($file) - 10); 199 200 if ($modName) 201 { 202 include_once($dir.$file); 203 $objMod = new $modName($db); 204 205 if ($objMod->numero > 0) 206 { 207 $j = $objMod->numero; 208 } 209 else 210 { 211 $j = 1000 + $i; 212 } 213 214 $modules[$i] = $objMod; 215 216 $nom[$i] = $modName; 217 $orders[$i] = "$objMod->family"."_".$j; // Tri par famille puis numero module 218 $j++; 219 $i++; 220 } 221 } 222 } 223 224 asort($orders); 225 $var=True; 226 227 $familylib=array( 228 'base'=>$langs->trans("ModuleFamilyBase"), 229 'crm'=>$langs->trans("ModuleFamilyCrm"), 230 'products'=>$langs->trans("ModuleFamilyProducts"), 231 'hr'=>$langs->trans("ModuleFamilyHr"), 232 'projects'=>$langs->trans("ModuleFamilyProjects"), 233 'other'=>$langs->trans("ModuleFamilyOther"), 234 'technic'=>$langs->trans("ModuleFamilyTechnic"), 235 'financial'=>$langs->trans("ModuleFamilyFinancial"), 236 ); 237 foreach ($orders as $key => $value) 238 { 239 $tab=split('_',$value); 240 $family=$tab[0]; $numero=$tab[1]; 241 242 $modName = $nom[$key]; 243 $objMod = $modules[$key]; 244 245 // On affiche pas module si en version 'development' et que 246 // constante MAIN_SHOW_DEVELOPMENT_MODULES non définie 247 if ($objMod->version == 'development' && ! $conf->global->MAIN_SHOW_DEVELOPMENT_MODULES) 248 { 249 continue; 250 } 251 252 $const_name = $objMod->const_name; 253 254 if ($oldfamily && $family!=$oldfamily && $atleastoneforfamily) { 255 print "<tr class=\"liste_titre\">\n <td colspan=\"9\"></td>\n</tr>\n"; 256 $atleastoneforfamily=0; 257 } 258 259 if((!$objMod->special && !$_GET["spe"] ) or ($objMod->special && $_GET["spe"])) 260 { 261 $atleastoneforfamily=1; 262 $var=!$var; 263 264 print "<tr $bc[$var]>\n"; 265 266 print " <td class=\"body\" valign=\"top\">"; 267 if ($family!=$oldfamily) 268 { 269 print "<div class=\"titre\">".$familylib[$family]."</div>"; 270 $oldfamily=$family; 271 } 272 else 273 { 274 print ' '; 275 } 276 print "</td>\n"; 277 print ' <td valign="top" width="14" align="center">'; 278 print $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); 279 print '</td><td valign="top">'.$objMod->getName(); 280 print "</td>\n <td valign=\"top\">"; 281 print $objMod->getDesc(); 282 print "</td>\n <td align=\"center\">"; 283 print $objMod->getVersion(); 284 print "</td>\n <td align=\"center\">"; 285 print $objMod->getDbVersion(); 286 print "</td>\n <td align=\"center\">"; 287 288 if ($conf->global->$const_name == 1) 289 { 290 print img_tick(); 291 } 292 else 293 { 294 print " "; 295 } 296 297 print "</td>\n <td align=\"center\">"; 298 299 if ($conf->global->$const_name == 1) 300 { 301 // Module actif 302 if ($family == 'base') print $langs->trans("Required"); 303 else print "<a href=\"modules.php?id=".$objMod->numero."&action=reset&value=" . $modName . "&spe=" . $_GET["spe"] . "\">" . $langs->trans("Disable") . "</a></td>\n"; 304 305 if ($objMod->config_page_url) 306 { 307 if (is_array($objMod->config_page_url)) { 308 print ' <td align="center">'; 309 $i=0; 310 foreach ($objMod->config_page_url as $page) 311 { 312 if ($i++) 313 { 314 print '<a href="'.$page.'">'.ucfirst($page).'</a> '; 315 } 316 else 317 { 318 //print '<a href="'.$page.'">'.$langs->trans("Setup").'</a> '; 319 print '<a href="'.$page.'">'.img_picto($langs->trans("Setup"),"setup").'</a> '; 320 } 321 } 322 print "</td>\n"; 323 } 324 else 325 { 326 //print ' <td align="center"><a href="'.$objMod->config_page_url.'">'.$langs->trans("Setup").'</a></td>'; 327 print ' <td align="center"><a href="'.$objMod->config_page_url.'">'.img_picto($langs->trans("Setup"),"setup").'</a></td>'; 328 } 329 } 330 else 331 { 332 print " <td> </td>"; 333 } 334 335 } 336 else 337 { 338 if ($family == 'base') 339 { 340 // Ne devrait pas arriver. 341 } 342 343 // Module non actif 344 print "<a href=\"modules.php?id=".$objMod->numero."&action=set&value=" . $modName . "&spe=" . $_GET["spe"] . "\">" . $langs->trans("Activate") . "</a></td>\n <td> </td>\n"; 345 } 346 347 print "</tr>\n"; 348 } 349 350 } 351 print "</table></div>\n"; 352 353 354 // Pour eviter bug mise en page IE 355 print '<div class="tabsAction">'; 356 print '</div>'; 357 358 359 llxFooter('$Date: 2005/10/22 13:48:19 $ - $Revision: 1.65 $'); 360 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |