2004-10-19 20:58:50 +02:00
< ? php
2017-06-16 17:01:43 +02:00
/* Copyright ( C ) 2003 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2003 Jean - Louis Bergamo < jlb @ j1b . org >
* Copyright ( C ) 2004 - 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2011 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
* Copyright ( C ) 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2003-03-11 17:18:54 +01:00
* ( 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
2011-08-01 00:21:57 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2003-03-11 17:18:54 +01:00
*/
2009-01-21 14:20:26 +01:00
2005-04-07 00:36:44 +02:00
/**
2008-09-11 00:07:38 +02:00
* \file htdocs / admin / modules . php
2010-11-13 19:57:10 +01:00
* \brief Page to activate / disable all modules
2008-09-11 00:07:38 +02:00
*/
2004-08-29 14:01:58 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2017-02-11 15:41:01 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/geturl.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2017-08-22 14:47:01 +02:00
require_once DOL_DOCUMENT_ROOT . '/admin/dolistore/class/dolistore.class.php' ;
2003-03-11 17:18:54 +01:00
2017-11-19 16:26:39 +01:00
$langs -> loadLangs ( array ( " errors " , " admin " , " modulebuilder " ));
2009-08-24 14:05:41 +02:00
2017-02-11 15:41:01 +01:00
$mode = GETPOST ( 'mode' , 'alpha' );
if ( empty ( $mode )) $mode = 'common' ;
2012-10-09 09:34:12 +02:00
$action = GETPOST ( 'action' , 'alpha' );
2012-10-20 09:33:39 +02:00
$value = GETPOST ( 'value' , 'alpha' );
2015-11-13 03:35:55 +01:00
$page_y = GETPOST ( 'page_y' , 'int' );
2016-03-14 19:40:52 +01:00
$search_keyword = GETPOST ( 'search_keyword' , 'alpha' );
$search_status = GETPOST ( 'search_status' , 'alpha' );
$search_nature = GETPOST ( 'search_nature' , 'alpha' );
2016-04-06 13:27:46 +02:00
$search_version = GETPOST ( 'search_version' , 'alpha' );
2006-03-31 21:30:08 +02:00
2017-08-22 14:47:01 +02:00
// For dolistore search
$options = array ();
$options [ 'per_page' ] = 20 ;
2017-09-15 11:19:19 +02:00
$options [ 'categorie' ] = (( GETPOST ( 'categorie' , 'int' ) ? GETPOST ( 'categorie' , 'int' ) : 0 ) + 0 );
$options [ 'start' ] = (( GETPOST ( 'start' , 'int' ) ? GETPOST ( 'start' , 'int' ) : 0 ) + 0 );
$options [ 'end' ] = (( GETPOST ( 'end' , 'int' ) ? GETPOST ( 'end' , 'int' ) : 0 ) + 0 );
2017-08-22 14:47:01 +02:00
$options [ 'search' ] = GETPOST ( 'search_keyword' , 'alpha' );
2017-09-16 10:42:23 +02:00
$dolistore = new Dolistore ();
2017-08-22 14:47:01 +02:00
2012-10-09 09:34:12 +02:00
if ( ! $user -> admin )
accessforbidden ();
2004-10-23 00:42:10 +02:00
2012-09-12 20:33:50 +02:00
$specialtostring = array ( 0 => 'common' , 1 => 'interfaces' , 2 => 'other' , 3 => 'functional' , 4 => 'marketplace' );
2015-10-07 07:57:09 +02:00
$familyinfo = array (
'hr' => array ( 'position' => '001' , 'label' => $langs -> trans ( " ModuleFamilyHr " )),
'crm' => array ( 'position' => '006' , 'label' => $langs -> trans ( " ModuleFamilyCrm " )),
2016-02-19 19:20:21 +01:00
'srm' => array ( 'position' => '007' , 'label' => $langs -> trans ( " ModuleFamilySrm " )),
'financial' => array ( 'position' => '009' , 'label' => $langs -> trans ( " ModuleFamilyFinancial " )),
2015-10-07 07:57:09 +02:00
'products' => array ( 'position' => '012' , 'label' => $langs -> trans ( " ModuleFamilyProducts " )),
'projects' => array ( 'position' => '015' , 'label' => $langs -> trans ( " ModuleFamilyProjects " )),
'ecm' => array ( 'position' => '018' , 'label' => $langs -> trans ( " ModuleFamilyECM " )),
'technic' => array ( 'position' => '021' , 'label' => $langs -> trans ( " ModuleFamilyTechnic " )),
'portal' => array ( 'position' => '040' , 'label' => $langs -> trans ( " ModuleFamilyPortal " )),
'interface' => array ( 'position' => '050' , 'label' => $langs -> trans ( " ModuleFamilyInterface " )),
'base' => array ( 'position' => '060' , 'label' => $langs -> trans ( " ModuleFamilyBase " )),
'other' => array ( 'position' => '100' , 'label' => $langs -> trans ( " ModuleFamilyOther " )),
);
2016-03-14 19:40:52 +01:00
$param = '' ;
if ( $search_keyword ) $param .= '&search_keyword=' . urlencode ( $search_keyword );
2018-04-02 23:30:23 +02:00
if ( $search_status && $search_status != '-1' ) $param .= '&search_status=' . urlencode ( $search_status );
if ( $search_nature && $search_nature != '-1' ) $param .= '&search_nature=' . urlencode ( $search_nature );
if ( $search_version && $search_version != '-1' ) $param .= '&search_version=' . urlencode ( $search_version );
2016-03-14 19:40:52 +01:00
2017-02-11 15:41:01 +01:00
$dirins = DOL_DOCUMENT_ROOT . '/custom' ;
$urldolibarrmodules = 'https://www.dolistore.com/' ;
2015-10-07 07:57:09 +02:00
2017-06-16 17:01:43 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager -> initHooks ( array ( 'adminmodules' , 'globaladmin' ));
2006-03-31 21:30:08 +02:00
2005-10-18 23:29:45 +02:00
/*
* Actions
*/
2003-03-11 17:18:54 +01:00
2017-12-05 11:34:07 +01:00
$formconfirm = '' ;
2017-06-16 17:01:43 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2017-06-17 11:43:00 +02:00
if ( GETPOST ( 'buttonreset' , 'alpha' ))
2016-09-30 18:26:32 +02:00
{
$search_keyword = '' ;
$search_status = '' ;
$search_nature = '' ;
$search_version = '' ;
}
2017-02-11 15:41:01 +01:00
if ( $action == 'install' )
{
$error = 0 ;
// $original_file should match format module_modulename-x.y[.z].zip
$original_file = basename ( $_FILES [ " fileinstall " ][ " name " ]);
$newfile = $conf -> admin -> dir_temp . '/' . $original_file . '/' . $original_file ;
if ( ! $original_file )
{
$langs -> load ( " Error " );
setEventMessages ( $langs -> trans ( " ErrorModuleFileRequired " ), null , 'warnings' );
$error ++ ;
}
else
{
2017-02-13 01:36:02 +01:00
if ( ! preg_match ( '/\.zip$/i' , $original_file ))
2017-02-11 15:41:01 +01:00
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFileMustBeADolibarrPackage " , $original_file ), null , 'errors' );
$error ++ ;
}
2017-02-13 01:36:02 +01:00
if ( ! preg_match ( '/module_.*\-[\d]+\.[\d]+.*$/i' , $original_file ))
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFilenameDosNotMatchDolibarrPackageRules " , $original_file , 'module_*-x.y*.zip' ), null , 'errors' );
$error ++ ;
}
2017-02-11 15:41:01 +01:00
}
if ( ! $error )
{
if ( $original_file )
{
@ dol_delete_dir_recursive ( $conf -> admin -> dir_temp . '/' . $original_file );
dol_mkdir ( $conf -> admin -> dir_temp . '/' . $original_file );
}
$tmpdir = preg_replace ( '/\.zip$/' , '' , $original_file ) . '.dir' ;
if ( $tmpdir )
{
@ dol_delete_dir_recursive ( $conf -> admin -> dir_temp . '/' . $tmpdir );
dol_mkdir ( $conf -> admin -> dir_temp . '/' . $tmpdir );
}
$result = dol_move_uploaded_file ( $_FILES [ 'fileinstall' ][ 'tmp_name' ], $newfile , 1 , 0 , $_FILES [ 'fileinstall' ][ 'error' ]);
if ( $result > 0 )
{
$result = dol_uncompress ( $newfile , $conf -> admin -> dir_temp . '/' . $tmpdir );
if ( ! empty ( $result [ 'error' ]))
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( $result [ 'error' ], $original_file ), null , 'errors' );
$error ++ ;
}
else
{
// Now we move the dir of the module
$modulename = preg_replace ( '/module_/' , '' , $original_file );
$modulename = preg_replace ( '/\-[\d]+\.[\d]+.*$/' , '' , $modulename );
// Search dir $modulename
$modulenamedir = $conf -> admin -> dir_temp . '/' . $tmpdir . '/' . $modulename ;
//var_dump($modulenamedir);
if ( ! dol_is_dir ( $modulenamedir ))
{
$modulenamedir = $conf -> admin -> dir_temp . '/' . $tmpdir . '/htdocs/' . $modulename ;
//var_dump($modulenamedir);
if ( ! dol_is_dir ( $modulenamedir ))
{
2017-02-13 01:36:02 +01:00
setEventMessages ( $langs -> trans ( " ErrorModuleFileSeemsToHaveAWrongFormat " ) . '<br>Dir not found: ' . $conf -> admin -> dir_temp . '/' . $tmpdir . '/' . $modulename . '<br>' . $conf -> admin -> dir_temp . '/' . $tmpdir . '/htdocs/' . $modulename , null , 'errors' );
2017-02-11 15:41:01 +01:00
$error ++ ;
}
}
if ( ! $error )
{
//var_dump($dirins);
@ dol_delete_dir_recursive ( $dirins . '/' . $modulename );
dol_syslog ( " Uncompress of module file is a success. We copy it from " . $modulenamedir . " into target dir " . $dirins . '/' . $modulename );
$result = dolCopyDir ( $modulenamedir , $dirins . '/' . $modulename , '0444' , 1 );
if ( $result <= 0 )
{
dol_syslog ( 'Failed to call dolCopyDir result=' . $result . " with param " . $modulenamedir . " and " . $dirins . '/' . $modulename , LOG_WARNING );
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFailToCopyDir " , $modulenamedir , $dirins . '/' . $modulename ), null , 'errors' );
$error ++ ;
}
}
}
}
else
{
$error ++ ;
}
}
if ( ! $error )
{
setEventMessages ( $langs -> trans ( " SetupIsReadyForUse " , DOL_URL_ROOT . '/admin/modules.php?mainmenu=home' , $langs -> transnoentitiesnoconv ( " Home " ) . ' - ' . $langs -> transnoentitiesnoconv ( " Setup " ) . ' - ' . $langs -> transnoentitiesnoconv ( " Modules " )), null , 'warnings' );
}
}
2012-02-24 11:06:05 +01:00
if ( $action == 'set' && $user -> admin )
2003-03-11 17:18:54 +01:00
{
2016-09-30 18:26:32 +02:00
$resarray = activateModule ( $value );
if ( ! empty ( $resarray [ 'errors' ])) setEventMessages ( '' , $resarray [ 'errors' ], 'errors' );
2016-06-04 13:25:39 +02:00
else
{
2016-09-30 18:26:32 +02:00
//var_dump($resarray);exit;
if ( $resarray [ 'nbperms' ] > 0 )
{
2017-06-24 22:13:00 +02:00
$tmpsql = " SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . " user WHERE admin <> 1 " ;
$resqltmp = $db -> query ( $tmpsql );
if ( $resqltmp )
{
$obj = $db -> fetch_object ( $resqltmp );
//var_dump($obj->nb);exit;
if ( $obj && $obj -> nb > 1 )
{
$msg = $langs -> trans ( 'ModuleEnabledAdminMustCheckRights' );
setEventMessages ( $msg , null , 'warnings' );
}
}
else dol_print_error ( $db );
2016-09-30 18:26:32 +02:00
}
2016-06-04 13:25:39 +02:00
}
2017-06-16 17:01:43 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?mode= " . $mode . $param . ( $page_y ? '&page_y=' . $page_y : '' ));
2006-03-23 00:44:46 +01:00
exit ;
2003-09-10 18:50:53 +02:00
}
2017-12-05 11:34:07 +01:00
else if ( $action == 'reset' && $user -> admin && GETPOST ( 'confirm' ) == 'yes' )
2004-02-28 00:11:26 +01:00
{
2012-10-09 09:34:12 +02:00
$result = unActivateModule ( $value );
2015-10-29 13:58:16 +01:00
if ( $result ) setEventMessages ( $result , null , 'errors' );
2017-06-16 17:01:43 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?mode= " . $mode . $param . ( $page_y ? '&page_y=' . $page_y : '' ));
2006-03-23 00:44:46 +01:00
exit ;
2004-02-28 00:11:26 +01:00
}
2016-03-14 19:40:52 +01:00
2004-02-28 00:11:26 +01:00
2005-10-18 23:29:45 +02:00
/*
2010-09-04 18:16:15 +02:00
* View
2005-10-18 23:29:45 +02:00
*/
2010-09-04 18:16:15 +02:00
2017-08-22 14:47:01 +02:00
$form = new Form ( $db );
2017-09-18 10:33:54 +02:00
//$morejs = array("/admin/dolistore/js/dolistore.js.php");
2017-08-22 14:47:01 +02:00
$morecss = array ( " /admin/dolistore/css/dolistore.css " );
2017-02-11 15:41:01 +01:00
// Set dir where external modules are installed
if ( ! dol_is_dir ( $dirins ))
{
dol_mkdir ( $dirins );
}
$dirins_ok = ( dol_is_dir ( $dirins ));
2010-05-26 13:28:10 +02:00
$help_url = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones' ;
2017-08-22 14:47:01 +02:00
llxHeader ( '' , $langs -> trans ( " Setup " ), $help_url , '' , '' , '' , $morejs , $morecss , 0 , 0 );
2004-11-22 10:57:37 +01:00
2016-04-06 16:45:22 +02:00
$arrayofnatures = array ( 'core' => $langs -> transnoentitiesnoconv ( " Core " ), 'external' => $langs -> transnoentitiesnoconv ( " External " ) . ' - ' . $langs -> trans ( " AllPublishers " ));
2017-03-09 15:16:16 +01:00
$arrayofwarnings = array (); // Array of warning each module want to show when activated
$arrayofwarningsext = array (); // Array of warning each module want to show when we activate an external module
2006-08-12 17:32:57 +02:00
2012-01-26 23:05:59 +01:00
// Search modules dirs
2015-08-31 17:42:08 +02:00
$modulesdir = dolGetModulesDirs ();
2004-10-23 00:42:10 +02:00
2012-01-26 23:05:59 +01:00
$filename = array ();
$modules = array ();
$orders = array ();
$categ = array ();
$dirmod = array ();
$i = 0 ; // is a sequencer of modules found
$j = 0 ; // j is module number. Automatically affected if module number not defined.
2012-03-15 15:47:01 +01:00
$modNameLoaded = array ();
2012-01-26 23:05:59 +01:00
2011-08-01 14:25:14 +02:00
foreach ( $modulesdir as $dir )
{
2008-12-02 15:16:18 +01:00
// Load modules attributes in arrays (name, numero, orders) from dir directory
2010-12-14 23:31:59 +01:00
//print $dir."\n<br>";
2012-07-30 21:43:40 +02:00
dol_syslog ( " Scan directory " . $dir . " for module descriptor files (modXXX.class.php) " );
2009-03-03 19:25:48 +01:00
$handle =@ opendir ( $dir );
2010-12-15 19:15:08 +01:00
if ( is_resource ( $handle ))
2008-03-10 00:14:08 +01:00
{
2008-12-02 15:16:18 +01:00
while (( $file = readdir ( $handle )) !== false )
{
//print "$i ".$file."\n<br>";
2010-08-24 16:42:18 +02:00
if ( is_readable ( $dir . $file ) && substr ( $file , 0 , 3 ) == 'mod' && substr ( $file , dol_strlen ( $file ) - 10 ) == '.class.php' )
2008-12-02 15:16:18 +01:00
{
2010-08-24 16:42:18 +02:00
$modName = substr ( $file , 0 , dol_strlen ( $file ) - 10 );
2009-01-21 14:20:26 +01:00
2008-12-02 15:16:18 +01:00
if ( $modName )
{
2017-03-09 15:16:16 +01:00
if ( ! empty ( $modNameLoaded [ $modName ])) // In cache of already loaded modules ?
2012-03-15 15:47:01 +01:00
{
$mesg = " Error: Module " . $modName . " was found twice: Into " . $modNameLoaded [ $modName ] . " and " . $dir . " . You probably have an old file on your disk.<br> " ;
2015-10-29 13:58:16 +01:00
setEventMessages ( $mesg , null , 'warnings' );
2012-10-09 09:34:12 +02:00
dol_syslog ( $mesg , LOG_ERR );
2012-05-08 15:00:46 +02:00
continue ;
2012-03-15 15:47:01 +01:00
}
2012-05-08 15:00:46 +02:00
2011-11-02 14:15:14 +01:00
try
2008-12-02 15:16:18 +01:00
{
2017-06-10 23:50:02 +02:00
$res = include_once $dir . $file ; // A class already exists in a different file will send a non catchable fatal error.
2013-12-08 02:32:04 +01:00
if ( class_exists ( $modName ))
{
try {
$objMod = new $modName ( $db );
$modNameLoaded [ $modName ] = $dir ;
2016-02-19 19:11:31 +01:00
if ( ! $objMod -> numero > 0 && $modName != 'modUser' )
2013-12-08 02:32:04 +01:00
{
2016-01-10 13:00:48 +01:00
dol_syslog ( 'The module descriptor ' . $modName . ' must have a numero property' , LOG_ERR );
2013-12-08 02:32:04 +01:00
}
2015-10-07 07:57:09 +02:00
$j = $objMod -> numero ;
2016-01-10 13:00:48 +01:00
2016-04-06 16:45:22 +02:00
$modulequalified = 1 ;
2013-12-08 02:32:04 +01:00
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_' . strtoupper ( preg_replace ( '/^mod/i' , '' , get_class ( $objMod )));
2016-04-06 16:45:22 +02:00
if ( $objMod -> version == 'development' && ( empty ( $conf -> global -> $const_name ) && ( $conf -> global -> MAIN_FEATURES_LEVEL < 2 ))) $modulequalified = 0 ;
if ( $objMod -> version == 'experimental' && ( empty ( $conf -> global -> $const_name ) && ( $conf -> global -> MAIN_FEATURES_LEVEL < 1 ))) $modulequalified = 0 ;
if ( preg_match ( '/deprecated/' , $objMod -> version ) && ( empty ( $conf -> global -> $const_name ) && ( $conf -> global -> MAIN_FEATURES_LEVEL >= 0 ))) $modulequalified = 0 ;
2017-03-09 15:16:16 +01:00
// We discard modules according to property ->hidden
2016-04-06 16:45:22 +02:00
if ( ! empty ( $objMod -> hidden )) $modulequalified = 0 ;
if ( $modulequalified > 0 )
2016-04-06 13:27:46 +02:00
{
2016-04-06 16:45:22 +02:00
$publisher = dol_escape_htmltag ( $objMod -> getPublisher ());
$external = ( $objMod -> isCoreOrExternalModule () == 'external' );
if ( $external )
{
if ( $publisher )
{
$arrayofnatures [ 'external_' . $publisher ] = $langs -> trans ( " External " ) . ' - ' . $publisher ;
}
else
{
$arrayofnatures [ 'external_' ] = $langs -> trans ( " External " ) . ' - ' . $langs -> trans ( " UnknownPublishers " );
}
}
ksort ( $arrayofnatures );
2016-04-06 13:27:46 +02:00
}
2017-01-15 16:07:04 +01:00
2013-12-08 02:32:04 +01:00
// Define array $categ with categ with at least one qualified module
2016-04-06 16:45:22 +02:00
if ( $modulequalified > 0 )
2013-12-08 02:32:04 +01:00
{
$filename [ $i ] = $modName ;
2017-03-09 15:16:16 +01:00
$modules [ $modName ] = $objMod ;
2016-01-10 13:00:48 +01:00
// Gives the possibility to the module, to provide his own family info and position of this family
if ( is_array ( $objMod -> familyinfo ) && ! empty ( $objMod -> familyinfo )) {
$familyinfo = array_merge ( $familyinfo , $objMod -> familyinfo );
$familykey = key ( $objMod -> familyinfo );
} else {
$familykey = $objMod -> family ;
}
2015-11-17 00:58:12 +01:00
$moduleposition = ( $objMod -> module_position ? $objMod -> module_position : '500' );
if ( $moduleposition == 500 && ( $objMod -> isCoreOrExternalModule () == 'external' ))
{
$moduleposition = 800 ;
}
2016-01-10 13:00:48 +01:00
2017-03-09 15:16:16 +01:00
// Add list of warnings to show into arrayofwarnings and arrayofwarningsext
if ( ! empty ( $objMod -> warnings_activation ))
{
$arrayofwarnings [ $modName ] = $objMod -> warnings_activation ;
}
if ( ! empty ( $objMod -> warnings_activation_ext ))
{
$arrayofwarningsext [ $modName ] = $objMod -> warnings_activation_ext ;
}
2017-06-10 23:50:02 +02:00
2015-11-17 00:58:12 +01:00
$orders [ $i ] = $familyinfo [ $familykey ][ 'position' ] . " _ " . $familykey . " _ " . $moduleposition . " _ " . $j ; // Sort by family, then by module position then number
2013-12-08 02:32:04 +01:00
$dirmod [ $i ] = $dir ;
2016-04-07 11:50:45 +02:00
//print $i.'-'.$dirmod[$i].'<br>';
2013-12-08 02:32:04 +01:00
// Set categ[$i]
2018-02-25 10:55:02 +01:00
$specialstring = 'unknown' ;
2015-10-07 07:57:09 +02:00
if ( $objMod -> version == 'development' || $objMod -> version == 'experimental' ) $specialstring = 'expdev' ;
if ( isset ( $categ [ $specialstring ])) $categ [ $specialstring ] ++ ; // Array of all different modules categories
else $categ [ $specialstring ] = 1 ;
2013-12-08 02:32:04 +01:00
$j ++ ;
$i ++ ;
}
else dol_syslog ( " Module " . get_class ( $objMod ) . " not qualified " );
}
catch ( Exception $e )
{
dol_syslog ( " Failed to load " . $dir . $file . " " . $e -> getMessage (), LOG_ERR );
}
}
else
{
print " Warning bad descriptor file : " . $dir . $file . " (Class " . $modName . " not found into file)<br> " ;
}
}
2011-11-02 14:15:14 +01:00
catch ( Exception $e )
2008-12-02 15:16:18 +01:00
{
2011-11-02 14:15:14 +01:00
dol_syslog ( " Failed to load " . $dir . $file . " " . $e -> getMessage (), LOG_ERR );
2008-12-02 15:16:18 +01:00
}
}
}
}
closedir ( $handle );
2008-03-10 00:14:08 +01:00
}
2009-03-03 19:25:48 +01:00
else
{
2009-04-30 00:11:08 +02:00
dol_syslog ( " htdocs/admin/modules.php: Failed to open directory " . $dir . " . See permission and open_basedir option. " , LOG_WARNING );
2009-03-03 19:25:48 +01:00
}
2008-04-19 22:48:59 +02:00
}
2007-04-10 20:54:34 +02:00
2017-12-05 11:34:07 +01:00
if ( $action == 'reset_confirm' && $user -> admin )
{
if ( ! empty ( $modules [ $value ])) {
$objMod = $modules [ $value ];
2017-12-15 10:36:35 +01:00
2017-12-05 11:34:07 +01:00
if ( ! empty ( $objMod -> langfiles )) $langs -> loadLangs ( $objMod -> langfiles );
2017-12-15 10:36:35 +01:00
2017-12-05 11:34:07 +01:00
$form = new Form ( $db );
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?value=' . $value . '&mode=' . $mode . $param , $langs -> trans ( 'ConfirmUnactivation' ), $langs -> trans ( GETPOST ( 'confirm_message_code' )), 'reset' , '' , 'no' , 1 );
2017-12-15 10:36:35 +01:00
2017-12-05 11:34:07 +01:00
}
2017-12-15 10:36:35 +01:00
2017-12-05 11:34:07 +01:00
}
print $formconfirm ;
2008-03-10 00:14:08 +01:00
asort ( $orders );
2008-09-29 23:29:18 +02:00
//var_dump($orders);
2010-12-19 00:49:40 +01:00
//var_dump($categ);
//var_dump($modules);
2008-04-19 22:48:59 +02:00
2012-07-22 01:03:19 +02:00
$nbofactivatedmodules = count ( $conf -> modules );
2016-02-16 12:54:42 +01:00
$moreinfo = $langs -> trans ( " TotalNumberOfActivatedModules " ,( $nbofactivatedmodules - 1 ), count ( $modules ));
2013-04-20 12:55:31 +02:00
if ( $nbofactivatedmodules <= 1 ) $moreinfo .= ' ' . img_warning ( $langs -> trans ( " YouMustEnableOneModule " ));
2015-04-18 19:47:09 +02:00
print load_fiche_titre ( $langs -> trans ( " ModulesSetup " ), $moreinfo , 'title_setup' );
2013-03-12 15:56:47 +01:00
2013-03-30 14:27:13 +01:00
// Start to show page
2017-05-06 20:43:14 +02:00
if ( $mode == 'common' ) print '<span class="opacitymedium">' . $langs -> trans ( " ModulesDesc " ) . " </span><br> \n " ;
if ( $mode == 'marketplace' ) print '<span class="opacitymedium">' . $langs -> trans ( " ModulesMarketPlaceDesc " ) . " </span><br> \n " ;
if ( $mode == 'deploy' ) print '<span class="opacitymedium">' . $langs -> trans ( " ModulesDeployDesc " , $langs -> transnoentitiesnoconv ( " AvailableModules " )) . " </span><br> \n " ;
2017-08-22 14:47:01 +02:00
if ( $mode == 'develop' ) print '<span class="opacitymedium">' . $langs -> trans ( " ModulesDevelopDesc " ) . " </span><br> \n " ;
2013-03-12 15:56:47 +01:00
2017-08-22 14:47:01 +02:00
$head = modules_prepare_head ();
2017-02-11 15:41:01 +01:00
2007-04-10 20:54:34 +02:00
2013-01-10 08:27:12 +01:00
print " <br> \n " ;
2013-01-02 18:43:59 +01:00
2017-02-11 15:41:01 +01:00
if ( $mode == 'common' )
2010-09-01 01:36:52 +02:00
{
2017-06-16 16:06:20 +02:00
dol_set_focus ( '#search_keyword' );
2018-04-02 23:30:23 +02:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2016-03-14 19:40:52 +01:00
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2017-05-21 02:43:51 +02:00
print '<input type="hidden" name="page" value="' . $page . '">' ;
2017-06-10 23:50:02 +02:00
2017-03-21 10:54:47 +01:00
dol_fiche_head ( $head , $mode , '' , - 1 );
2017-02-04 14:16:17 +01:00
2016-03-14 19:40:52 +01:00
$moreforfilter = '' ;
$moreforfilter .= '<div class="divsearchfield">' ;
2017-06-16 16:06:20 +02:00
$moreforfilter .= $langs -> trans ( 'Keyword' ) . ': <input type="text" id="search_keyword" name="search_keyword" value="' . dol_escape_htmltag ( $search_keyword ) . '">' ;
2016-03-14 19:40:52 +01:00
$moreforfilter .= '</div>' ;
$moreforfilter .= '<div class="divsearchfield">' ;
2017-01-15 16:07:04 +01:00
$moreforfilter .= $langs -> trans ( 'Origin' ) . ': ' . $form -> selectarray ( 'search_nature' , $arrayofnatures , dol_escape_htmltag ( $search_nature ), 1 );
2016-03-14 19:40:52 +01:00
$moreforfilter .= '</div>' ;
2016-04-06 13:27:46 +02:00
if ( ! empty ( $conf -> global -> MAIN_FEATURES_LEVEL ))
{
$array_version = array ( 'stable' => $langs -> transnoentitiesnoconv ( " Stable " ));
if ( $conf -> global -> MAIN_FEATURES_LEVEL < 0 ) $array_version [ 'deprecated' ] = $langs -> trans ( " Deprecated " );
if ( $conf -> global -> MAIN_FEATURES_LEVEL > 0 ) $array_version [ 'experimental' ] = $langs -> trans ( " Experimental " );
if ( $conf -> global -> MAIN_FEATURES_LEVEL > 1 ) $array_version [ 'development' ] = $langs -> trans ( " Development " );
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'Version' ) . ': ' . $form -> selectarray ( 'search_version' , $array_version , $search_version , 1 );
$moreforfilter .= '</div>' ;
}
2016-04-07 11:50:45 +02:00
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'Status' ) . ': ' . $form -> selectarray ( 'search_status' , array ( 'active' => $langs -> transnoentitiesnoconv ( " Enabled " ), 'disabled' => $langs -> transnoentitiesnoconv ( " Disabled " )), $search_status , 1 );
$moreforfilter .= '</div>' ;
2016-03-14 19:40:52 +01:00
$moreforfilter .= ' ' ;
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= '<input type="submit" name="buttonsubmit" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( " Refresh " )) . '">' ;
$moreforfilter .= ' ' ;
$moreforfilter .= '<input type="submit" name="buttonreset" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( " Reset " )) . '">' ;
$moreforfilter .= '</div>' ;
2016-11-20 22:59:13 +01:00
2016-03-14 19:40:52 +01:00
if ( ! empty ( $moreforfilter ))
{
print $moreforfilter ;
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2016-11-20 22:59:13 +01:00
}
2017-06-10 23:50:02 +02:00
2017-06-16 17:01:43 +02:00
$moreforfilter = '' ;
2017-06-10 23:50:02 +02:00
2016-11-27 14:21:23 +01:00
print '<div class="clearboth"></div><br>' ;
2017-06-16 17:01:43 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'insertExtraHeader' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2017-06-10 23:50:02 +02:00
2012-09-12 20:33:50 +02:00
// Show list of modules
2016-03-14 19:40:52 +01:00
2010-09-01 01:36:52 +02:00
$oldfamily = '' ;
foreach ( $orders as $key => $value )
2008-09-30 01:34:56 +02:00
{
2010-09-01 01:36:52 +02:00
$tab = explode ( '_' , $value );
2015-11-17 00:58:12 +01:00
$familyposition = $tab [ 0 ]; $familykey = $tab [ 1 ]; $module_position = $tab [ 2 ]; $numero = $tab [ 3 ];
2009-01-21 14:20:26 +01:00
2010-09-01 01:36:52 +02:00
$modName = $filename [ $key ];
2017-03-09 15:16:16 +01:00
$objMod = $modules [ $modName ];
2016-04-07 11:50:45 +02:00
$dirofmodule = $dirmod [ $key ];
2016-11-20 22:59:13 +01:00
2018-02-25 10:55:02 +01:00
//print $objMod->name." - ".$key." - ".$objMod->version."<br>";
2015-10-07 07:57:09 +02:00
//if (($mode != (isset($specialtostring[$special])?$specialtostring[$special]:'unknown') && $mode != 'expdev')
2018-02-25 10:55:02 +01:00
if ( $mode == 'expdev' && $objMod -> version != 'development' && $objMod -> version != 'experimental' ) continue ; // Discard if not for current tab
2012-09-12 20:33:50 +02:00
2010-12-19 00:49:40 +01:00
if ( ! $objMod -> getName ())
{
dol_syslog ( " Error for module " . $key . " - Property name of module looks empty " , LOG_WARNING );
2011-01-14 22:30:19 +01:00
continue ;
2010-12-19 00:49:40 +01:00
}
2016-11-20 22:59:13 +01:00
2010-09-01 01:36:52 +02:00
$const_name = 'MAIN_MODULE_' . strtoupper ( preg_replace ( '/^mod/i' , '' , get_class ( $objMod )));
2016-11-20 22:59:13 +01:00
2016-03-14 19:40:52 +01:00
// Check filters
$modulename = $objMod -> getName ();
2017-03-10 14:59:57 +01:00
$moduletechnicalname = $objMod -> name ;
2016-03-14 19:40:52 +01:00
$moduledesc = $objMod -> getDesc ();
$moduledesclong = $objMod -> getDescLong ();
$moduleauthor = $objMod -> getPublisher ();
2016-04-06 16:45:22 +02:00
// We discard showing according to filters
2016-03-14 19:40:52 +01:00
if ( $search_keyword )
{
$qualified = 0 ;
2017-01-15 16:07:04 +01:00
if ( preg_match ( '/' . preg_quote ( $search_keyword ) . '/i' , $modulename )
2017-03-10 14:59:57 +01:00
|| preg_match ( '/' . preg_quote ( $search_keyword ) . '/i' , $moduletechnicalname )
2016-03-14 19:40:52 +01:00
|| preg_match ( '/' . preg_quote ( $search_keyword ) . '/i' , $moduledesc )
|| preg_match ( '/' . preg_quote ( $search_keyword ) . '/i' , $moduledesclong )
|| preg_match ( '/' . preg_quote ( $search_keyword ) . '/i' , $moduleauthor )
) $qualified = 1 ;
if ( ! $qualified ) continue ;
}
if ( $search_status )
{
if ( $search_status == 'active' && empty ( $conf -> global -> $const_name )) continue ;
if ( $search_status == 'disabled' && ! empty ( $conf -> global -> $const_name )) continue ;
}
if ( $search_nature )
{
2016-04-06 16:45:22 +02:00
if ( preg_match ( '/^external/' , $search_nature ) && $objMod -> isCoreOrExternalModule () != 'external' ) continue ;
if ( preg_match ( '/^external_(.*)$/' , $search_nature , $reg ))
{
//print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher());
$publisher = dol_escape_htmltag ( $objMod -> getPublisher ());
2017-01-15 16:07:04 +01:00
if ( $reg [ 1 ] && dol_escape_htmltag ( $reg [ 1 ]) != $publisher ) continue ;
2016-04-06 16:45:22 +02:00
if ( ! $reg [ 1 ] && ! empty ( $publisher )) continue ;
}
if ( $search_nature == 'core' && $objMod -> isCoreOrExternalModule () == 'external' ) continue ;
}
if ( $search_version )
{
if (( $objMod -> version == 'development' || $objMod -> version == 'experimental' || preg_match ( '/deprecated/' , $objMod -> version )) && $search_version == 'stable' ) continue ;
if ( $objMod -> version != 'development' && ( $search_version == 'development' )) continue ;
if ( $objMod -> version != 'experimental' && ( $search_version == 'experimental' )) continue ;
if ( ! preg_match ( '/deprecated/' , $objMod -> version ) && ( $search_version == 'deprecated' )) continue ;
2016-03-14 19:40:52 +01:00
}
2005-08-13 22:15:35 +02:00
2010-09-01 01:36:52 +02:00
// Load all lang files of module
if ( isset ( $objMod -> langfiles ) && is_array ( $objMod -> langfiles ))
2005-08-13 22:15:35 +02:00
{
2010-09-01 01:36:52 +02:00
foreach ( $objMod -> langfiles as $domain )
{
$langs -> load ( $domain );
}
}
// Print a separator if we change family
2015-10-07 07:57:09 +02:00
if ( $familykey != $oldfamily )
2013-10-25 18:01:45 +02:00
{
2017-03-27 22:44:50 +02:00
if ( $oldfamily ) print '</table></div><br>' ;
2017-06-10 23:50:02 +02:00
2015-10-07 07:57:09 +02:00
$familytext = empty ( $familyinfo [ $familykey ][ 'label' ]) ? $familykey : $familyinfo [ $familykey ][ 'label' ];
2017-03-27 22:44:50 +02:00
print_fiche_titre ( $familytext , '' , '' );
2017-06-10 23:50:02 +02:00
2017-03-27 22:44:50 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste" summary="list_of_modules">' . " \n " ;
2017-06-10 23:50:02 +02:00
2017-03-27 22:44:50 +02:00
$atleastoneforfamily = 0 ;
2005-08-13 22:15:35 +02:00
}
2009-02-11 21:44:00 +01:00
2013-10-25 18:01:45 +02:00
$atleastoneforfamily ++ ;
2005-08-13 22:15:35 +02:00
2015-10-07 07:57:09 +02:00
if ( $familykey != $oldfamily )
2013-10-25 18:01:45 +02:00
{
2015-10-07 07:57:09 +02:00
$familytext = empty ( $familyinfo [ $familykey ][ 'label' ]) ? $familykey : $familyinfo [ $familykey ][ 'label' ];
$oldfamily = $familykey ;
2013-10-25 18:01:45 +02:00
}
2010-09-01 01:36:52 +02:00
2017-06-10 23:50:02 +02:00
2017-02-04 14:16:17 +01:00
// Version (with picto warning or not)
$version = $objMod -> getVersion ( 0 );
$versiontrans = '' ;
if ( preg_match ( '/development/i' , $version )) $versiontrans .= img_warning ( $langs -> trans ( " Development " ), 'style="float: left"' );
if ( preg_match ( '/experimental/i' , $version )) $versiontrans .= img_warning ( $langs -> trans ( " Experimental " ), 'style="float: left"' );
if ( preg_match ( '/deprecated/i' , $version )) $versiontrans .= img_warning ( $langs -> trans ( " Deprecated " ), 'style="float: left"' );
$versiontrans .= $objMod -> getVersion ( 1 );
2017-06-10 23:50:02 +02:00
2017-02-04 14:16:17 +01:00
// Define imginfo
$imginfo = " info " ;
if ( $objMod -> isCoreOrExternalModule () == 'external' )
2013-10-25 18:01:45 +02:00
{
2017-02-04 14:16:17 +01:00
$imginfo = " info_black " ;
2013-10-25 18:01:45 +02:00
}
2017-06-10 23:50:02 +02:00
2017-10-10 14:55:42 +02:00
print '<tr class="oddeven">' . " \n " ;
2017-02-04 14:16:17 +01:00
2017-03-27 22:44:50 +02:00
// Picto + Name of module
print ' <td width="200px">' ;
2017-02-04 14:16:17 +01:00
$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 );
2017-03-27 22:44:50 +02:00
else print img_object ( $alttext , $objMod -> picto , 'class="valignmiddle" width="14px"' );
2017-02-04 14:16:17 +01:00
}
else
{
2017-03-27 22:44:50 +02:00
print img_object ( $alttext , 'generic' , 'class="valignmiddle"' );
2017-02-04 14:16:17 +01:00
}
2017-03-27 22:44:50 +02:00
print ' <span class="valignmiddle">' . $objMod -> getName () . '</span>' ;
2017-02-04 14:16:17 +01:00
print " </td> \n " ;
2017-01-15 16:07:04 +01:00
2017-02-04 14:16:17 +01:00
// Desc
2017-03-27 22:44:50 +02:00
print '<td class="valignmiddle tdoverflowmax300">' ;
2017-02-04 14:16:17 +01:00
print nl2br ( $objMod -> getDesc ());
print " </td> \n " ;
2016-04-07 11:50:45 +02:00
2017-02-04 14:16:17 +01:00
// Help
2017-03-27 22:44:50 +02:00
print '<td class="center nowrap" style="width: 82px;">' ;
2017-02-04 14:16:17 +01:00
//print $form->textwithpicto('', $text, 1, $imginfo, 'minheight20', 0, 2, 1);
print '<a href="javascript:document_preview(\'' . DOL_URL_ROOT . '/admin/modulehelp.php?id=' . $objMod -> numero . '\',\'text/html\',\'' . dol_escape_js ( $langs -> trans ( " Module " )) . '\')">' . img_picto ( $langs -> trans ( " ClickToShowDescription " ), $imginfo ) . '</a>' ;
2016-10-02 10:41:22 +02:00
print '</td>' ;
2016-11-20 22:59:13 +01:00
2016-10-02 10:41:22 +02:00
// Version
2017-03-27 22:44:50 +02:00
print '<td class="center nowrap" width="120px">' ;
2016-04-07 20:01:52 +02:00
print $versiontrans ;
2013-10-25 18:01:45 +02:00
print " </td> \n " ;
// Activate/Disable and Setup (2 columns)
2017-03-09 15:16:16 +01:00
if ( ! empty ( $conf -> global -> $const_name )) // If module is already activated
2013-10-25 18:01:45 +02:00
{
$disableSetup = 0 ;
2017-05-06 17:08:38 +02:00
// Link enable/disabme
print '<td class="center valignmiddle" width="60px">' ;
2017-03-27 22:44:50 +02:00
if ( ! empty ( $arrayofwarnings [ $modName ]))
{
print '<!-- This module has a warning to show when we activate it (note: your country is ' . $mysoc -> country_code . ') -->' . " \n " ;
}
if ( ! empty ( $objMod -> disabled ))
2014-05-03 02:15:33 +02:00
{
print $langs -> trans ( " Disabled " );
}
else if ( ! empty ( $objMod -> always_enabled ) || (( ! empty ( $conf -> multicompany -> enabled ) && $objMod -> core_enabled ) && ( $user -> entity || $conf -> entity != 1 )))
2013-10-25 18:01:45 +02:00
{
2017-12-15 17:07:32 +01:00
if ( method_exists ( $objMod , 'alreadyUsed' ) && $objMod -> alreadyUsed ()) print $langs -> trans ( " Used " );
2017-12-15 15:15:14 +01:00
else print $langs -> trans ( " Required " );
2013-10-25 18:01:45 +02:00
if ( ! empty ( $conf -> multicompany -> enabled ) && $user -> entity ) $disableSetup ++ ;
}
else
{
2017-12-05 11:34:07 +01:00
if ( ! empty ( $objMod -> warnings_unactivation [ $mysoc -> country_code ]) && method_exists ( $objMod , 'alreadyUsed' ) && $objMod -> alreadyUsed ()) {
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $objMod -> numero . '&module_position=' . $module_position . '&action=reset_confirm&confirm_message_code=' . $objMod -> warnings_unactivation [ $mysoc -> country_code ] . '&value=' . $modName . '&mode=' . $mode . $param . '">' ;
print img_picto ( $langs -> trans ( " Activated " ), 'switch_on' );
print '</a>' ;
2017-12-15 10:36:35 +01:00
2017-12-05 11:34:07 +01:00
}
else {
2017-12-15 10:36:35 +01:00
2017-12-05 11:34:07 +01:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $objMod -> numero . '&module_position=' . $module_position . '&action=reset&value=' . $modName . '&mode=' . $mode . '&confirm=yes' . $param . '">' ;
print img_picto ( $langs -> trans ( " Activated " ), 'switch_on' );
print '</a>' ;
2017-12-15 10:36:35 +01:00
2017-12-05 11:34:07 +01:00
}
2017-12-15 10:36:35 +01:00
2013-10-25 18:01:45 +02:00
}
2014-05-03 02:15:33 +02:00
print '</td>' . " \n " ;
2013-10-25 18:01:45 +02:00
2017-05-06 17:08:38 +02:00
// Link config
2013-10-25 18:01:45 +02:00
if ( ! empty ( $objMod -> config_page_url ) && ! $disableSetup )
{
2017-12-15 10:36:35 +01:00
$backtourlparam = '' ;
if ( $search_keyword != '' ) $backtourlparam .= ( $backtourlparam ? '&' : '?' ) . 'search_keyword=' . $search_keyword ; // No urlencode here, done later
if ( $search_nature > - 1 ) $backtourlparam .= ( $backtourlparam ? '&' : '?' ) . 'search_nature=' . $search_nature ;
if ( $search_version > - 1 ) $backtourlparam .= ( $backtourlparam ? '&' : '?' ) . 'search_version=' . $search_version ;
if ( $search_status > - 1 ) $backtourlparam .= ( $backtourlparam ? '&' : '?' ) . 'search_status=' . $search_status ;
$backtourl = $_SERVER [ " PHP_SELF " ] . $backtourlparam ;
2013-10-25 18:01:45 +02:00
if ( is_array ( $objMod -> config_page_url ))
{
2017-05-06 17:08:38 +02:00
print '<td class="tdsetuppicto right" width="60px">' ;
2013-10-25 18:01:45 +02:00
$i = 0 ;
foreach ( $objMod -> config_page_url as $page )
{
$urlpage = $page ;
if ( $i ++ )
{
2016-03-30 16:07:48 +02:00
print '<a href="' . $urlpage . '" title="' . $langs -> trans ( $page ) . '">' . img_picto ( ucfirst ( $page ), " setup " ) . '</a>' ;
2013-10-25 18:01:45 +02:00
// print '<a href="'.$page.'">'.ucfirst($page).'</a> ';
}
else
{
if ( preg_match ( '/^([^@]+)@([^@]+)$/i' , $urlpage , $regs ))
{
2017-12-16 21:50:58 +01:00
$urltouse = dol_buildpath ( '/' . $regs [ 2 ] . '/admin/' . $regs [ 1 ], 1 );
2018-02-23 11:40:20 +01:00
print '<a href="' . $urltouse . ( preg_match ( '/\?/' , $urltouse ) ? '&' : '?' ) . 'save_lastsearch_values=1&backtopage=' . urlencode ( $backtourl ) . '" title="' . $langs -> trans ( " Setup " ) . '">' . img_picto ( $langs -> trans ( " Setup " ), " setup " , 'style="padding-right: 6px"' ) . '</a>' ;
2013-10-25 18:01:45 +02:00
}
else
{
2017-12-16 21:50:58 +01:00
$urltouse = $urlpage ;
2018-02-23 11:40:20 +01:00
print '<a href="' . $urltouse . ( preg_match ( '/\?/' , $urltouse ) ? '&' : '?' ) . 'save_lastsearch_values=1&backtopage=' . urlencode ( $backtourl ) . '" title="' . $langs -> trans ( " Setup " ) . '">' . img_picto ( $langs -> trans ( " Setup " ), " setup " , 'style="padding-right: 6px"' ) . '</a>' ;
2013-10-25 18:01:45 +02:00
}
}
}
print " </td> \n " ;
}
else if ( preg_match ( '/^([^@]+)@([^@]+)$/i' , $objMod -> config_page_url , $regs ))
{
2018-02-23 11:40:20 +01:00
print '<td class="tdsetuppicto right valignmiddle" width="60px"><a href="' . dol_buildpath ( '/' . $regs [ 2 ] . '/admin/' . $regs [ 1 ], 1 ) . '?save_lastsearch_values=1&backtopage=' . urlencode ( $backtourl ) . '" title="' . $langs -> trans ( " Setup " ) . '">' . img_picto ( $langs -> trans ( " Setup " ), " setup " , 'style="padding-right: 6px"' ) . '</a></td>' ;
2013-10-25 18:01:45 +02:00
}
else
{
2018-02-23 11:40:20 +01:00
print '<td class="tdsetuppicto right valignmiddle" width="60px"><a href="' . $objMod -> config_page_url . '?save_lastsearch_values=1&backtopage=' . urlencode ( $backtourl ) . '" title="' . $langs -> trans ( " Setup " ) . '">' . img_picto ( $langs -> trans ( " Setup " ), " setup " , 'style="padding-right: 6px"' ) . '</a></td>' ;
2013-10-25 18:01:45 +02:00
}
}
else
{
2017-05-06 17:08:38 +02:00
print '<td class="tdsetuppicto right valignmiddle" width="60px">' . img_picto ( $langs -> trans ( " NothingToSetup " ), " setup " , 'class="opacitytransp" style="padding-right: 6px"' ) . '</td>' ;
2013-10-25 18:01:45 +02:00
}
}
2017-03-09 15:16:16 +01:00
else // Module not yet activated
2013-10-28 01:37:04 +01:00
{
2017-05-06 17:08:38 +02:00
// Link enable/disable
print '<td class="center valignmiddle" width="60px">' ;
2014-05-03 02:15:33 +02:00
if ( ! empty ( $objMod -> always_enabled ))
2013-10-25 18:01:45 +02:00
{
2017-03-09 15:16:16 +01:00
// Should never happened
2013-10-25 18:01:45 +02:00
}
2014-05-03 02:15:33 +02:00
else if ( ! empty ( $objMod -> disabled ))
{
print $langs -> trans ( " Disabled " );
}
else
{
2017-03-09 15:16:16 +01:00
// Module qualified for activation
$warningmessage = '' ;
if ( ! empty ( $arrayofwarnings [ $modName ]))
{
print '<!-- This module has a warning to show when we activate it (note: your country is ' . $mysoc -> country_code . ') -->' . " \n " ;
foreach ( $arrayofwarnings [ $modName ] as $keycountry => $cursorwarningmessage )
{
$warningmessage .= ( $warningmessage ? " \n " : " " ) . $langs -> trans ( $cursorwarningmessage , $objMod -> getName (), $mysoc -> country_code );
}
}
if ( $objMod -> isCoreOrExternalModule () == 'external' && ! empty ( $arrayofwarningsext ))
{
print '<!-- This module is an external module and it may have a warning to show (note: your country is ' . $mysoc -> country_code . ') -->' . " \n " ;
foreach ( $arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry )
{
2017-06-17 11:43:00 +02:00
$keymodulelowercase = strtolower ( preg_replace ( '/^mod/' , '' , $keymodule ));
if ( in_array ( $keymodulelowercase , $conf -> modules )) // If module that request warning is on
2017-03-09 15:16:16 +01:00
{
foreach ( $arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage )
{
if ( $keycountry == 'always' || $keycountry == $mysoc -> country_code )
{
$warningmessage .= ( $warningmessage ? " \n " : " " ) . $langs -> trans ( $cursorwarningmessage , $objMod -> getName (), $mysoc -> country_code , $modules [ $keymodule ] -> getName ());
2017-06-17 11:43:00 +02:00
$warningmessage .= ( $warningmessage ? " \n " : " " ) . ( $warningmessage ? " \n " : " " ) . $langs -> trans ( " Module " ) . ' : ' . $objMod -> getName ();
if ( ! empty ( $objMod -> editor_name )) $warningmessage .= ( $warningmessage ? " \n " : " " ) . $langs -> trans ( " Publisher " ) . ' : ' . $objMod -> editor_name ;
if ( ! empty ( $objMod -> editor_name )) $warningmessage .= ( $warningmessage ? " \n " : " " ) . $langs -> trans ( " ModuleTriggeringThisWarning " ) . ' : ' . $modules [ $keymodule ] -> getName ();
2017-03-09 15:16:16 +01:00
}
}
}
}
}
print '<!-- Message to show: ' . $warningmessage . ' -->' . " \n " ;
2017-06-16 17:01:43 +02:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $objMod -> numero . '&module_position=' . $module_position . '&action=set&value=' . $modName . '&mode=' . $mode . $param . '"' ;
2017-03-27 22:44:50 +02:00
if ( $warningmessage ) print ' onclick="return confirm(\'' . dol_escape_js ( $warningmessage ) . '\');"' ;
print '>' ;
2014-05-03 02:15:33 +02:00
print img_picto ( $langs -> trans ( " Disabled " ), 'switch_off' );
print " </a> \n " ;
}
2015-08-28 20:17:36 +02:00
print " </td> \n " ;
2017-06-10 23:50:02 +02:00
2017-05-06 17:08:38 +02:00
// Link config
print '<td class="tdsetuppicto right valignmiddle" width="60px">' . img_picto ( $langs -> trans ( " NothingToSetup " ), " setup " , 'class="opacitytransp" style="padding-right: 6px"' ) . '</td>' ;
2013-10-25 18:01:45 +02:00
}
print " </tr> \n " ;
2004-10-07 09:26:16 +02:00
}
2017-06-10 23:50:02 +02:00
2017-05-30 01:32:36 +02:00
if ( $oldfamily )
{
print " </table> \n " ;
print '</div>' ;
}
2017-06-10 23:50:02 +02:00
2017-02-11 15:41:01 +01:00
dol_fiche_end ();
2017-06-10 23:50:02 +02:00
2017-05-30 01:32:36 +02:00
// Show warning about external users
print info_admin ( showModulesExludedForExternal ( $modules )) . " \n " ;
2017-06-10 23:50:02 +02:00
2017-05-30 01:32:36 +02:00
print '</form>' ;
2004-10-23 00:42:10 +02:00
}
2017-02-11 15:41:01 +01:00
if ( $mode == 'marketplace' )
2010-09-01 01:36:52 +02:00
{
2017-03-21 10:54:47 +01:00
dol_fiche_head ( $head , $mode , '' , - 1 );
2017-06-10 23:50:02 +02:00
2010-09-01 01:36:52 +02:00
// 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>' ;
2017-04-25 11:59:18 +02:00
print " <tr class= \" oddeven \" > \n " ;
2016-03-14 19:40:52 +01:00
$url = 'https://www.dolistore.com' ;
2016-11-27 14:21:23 +01:00
print '<td align="left"><a href="' . $url . '" target="_blank" rel="external"><img border="0" class="imgautosize imgmaxwidth180" src="' . DOL_URL_ROOT . '/theme/dolistore_logo.png"></a></td>' ;
2010-09-01 01:36:52 +02:00
print '<td>' . $langs -> trans ( " DoliStoreDesc " ) . '</td>' ;
2015-01-04 14:51:16 +01:00
print '<td><a href="' . $url . '" target="_blank" rel="external">' . $url . '</a></td>' ;
2010-09-01 01:36:52 +02:00
print '</tr>' ;
print " </table> \n " ;
2017-02-11 15:41:01 +01:00
dol_fiche_end ();
2017-08-22 14:47:01 +02:00
print '<br>' ;
2017-08-22 14:55:01 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_DOLISTORE_SEARCH ) && $conf -> global -> MAIN_FEATURES_LEVEL >= 1 )
2017-08-22 14:47:01 +02:00
{
2017-09-16 10:42:23 +02:00
// $options is array with filter criterias
//var_dump($options);
$dolistore -> getRemoteData ( $options );
2017-09-12 21:02:18 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( 'DOLISTOREdescriptionLong' ) . '</span><br><br>' ;
2017-08-22 14:47:01 +02:00
2017-09-12 21:02:18 +02:00
$previouslink = $dolistore -> get_previous_link ();
$nextlink = $dolistore -> get_next_link ();
2017-08-22 14:47:01 +02:00
2017-09-12 21:02:18 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">'
2017-08-22 14:47:01 +02:00
2017-09-12 21:02:18 +02:00
?>
< form method = " POST " class = " centpercent " id = " searchFormList " action = " <?php echo $dolistore->url ?> " >
2017-08-22 14:47:01 +02:00
< input type = " hidden " name = " mode " value = " marketplace " />
2017-09-12 21:02:18 +02:00
< div class = " divsearchfield " >< ? php echo $langs -> trans ( 'Keyword' ) ?> :
2017-08-22 14:47:01 +02:00
< input name = " search_keyword " placeholder = " <?php echo $langs->trans ('Chercher un module') ?> " id = " search_keyword " type = " text " size = " 50 " value = " <?php echo $options['search'] ?> " >< br >
</ div >
< div class = " divsearchfield " >
2017-09-12 21:02:18 +02:00
< input class = " button " value = " <?php echo $langs->trans ('Rechercher') ?> " type = " submit " >
< a class = " button " href = " <?php echo $dolistore->url ?> " >< ? php echo $langs -> trans ( 'Reset' ) ?> </a>
& nbsp ;
</ div >
< div class = " divsearchfield right " >
< ? php
print $previouslink ;
print $nextlink ;
?>
</ div >
2017-08-22 14:47:01 +02:00
</ form >
2017-09-12 21:02:18 +02:00
< ? php
print '</div></div>' ;
print '<div class="clearboth"></div>' ;
?>
2017-08-22 14:47:01 +02:00
< div id = " category-tree-left " >
< ul class = " tree " >
< ? php echo $dolistore -> get_categories (); ?>
</ ul >
</ div >
< div id = " listing-content " >
2017-09-12 21:02:18 +02:00
< table summary = " list_of_modules " id = " list_of_modules " class = " productlist centpercent " >
2017-08-22 14:47:01 +02:00
< tbody id = " listOfModules " >
< ? php echo $dolistore -> get_products ( $categorie ); ?>
</ tbody >
</ table >
</ div >
< ? php
}
2017-02-11 15:41:01 +01:00
}
// Install external module
2017-06-10 23:50:02 +02:00
2017-02-11 15:41:01 +01:00
if ( $mode == 'deploy' )
{
2017-09-01 08:20:33 +02:00
dol_fiche_head ( $head , $mode , '' , - 1 );
2017-02-11 15:41:01 +01:00
2017-09-01 08:20:33 +02:00
$dolibarrdataroot = preg_replace ( '/([\\/]+)$/i' , '' , DOL_DATA_ROOT );
$allowonlineinstall = true ;
$allowfromweb = 1 ;
if ( dol_is_file ( $dolibarrdataroot . '/installmodules.lock' )) $allowonlineinstall = false ;
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
$fullurl = '<a href="' . $urldolibarrmodules . '" target="_blank">' . $urldolibarrmodules . '</a>' ;
$message = '' ;
if ( ! empty ( $allowonlineinstall ))
{
if ( ! in_array ( '/custom' , explode ( ',' , $dolibarr_main_url_root_alt )))
{
$message = info_admin ( $langs -> trans ( " ConfFileMustContainCustom " , DOL_DOCUMENT_ROOT . '/custom' , DOL_DOCUMENT_ROOT ));
$allowfromweb =- 1 ;
}
else
{
if ( $dirins_ok )
{
if ( ! is_writable ( dol_osencode ( $dirins )))
{
$langs -> load ( " errors " );
$message = info_admin ( $langs -> trans ( " ErrorFailedToWriteInDir " , $dirins ));
$allowfromweb = 0 ;
}
}
else
{
$message = info_admin ( $langs -> trans ( " NotExistsDirect " , $dirins ) . $langs -> trans ( " InfDirAlt " ) . $langs -> trans ( " InfDirExample " ));
$allowfromweb = 0 ;
}
}
}
else
{
$message = info_admin ( $langs -> trans ( " InstallModuleFromWebHasBeenDisabledByFile " , $dolibarrdataroot . '/installmodules.lock' ));
$allowfromweb = 0 ;
}
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
if ( $allowfromweb < 1 )
{
print $langs -> trans ( " SomethingMakeInstallFromWebNotPossible " );
print $message ;
//print $langs->trans("SomethingMakeInstallFromWebNotPossible2");
print '<br>' ;
}
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
print '<br>' ;
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
if ( $allowfromweb >= 0 )
{
if ( $allowfromweb == 1 )
{
//print $langs->trans("ThisIsProcessToFollow").'<br>';
}
else
{
print $langs -> trans ( " ThisIsAlternativeProcessToFollow " ) . '<br>' ;
print '<b>' . $langs -> trans ( " StepNb " , 1 ) . '</b>: ' ;
print $langs -> trans ( " FindPackageFromWebSite " , $fullurl ) . '<br>' ;
print '<b>' . $langs -> trans ( " StepNb " , 2 ) . '</b>: ' ;
print $langs -> trans ( " DownloadPackageFromWebSite " , $fullurl ) . '<br>' ;
print '<b>' . $langs -> trans ( " StepNb " , 3 ) . '</b>: ' ;
}
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
if ( $allowfromweb == 1 )
{
print $langs -> trans ( " UnpackPackageInModulesRoot " , $dirins ) . '<br>' ;
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
print '<br>' ;
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
print '<form enctype="multipart/form-data" method="POST" class="noborder" action="' . $_SERVER [ " PHP_SELF " ] . '" name="forminstall">' ;
print '<input type="hidden" name="action" value="install">' ;
print '<input type="hidden" name="mode" value="deploy">' ;
print $langs -> trans ( " YouCanSubmitFile " ) . ' <input type="file" name="fileinstall"> ' ;
print '<input type="submit" name="send" value="' . dol_escape_htmltag ( $langs -> trans ( " Send " )) . '" class="button">' ;
print '</form>' ;
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
print '<br>' ;
print '<br>' ;
2017-06-10 23:50:02 +02:00
2017-09-01 08:20:33 +02:00
print '<div class="center"><div class="logo_setup"></div></div>' ;
}
else
{
print $langs -> trans ( " UnpackPackageInModulesRoot " , $dirins ) . '<br>' ;
print '<b>' . $langs -> trans ( " StepNb " , 4 ) . '</b>: ' ;
print $langs -> trans ( " SetupIsReadyForUse " ) . '<br>' ;
}
}
2017-02-11 15:41:01 +01:00
2017-09-01 08:20:33 +02:00
if ( ! empty ( $result [ 'return' ]))
{
print '<br>' ;
2004-10-23 00:42:10 +02:00
2017-09-01 08:20:33 +02:00
foreach ( $result [ 'return' ] as $value )
{
echo $value . '<br>' ;
}
}
2005-10-14 23:05:13 +02:00
2017-09-01 08:20:33 +02:00
dol_fiche_end ();
}
2013-02-01 17:34:19 +01:00
2017-08-22 14:47:01 +02:00
if ( $mode == 'develop' )
{
dol_fiche_head ( $head , $mode , '' , - 1 );
// 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 ( " DevelopYourModuleDesc " ) . '</td>' ;
print '<td>' . $langs -> trans ( " URL " ) . '</td>' ;
print '</tr>' ;
2017-11-19 16:26:39 +01:00
print '<tr class="oddeven" height="80">' . " \n " ;
print '<td align="left">' ;
//span class="fa fa-bug"></span>
//print '<img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolibarr_preferred_partner_int.png">';
print '<div class="imgmaxheight50 logo_setup"></div>' ;
print '</td>' ;
print '<td>' . $langs -> trans ( " TryToUseTheModuleBuilder " ) . '</td>' ;
print '<td>' . $langs -> trans ( " SeeTopRightMenu " ) . '</td>' ;
print '</tr>' ;
print '<tr class="oddeven" height="80">' . " \n " ;
2017-08-22 14:47:01 +02:00
$url = 'https://partners.dolibarr.org' ;
2017-11-19 16:26:39 +01:00
print '<td align="left">' ;
print '<a href="' . $url . '" target="_blank" rel="external"><img border="0" class="imgautosize imgmaxwidth180" src="' . DOL_URL_ROOT . '/theme/dolibarr_preferred_partner_int.png"></a>' ;
print '</td>' ;
2017-08-22 14:47:01 +02:00
print '<td>' . $langs -> trans ( " DoliPartnersDesc " ) . '</td>' ;
print '<td><a href="' . $url . '" target="_blank" rel="external">' . $url . '</a></td>' ;
print '</tr>' ;
print " </table> \n " ;
dol_fiche_end ();
}
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-05 19:37:52 +01:00
$db -> close ();