mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
Fix: Update entity field in llx_user_rights and llx_usergroup_rights
This commit is contained in:
@@ -288,6 +288,8 @@ Following changes may create regression for some external modules, but were nece
|
||||
* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode. So, if you set var
|
||||
$multicompany_transverse_mode to 1 into your conf file, you must remove this line and a new key into
|
||||
the Home - setup - other admin page.
|
||||
* If you use Multicompany transverse mode, it will be necessary to check the activation of the modules in the children
|
||||
entities and to review completely the rights of the groups and the users.
|
||||
* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx')
|
||||
* Some other change were done in the way we read permission of a user when module multicompany is enabled. You can
|
||||
retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1.
|
||||
|
||||
@@ -371,7 +371,20 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09
|
||||
$beforeversionarray=explode('.','6.0.9');
|
||||
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
|
||||
{
|
||||
// No particular code
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
global $multicompany_transverse_mode;
|
||||
|
||||
// Only if the transverse mode is not used
|
||||
if (empty($multicompany_transverse_mode))
|
||||
{
|
||||
// Migrate to add entity value into llx_user_rights
|
||||
migrate_user_rights_entity($db, $langs, $conf);
|
||||
|
||||
// Migrate to add entity value into llx_usergroup_rights
|
||||
migrate_usergroup_rights_entity($db, $langs, $conf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3967,6 +3980,158 @@ function migrate_remise_except_entity($db,$langs,$conf)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate to add entity value into llx_user_rights
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Translate $langs Object langs
|
||||
* @param Conf $conf Object conf
|
||||
* @return void
|
||||
*/
|
||||
function migrate_user_rights_entity($db,$langs,$conf)
|
||||
{
|
||||
print '<tr><td colspan="4">';
|
||||
|
||||
print '<b>'.$langs->trans('MigrationUserRightsEntity')."</b><br>\n";
|
||||
|
||||
$error = 0;
|
||||
|
||||
dolibarr_install_syslog("upgrade2::migrate_user_rights_entity");
|
||||
|
||||
$db->begin();
|
||||
|
||||
$sqlSelect = "SELECT u.rowid, u.entity";
|
||||
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sqlSelect.= " WHERE u.entity > 1";
|
||||
//print $sqlSelect;
|
||||
|
||||
$resql = $db->query($sqlSelect);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."user_rights SET";
|
||||
$sqlUpdate.= " entity = " . $obj->entity;
|
||||
$sqlUpdate.= " WHERE fk_user = " . $obj->rowid;
|
||||
|
||||
$result=$db->query($sqlUpdate);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print ". ";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('AlreadyDone')."<br>\n";
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate to add entity value into llx_usergroup_rights
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Translate $langs Object langs
|
||||
* @param Conf $conf Object conf
|
||||
* @return void
|
||||
*/
|
||||
function migrate_usergroup_rights_entity($db,$langs,$conf)
|
||||
{
|
||||
print '<tr><td colspan="4">';
|
||||
|
||||
print '<b>'.$langs->trans('MigrationUserGroupRightsEntity')."</b><br>\n";
|
||||
|
||||
$error = 0;
|
||||
|
||||
dolibarr_install_syslog("upgrade2::migrate_usergroup_rights_entity");
|
||||
|
||||
$db->begin();
|
||||
|
||||
$sqlSelect = "SELECT u.rowid, u.entity";
|
||||
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."usergroup as u";
|
||||
$sqlSelect.= " WHERE u.entity > 1";
|
||||
//print $sqlSelect;
|
||||
|
||||
$resql = $db->query($sqlSelect);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."usergroup_rights SET";
|
||||
$sqlUpdate.= " entity = " . $obj->entity;
|
||||
$sqlUpdate.= " WHERE fk_usergroup = " . $obj->rowid;
|
||||
|
||||
$result=$db->query($sqlUpdate);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print ". ";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('AlreadyDone')."<br>\n";
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migration directory
|
||||
*
|
||||
|
||||
@@ -193,6 +193,8 @@ MigrationCategorieAssociation=Migration of categories
|
||||
MigrationEvents=Migration of events to add event owner into assignement table
|
||||
MigrationRemiseEntity=Update entity field value of llx_societe_remise
|
||||
MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_except
|
||||
MigrationUserRightsEntity=Update entity field value of llx_user_rights
|
||||
MigrationUserGroupRightsEntity=Update entity field value of llx_usergroup_rights
|
||||
MigrationReloadModule=Reload module %s
|
||||
ShowNotAvailableOptions=Show not available options
|
||||
HideNotAvailableOptions=Hide not available options
|
||||
|
||||
Reference in New Issue
Block a user