diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index ac2f244969a237e642b9b348c2a6ee8170cd9a55..3ed30274972e17b8e07224841e2999e825ba7fce 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -47,10 +47,10 @@ print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY // Registering the location of boxes if ((isset($_GET['action']) && ! empty($_GET['action'])) && (isset($_GET['name']) && ! empty($_GET['name'])) ) { - $entity = (GETPOST('entity','int') >= 0 ? GETPOST('entity','int') : $conf->entity); + $entity = GETPOST('entity','int'); $action = GETPOST('action', 'alpha'); $name = GETPOST('name', 'alpha'); - + if ($user->admin) { if ($action == 'set') diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index ec500d7ae46dfe0650057cdd71905cfadf22635e..937c187d1e56c4e7b045d7e2c88c1e01375ba59a 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2007-2011 Regis Houssin <regis@dolibarr.fr> + * Copyright (C) 2007-2012 Regis Houssin <regis@dolibarr.fr> * * 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 @@ -229,7 +229,7 @@ function ajax_constantonoff($code,$input=array(),$entity=false) { global $conf, $langs; - $entity = ((! empty($entity) && is_numeric($entity) && $entity > 0) || $entity == 0 ? $entity : $conf->entity); + $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity); $out= '<script type="text/javascript"> $(function() {