2
0
forked from Wavyzz/dolibarr

New: Add trigger on enabled and disable user.

This commit is contained in:
Laurent Destailleur
2008-03-20 21:22:35 +00:00
parent cbec6ec2aa
commit d50b3ae380
7 changed files with 33 additions and 15 deletions

View File

@@ -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),

View File

@@ -149,16 +149,24 @@ 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;
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')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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<43>ation groupe %s
GroupModified=Modification groupe %s

View File

@@ -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;
}
}

View File

@@ -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");
@@ -84,8 +82,9 @@ 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"]);
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;