mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/17332] Fix permission migrator tool to work with copied permissions
PHPBB-17332
This commit is contained in:
parent
cd0e682984
commit
ef4db99709
1 changed files with 26 additions and 35 deletions
|
@ -435,15 +435,14 @@ class permission implements \phpbb\db\migration\tool\tool_interface
|
||||||
}
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
if (empty($new_auth))
|
$type = (string) $type; // Prevent PHP bug.
|
||||||
|
if (empty($new_auth) || !in_array($type, ['role','group']))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_auth = array();
|
$current_auth = array();
|
||||||
|
|
||||||
$type = (string) $type; // Prevent PHP bug.
|
|
||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
case 'role':
|
case 'role':
|
||||||
|
@ -525,40 +524,32 @@ class permission implements \phpbb\db\migration\tool\tool_interface
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_ary = array();
|
$sql_ary = $auth_update_list = [];
|
||||||
switch ($type)
|
$table = $type == 'role' ? ACL_ROLES_DATA_TABLE : ACL_GROUPS_TABLE;
|
||||||
{
|
|
||||||
case 'role':
|
|
||||||
foreach ($new_auth as $auth_option_id)
|
foreach ($new_auth as $auth_option_id)
|
||||||
{
|
{
|
||||||
if (!isset($current_auth[$auth_option_id]))
|
if (!isset($current_auth[$auth_option_id]))
|
||||||
{
|
{
|
||||||
$sql_ary[] = array(
|
$sql_ary[] = [
|
||||||
'role_id' => $role_id,
|
$type . '_id' => ${$type . '_id'},
|
||||||
'auth_option_id' => $auth_option_id,
|
'auth_option_id' => $auth_option_id,
|
||||||
'auth_setting' => $has_permission,
|
'auth_setting' => (int) $has_permission,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
$this->db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'group':
|
|
||||||
foreach ($new_auth as $auth_option_id)
|
|
||||||
{
|
{
|
||||||
if (!isset($current_auth[$auth_option_id]))
|
$auth_update_list[] = $auth_option_id;
|
||||||
{
|
|
||||||
$sql_ary[] = array(
|
|
||||||
'group_id' => $group_id,
|
|
||||||
'auth_option_id' => $auth_option_id,
|
|
||||||
'auth_setting' => $has_permission,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->db->sql_multi_insert($table, $sql_ary);
|
||||||
|
|
||||||
$this->db->sql_multi_insert(ACL_GROUPS_TABLE, $sql_ary);
|
if (count($auth_update_list))
|
||||||
break;
|
{
|
||||||
|
$sql = 'UPDATE ' . $table . '
|
||||||
|
SET auth_setting = ' . (int) $has_permission . '
|
||||||
|
WHERE ' . $this->db->sql_in_set('auth_option_id', $auth_update_list) . '
|
||||||
|
AND ' . $type . '_id = ' . (int) ${$type . '_id'};
|
||||||
|
$this->db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->auth->acl_clear_prefetch();
|
$this->auth->acl_clear_prefetch();
|
||||||
|
|
Loading…
Add table
Reference in a new issue