diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 029aaef1116cd202ac794ecb8046938d0e5ece4f..127bf46f2fa5985b1353fa3280e51fb0821c5623 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -66,11 +66,17 @@ class Interfaces $this->errors[]=$this->error; return -1; } - if (! is_object($user) || ! is_object($langs)) // Warning + if (! is_object($langs)) // Warning { dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); } - + if (! is_object($user)) // Warning + { + dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); + global $db; + $user = new User($db); + } + $nbfile = $nbtotal = $nbok = $nbko = 0; $files = array(); diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index efb2ec646c8e748255d0320b280fe7a859923a96..8e526baa241e2f76248ea86e574827ef91852189 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -377,7 +377,7 @@ class DolibarrModules // Can not be abstract, because we need to insta if (! $err) $err+=$this->insert_cronjobs(); // Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user. - if (! $err) $err+=$this->insert_permissions(1); + if (! $err) $err+=$this->insert_permissions(1, null, 1); // Insert specific menus entries into database if (! $err) $err+=$this->insert_menus(); @@ -1414,10 +1414,10 @@ class DolibarrModules // Can not be abstract, because we need to insta * * @param int $reinitadminperms If 1, we also grant them to all admin users * @param int $force_entity Force current entity - * + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int Error count (0 if OK) */ - function insert_permissions($reinitadminperms=0, $force_entity=null) + function insert_permissions($reinitadminperms=0, $force_entity=null, $notrigger=0) { global $conf,$user; @@ -1523,7 +1523,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $tmpuser=new User($this->db); $tmpuser->fetch($obj2->rowid); if (!empty($tmpuser->id)) { - $tmpuser->addrights($r_id); + $tmpuser->addrights($r_id, '', '', 0, 1); } $i++; } @@ -1552,8 +1552,8 @@ class DolibarrModules // Can not be abstract, because we need to insta /** * Removes access rights - * - * @return int Error count (0 if OK) + * + * @return int Error count (0 if OK) */ function delete_permissions() { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 0d75f4f6c57b5fd953180d4fc6cd70fb985c9210..9715abfd77b6380cba208af6a0ec0d3950c54f51 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -375,9 +375,10 @@ class User extends CommonObject * @param string $allmodule Ajouter tous les droits du module allmodule * @param string $allperms Ajouter tous les droits du module allmodule, perms allperms * @param int $entity Entity to use + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int > 0 if OK, < 0 if KO */ - function addrights($rid, $allmodule='', $allperms='', $entity='') + function addrights($rid, $allmodule='', $allperms='', $entity=0, $notrigger=0) { global $conf, $user, $langs; @@ -458,7 +459,7 @@ class User extends CommonObject } } - if (! $error) + if (! $error && ! $notrigger) { $this->context = array('audit'=>$langs->trans("PermissionsAdd")); @@ -486,10 +487,11 @@ class User extends CommonObject * @param int $rid Id du droit a retirer * @param string $allmodule Retirer tous les droits du module allmodule * @param string $allperms Retirer tous les droits du module allmodule, perms allperms - * @param int $entity Entity to use + * @param int $entity Entity to use + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int > 0 if OK, < 0 if OK */ - function delrights($rid, $allmodule='', $allperms='', $entity='') + function delrights($rid, $allmodule='', $allperms='', $entity=0, $notrigger=0) { global $conf, $user, $langs; @@ -566,7 +568,7 @@ class User extends CommonObject } } - if (! $error) + if (! $error && ! $notrigger) { $this->context = array('audit'=>$langs->trans("PermissionsDelete"));