* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/user.php * \ingroup core * \brief Page to setup user module */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'members', 'users')); if (!$user->admin) { accessforbidden(); } $extrafields = new ExtraFields($db); $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scandir', 'alpha'); $type = 'user'; /* * Action */ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'set_default') { $ret = addDocumentModel($value, $type, $label, $scandir); $res = true; } elseif ($action == 'del_default') { $ret = delDocumentModel($value, $type); if ($ret > 0) { if ($conf->global->USER_ADDON_PDF_ODT == "$value") { dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); } } $res = true; } elseif ($action == 'setdoc') { // Set default model if (dolibarr_set_const($db, "USER_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->USER_ADDON_PDF_ODT = $value; } // On active le modele $ret = delDocumentModel($value, $type); if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } $res = true; } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } elseif ($action == 'sethideinactiveuser') { //Set hide closed customer into combox or select $status = GETPOST('status', 'alpha'); if (dolibarr_set_const($db, "USER_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } /* * View */ $form = new Form($db); $help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios'; llxHeader('', $langs->trans("UsersSetup"), $help_url); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup'); $head = user_admin_prepare_head(); print dol_get_fiche_head($head, 'card', $langs->trans("MenuUsersAndGroups"), -1, 'user'); print '
'; print ''; print ''; print ''; print ''; print ''."\n"; print ''; // Mail required for users print ''; print ''; print ''; print ''; // user hide inactive print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameter").' '.$langs->trans("Value").'
'.$langs->trans("UserMailRequired").' '; if ($conf->use_javascript_ajax) { print ajax_constantonoff('USER_MAIL_REQUIRED'); } else { if (empty($conf->global->USER_MAIL_REQUIRED)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; } } print '
'.$langs->trans("UserHideInactive").' '; if ($conf->use_javascript_ajax) { print ajax_constantonoff('USER_HIDE_INACTIVE_IN_COMBOBOX'); } else { if (empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; } } print '
'; print '
'; print '
'; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); // Defini tableau def des modeles $def = array(); $sql = "SELECT nom"; $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; } } else { dol_print_error($db); } print load_fiche_titre($langs->trans("UsersDocModules"), '', ''); print '
'; print ''; print ''; print ''; print ''; print '\n"; print '\n"; print ''; print ''; print "\n"; clearstatcache(); foreach ($dirmodels as $reldir) { foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/user".$valdir); if (is_dir($dir)) { $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); $modulequalified = 1; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { $modulequalified = 0; } if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { $modulequalified = 0; } if ($modulequalified) { print ''; // Active if (in_array($name, $def)) { print ''; } else { print '"; } // Defaut print ''; // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); print ''; // Preview print ''; print "\n"; } } } } } } } } print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) { print $module->info($langs); } else { print $module->description; } print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print ''."\n"; print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; if (getDolGlobalString('USER_ADDON_PDF_ODT') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } print '
'; print '
'; print '
'; print dol_get_fiche_end(); // End of page llxFooter(); $db->close();