Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2001
DefaultRestrictions.php
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 8:27 PM
2014-11-21 20:27:06 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
DefaultRestrictions.php
View Options
<?php
$wgExtensionFunctions
[]
=
"wfDefaultRestrictions"
;
function
wfDefaultRestrictions
()
{
global
$IP
,
$wgMessageCache
,
$wgHooks
;
require_once
(
"$IP/includes/SpecialPage.php"
);
$wgExtensionCredits
[
'other'
][]
=
array
(
'name'
=>
'Default restrictions'
,
'author'
=>
'Zhen Lin'
,
'description'
=>
''
);
$wgHooks
[
'userCan'
][]
=
'wfDefaultRestrictionsHook1'
;
$wgHooks
[
'ArticleInsertComplete'
][]
=
'wfDefaultRestrictionsHook2'
;
}
function
wfDefaultRestrictionsHook1
(&
$title
,
&
$user
,
$action
,
&
$result
)
{
global
$wgDefaultRestrictions
,
$wgCreateRestrictions
;
$id
=
$title
->
getArticleID
();
if
(
$id
!=
0
)
{
$result
=
null
;
return
;
}
$res
=
$wgDefaultRestrictions
[
$title
->
mNamespace
];
if
(!
isset
(
$res
))
$res
=
''
;
if
(!
$title
->
mRestrictionsLoaded
)
$title
->
loadRestrictions
(
$res
);
if
(
$action
==
'create'
)
{
$res
=
$wgCreateRestrictions
[
$title
->
mNamespace
];
if
(
isset
(
$res
))
{
$result
=
$user
->
isAllowed
(
$res
);
return
;
}
}
$result
=
null
;
return
;
}
function
wfDefaultRestrictionsHook2
(&
$article
,
&
$user
,
$text
,
$summary
,
$isminor
,
$iswatch
,
$section
)
{
global
$wgDefaultRestrictions
;
$id
=
$article
->
mTitle
->
mArticleID
;
if
(
$id
==
0
)
return
;
$res
=
$wgDefaultRestrictions
[
$article
->
mTitle
->
mNamespace
];
if
(!
isset
(
$res
))
return
;
$dbw
=&
wfGetDB
(
DB_MASTER
);
$dbw
->
update
(
'page'
,
array
(
/* SET */
'page_restrictions'
=>
$res
),
array
(
/* WHERE */
'page_id'
=>
$id
),
'Article::protect'
);
return
;
}
?>
File Metadata
Details
Attached
Mime Type
text/x-php
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1578
Default Alt Text
DefaultRestrictions.php (1 KB)
Attached To
Mode
T4073: Default page restrictions for each namespace
Attached
Detach File
Event Timeline
Log In to Comment