New: Ajout de la gestion des triggers sur les actions sur les groupes
This commit is contained in:
parent
0f01c13153
commit
616fd81602
@ -579,7 +579,7 @@ class User
|
|||||||
*/
|
*/
|
||||||
function create()
|
function create()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
$this->login = trim($this->login);
|
$this->login = trim($this->login);
|
||||||
@ -632,6 +632,12 @@ class User
|
|||||||
if ($result < 0) $error++;
|
if ($result < 0) $error++;
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
|
// \todo Mettre en trigger
|
||||||
|
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
|
{
|
||||||
|
$this->create_ldap($user);
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
@ -776,9 +782,7 @@ class User
|
|||||||
*/
|
*/
|
||||||
function update($create=0)
|
function update($create=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
$this->nom=trim($this->nom);
|
$this->nom=trim($this->nom);
|
||||||
@ -817,10 +821,10 @@ class User
|
|||||||
$sql .= ", note = '".addslashes($this->note)."'";
|
$sql .= ", note = '".addslashes($this->note)."'";
|
||||||
$sql .= " WHERE rowid = ".$this->id;
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($result)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ($this->db->affected_rows())
|
if ($this->db->affected_rows($resql))
|
||||||
{
|
{
|
||||||
if (! $create)
|
if (! $create)
|
||||||
{
|
{
|
||||||
@ -830,6 +834,12 @@ class User
|
|||||||
$result=$interface->run_triggers('USER_MODIFY',$this,$user,$lang,$conf);
|
$result=$interface->run_triggers('USER_MODIFY',$this,$user,$lang,$conf);
|
||||||
if ($result < 0) $error++;
|
if ($result < 0) $error++;
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
|
// \todo Mettre en trigger
|
||||||
|
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
|
{
|
||||||
|
$this->update_ldap($user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@ -368,39 +368,56 @@ class UserGroup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Crée un groupe en base
|
* \brief Crée un groupe en base
|
||||||
* \return si erreur <0, si ok renvoie id groupe créé
|
* \return si erreur <0, si ok renvoie id groupe cr
|
||||||
*/
|
*/
|
||||||
function create()
|
function create()
|
||||||
{
|
{
|
||||||
$sql = "INSERT into ".MAIN_DB_PREFIX."usergroup (datec,nom)";
|
global $conf,$langs;
|
||||||
$sql .= " VALUES(now(),'".addslashes($this->nom)."')";
|
|
||||||
|
|
||||||
$result=$this->db->query($sql);
|
$sql = "INSERT into ".MAIN_DB_PREFIX."usergroup (datec,nom)";
|
||||||
if ($result)
|
$sql .= " VALUES(now(),'".addslashes($this->nom)."')";
|
||||||
|
|
||||||
|
$result=$this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$table = "".MAIN_DB_PREFIX."usergroup";
|
||||||
|
$this->id = $this->db->last_insert_id($table);
|
||||||
|
|
||||||
|
if ($this->update(1) < 0) return -2;
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('GROUP_CREATE',$this,$user,$lang,$conf);
|
||||||
|
if ($result < 0) $error++;
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
// \todo Mettre en trigger
|
||||||
|
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
|
{
|
||||||
|
$this->create_ldap($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("UserGroup::Create");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Mise à jour en base d'un utilisateur
|
||||||
|
* \return <0 si echec, >=0 si ok
|
||||||
|
*/
|
||||||
|
function update($notrigger=0)
|
||||||
{
|
{
|
||||||
$table = "".MAIN_DB_PREFIX."usergroup";
|
global $conf, $langs;
|
||||||
$this->id = $this->db->last_insert_id($table);
|
|
||||||
|
|
||||||
if ($this->update() < 0) return -2;
|
|
||||||
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_syslog("UserGroup::Create");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Mise à jour en base d'un utilisateur
|
|
||||||
* \return <0 si echec, >=0 si ok
|
|
||||||
*/
|
|
||||||
function update()
|
|
||||||
{
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET ";
|
||||||
$sql .= " nom = '".addslashes($this->nom)."',";
|
$sql .= " nom = '".addslashes($this->nom)."',";
|
||||||
$sql .= " note = '".addslashes($this->note)."'";
|
$sql .= " note = '".addslashes($this->note)."'";
|
||||||
@ -412,6 +429,24 @@ class UserGroup
|
|||||||
{
|
{
|
||||||
if ($this->db->affected_rows())
|
if ($this->db->affected_rows())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (! $notrigger)
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('GROUP_MODIFY',$this,$user,$lang,$conf);
|
||||||
|
if ($result < 0) $error++;
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
|
||||||
|
// \todo Mettre en trigger
|
||||||
|
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
|
{
|
||||||
|
$this->update_ldap($user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user