Fix avoid trigger during migration
This commit is contained in:
parent
c228b04f32
commit
3c54cb5ba9
@ -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();
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -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"));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user