r62523 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62522‎ | r62523 | r62524 >
Date:15:41, 15 February 2010
Author:raymond
Status:ok
Tags:
Comment:
Run code through stylize.php, use indention instead of spaces
Update extension credits
Add right definition
Add i18n file
Add extension to translatewiki
Modified paths:
  • /trunk/extensions/Translate/groups/mediawiki-defines.txt (modified) (history)
  • /trunk/extensions/UserPageEditProtection/UserPageEditProtection.i18n.php (added) (history)
  • /trunk/extensions/UserPageEditProtection/UserPageEditProtection.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UserPageEditProtection/UserPageEditProtection.i18n.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+/**
 5+ * Internationalisation file for the UserPageEditProtection extension
 6+ *
 7+ * @author Lisa Ridley
 8+ * @addtogroup Extensions
 9+ */
 10+
 11+$messages = array();
 12+
 13+/** English
 14+ * @author Lisa Ridley
 15+ */
 16+$messages['en'] = array(
 17+ 'userpageeditprotection-desc' => 'Restricts editing on user pages to user and allowed editors',
 18+ 'right-editalluserpages' => 'Edit user pages',
 19+);
 20+
Property changes on: trunk/extensions/UserPageEditProtection/UserPageEditProtection.i18n.php
___________________________________________________________________
Name: svn:eol-style
121 + native
Index: trunk/extensions/UserPageEditProtection/UserPageEditProtection.php
@@ -1,7 +1,7 @@
22 <?php
3 -if(! defined( 'MEDIAWIKI' ) ) {
 3+if ( ! defined( 'MEDIAWIKI' ) ) {
44 echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" );
5 - die( -1 );
 5+ die( - 1 );
66 }
77 /**
88 * Extension: UserPageEditProtection.php
@@ -30,47 +30,56 @@
3131 *
3232 *
3333 * Usage:
34 - * Save this file in your extensions folder of your MediaWiki installation. Add the following to LocalSettings.php:
 34+ * Save this file in your extensions folder of your MediaWiki installation.
 35+ * Add the following lines to LocalSettings.php:
 36+ * require_once('extensions/UserPageEditProtection.php');
3537 * //turn on user page protection
3638 * $wgOnlyUserEditUserPage = true;
37 - * //allow sysops to edit user pages by adding the following setting
38 - * $wgGroupPermissions['sysop']['editalluserpages'] = true;
39 - * require_once('extensions/UserPageEditProtection.php');
4039 **/
4140
4241 /* register extension */
4342 $wgExtensionCredits['other'][] = array(
44 - 'name' => 'UserPageEditProtection',
45 - 'author' => 'Lisa Ridley, Eric Gingell',
46 - 'version' => '2.0',
47 - 'url' => 'http://www.mediawiki.org/wiki/Extension:UserPageEditProtection',
48 - 'description' => 'This Extension restricts editing on user pages to User and allowed editors');
 43+ 'path' => __FILE__,
 44+ 'name' => 'UserPageEditProtection',
 45+ 'author' => array( 'Lisa Ridley', 'Eric Gingell' ),
 46+ 'version' => '2.0',
 47+ 'url' => 'http://www.mediawiki.org/wiki/Extension:UserPageEditProtection',
 48+ 'description' => 'Restricts editing on user pages to user and allowed editors',
 49+ 'descriptionmsg' => 'userpageeditprotection-desc',
 50+);
4951
 52+# Internationalisation file
 53+$dir = dirname(__FILE__) . '/';
 54+$wgExtensionMessagesFiles['UserPageEditProtection'] = $dir . 'UserPageEditProtection.i18n.php';
 55+
 56+# Define the new user right
 57+$wgAvailableRights[] = 'editalluserpages';
 58+$wgGroupPermissions['sysop']['editalluserpages'] = true;
 59+
5060 /* use the userCan hook to check user page edit permissions */
51 -$wgHooks[ 'userCan' ][] = 'fnUserPageEditProtection';
 61+$wgHooks['userCan'][] = 'fnUserPageEditProtection';
5262
5363 function fnUserPageEditProtection( $title, $user, $action, &$result ) {
54 - global $wgOnlyUserEditUserPage;
55 - $lTitle = explode('/', $title->getText());
56 - if (!($action == 'edit'||$action == 'move')) {
57 - $result = null;
58 - return true;
 64+ global $wgOnlyUserEditUserPage;
 65+ $lTitle = explode( '/', $title->getText() );
 66+ if ( !( $action == 'edit' || $action == 'move' ) ) {
 67+ $result = null;
 68+ return true;
5969 }
60 - if (NS_USER !== $title->mNamespace) {
61 - $result = null;
62 - return true;
63 - }
64 - if ($wgOnlyUserEditUserPage) {
65 - if ($user->isAllowed('editalluserpages') || ($lTitle[0] == $user->getname())) {
66 - $result = null;
67 - return true;
68 - } else {
69 - $result = false;
70 - return false;
71 - }
72 - }
73 - $result = null;
74 - return true;
75 -
 70+ if ( $title->mNamespace !== NS_USER ) {
 71+ $result = null;
 72+ return true;
 73+ }
 74+ if ( $wgOnlyUserEditUserPage ) {
 75+ if ( $user->isAllowed( 'editalluserpages' ) || ( $user->getname() == $lTitle[0] ) ) {
 76+ $result = null;
 77+ return true;
 78+ } else {
 79+ $result = false;
 80+ return false;
 81+ }
 82+ }
 83+ $result = null;
 84+ return true;
7685 }
7786
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt
@@ -1319,6 +1319,8 @@
13201320 User Option Stats
13211321 aliasfile = UserOptionStats/UserOptionStats.alias.php
13221322
 1323+User Page Edit Protection
 1324+
13231325 User Rights Notif
13241326
13251327 Validator

Status & tagging log