diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index 2e036410a0b..6c55219dc20 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -44,7 +44,7 @@ $eventstolog=array( array('id'=>'USER_CREATE', 'test'=>1), array('id'=>'USER_MODIFY', 'test'=>1), array('id'=>'USER_NEW_PASSWORD', 'test'=>1), - array('id'=>'USER_DISABLE', 'test'=>1), + array('id'=>'USER_ENABLEDISABLE', 'test'=>1), array('id'=>'USER_DELETE', 'test'=>1), array('id'=>'GROUP_CREATE', 'test'=>1), array('id'=>'GROUP_MODIFY', 'test'=>1), diff --git a/htdocs/includes/triggers/interface_all_Logevents.class.php b/htdocs/includes/triggers/interface_all_Logevents.class.php index 0b41e7c6c76..c64ddf94c33 100644 --- a/htdocs/includes/triggers/interface_all_Logevents.class.php +++ b/htdocs/includes/triggers/interface_all_Logevents.class.php @@ -149,15 +149,23 @@ class InterfaceLogevents $this->texte=$langs->transnoentities("NewUserPassword",$object->login); $this->desc=$langs->transnoentities("NewUserPassword",$object->login); } - elseif ($action == 'USER_DISABLE') + elseif ($action == 'USER_ENABLEDISABLE') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $this->date=time(); $this->duree=0; - $this->texte=$langs->transnoentities("UserDisabled",$object->login); - $this->desc=$langs->transnoentities("UserDisabled",$object->login); + if ($object->statut == 0) + { + $this->texte=$langs->transnoentities("UserEnabled",$object->login); + $this->desc=$langs->transnoentities("UserEnabled",$object->login); + } + if ($object->statut == 1) + { + $this->texte=$langs->transnoentities("UserDisabled",$object->login); + $this->desc=$langs->transnoentities("UserDisabled",$object->login); + } } elseif ($action == 'USER_DELETE') { diff --git a/htdocs/includes/triggers/interface_modLdap_Ldapsynchro.class.php b/htdocs/includes/triggers/interface_modLdap_Ldapsynchro.class.php index 218b4e61fc4..1c86c168068 100644 --- a/htdocs/includes/triggers/interface_modLdap_Ldapsynchro.class.php +++ b/htdocs/includes/triggers/interface_modLdap_Ldapsynchro.class.php @@ -138,7 +138,7 @@ class InterfaceLdapsynchro { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } - elseif ($action == 'USER_DISABLE') + elseif ($action == 'USER_ENABLEDISABLE') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 9cf205a2c58..5dadc171c9e 100755 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -90,6 +90,7 @@ NewUserCreated=User %s created NewUserPassword=Password change for %s EventUserModified=User %s modified UserDisabled=User %s disabled +UserEnabled=User %s activated UserDeleted=User %s removed NewGroupCreated=Group %s created GroupModified=Group %s modified diff --git a/htdocs/langs/fr_FR/users.lang b/htdocs/langs/fr_FR/users.lang index e93054c69b4..5ae06d98d33 100755 --- a/htdocs/langs/fr_FR/users.lang +++ b/htdocs/langs/fr_FR/users.lang @@ -90,6 +90,7 @@ NewUserCreated=Cr NewUserPassword=Changement mot de passe de %s EventUserModified=Modification utiliateur %s UserDisabled=Désactivation utilisateur %s +UserEnabled=Activation utilisateur %s UserDeleted=Suppression utilisateur %s NewGroupCreated=Création groupe %s GroupModified=Modification groupe %s diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 94616364d9d..0db8b9ef564 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -585,7 +585,7 @@ class User extends CommonObject /** * \brief Change statut d'un utilisateur - * \return int <0 si ko, >0 si ok + * \return int <0 si ko, >=0 si ok */ function setstatus($statut) { @@ -593,6 +593,12 @@ class User extends CommonObject $error=0; + // Check parameters + if ($this->statut == $statut) + { + return 0; + } + $this->db->begin(); // Desactive utilisateur @@ -601,12 +607,13 @@ class User extends CommonObject $sql.= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); + dolibarr_syslog("User::setstatus sql=".$sql); if ($result) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); $interface=new Interfaces($this->db); - $result=$interface->run_triggers('USER_DISABLE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('USER_ENABLEDISABLE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers } @@ -619,6 +626,7 @@ class User extends CommonObject else { $this->db->commit(); + $this->statut=$statut; return 1; } } diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index aa16c9ac261..ed796e44255 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -19,14 +19,12 @@ * 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. - * - * $Id$ */ /** \file htdocs/user/fiche.php \brief Onglet user et permissions de la fiche utilisateur - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -52,7 +50,7 @@ if ($_GET["id"]) } if ($user->id <> $_GET["id"] && ! $canreadperms) { - accessforbidden(); + accessforbidden(); } $langs->load("users"); @@ -84,10 +82,11 @@ if ($_POST["action"] == 'confirm_disable' && $_POST["confirm"] == "yes") { if ($_GET["id"] <> $user->id) { - $edituser = new User($db, $_GET["id"]); - $edituser->fetch($_GET["id"]); + $edituser = new User($db); + $edituser->id=$_GET["id"]; + $edituser->fetch(); $edituser->setstatus(0); - Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); + Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); exit; } } @@ -96,7 +95,8 @@ if ($_POST["action"] == 'confirm_enable' && $_POST["confirm"] == "yes") if ($_GET["id"] <> $user->id) { $edituser = new User($db, $_GET["id"]); - $edituser->fetch($_GET["id"]); + $edituser->id=$_GET["id"]; + $edituser->fetch(); $edituser->setstatus(1); Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); exit;