2003-03-11 17:18:54 +01:00
< ? PHP
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-02-21 00:40:13 +01:00
* Copyright ( C ) 2003 Jean - Louis Bergamo < jlb @ j1b . org >
* Copyright ( C ) 2004 Laurent Destailleur < eldy @ users . sourceforge . net >
2003-03-11 17:18:54 +01:00
*
* 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 , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* $Id $
* $Source $
*/
require ( " ./pre.inc.php " );
2004-02-15 01:05:21 +01:00
if ( ! $user -> admin )
accessforbidden ();
2003-03-11 17:18:54 +01:00
//
// TODO mettre cette section dans la base de donn<6E> es
//
2003-11-05 12:46:09 +01:00
if ( $_GET [ " action " ] == 'set' && $user -> admin )
2003-03-11 17:18:54 +01:00
{
2003-11-05 12:46:09 +01:00
Activate ( $_GET [ " value " ]);
2003-09-10 18:50:53 +02:00
Header ( " Location: modules.php " );
}
2004-02-28 00:11:26 +01:00
if ( $_GET [ " action " ] == 'reset' && $user -> admin )
{
UnActivate ( $_GET [ " value " ]);
Header ( " Location: modules.php " );
}
2003-09-10 18:50:53 +02:00
function Activate ( $value )
{
global $db , $modules ;
2003-11-13 16:09:12 +01:00
$modName = $value ;
2003-03-11 17:18:54 +01:00
2004-02-28 00:11:26 +01:00
// Activation du module
2003-11-13 16:09:12 +01:00
if ( $modName )
2003-03-11 17:18:54 +01:00
{
2003-11-13 16:09:12 +01:00
$file = $modName . " .class.php " ;
include_once ( " ../includes/modules/ $file " );
$objMod = new $modName ( $db );
$objMod -> init ();
2003-03-11 17:18:54 +01:00
}
2004-02-28 00:11:26 +01:00
// Activation des modules dont le module d<> pend
2003-09-10 18:50:53 +02:00
for ( $i = 0 ; $i < sizeof ( $objMod -> depends ); $i ++ )
{
Activate ( $objMod -> depends [ $i ]);
}
2004-02-28 00:11:26 +01:00
2003-03-11 17:18:54 +01:00
}
2004-02-28 00:11:26 +01:00
function UnActivate ( $value )
2003-03-11 17:18:54 +01:00
{
2004-02-28 00:11:26 +01:00
global $db , $modules ;
$modName = $value ;
2003-03-11 17:18:54 +01:00
2004-02-28 00:11:26 +01:00
// Desactivation du module
2003-11-13 16:09:12 +01:00
if ( $modName )
2003-03-11 17:18:54 +01:00
{
2003-11-13 16:09:12 +01:00
$file = $modName . " .class.php " ;
2004-01-27 00:01:31 +01:00
include_once ( " ../includes/modules/ $file " );
2003-11-13 16:09:12 +01:00
$objMod = new $modName ( $db );
$objMod -> remove ();
2003-03-11 17:18:54 +01:00
}
2003-11-13 16:09:12 +01:00
2004-02-28 00:11:26 +01:00
// Desactivation des modules qui dependent de lui
for ( $i = 0 ; $i < sizeof ( $objMod -> requiredby ); $i ++ )
{
UnActivate ( $objMod -> requiredby [ $i ]);
}
2003-09-10 18:50:53 +02:00
Header ( " Location: modules.php " );
2003-03-11 17:18:54 +01:00
}
2004-02-28 00:11:26 +01:00
2003-03-11 17:18:54 +01:00
$db -> close ();
2003-09-10 18:03:01 +02:00
llxHeader ();
if ( ! $user -> admin )
{
print " Forbidden " ;
llxfooter ();
exit ;
}
2003-03-11 17:18:54 +01:00
print_titre ( " Modules " );
2004-02-28 18:48:35 +01:00
print '<br>' ;
print 'Les modules Dolibarr d<> finissent les fonctionnalit<69> s disponibles dans l\'application.<br>' ;
print 'Certains modules n<> cessitent des droits qu\'il vous faudra affecter aux utilisateurs pour qu\'ils puissent acc<63> der <20> ces fonctionnalit<69> s.<br>' ;
2004-02-15 01:05:21 +01:00
print '<br>' ;
print '<table class="noborder" cellpadding="3" cellspacing="0">' ;
print '<tr class="liste_titre">' ;
2004-06-26 19:15:28 +02:00
print '<td>Famille</td>' ;
2004-06-26 19:43:07 +02:00
print '<td>Module</td>' ;
2003-11-13 16:09:12 +01:00
print '<td>Info</td>' ;
2004-02-28 18:48:35 +01:00
print '<td align="center">Actif</td>' ;
print '<td align="center">Action</td>' ;
print '<td> </td>' ;
2003-11-13 16:09:12 +01:00
print " </tr> \n " ;
$dir = DOL_DOCUMENT_ROOT . " /includes/modules/ " ;
$handle = opendir ( $dir );
$modules = array ();
$i = 0 ;
$j = 0 ;
while (( $file = readdir ( $handle )) !== false )
{
if ( is_readable ( $dir . $file ) && substr ( $file , 0 , 3 ) == 'mod' && substr ( $file , strlen ( $file ) - 10 ) == '.class.php' )
{
$modName = substr ( $file , 0 , strlen ( $file ) - 10 );
if ( $modName )
{
2004-01-27 00:01:31 +01:00
include_once ( " ../includes/modules/ $file " );
2003-11-13 16:09:12 +01:00
$objMod = new $modName ( $db );
if ( $objMod -> numero > 0 )
{
$j = $objMod -> numero ;
2004-06-26 19:15:28 +02:00
// $modules[$objMod->numero] = $modName;
2003-11-13 16:09:12 +01:00
}
else
{
$j = 1000 + $i ;
}
2004-06-26 19:15:28 +02:00
$modules [ $i ] = $modName ;
$numero [ $i ] = $j ;
$orders [ $i ] = " $objMod->family " . " _ " . $j ; // Tri par famille puis numero module
2003-11-13 16:09:12 +01:00
$j ++ ;
$i ++ ;
}
}
}
2003-03-11 17:18:54 +01:00
2004-06-26 19:15:28 +02:00
asort ( $orders );
2004-02-15 01:05:21 +01:00
$var = True ;
2003-11-13 16:09:12 +01:00
2004-06-26 19:15:28 +02:00
$familylib = array (
'crm' => 'Gestion client (CRM)' ,
'products' => 'Gestion produits' ,
'hr' => 'Ressources humaines' ,
'projects' => 'Projets/Travail collaboratif' ,
'other' => 'Autre' ,
'technic' => 'Modules techniques, interfaces' ,
'financial' => 'Modules financiers (Compta/tr<74> sorerie)'
);
2003-11-13 16:09:12 +01:00
foreach ( $orders as $key => $value )
2003-03-11 17:18:54 +01:00
{
2004-06-26 19:15:28 +02:00
$tab = split ( '_' , $value );
$family = $tab [ 0 ]; $numero = $tab [ 1 ];
2004-02-15 01:05:21 +01:00
$var =! $var ;
2004-06-26 19:15:28 +02:00
$modName = $modules [ $key ];
2003-11-13 16:09:12 +01:00
if ( $modName )
{
$objMod = new $modName ( $db );
}
$const_name = $objMod -> const_name ;
$const_value = $objMod -> const_config ;
2004-06-26 19:43:07 +02:00
if ( $oldfamily && $family != $oldfamily ) { print '<tr class="liste_titre"><td colspan="6"></td></tr>' ; }
2003-11-13 16:09:12 +01:00
2004-06-26 19:15:28 +02:00
print " <tr $bc[$var] > " ;
print " <td class='body'> " ;
if ( $family != $oldfamily ) { print '<div class="titre">' . $familylib [ $family ] . '</td>' ; $oldfamily = $family ; }
else { print ' ' ; }
print " </td> " ;
print " <td> " ;
print $objMod -> name ;
2003-03-11 17:18:54 +01:00
print " </td><td> \n " ;
2003-11-13 16:09:12 +01:00
print $objMod -> description ;
2003-03-11 17:18:54 +01:00
print '</td><td align="center">' ;
2003-11-13 16:09:12 +01:00
2003-03-11 17:18:54 +01:00
if ( $const_value == 1 )
{
2003-06-24 00:18:58 +02:00
print '<img src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/tick.png" border="0"></a>' ;
2003-03-11 17:18:54 +01:00
}
else
{
print " " ;
}
print '</td><td align="center">' ;
2003-11-13 16:09:12 +01:00
2003-03-11 17:18:54 +01:00
if ( $const_value == 1 )
{
2003-11-13 16:09:12 +01:00
print '<a href="modules.php?action=reset&value=' . $modName . '">D<> sactiver</a></td>' ;
2003-11-07 18:44:20 +01:00
if ( $objMod -> config_page_url )
{
2004-02-21 00:40:13 +01:00
if ( is_array ( $objMod -> config_page_url )) {
print '<td>' ;
$i = 0 ;
foreach ( $objMod -> config_page_url as $page ) {
if ( $i ++ ) { print '<a href="' . $page . '">' . ucfirst ( $page ) . '</a> ' ; }
else { print '<a href="' . $page . '">Configurer</a> ' ; }
}
print '</td>' ;
} else {
print '<td><a href="' . $objMod -> config_page_url . '">Configurer</a></td>' ;
}
2003-11-07 18:44:20 +01:00
}
else
{
print " <td> </td> " ;
}
2003-03-11 17:18:54 +01:00
}
else
{
2003-11-13 16:09:12 +01:00
print '<a href="modules.php?action=set&value=' . $modName . '">Activer</a></td><td> </td>' ;
2003-03-11 17:18:54 +01:00
}
2003-11-07 18:44:20 +01:00
print '</tr>' ;
2003-11-13 16:09:12 +01:00
2003-03-11 17:18:54 +01:00
}
2003-11-13 16:09:12 +01:00
print " </table> " ;
2003-03-11 17:18:54 +01:00
llxFooter ();
?>