Fix: La mise a jour des nouveaux droits en automatique ne fonctionnait pas.
This commit is contained in:
parent
d0d1212171
commit
ef06e53719
@ -439,50 +439,62 @@ class DolibarrModules
|
|||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
//print $this->rights_class." ".sizeof($this->rights)."<br>";
|
//print $this->rights_class." ".sizeof($this->rights)."<br>";
|
||||||
foreach ($this->rights as $key => $value)
|
|
||||||
{
|
|
||||||
$r_id = $this->rights[$key][0];
|
|
||||||
$r_desc = $this->rights[$key][1];
|
|
||||||
$r_type = $this->rights[$key][2];
|
|
||||||
$r_def = $this->rights[$key][3];
|
|
||||||
$r_perms = $this->rights[$key][4];
|
|
||||||
$r_subperms = $this->rights[$key][5];
|
|
||||||
$r_modul = $this->rights_class;
|
|
||||||
|
|
||||||
if (strlen($r_perms) )
|
// Test si module actif
|
||||||
{
|
$sql_del = "SELECT value FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->const_name."';";
|
||||||
if (strlen($r_subperms) )
|
$resql=$this->db->query($sql_del);
|
||||||
|
if ($resql) {
|
||||||
|
|
||||||
|
$obj=$this->db->fetch_object($resql);
|
||||||
|
if ($obj->value) {
|
||||||
|
|
||||||
|
// Si module actif
|
||||||
|
foreach ($this->rights as $key => $value)
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
|
$r_id = $this->rights[$key][0];
|
||||||
$sql .= " (id, libelle, module, type, bydefault, perms, subperms)";
|
$r_desc = $this->rights[$key][1];
|
||||||
$sql .= " VALUES ";
|
$r_type = $this->rights[$key][2];
|
||||||
$sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."');";
|
$r_def = $this->rights[$key][3];
|
||||||
}
|
$r_perms = $this->rights[$key][4];
|
||||||
else
|
$r_subperms = $this->rights[$key][5];
|
||||||
{
|
$r_modul = $this->rights_class;
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
|
|
||||||
$sql .= " (id, libelle, module, type, bydefault, perms)";
|
if (strlen($r_perms) )
|
||||||
$sql .= " VALUES ";
|
{
|
||||||
$sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."');";
|
if (strlen($r_subperms) )
|
||||||
}
|
{
|
||||||
}
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
|
||||||
else
|
$sql .= " (id, libelle, module, type, bydefault, perms, subperms)";
|
||||||
{
|
$sql .= " VALUES ";
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
|
$sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."');";
|
||||||
$sql .= " (id, libelle, module, type, bydefault)";
|
}
|
||||||
$sql .= " VALUES ";
|
else
|
||||||
$sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.");";
|
{
|
||||||
}
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
|
||||||
|
$sql .= " (id, libelle, module, type, bydefault, perms)";
|
||||||
$resql=$this->db->query($sql);
|
$sql .= " VALUES ";
|
||||||
if (! $resql)
|
$sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."');";
|
||||||
{
|
}
|
||||||
if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") {
|
}
|
||||||
$err++;
|
else
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
|
||||||
|
$sql .= " (id, libelle, module, type, bydefault)";
|
||||||
|
$sql .= " VALUES ";
|
||||||
|
$sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.");";
|
||||||
|
}
|
||||||
|
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") {
|
||||||
|
$err++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $err;
|
return $err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user