allwiki首页  
天下维客 你可以修改的网络知识库
首页最近更改优秀条目专题展示电脑科技词典软件学习网络知识电脑安全明星时尚天下百科
 

MediaWiki修改:用户页面仅限拥有者编辑

天下维客,你可以修改的网络知识库

Jump to: navigation, search

本文取自元维基,欢迎共同翻译、整理与大家共享,促进中文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 the
userCan()
function of
Title.php
that enables this-user-only editing of User: pages and subpages.

Superusers are NOT enabled to edit by this patch.

The thing to note is that
userCan()
runs a number of tests, each one returning
false
if 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 ) ) {

原文参见: User Pages Editable Only By User

Personal tools
工具
金银币拍卖 金币拍卖预展  金银币网店 熊猫金银币 生肖金银币