MediaWiki修改:用户页面仅限拥有者编辑
天下维客,你可以修改的网络知识库
本文取自元维基,欢迎共同翻译、整理与大家共享,促进中文wiki发展^_^
We want to have user pages act as truly "personal" pages, editable only by the owning user. While we understand that this is not "wiki-like", we are interested in providing a personal journal space for users that is integrated with the wiki and uses wiki markup, but that also provides them with a secure sense of ownership.
I wrote a patch to theuserCan()function of
Title.phpthat enables this-user-only editing of User: pages and subpages.
Superusers are NOT enabled to edit by this patch.
The thing to note is thatuserCan()runs a number of tests, each one returning
falseif the user "can't". If none of the tests does a
return, then
userCan()returns
true. So you can add as many disqualifying tests as
needed.
NOTE: This patch is for version 1.4.7; other versions not reviewed or tested
diff -u -r1.1.1.1 Title.php
--- Title.php 21 Jun 2005 22:31:06 -0000 1.1.1.1
+++ Title.php 29 Aug 2005 20:56:59 -0000
@@ -803,6 +803,17 @@
wfProfileOut( $fname );
return false;
}
+
+ # CTLT - make user pages and subpages editable only by owning user
+ if ( NS_USER == $this->mNamespace && $action = 'edit'
+ && !preg_match('/^'.preg_quote($wgUser->getName(), '/').'\/?/',
$this->mTextform) ) {
+ # user is not owner
+ wfProfileOut( $fname );
+ return false;
+ }
+ # end CTLT mod
foreach( $this->getRestrictions($action) as $right ) {
if( '' != $right && !$wgUser->isAllowed( $right ) ) {


