public static function applyGlobalPermission($applyGroupId, $applyPermissionId, $dependGroupId = null, $dependPermissionId = null, $checkModerator = true)
{
$db = XenForo_Application::getDb();
XenForo_Db::beginTransaction($db);
if ($dependGroupId && $dependPermissionId)
{
$db->query("
INSERT IGNORE INTO xf_permission_entry
(user_group_id, user_id, permission_group_id, permission_id, permission_value, permission_value_int)
SELECT user_group_id, user_id, ?, ?, 'allow', 0
FROM xf_permission_entry
WHERE permission_group_id = ?
AND permission_id = ?
AND permission_value = 'allow'
", array($applyGroupId, $applyPermissionId, $dependGroupId, $dependPermissionId));
}
else
{
$db->query("
INSERT IGNORE INTO xf_permission_entry
(user_group_id, user_id, permission_group_id, permission_id, permission_value, permission_value_int)
SELECT DISTINCT user_group_id, user_id, ?, ?, 'allow', 0
FROM xf_permission_entry
", array($applyGroupId, $applyPermissionId));
}
if ($checkModerator)
{
$moderators = self::_getGlobalModPermissions();
foreach ($moderators AS $userId => $permissions)
{
if (!$dependGroupId || !$dependPermissionId || !empty($permissions[$dependGroupId][$dependPermissionId]))
{
$permissions[$applyGroupId][$applyPermissionId] = '1'; // string 1 is stored by the code
self::_updateGlobalModPermissions($userId, $permissions);
}
}
}
XenForo_Db::commit($db);
}
self::applyGlobalPermission('resource', 'approveUnapprove', 'forum', 'approveUnapprove', true);
Well okay, but has this design an intention? E.g. to allow you to reuse the permissions after a reinstallation?That's currently as designed, yes. You will need to manually remove permission entries on uninstall in the same way they were added.
Well okay, but has this design an intention? E.g. to allow you to reuse the permissions after a reinstallation?
So in other words: Would you recommend to delete these entries during the uninstallation of the add-on?
We use essential cookies to make this site work, and optional cookies to enhance your experience.