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 |
1 | 21 | + native |
Index: trunk/extensions/UserPageEditProtection/UserPageEditProtection.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | | -if(! defined( 'MEDIAWIKI' ) ) { |
| 3 | +if ( ! defined( 'MEDIAWIKI' ) ) { |
4 | 4 | echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" ); |
5 | | - die( -1 ); |
| 5 | + die( - 1 ); |
6 | 6 | } |
7 | 7 | /** |
8 | 8 | * Extension: UserPageEditProtection.php |
— | — | @@ -30,47 +30,56 @@ |
31 | 31 | * |
32 | 32 | * |
33 | 33 | * 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'); |
35 | 37 | * //turn on user page protection |
36 | 38 | * $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'); |
40 | 39 | **/ |
41 | 40 | |
42 | 41 | /* register extension */ |
43 | 42 | $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 | +); |
49 | 51 | |
| 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 | + |
50 | 60 | /* use the userCan hook to check user page edit permissions */ |
51 | | -$wgHooks[ 'userCan' ][] = 'fnUserPageEditProtection'; |
| 61 | +$wgHooks['userCan'][] = 'fnUserPageEditProtection'; |
52 | 62 | |
53 | 63 | 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; |
59 | 69 | } |
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; |
76 | 85 | } |
77 | 86 | |
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt |
— | — | @@ -1319,6 +1319,8 @@ |
1320 | 1320 | User Option Stats |
1321 | 1321 | aliasfile = UserOptionStats/UserOptionStats.alias.php |
1322 | 1322 | |
| 1323 | +User Page Edit Protection |
| 1324 | + |
1323 | 1325 | User Rights Notif |
1324 | 1326 | |
1325 | 1327 | Validator |