Newer
Older
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* \file htdocs/admin/modules.php
* \brief Page to activate/disable all modules
* \version $Id: modules.php,v 1.157 2011/08/01 12:25:15 hregis Exp $
Laurent Destailleur
committed
Laurent Destailleur
committed
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
$langs->load("errors");
$mode=isset($_GET["mode"])?GETPOST("mode"):(isset($_SESSION['mode'])?$_SESSION['mode']:0);
if (!$user->admin)
/*
* Actions
*/
if (isset($_GET["action"]) && $_GET["action"] == 'set' && $user->admin)
$result=Activate($_GET["value"]);
$mesg='';
if ($result) $mesg=$result;
Header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg));
if (isset($_GET["action"]) && $_GET["action"] == 'reset' && $user->admin)
Laurent Destailleur
committed
{
$result=UnActivate($_GET["value"]);
$mesg='';
if ($result) $mesg=$result;
Header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg));
Laurent Destailleur
committed
}
$help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
llxHeader('',$langs->trans("Setup"),$help_url);
Rodolphe Quiedeville
committed
print_fiche_titre($langs->trans("ModulesSetup"),'','setup');
Laurent Destailleur
committed
// Search modules
Laurent Destailleur
committed
$filename = array();
Laurent Destailleur
committed
$categ = array();
Laurent Destailleur
committed
$dirmod = array();
$modulesdir = array();
$i = 0; // is a sequencer of modules found
$j = 0; // j is module number. Automatically affected if module number not defined.
foreach ($conf->file->dol_document_root as $type => $dirroot)
$modulesdir[] = $dirroot . "/includes/modules/";
if ($type == 'alt')
{
$althandle=@opendir($dirroot);
if (is_resource($althandle))
while (($file = readdir($althandle))!==false)
{
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
{
if (is_dir($dirroot . '/' . $file . '/includes/modules/'))
{
$modulesdir[] = $dirroot . '/' . $file . '/includes/modules/';
}
}
}
}
}
}
foreach ($modulesdir as $dir)
{
// Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>";
dol_syslog("Scan directory ".$dir." for modules");
Laurent Destailleur
committed
if (is_resource($handle))
Laurent Destailleur
committed
{
while (($file = readdir($handle))!==false)
{
//print "$i ".$file."\n<br>";
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
$modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName)
{
include_once($dir.$file);
$objMod = new $modName($db);
if ($objMod->numero > 0)
{
$j = $objMod->numero;
}
else
{
$j = 1000 + $i;
}
$modulequalified=1;
// We discard modules according to features level (PS: if module is activated we always show it)
Regis Houssin
committed
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0;
if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0;
if ($modulequalified)
{
$modules[$i] = $objMod;
$filename[$i]= $modName;
$orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module
//print "x".$modName." ".$orders[$i]."\n<br>";
if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories
else $categ[$objMod->special]=1;
$dirmod[$i] = $dirroot;
$j++;
$i++;
}
else dol_syslog("Module ".get_class($objMod)." not qualified");
}
}
}
closedir($handle);
Laurent Destailleur
committed
}
dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
Laurent Destailleur
committed
Laurent Destailleur
committed
asort($orders);
Laurent Destailleur
committed
//var_dump($orders);
//var_dump($categ);
//var_dump($modules);
Laurent Destailleur
committed
// Affichage debut page
if ($mode==0) { $tagmode = 'common'; print $langs->trans("ModulesDesc")."<br>\n"; }
if ($mode==2) { $tagmode = 'other'; print $langs->trans("ModulesSpecialDesc")."<br>\n"; }
if ($mode==1) { $tagmode = 'interfaces'; print $langs->trans("ModulesInterfaceDesc")."<br>\n"; }
if ($mode==3) { $tagmode = 'functional'; print $langs->trans("ModulesJobDesc")."<br>\n"; }
if ($mode==4) { $tagmode = 'marketplace'; print $langs->trans("ModulesMarketPlaceDesc")."<br>\n"; }
Laurent Destailleur
committed
print "<br>\n";
$h = 0;
if (! empty($categ[$categidx]))
Laurent Destailleur
committed
{
$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
$head[$h][1] = $langs->trans("ModulesCommon");
$head[$h][2] = 'common';
$h++;
}
if (! empty($categ[$categidx]))
Laurent Destailleur
committed
{
$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
$head[$h][1] = $langs->trans("ModulesOther");
$head[$h][2] = 'other';
Laurent Destailleur
committed
$h++;
}
$categidx=1; // Interfaces
if (! empty($categ[$categidx]))
Laurent Destailleur
committed
{
$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
$head[$h][1] = $langs->trans("ModulesInterfaces");
$head[$h][2] = 'interfaces';
Laurent Destailleur
committed
$h++;
}
$categidx=3; // Not used
if (! empty($categ[$categidx]))
Laurent Destailleur
committed
{
$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
$head[$h][1] = $langs->trans("ModulesSpecial");
Laurent Destailleur
committed
$head[$h][2] = 'functional';
$h++;
}
$categidx=4;
//if (! empty($categ[$categidx]))
//{
$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
$head[$h][1] = $langs->trans("ModulesMarketPlaces");
$head[$h][2] = 'marketplace';
$h++;
//}
Laurent Destailleur
committed
dol_fiche_head($head, $tagmode, $langs->trans("Modules"));
Laurent Destailleur
committed
Laurent Destailleur
committed
if ($mesg) print '<div class="error">'.$mesg.'</div>';
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
if ($mode != 4)
{
print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
//print "<tr class=\"liste_titre\">\n";
print '<tr class="liste_total">'."\n";
//print " <td>".$langs->trans("Family")."</td>\n";
print " <td colspan=\"2\">".$langs->trans("Module")."</td>\n";
print " <td>".$langs->trans("Description")."</td>\n";
print " <td align=\"center\">".$langs->trans("Version")."</td>\n";
//print " <td align=\"center\">".$langs->trans("DbVersion")."</td>\n";
print " <td align=\"center\">".$langs->trans("Status")."</td>\n";
print " <td align=\"right\">".$langs->trans("SetupShort")."</td>\n";
print "</tr>\n";
// Affichage liste modules
$var=true;
$oldfamily='';
$familylib=array(
'base'=>$langs->trans("ModuleFamilyBase"),
'crm'=>$langs->trans("ModuleFamilyCrm"),
'products'=>$langs->trans("ModuleFamilyProducts"),
'hr'=>$langs->trans("ModuleFamilyHr"),
'projects'=>$langs->trans("ModuleFamilyProjects"),
'financial'=>$langs->trans("ModuleFamilyFinancial"),
'ecm'=>$langs->trans("ModuleFamilyECM"),
'technic'=>$langs->trans("ModuleFamilyTechnic"),
'other'=>$langs->trans("ModuleFamilyOther")
);
foreach ($orders as $key => $value)
$tab=explode('_',$value);
$family=$tab[0]; $numero=$tab[1];
$modName = $filename[$key];
$objMod = $modules[$key];
//var_dump($objMod);
if ($objMod->special != $mode) continue; // Discard if not for tab
if (! $objMod->getName())
{
dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
// Load all lang files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles))
foreach($objMod->langfiles as $domain)
{
$langs->load($domain);
}
}
// Print a separator if we change family
//print "<tr><td>xx".$oldfamily."-".$family."-".$atleastoneforfamily."<br></td><tr>";
//if ($oldfamily && $family!=$oldfamily && $atleastoneforfamily) {
if ($family!=$oldfamily) {
print '<tr class="liste_titre">'."\n <td colspan=\"6\">";
Laurent Destailleur
committed
$familytext=empty($familylib[$family])?$family:$familylib[$family];
print $familytext;
print "</td>\n</tr>\n";
$atleastoneforfamily=0;
//print "<tr><td>yy".$oldfamily."-".$family."-".$atleastoneforfamily."<br></td><tr>";
if ($objMod->special == $mode)
$atleastoneforfamily++;
$var=!$var;
//print ' <td valign="top" nowrap="nowrap">';
if ($family!=$oldfamily)
{
$familytext=empty($familylib[$family])?$family:$familylib[$family];
//print $familytext;
$oldfamily=$family;
}
else
{
//print ' ';
}
//print "</td>\n";
// Picto
print ' <td valign="top" width="14" align="center">';
$alttext='';
//if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
//if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
if (! empty($objMod->picto))
if (preg_match('/^\//i',$objMod->picto)) print img_picto($alttext,$objMod->picto,' width="14px"',1);
else print img_object($alttext,$objMod->picto,' width="14px"');
}
else
{
print img_object($alttext,'generic');
print '</td>';
// Name
print '<td valign="top">'.$objMod->getName();
print "</td>\n";
// Desc
print "<td valign=\"top\">";
print nl2br($objMod->getDesc());
print "</td>\n";
// Version
print "<td align=\"center\" valign=\"top\" nowrap=\"nowrap\">";
print $objMod->getVersion();
print "</td>\n";
// Activate/Disable and Setup (2 columns)
if (! empty($conf->global->$const_name))
$disableSetup = 0;
print "<td align=\"center\" valign=\"top\">";
// Module actif
if (! empty($objMod->always_enabled) || (($conf->global->MAIN_MODULE_MULTICOMPANY && $objMod->core_enabled) && ($user->entity || $conf->entity!=1)))
{
print $langs->trans("Required");
if ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->entity) $disableSetup++;
print '</td>'."\n";
}
else
{
print '<a href="modules.php?id='.$objMod->numero.'&action=reset&value=' . $modName . '&mode=' . $mode . '">';
print img_picto($langs->trans("Activated"),'on');
print '</a></td>'."\n";
}
if (! empty($objMod->config_page_url) && !$disableSetup)
if (is_array($objMod->config_page_url))
print ' <td align="right" valign="top">';
$i=0;
foreach ($objMod->config_page_url as $page)
$urlpage=$page;
if ($i++)
{
print '<a href="'.$urlpage.'" title="'.$langs->trans($page).'">'.img_picto(ucfirst($page),"setup").'</a> ';
// print '<a href="'.$page.'">'.ucfirst($page).'</a> ';
}
else
{
if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs))
{
print '<a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup").'</a> ';
}
else
{
print '<a href="'.$urlpage.'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup").'</a> ';
}
}
print "</td>\n";
}
else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs))
{
print '<td align="right" valign="top"><a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup").'</a></td>';
}
else
{
print '<td align="right" valign="top"><a href="'.$objMod->config_page_url.'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup").'</a></td>';
print "<td> </td>";
print "<td align=\"center\" valign=\"top\">";
if (! empty($objMod->always_enabled))
{
// Ne devrait pas arriver.
}
// Module non actif
print '<a href="modules.php?id='.$objMod->numero.'&action=set&value=' . $modName . '&mode=' . $mode . '">';
print img_picto($langs->trans("Disabled"),'off');
print "</a></td>\n <td> </td>\n";
}
else
{
// Marketplace
print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
//print '<td>'.$langs->trans("Logo").'</td>';
print '<td colspan="2">'.$langs->trans("WebSiteDesc").'</td>';
print '<td>'.$langs->trans("URL").'</td>';
print '</tr>';
$var=!$var;
print "<tr ".$bc[$var].">\n";
$url='http://www.dolistore.com';
print '<td align="left"><a href="'.$url.'" target="_blank"><img border="0" src="'.DOL_URL_ROOT.'/theme/common/dolistore.jpg"></a></td>';
print '<td>'.$langs->trans("DoliStoreDesc").'</td>';
print '<td><a href="'.$url.'" target="_blank">'.$url.'</a></td>';
print '</tr>';
print "</table>\n";
}
// Pour eviter bug mise en page IE
print '<div class="tabsAction">';
print '</div>';
$db->close();
llxFooter('$Date: 2011/08/01 12:25:15 $ - $Revision: 1.157 $');