* 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 * * 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','alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $value = GETPOST('value','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; } // Set default model elseif ($action == 'setdoc') { 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); } } //Set hide closed customer into combox or select elseif ($action == 'sethideinactiveuser') { $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(); dol_fiche_head($head,'card', $langs->trans("MenuUsersAndGroups"), -1, 'user'); print ''; print ''; print ''; print ''; print ''."\n"; print ''; // Mail required for members print ''; print ''; print ''; print ''; print '
'.$langs->trans("Description").' '.$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 '
'; print '
'; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); $form=new Form($db); // Defini tableau def des modeles $def = array(); $sql = "SELECT nom"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " WHERE type = '".$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 ''; 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("PaymentMode").': '.yn($module->option_modereg,1,1); $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,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 ($conf->global->USER_ADDON_PDF == $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"),'contract').''; } else { print img_object($langs->trans("PreviewNotAvailable"),'generic'); } print '
'; print "
"; dol_fiche_end(); // End of page llxFooter(); $db->close();