-
Notifications
You must be signed in to change notification settings - Fork 0
/
SMWUserProtect.php
executable file
·70 lines (50 loc) · 1.93 KB
/
SMWUserProtect.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
echo 'Not a valid entry point';
exit( 1 );
}
if ( !defined( 'SMW_VERSION' ) ) {
echo 'This extension requires Semantic MediaWiki to be installed.';
exit( 1 );
}
call_user_func( function () {
# Extension credits
$GLOBALS['wgExtensionCredits'][defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'other'][] = array(
'path' => __FILE__,
'name' => 'SMWUserProtect',
'author' => array(
'[https://www.mediawiki.org/wiki/User:Toniher Toni Hermoso]'
),
'version' => '0.1.2',
'url' => 'https://www.mediawiki.org/wiki/Extension:SMWUserProtect',
'descriptionmsg' => 'SMWUserProtect-desc',
);
// i18n
$GLOBALS['$wgExtensionMessagesFiles']['SMWUserProtect'] = dirname( __FILE__ ) . '/SMWUserProtect.i18n.php';
// Autoloading
$GLOBALS['wgAutoloadClasses']['SMWUserProtect'] = dirname( __FILE__ ) . '/SMWUserProtect.classes.php';
// Allowed groups
$GLOBALS['wgSMWUserProtectGroups'] = array( 'sysop', 'team' );
// User Property
$GLOBALS['wgSMWUserProtectProps'] = array( 'Has User' );
// Namespaces with protection
$GLOBALS['wgSMWUserProtectNS'] = array( NS_REQUEST, NS_SAMPLE, NS_PROCESS );
$GLOBALS['wgSMWUserProtectNSParent'] = array( NS_REQUEST );
# Edit prohibited depending on the value
$GLOBALS['wgSMWUserProtectEditClose'] = array (
NS_REQUEST => array(
"Has Request Status" => array( "Accepted", "Closed", "Discarded" )
)
);
# If visiting user is not in the groups above, avoid reading User pages
$GLOBALS['wgSMWUserProtectUserPages'] = true;
# Block edition of user pages by non-owning users. It actually makes sense if previous wgSMWUserProtectUserPages is false
$GLOBALS['wgSMWUserProtectEditUserPages'] = true;
// Hooks
$GLOBALS['wgHooks']['userCan'][] = 'SMWUserProtectfunc';
});
function SMWUserProtectfunc( $title, $user, $action, &$result ) {
$object = new SMWUserProtect;
$result = $object->checkIfUserCan( $title, $user, $action );
return($result);
}