diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 723a9f74e8d..4dd1cf42144 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2011 Regis Houssin * * 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 @@ -37,38 +38,35 @@ $langs->load("users"); if (!$user->admin) accessforbidden(); - -$typeconst=array('yesno','texte','chaine'); - - -// Action mise a jour ou ajout d'une constante -if ($_POST["action"] == 'update' || $_POST["action"] == 'add') +/* + * Action + */ +if (preg_match('/set_(.*)/',$action,$reg)) { - $result=dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],0,isset($_POST["constnote"])?$_POST["constnote"]:'',$conf->entity); - if ($result < 0) - { - print $db->error(); - } + $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); + } } -// Action activation d'un sous module du module adherent -if ($_GET["action"] == 'set') +if (preg_match('/del_(.*)/',$action,$reg)) { - $result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity); - if ($result < 0) - { - print $db->error(); - } -} - -// Action desactivation d'un sous module du module adherent -if ($_GET["action"] == 'unset') -{ - $result=dolibarr_del_const($db,$_GET["name"],$conf->entity); - if ($result < 0) - { - print $db->error(); - } + $code=$reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } } @@ -78,9 +76,6 @@ if ($_GET["action"] == 'unset') llxHeader(); - -$var=True; - $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("UsersSetup"),$linkback,'setup'); print "
"; @@ -90,25 +85,36 @@ print_fiche_titre($langs->trans("MemberMainOptions"),'',''); print ''; print ''; print ''; -print ''; -print ''; -print "\n"; +print ''; +print ''."\n"; +print ''; + $var=true; $form = new Form($db); // Mail required for members $var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; -print '\n"; -print ''; +print ''; +print ''; +print ''; + +print ''; print '
'.$langs->trans("Description").''.$langs->trans("Value").''.$langs->trans("Action").'
 '.$langs->trans("Value").'
'.$langs->trans("UserMailRequired").''; -print $form->selectyesno('constvalue',$conf->global->USER_MAIL_REQUIRED,1); -print ''; -print ''; -print "
'.$langs->trans("UserMailRequired").' '; +if ($conf->use_javascript_ajax) +{ + print ajax_constantonoff('USER_MAIL_REQUIRED'); +} +else +{ + if($conf->global->USER_MAIL_REQUIRED == 0) + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + else if($conf->global->USER_MAIL_REQUIRED == 1) + { + print ''.img_picto($langs->trans("Enabled"),'on').''; + } +} +print '
'; print '
'; diff --git a/htdocs/core/ajaxconstantonoff.php b/htdocs/core/ajaxconstantonoff.php new file mode 100644 index 00000000000..104f4b4fa1c --- /dev/null +++ b/htdocs/core/ajaxconstantonoff.php @@ -0,0 +1,65 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/core/ajaxconstantonoff.php + * \brief File to set or del an on/off constant + * \version $Id$ + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +require('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); + + +/* + * View + */ + +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); + +print ''."\n"; + +// Registering the location of boxes +if((isset($_GET['action']) && ! empty($_GET['action'])) && (isset($_GET['name']) && ! empty($_GET['name'])) ) +{ + if ($user->admin && ! $user->entity) + { + if ($_GET['action'] == 'set') + { + dolibarr_set_const($db, $_GET['name'], 1, 'chaine', 0, '', $conf->entity); + } + else if ($_GET['action'] == 'del') + { + dolibarr_del_const($db, $_GET['name'], $conf->entity); + } + } +} + +?> diff --git a/htdocs/lib/ajax.lib.php b/htdocs/lib/ajax.lib.php index 5be8794e3bc..37b2e0b032d 100644 --- a/htdocs/lib/ajax.lib.php +++ b/htdocs/lib/ajax.lib.php @@ -213,6 +213,45 @@ function ajax_combobox($htmlname) return $msg; } +/** + * On/off button for constant + * @param code Name of constant + */ +function ajax_constantonoff($code) +{ + global $conf, $langs; + + $out= ''; + + $out.= '
'.img_picto($langs->trans("Disabled"),'off').'
'; + $out.= '
'.img_picto($langs->trans("Enabled"),'on').'
'; + + return $out; +} + /** * * Enter description here ... diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index d1fd78a198c..91fc347c169 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -165,6 +165,8 @@ div.float float:; } +.hideobject { display: none; } +.linkobject { cursor: pointer; } /* For dragging lines */