Fix context must be provided to triggers using ->context no a dedicated
property.
This commit is contained in:
parent
a71541e6de
commit
59d2943d8d
@ -58,6 +58,8 @@ class Events // extends CommonObject
|
||||
array('id'=>'USER_NEW_PASSWORD', 'test'=>1),
|
||||
array('id'=>'USER_ENABLEDISABLE', 'test'=>1),
|
||||
array('id'=>'USER_DELETE', 'test'=>1),
|
||||
/* array('id'=>'USER_SETINGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY
|
||||
array('id'=>'USER_REMOVEFROMGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY */
|
||||
array('id'=>'GROUP_CREATE', 'test'=>1),
|
||||
array('id'=>'GROUP_MODIFY', 'test'=>1),
|
||||
array('id'=>'GROUP_DELETE', 'test'=>1),
|
||||
|
||||
@ -175,6 +175,9 @@ class InterfaceLogevents extends DolibarrTriggers
|
||||
}
|
||||
*/
|
||||
|
||||
// Add more information into desc from the context property
|
||||
if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
|
||||
|
||||
// Add entry in event table
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
|
||||
|
||||
|
||||
@ -379,12 +379,12 @@ class User extends CommonObject
|
||||
*/
|
||||
function addrights($rid, $allmodule='', $allperms='', $entity='')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$entity = (! empty($entity)?$entity:$conf->entity);
|
||||
|
||||
dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity");
|
||||
$err=0;
|
||||
$error=0;
|
||||
$whereforadd='';
|
||||
|
||||
$this->db->begin();
|
||||
@ -406,7 +406,7 @@ class User extends CommonObject
|
||||
$subperms=$obj->subperms;
|
||||
}
|
||||
else {
|
||||
$err++;
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
@ -444,23 +444,33 @@ class User extends CommonObject
|
||||
$nid = $obj->id;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id." AND fk_id=".$nid;
|
||||
if (! $this->db->query($sql)) $err++;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES (".$this->id.", ".$nid.")";
|
||||
if (! $this->db->query($sql)) $err++;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$err++;
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
if ($err) {
|
||||
if (! $error)
|
||||
{
|
||||
$this->context = array('audit'=>$langs->trans("PermissionsAdd"));
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('USER_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -$err;
|
||||
return -$error;
|
||||
}
|
||||
else {
|
||||
$this->db->commit();
|
||||
@ -481,9 +491,9 @@ class User extends CommonObject
|
||||
*/
|
||||
function delrights($rid, $allmodule='', $allperms='', $entity='')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$err=0;
|
||||
$error=0;
|
||||
$wherefordel='';
|
||||
$entity = (! empty($entity)?$entity:$conf->entity);
|
||||
|
||||
@ -506,7 +516,7 @@ class User extends CommonObject
|
||||
$subperms=$obj->subperms;
|
||||
}
|
||||
else {
|
||||
$err++;
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
@ -544,21 +554,31 @@ class User extends CommonObject
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights";
|
||||
$sql.= " WHERE fk_user = ".$this->id." AND fk_id=".$nid;
|
||||
if (! $this->db->query($sql)) $err++;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$err++;
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
if ($err) {
|
||||
if (! $error)
|
||||
{
|
||||
$this->context = array('audit'=>$langs->trans("PermissionsDelete"));
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('USER_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -$err;
|
||||
return -$error;
|
||||
}
|
||||
else {
|
||||
$this->db->commit();
|
||||
@ -1846,8 +1866,9 @@ class User extends CommonObject
|
||||
{
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
$this->newgroupid=$group;
|
||||
|
||||
$this->newgroupid=$group; // deprecated. Remove this.
|
||||
$this->context = array('audit'=>$langs->trans("UserSetInGroup"), 'newgroupid'=>$group);
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('USER_SETINGROUP',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
@ -1900,8 +1921,9 @@ class User extends CommonObject
|
||||
{
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
$this->oldgroupid=$group;
|
||||
|
||||
$this->oldgroupid=$group; // deprecated. Remove this.
|
||||
$this->context = array('audit'=>$langs->trans("UserRemovedFromGroup"), 'oldgroupid'=>$group);
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('USER_REMOVEFROMGROUP',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
|
||||
@ -249,7 +249,7 @@ class UserGroup extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute un droit a l'utilisateur
|
||||
* Add a permission to a group
|
||||
*
|
||||
* @param int $rid id du droit a ajouter
|
||||
* @param string $allmodule Ajouter tous les droits du module allmodule
|
||||
@ -258,10 +258,10 @@ class UserGroup extends CommonObject
|
||||
*/
|
||||
function addrights($rid,$allmodule='',$allperms='')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $user, $langs;
|
||||
|
||||
dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms");
|
||||
$err=0;
|
||||
$error=0;
|
||||
$whereforadd='';
|
||||
|
||||
$this->db->begin();
|
||||
@ -283,7 +283,7 @@ class UserGroup extends CommonObject
|
||||
$subperms=$obj->subperms;
|
||||
}
|
||||
else {
|
||||
$err++;
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
@ -323,23 +323,33 @@ class UserGroup extends CommonObject
|
||||
$nid = $obj->id;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid;
|
||||
if (! $this->db->query($sql)) $err++;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (fk_usergroup, fk_id) VALUES ($this->id, $nid)";
|
||||
if (! $this->db->query($sql)) $err++;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$err++;
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->context = array('audit'=>$langs->trans("PermissionsAdd"));
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('GROUP_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if ($err) {
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -$err;
|
||||
return -$error;
|
||||
}
|
||||
else {
|
||||
$this->db->commit();
|
||||
@ -350,7 +360,7 @@ class UserGroup extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Retire un droit a l'utilisateur
|
||||
* Remove a permission from group
|
||||
*
|
||||
* @param int $rid id du droit a retirer
|
||||
* @param string $allmodule Retirer tous les droits du module allmodule
|
||||
@ -359,9 +369,9 @@ class UserGroup extends CommonObject
|
||||
*/
|
||||
function delrights($rid,$allmodule='',$allperms='')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$err=0;
|
||||
$error=0;
|
||||
$wherefordel='';
|
||||
|
||||
$this->db->begin();
|
||||
@ -383,7 +393,7 @@ class UserGroup extends CommonObject
|
||||
$subperms=$obj->subperms;
|
||||
}
|
||||
else {
|
||||
$err++;
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
@ -424,21 +434,31 @@ class UserGroup extends CommonObject
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
|
||||
$sql.= " WHERE fk_usergroup = $this->id AND fk_id=".$nid;
|
||||
if (! $this->db->query($sql)) $err++;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$err++;
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->context = array('audit'=>$langs->trans("PermissionsDelete"));
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('GROUP_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if ($err) {
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -$err;
|
||||
return -$error;
|
||||
}
|
||||
else {
|
||||
$this->db->commit();
|
||||
|
||||
@ -140,7 +140,7 @@ if ($action == 'adduser' || $action =='removeuser')
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
if ($userid)
|
||||
if ($userid > 0)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->oldcopy = clone $object;
|
||||
@ -311,15 +311,15 @@ else
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="2">';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>';
|
||||
print '<td>';
|
||||
print $form->showrefnav($object,'id','',$user->rights->user->user->lire || $user->admin);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Name
|
||||
print '<tr><td width="25%">'.$langs->trans("Name").'</td>';
|
||||
print '<td width="75%" class="valeur">'.$object->name;
|
||||
print '<tr><td>'.$langs->trans("Name").'</td>';
|
||||
print '<td class="valeur">'.$object->name;
|
||||
if (empty($object->entity))
|
||||
{
|
||||
print img_picto($langs->trans("GlobalGroup"),'redstar');
|
||||
@ -331,12 +331,12 @@ else
|
||||
{
|
||||
$mc->getInfo($object->entity);
|
||||
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
|
||||
print '<td width="75%" class="valeur">'.$mc->label;
|
||||
print '<td class="valeur">'.$mc->label;
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Note
|
||||
print '<tr><td width="25%" class="tdtop">'.$langs->trans("Description").'</td>';
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
|
||||
print '<td class="valeur">'.dol_htmlentitiesbr($object->note).' </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
@ -397,8 +397,8 @@ else
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="adduser">';
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre"><td class="liste_titre" width="25%">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
|
||||
print '<td>';
|
||||
print '<tr class="liste_titre"><td class="titlefield liste_titre">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
|
||||
print '<td class="liste_titre">';
|
||||
print $form->select_dolusers('', 'user', 1, $exclude, 0, '', '', $object->entity, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print ' ';
|
||||
// Multicompany
|
||||
@ -491,7 +491,7 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan=2 class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
print "<br>";
|
||||
@ -509,8 +509,8 @@ else
|
||||
dol_fiche_head($head, 'group', $title, 0, 'group');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="25%" valign="top" class="fieldrequired">'.$langs->trans("Name").'</td>';
|
||||
print '<td width="75%" class="valeur"><input size="15" type="text" name="group" value="'.$object->name.'">';
|
||||
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Name").'</td>';
|
||||
print '<td class="valeur"><input size="15" type="text" name="group" value="'.$object->name.'">';
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Multicompany
|
||||
@ -528,7 +528,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Description").'</td>';
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
|
||||
print '<td class="valeur">';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor('note',$object->note,'',240,'dolibarr_notes','',true,false,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_8,'90%');
|
||||
@ -536,7 +536,7 @@ else
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="2"');
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user