FIX for migration from old versions
This commit is contained in:
parent
5583600066
commit
275f981545
@ -1671,11 +1671,12 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
|||||||
// Search if perm already present
|
// Search if perm already present
|
||||||
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";
|
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";
|
||||||
$sql.= " WHERE id = ".$r_id." AND entity = ".$entity;
|
$sql.= " WHERE id = ".$r_id." AND entity = ".$entity;
|
||||||
|
|
||||||
$resqlselect=$this->db->query($sql);
|
$resqlselect=$this->db->query($sql);
|
||||||
if ($resqlselect)
|
if ($resqlselect)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resqlselect);
|
$objcount = $this->db->fetch_object($resqlselect);
|
||||||
if ($obj->nb == 0)
|
if ($objcount && $objcount->nb == 0)
|
||||||
{
|
{
|
||||||
if (dol_strlen($r_perms) )
|
if (dol_strlen($r_perms) )
|
||||||
{
|
{
|
||||||
@ -1739,23 +1740,33 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
|||||||
{
|
{
|
||||||
$obj2=$this->db->fetch_object($resqlseladmin);
|
$obj2=$this->db->fetch_object($resqlseladmin);
|
||||||
dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid);
|
dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid);
|
||||||
|
|
||||||
$tmpuser=new User($this->db);
|
$tmpuser=new User($this->db);
|
||||||
$tmpuser->fetch($obj2->rowid);
|
$result = $tmpuser->fetch($obj2->rowid);
|
||||||
if (!empty($tmpuser->id)) {
|
if ($result > 0) {
|
||||||
$tmpuser->addrights($r_id, '', '', 0, 1);
|
$tmpuser->addrights($r_id, '', '', 0, 1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if (! empty($user->admin)) // Reload permission for current user if defined
|
|
||||||
{
|
|
||||||
// We reload permissions
|
|
||||||
$user->clearrights();
|
|
||||||
$user->getrights();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else dol_print_error($this->db);
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($reinitadminperms && ! empty($user->admin)) // Reload permission for current user if defined
|
||||||
|
{
|
||||||
|
// We reload permissions
|
||||||
|
$user->clearrights();
|
||||||
|
$user->getrights();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -246,7 +246,7 @@ class modSupplierProposal extends DolibarrModules
|
|||||||
public function remove($options = '')
|
public function remove($options = '')
|
||||||
{
|
{
|
||||||
$sql = array(
|
$sql = array(
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'"
|
"DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->_remove($sql, $options);
|
return $this->_remove($sql, $options);
|
||||||
|
|||||||
@ -192,6 +192,32 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09
|
|||||||
$versiontoarray=explode('.',$versionto);
|
$versiontoarray=explode('.',$versionto);
|
||||||
$versionranarray=explode('.',DOL_VERSION);
|
$versionranarray=explode('.',DOL_VERSION);
|
||||||
|
|
||||||
|
|
||||||
|
// Force to execute this at begin to avoid the new core code into Dolibarr to be broken.
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemployment date';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemploymentend date';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_range integer';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_c_exp_tax_cat integer';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN langs varchar(24)';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fieldcomputed text';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fielddefault varchar(255)';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX."extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'";
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN help text';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL';
|
||||||
|
$db->query($sql, 1);
|
||||||
|
|
||||||
|
|
||||||
$afterversionarray=explode('.','2.0.0');
|
$afterversionarray=explode('.','2.0.0');
|
||||||
$beforeversionarray=explode('.','2.7.9');
|
$beforeversionarray=explode('.','2.7.9');
|
||||||
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
|
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user