Skip to content

Commit

Permalink
Add support for removing permissions from ManageWiki
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Jan 8, 2024
1 parent f8489ef commit ea618ec
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion includes/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,24 @@ public static function onCreateWikiJsonBuilder( string $wiki, DBConnRef $dbr, ar

foreach ( $permObjects as $perm ) {
$addPerms = [];
$removePerms = [];

foreach ( ( self::getConfig( 'ManageWikiPermissionsAdditionalRights' )[$perm->perm_group] ?? [] ) as $right => $bool ) {
if ( $bool ) {
$addPerms[] = $right;
continue;
}

if ( $bool === false ) {
$removePerms[] = $right;
}
}

$permissions = array_merge( json_decode( $perm->perm_permissions ?? '', true ) ?? [], $addPerms );
$filteredPermissions = array_diff( $permissions, $removePerms );

$jsonArray['permissions'][$perm->perm_group] = [
'permissions' => array_merge( json_decode( $perm->perm_permissions ?? '', true ) ?? [], $addPerms ),
'permissions' => $filteredPermissions,
'addgroups' => array_merge(
json_decode( $perm->perm_addgroups ?? '', true ) ?? [],
self::getConfig( 'ManageWikiPermissionsAdditionalAddGroups' )[$perm->perm_group] ?? []
Expand Down

0 comments on commit ea618ec

Please sign in to comment.