diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index d7e0962239b..7d6a3ff0454 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -28,7 +28,9 @@ * \brief Page to activate/disable all modules */ -if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +if (!defined('CSRFCHECK_WITH_TOKEN')) { + define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +} require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -41,7 +43,9 @@ require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php'; $langs->loadLangs(array("errors", "admin", "modulebuilder")); $mode = GETPOSTISSET('mode') ? GETPOST('mode', 'alpha') : (empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common'); -if (empty($mode)) $mode = 'common'; +if (empty($mode)) { + $mode = 'common'; +} $action = GETPOST('action', 'aZ09'); //var_dump($_POST);exit; $value = GETPOST('value', 'alpha'); @@ -62,8 +66,9 @@ $options['search'] = GETPOST('search_keyword', 'alpha'); $dolistore = new Dolistore(false); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $familyinfo = array( 'hr'=>array('position'=>'001', 'label'=>$langs->trans("ModuleFamilyHr")), @@ -81,12 +86,19 @@ $familyinfo = array( ); $param = ''; -if (!GETPOST('buttonreset', 'alpha')) -{ - if ($search_keyword) $param .= '&search_keyword='.urlencode($search_keyword); - 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); +if (!GETPOST('buttonreset', 'alpha')) { + if ($search_keyword) { + $param .= '&search_keyword='.urlencode($search_keyword); + } + 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); + } } $dirins = DOL_DOCUMENT_ROOT.'/custom'; @@ -104,18 +116,18 @@ $formconfirm = ''; $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'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (GETPOST('buttonreset', 'alpha')) -{ +if (GETPOST('buttonreset', 'alpha')) { $search_keyword = ''; $search_status = ''; $search_nature = ''; $search_version = ''; } -if ($action == 'install') -{ +if ($action == 'install') { $error = 0; // $original_file should match format module_modulename-x.y[.z].zip @@ -123,54 +135,45 @@ if ($action == 'install') $original_file = preg_replace('/\(\d+\)\.zip$/i', '.zip', $original_file); $newfile = $conf->admin->dir_temp.'/'.$original_file.'/'.$original_file; - if (!$original_file) - { + if (!$original_file) { $langs->load("Error"); setEventMessages($langs->trans("ErrorModuleFileRequired"), null, 'warnings'); $error++; } else { - if (!$error && !preg_match('/\.zip$/i', $original_file)) - { + if (!$error && !preg_match('/\.zip$/i', $original_file)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage", $original_file), null, 'errors'); $error++; } - if (!$error && !preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file)) - { + if (!$error && !preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules", $original_file, 'module_*-x.y*.zip'), null, 'errors'); $error++; } - if (empty($_FILES['fileinstall']['tmp_name'])) - { + if (empty($_FILES['fileinstall']['tmp_name'])) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); $error++; } } - if (!$error) - { - if ($original_file) - { + 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$/i', '', $original_file).'.dir'; - if ($tmpdir) - { + 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) - { + if ($result > 0) { $result = dol_uncompress($newfile, $conf->admin->dir_temp.'/'.$tmpdir); - if (!empty($result['error'])) - { + if (!empty($result['error'])) { $langs->load("errors"); setEventMessages($langs->trans($result['error'], $original_file), null, 'errors'); $error++; @@ -181,19 +184,16 @@ if ($action == 'install') // Search dir $modulename $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example ./mymodule - if (!dol_is_dir($modulenamedir)) - { + if (!dol_is_dir($modulenamedir)) { $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example ./htdocs/mymodule //var_dump($modulenamedir); - if (!dol_is_dir($modulenamedir)) - { + if (!dol_is_dir($modulenamedir)) { setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat").'
'.$langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat2", $modulename, 'htdocs/'.$modulename), null, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { // TODO Make more test } @@ -209,18 +209,22 @@ if ($action == 'install') //var_dump($modulenamearrays);exit; foreach ($modulenamearrays as $modulenameval) { - if (strpos($modulenameval, '#') === 0) continue; // Discard comments - if (strpos($modulenameval, '//') === 0) continue; // Discard comments - if (!trim($modulenameval)) continue; + if (strpos($modulenameval, '#') === 0) { + continue; // Discard comments + } + if (strpos($modulenameval, '//') === 0) { + continue; // Discard comments + } + if (!trim($modulenameval)) { + continue; + } // Now we install the module - if (!$error) - { + if (!$error) { @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the zip file dol_syslog("We copy now directory ".$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval." into target dir ".$dirins.'/'.$modulenameval); $result = dolCopyDir($modulenamedir, $dirins.'/'.$modulenameval, '0444', 1); - if ($result <= 0) - { + if ($result <= 0) { dol_syslog('Failed to call dolCopyDir result='.$result." with param ".$modulenamedir." and ".$dirins.'/'.$modulenameval, LOG_WARNING); $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyDir", $modulenamedir, $dirins.'/'.$modulenameval), null, 'errors'); @@ -235,40 +239,39 @@ if ($action == 'install') } } - if (!$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'); } } -if ($action == 'set' && $user->admin) -{ +if ($action == 'set' && $user->admin) { $resarray = activateModule($value); - if (!empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); - else { + if (!empty($resarray['errors'])) { + setEventMessages('', $resarray['errors'], 'errors'); + } else { //var_dump($resarray);exit; - if ($resarray['nbperms'] > 0) - { + if ($resarray['nbperms'] > 0) { $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; $resqltmp = $db->query($tmpsql); - if ($resqltmp) - { + if ($resqltmp) { $obj = $db->fetch_object($resqltmp); //var_dump($obj->nb);exit; - if ($obj && $obj->nb > 1) - { + if ($obj && $obj->nb > 1) { $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); setEventMessages($msg, null, 'warnings'); } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } } header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); exit; -} elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') -{ +} elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') { $result = unActivateModule($value); - if ($result) setEventMessages($result, null, 'errors'); + if ($result) { + setEventMessages($result, null, 'errors'); + } header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); exit; } @@ -285,8 +288,7 @@ $morejs = array(); $morecss = array("/admin/dolistore/css/dolistore.css"); // Set dir where external modules are installed -if (!dol_is_dir($dirins)) -{ +if (!dol_is_dir($dirins)) { dol_mkdir($dirins); } $dirins_ok = (dol_is_dir($dirins)); @@ -310,25 +312,19 @@ $i = 0; // is a sequencer of modules found $j = 0; // j is module number. Automatically affected if module number not defined. $modNameLoaded = array(); -foreach ($modulesdir as $dir) -{ +foreach ($modulesdir as $dir) { // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
"; dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)"); $handle = @opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { + 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) - { - if (!empty($modNameLoaded[$modName])) // In cache of already loaded modules ? - { + if ($modName) { + if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ? $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; setEventMessages($mesg, null, 'warnings'); dol_syslog($mesg, LOG_ERR); @@ -337,14 +333,12 @@ foreach ($modulesdir as $dir) try { $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error. - if (class_exists($modName)) - { + if (class_exists($modName)) { try { $objMod = new $modName($db); $modNameLoaded[$modName] = $dir; - if (!$objMod->numero > 0 && $modName != 'modUser') - { - dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); + if (!$objMod->numero > 0 && $modName != 'modUser') { + dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); } $j = $objMod->numero; @@ -352,21 +346,26 @@ foreach ($modulesdir as $dir) // 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))); - 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; + 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; + } // We discard modules according to property ->hidden - if (!empty($objMod->hidden)) $modulequalified = 0; + if (!empty($objMod->hidden)) { + $modulequalified = 0; + } - if ($modulequalified > 0) - { + if ($modulequalified > 0) { $publisher = dol_escape_htmltag($objMod->getPublisher()); $external = ($objMod->isCoreOrExternalModule() == 'external'); - if ($external) - { - if ($publisher) - { + if ($external) { + if ($publisher) { $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; } else { $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); @@ -387,25 +386,21 @@ foreach ($modulesdir as $dir) } $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); - if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) - { + if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) { $moduleposition = '80'; // External modules at end by default } // Add list of warnings to show into arrayofwarnings and arrayofwarningsext - if (!empty($objMod->warnings_activation)) - { + if (!empty($objMod->warnings_activation)) { $arrayofwarnings[$modName] = $objMod->warnings_activation; } - if (!empty($objMod->warnings_activation_ext)) - { + if (!empty($objMod->warnings_activation_ext)) { $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; } $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); - if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) - { + if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). if (is_numeric($familyposition)) { $familyposition = sprintf("%03d", (int) $familyposition + 100); @@ -416,21 +411,26 @@ foreach ($modulesdir as $dir) // Set categ[$i] $specialstring = 'unknown'; - 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; + 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; + } $j++; $i++; - } else dol_syslog("Module ".get_class($objMod)." not qualified"); - } catch (Exception $e) - { + } 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)
"; } - } catch (Exception $e) - { + } catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } } @@ -442,12 +442,13 @@ foreach ($modulesdir as $dir) } } -if ($action == 'reset_confirm' && $user->admin) -{ +if ($action == 'reset_confirm' && $user->admin) { if (!empty($modules[$value])) { $objMod = $modules[$value]; - if (!empty($objMod->langfiles)) $langs->loadLangs($objMod->langfiles); + if (!empty($objMod->langfiles)) { + $langs->loadLangs($objMod->langfiles); + } $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); @@ -464,16 +465,27 @@ asort($orders); $nbofactivatedmodules = count($conf->modules); $moreinfo = $langs->trans("TitleNumberOfActivatedModules"); $moreinfo2 = ($nbofactivatedmodules - 1)." / ".count($modules); -if ($nbofactivatedmodules <= 1) $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); +if ($nbofactivatedmodules <= 1) { + $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); +} print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup'); // Start to show page -if ($mode == 'common') print ''.$langs->trans("ModulesDesc", img_picto('', 'switch_off'))."
\n"; -if ($mode == 'commonkanban') print ''.$langs->trans("ModulesDesc", img_picto('', 'switch_off'))."
\n"; -if ($mode == 'marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; -if ($mode == 'deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; -if ($mode == 'develop') print ''.$langs->trans("ModulesDevelopDesc")."
\n"; +if ($mode == 'common' || $mode == 'commonkanban') { + $desc = $langs->trans("ModulesDesc", '{picto}'); + $desc = str_replace('{picto}', img_picto('', 'switch_off'), $desc); + print ''.$desc."
\n"; +} +if ($mode == 'marketplace') { + print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; +} +if ($mode == 'deploy') { + print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; +} +if ($mode == 'develop') { + print ''.$langs->trans("ModulesDevelopDesc")."
\n"; +} $head = modules_prepare_head(); @@ -481,22 +493,20 @@ $head = modules_prepare_head(); print "
\n"; -if ($mode == 'common' || $mode == 'commonkanban') -{ +if ($mode == 'common' || $mode == 'commonkanban') { dol_set_focus('#search_keyword'); print '
'; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; print ''; print ''; - $newmode = $mode; - if ($newmode == 'common') $newmode = 'commonkanban'; - - print dol_get_fiche_head($head, $newmode, '', -1); + print dol_get_fiche_head($head, 'modules', '', -1); $moreforfilter = '
'; @@ -514,12 +524,17 @@ if ($mode == 'common' || $mode == 'commonkanban') $moreforfilter .= '
'; $moreforfilter .= $langs->trans('Origin').': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200', 1); $moreforfilter .= '
'; - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) - { + 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"); + 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 .= '
'; $moreforfilter .= $langs->trans('Version').': '.$form->selectarray('search_version', $array_version, $search_version, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); $moreforfilter .= '
'; @@ -537,8 +552,7 @@ if ($mode == 'common' || $mode == 'commonkanban') $moreforfilter .= '
'; - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print $moreforfilter; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -552,14 +566,15 @@ if ($mode == 'common' || $mode == 'commonkanban') $object = new stdClass(); $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'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } // Show list of modules $oldfamily = ''; $linenum = 0; - foreach ($orders as $key => $value) - { + foreach ($orders as $key => $value) { $linenum++; $tab = explode('_', $value); $familykey = $tab[1]; @@ -569,12 +584,13 @@ if ($mode == 'common' || $mode == 'commonkanban') $objMod = $modules[$modName]; //print $objMod->name." - ".$key." - ".$objMod->version."
"; - if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab + if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') { + continue; // Discard if not for current tab + } - if (!$objMod->getName()) - { + if (!$objMod->getName()) { dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING); - continue; + continue; } $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); @@ -587,48 +603,65 @@ if ($mode == 'common' || $mode == 'commonkanban') $moduleauthor = $objMod->getPublisher(); // We discard showing according to filters - if ($search_keyword) - { + if ($search_keyword) { $qualified = 0; if (preg_match('/'.preg_quote($search_keyword).'/i', $modulename) || preg_match('/'.preg_quote($search_keyword).'/i', $moduletechnicalname) || 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; + ) { + $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_status) { + if ($search_status == 'active' && empty($conf->global->$const_name)) { + continue; + } + if ($search_status == 'disabled' && !empty($conf->global->$const_name)) { + continue; + } } - if ($search_nature) - { - if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') continue; + if ($search_nature) { + if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') { + continue; + } $reg = array(); - if (preg_match('/^external_(.*)$/', $search_nature, $reg)) - { + if (preg_match('/^external_(.*)$/', $search_nature, $reg)) { //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher()); $publisher = dol_escape_htmltag($objMod->getPublisher()); - if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) continue; - if (!$reg[1] && !empty($publisher)) continue; + if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) { + continue; + } + if (!$reg[1] && !empty($publisher)) { + continue; + } + } + if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') { + 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; + 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; + } } // Load all lang files of module - if (isset($objMod->langfiles) && is_array($objMod->langfiles)) - { - foreach ($objMod->langfiles as $domain) - { + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { + foreach ($objMod->langfiles as $domain) { $langs->load($domain); } } @@ -655,8 +688,7 @@ if ($mode == 'common' || $mode == 'commonkanban') $atleastoneforfamily++; - if ($familykey != $oldfamily) - { + if ($familykey != $oldfamily) { $familytext = empty($familyinfo[$familykey]['label']) ? $familykey : $familyinfo[$familykey]['label']; $oldfamily = $familykey; } @@ -664,17 +696,22 @@ if ($mode == 'common' || $mode == 'commonkanban') // Version (with picto warning or not) $version = $objMod->getVersion(0); $versiontrans = ''; - if (preg_match('/development/i', $version)) $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); - if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); - if (preg_match('/deprecated/i', $version)) $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); + if (preg_match('/development/i', $version)) { + $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); + } + if (preg_match('/experimental/i', $version)) { + $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); + } + if (preg_match('/deprecated/i', $version)) { + $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); + } if ($objMod->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) { $versiontrans .= $objMod->getVersion(1); } // Define imginfo $imginfo = "info"; - if ($objMod->isCoreOrExternalModule() == 'external') - { + if ($objMod->isCoreOrExternalModule() == 'external') { $imginfo = "info_black"; } @@ -682,25 +719,24 @@ if ($mode == 'common' || $mode == 'commonkanban') $codetoconfig = ''; // Activate/Disable and Setup (2 columns) - if (!empty($conf->global->$const_name)) // If module is already activated - { - // Set $codeenabledisable + if (!empty($conf->global->$const_name)) { // If module is already activated + // Set $codeenabledisable $disableSetup = 0; - if (!empty($arrayofwarnings[$modName])) - { + if (!empty($arrayofwarnings[$modName])) { $codeenabledisable .= ''."\n"; } - if (!empty($objMod->disabled)) - { + if (!empty($objMod->disabled)) { $codeenabledisable .= $langs->trans("Disabled"); - } elseif (!empty($objMod->always_enabled) || ((!empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) - { - if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) $codeenabledisable .= $langs->trans("Used"); - else { + } elseif (!empty($objMod->always_enabled) || ((!empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) { + if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { + $codeenabledisable .= $langs->trans("Used"); + } else { $codeenabledisable .= img_picto($langs->trans("Required"), 'switch_on', '', false, 0, 0, '', 'opacitymedium valignmiddle'); //print $langs->trans("Required"); } - if (!empty($conf->multicompany->enabled) && $user->entity) $disableSetup++; + if (!empty($conf->multicompany->enabled) && $user->entity) { + $disableSetup++; + } } else { if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { $codeenabledisable .= 'warnings_unactivation[$mysoc->country_code].'&value='.$modName.'&mode='.$mode.$param.'">'; @@ -714,29 +750,32 @@ if ($mode == 'common' || $mode == 'commonkanban') } // Set $codetoconfig - if (!empty($objMod->config_page_url) && !$disableSetup) - { + if (!empty($objMod->config_page_url) && !$disableSetup) { $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; + 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; $regs = array(); - if (is_array($objMod->config_page_url)) - { + if (is_array($objMod->config_page_url)) { $i = 0; - foreach ($objMod->config_page_url as $page) - { + foreach ($objMod->config_page_url as $page) { $urlpage = $page; - if ($i++) - { + if ($i++) { $codetoconfig .= ''.img_picto(ucfirst($page), "setup").''; // print ''.ucfirst($page).' '; } else { - if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) - { + if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } else { @@ -745,8 +784,7 @@ if ($mode == 'common' || $mode == 'commonkanban') } } } - } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) - { + } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) { $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } else { $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; @@ -757,42 +795,36 @@ if ($mode == 'common' || $mode == 'commonkanban') } else // Module not yet activated { // Set $codeenabledisable - if (!empty($objMod->always_enabled)) - { + if (!empty($objMod->always_enabled)) { // Should never happened - } elseif (!empty($objMod->disabled)) - { + } elseif (!empty($objMod->disabled)) { $codeenabledisable .= $langs->trans("Disabled"); } else { // Module qualified for activation $warningmessage = ''; - if (!empty($arrayofwarnings[$modName])) - { + if (!empty($arrayofwarnings[$modName])) { $codeenabledisable .= ''."\n"; - foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) - { - if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) - { + foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) { + if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) { $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); } } } - if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) - { + if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) { $codeenabledisable .= ''."\n"; - foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) - { + foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) { $keymodulelowercase = strtolower(preg_replace('/^mod/', '', $keymodule)); - if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on - { - foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) - { - if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) - { + if (in_array($keymodulelowercase, $conf->modules)) { // If module that request warning is on + foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) { + if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) { $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); $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(); + 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(); + } } } } @@ -800,7 +832,9 @@ if ($mode == 'common' || $mode == 'commonkanban') } $codeenabledisable .= ''."\n"; $codeenabledisable .= 'trans("Disabled"), 'switch_off'); $codeenabledisable .= "\n"; @@ -815,17 +849,21 @@ if ($mode == 'common' || $mode == 'commonkanban') print $objMod->getKanbanView($codeenabledisable, $codetoconfig); } else { print ''."\n"; - if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print ''.$linenum.''; + if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) { + print ''.$linenum.''; + } // Picto + Name of module print ' '; $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, 'class="valignmiddle pictomodule paddingrightonly"', 1); - else print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"'); + if (!empty($objMod->picto)) { + if (preg_match('/^\//i', $objMod->picto)) { + print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"', 1); + } else { + print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"'); + } } else { print img_object($alttext, 'generic', 'class="valignmiddle paddingrightonly"'); } @@ -873,8 +911,7 @@ if ($mode == 'common' || $mode == 'commonkanban') } } - if ($oldfamily) - { + if ($oldfamily) { if ($mode == 'commonkanban') { print ''; } else { @@ -893,8 +930,7 @@ if ($mode == 'common' || $mode == 'commonkanban') print '
'; } -if ($mode == 'marketplace') -{ +if ($mode == 'marketplace') { print dol_get_fiche_head($head, $mode, '', -1); // Marketplace @@ -920,8 +956,7 @@ if ($mode == 'marketplace') print '
'; - if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1) - { + if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1) { // $options is array with filter criterias //var_dump($options); $dolistore->getRemoteCategories(); @@ -937,17 +972,17 @@ if ($mode == 'marketplace') print '
'; ?> - -
trans('Keyword') ?>: -
-
-
- - trans('Reset') ?> - -   + +
trans('Keyword') ?>: +
- + + trans('Reset') ?> + +   +
+ '; @@ -958,48 +993,45 @@ if ($mode == 'marketplace') ?> -
- -
-
- - - get_products($categorie); ?> - -
-
+
+ +
+
+ + + get_products($categorie); ?> + +
+
- '.$urldolibarrmodules.''; $message = ''; - if (!empty($allowonlineinstall)) - { - if (!in_array('/custom', explode(',', $dolibarr_main_url_root_alt))) - { + 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))) - { + if ($dirins_ok) { + if (!is_writable(dol_osencode($dirins))) { $langs->load("errors"); $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning'); $allowfromweb = 0; @@ -1014,8 +1046,7 @@ if ($mode == 'deploy') $allowfromweb = 0; } - if ($allowfromweb < 1) - { + if ($allowfromweb < 1) { print $langs->trans("SomethingMakeInstallFromWebNotPossible"); print $message; //print $langs->trans("SomethingMakeInstallFromWebNotPossible2"); @@ -1024,10 +1055,8 @@ if ($mode == 'deploy') print '
'; - if ($allowfromweb >= 0) - { - if ($allowfromweb == 1) - { + if ($allowfromweb >= 0) { + if ($allowfromweb == 1) { //print $langs->trans("ThisIsProcessToFollow").'
'; } else { print $langs->trans("ThisIsAlternativeProcessToFollow").'
'; @@ -1038,8 +1067,7 @@ if ($mode == 'deploy') print ''.$langs->trans("StepNb", 3).': '; } - if ($allowfromweb == 1) - { + if ($allowfromweb == 1) { print $langs->trans("UnpackPackageInModulesRoot", $dirins).'
'; print '
'; @@ -1053,36 +1081,48 @@ if ($mode == 'deploy') $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb $maxphp = @ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; - if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; - if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; - if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; + if (preg_match('/k$/i', $maxphp)) { + $maxphp = $maxphp * 1; + } + if (preg_match('/m$/i', $maxphp)) { + $maxphp = $maxphp * 1024; + } + if (preg_match('/g$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024 * 1024; + } $maxphp2 = @ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1; - if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024; - if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024; - if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1; + } + if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024; + } + if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + } // Now $max and $maxphp and $maxphp2 are in Kb $maxmin = $max; $maxphptoshow = $maxphptoshowparam = ''; - if ($maxphp > 0) - { + if ($maxphp > 0) { $maxmin = min($max, $maxphp); $maxphptoshow = $maxphp; $maxphptoshowparam = 'upload_max_filesize'; } - if ($maxphp2 > 0) - { + if ($maxphp2 > 0) { $maxmin = min($max, $maxphp2); - if ($maxphp2 < $maxphp) - { + if ($maxphp2 < $maxphp) { $maxphptoshow = $maxphp2; $maxphptoshowparam = 'post_max_size'; } } - if ($maxmin > 0) - { + if ($maxmin > 0) { print '