From a00205a17d4c7e83221b09ae1352a0b97394fe53 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 13 Aug 2012 11:42:50 +0200 Subject: [PATCH] New: add possibility to set and del anothers constants --- htdocs/core/ajax/constantonoff.php | 9 +-- htdocs/core/lib/ajax.lib.php | 94 +++++++++++++++++++----------- 2 files changed, 66 insertions(+), 37 deletions(-) diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index a79a9f5d0ff..d195df7631f 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -30,6 +30,8 @@ if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +$action=GETPOST('action','alpha'); +$name=GETPOST('name','alpha'); /* * View @@ -45,17 +47,16 @@ top_httphead(); print ''."\n"; // Registering the location of boxes -if ((isset($_GET['action']) && ! empty($_GET['action'])) && (isset($_GET['name']) && ! empty($_GET['name'])) ) +if (! empty($action) && ! empty($name)) { $entity = GETPOST('entity','int'); - $action = GETPOST('action', 'alpha'); - $name = GETPOST('name', 'alpha'); + $value = (GETPOST('value')?GETPOST('value'):1); if ($user->admin) { if ($action == 'set') { - dolibarr_set_const($db, $name, 1, 'chaine', 0, '', $entity); + dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity); } else if ($action == 'del') { diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 2993197b660..ebfb2cfdd8d 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -346,7 +346,7 @@ function ajax_combobox($htmlname, $event=array()) * On/off button for constant * * @param string $code Name of constant - * @param array $input Input element + * @param array $input Input element (enable/disable or show/hide another element, set/del another constant) * @param int $entity Entity to set * @return void */ @@ -359,10 +359,11 @@ function ajax_constantonoff($code,$input=array(),$entity=false) $out= '