User:Gauravpahuja/Userpage Restriction

From mediawiki.org

If you would like to restrict [edit] access to a user's page (the page created for the user) to just the user who created it and to wiki admins then you can use following hack. I have tested it on Mediawiki 1.6.9. Hope it will work on other versions also.

Go to includes/Title.php and made change in these two functions userCanEdit() and userCanMove()[edit]

function userCanEdit() {
   global $wgOnlyUserEditUserPage;
   global $wgUser;
   if(NS_USER == $this->mNamespace && $wgOnlyUserEditUserPage) {
      return ($wgUser->isAllowed('editalluserpages')|| $wgUser->getName()==$this->getText());
   } else {
      return $this->userCan('edit');
   }
}

function userCanMove() {
   global $wgOnlyUserEditUserPage;
   global $wgUser;
   if(NS_USER == $this->mNamespace && $wgOnlyUserEditUserPage) {
      return ($wgUser->isAllowed('editalluserpages')|| $wgUser->getName()==$this->getText());
   } else {
      return $this->userCan('move');
   }
}

Add the following code to LocalSettings.php[edit]

$wgOnlyUserEditUserPage = true;
$wgGroupPermissions['sysop']['editalluserpages'] = true;

Some more modification has been done to this code to restrict user/subpages also. This code is available at User:Hoggwild5/Restricting_Access_to_User_Pages

http://interestingindian.blogspot.com