-
Notifications
You must be signed in to change notification settings - Fork 0
/
LockFormEdit.hooks.php
35 lines (27 loc) · 1.08 KB
/
LockFormEdit.hooks.php
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
<?php
class LockFormEditHooks {
public static function onMediaWikiPerformAction( $output, $article, $title, $user, $request, $wiki )
{
global $wgLockFormEditCategories;
// Skin check for sysop user
if( $user && !$user->isAnon() && in_array( 'sysop', $user->getGroups() ) ) {
return true;
}
// Skip check if title not exists
if( !$title || !$title->exists() ) {
return true;
}
// Skip check if it is not in specified category
$categories = SFUtils::getCategoriesForPage( $title );
if( !count( array_intersect( $wgLockFormEditCategories, $categories ) ) ) {
return true;
}
// Prevent users for edit
if( $request && $request->getCheck('action') && $request->getVal('action') == 'edit' )
{
$output->setPageTitle( wfMessage('lockformedit-error-title')->plain() );
$output->addWikiText( wfMessage('lockformedit-error-text')->plain() );
return false;
}
}
}