-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathosblocks.php
More file actions
43 lines (34 loc) · 996 Bytes
/
osblocks.php
File metadata and controls
43 lines (34 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
class OSBlocks {
private const disallowedSpecialPages = ['BlockList', 'AutoblockList'];
public static function onGetUserPermissionsErrors( $title, $user, $action, &$out_result ) {
if (self::isDisallowedSpecialPage($title) && !$user->isAllowed('block')) {
$out_result = [
'badaccess'
];
return false;
}
return true;
}
public static function onApiCheckCanExecute($module, $user, &$message) {
if (!$user->isAllowed('block') && self::isBlockListApi($module)) {
$message = 'badaccess';
return false;
}
return true;
}
private static function isBlockListApi($module) {
$params = $module->extractRequestParams();
return isset($params['list']) && in_array('blocks', $params['list']);
}
private static function isDisallowedSpecialPage($title) {
return !empty(
array_filter(
self::disallowedSpecialPages,
function ($disallowedTitle) use($title) {
return $title->isSpecial($disallowedTitle);
}
)
);
}
}