Index: trunk/extensions/ProtectSite/ProtectSite.body.php |
— | — | @@ -22,37 +22,37 @@ |
23 | 23 | public function execute( $par ) { |
24 | 24 | global $wgOut, $wgUser, $wgRequest; |
25 | 25 | |
26 | | - # If the user doesn't have 'protectsite' permission, display an error |
| 26 | + // If the user doesn't have 'protectsite' permission, display an error |
27 | 27 | if ( !$wgUser->isAllowed( 'protectsite' ) ) { |
28 | 28 | $this->displayRestrictionError(); |
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | | - # Show a message if the database is in read-only mode |
| 32 | + // Show a message if the database is in read-only mode |
33 | 33 | if ( wfReadOnly() ) { |
34 | 34 | $wgOut->readOnlyPage(); |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | | - # If user is blocked, s/he doesn't need to access this page |
| 38 | + // If user is blocked, s/he doesn't need to access this page |
39 | 39 | if ( $wgUser->isBlocked() ) { |
40 | 40 | $wgOut->blockedPage(); |
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | | - wfLoadExtensionMessages( 'ProtectSite' ); |
45 | 44 | $this->setHeaders(); |
46 | 45 | |
47 | | - $form = new ProtectsiteForm( $wgRequest ); |
| 46 | + $form = new ProtectSiteForm( $wgRequest ); |
48 | 47 | } |
49 | 48 | |
50 | 49 | } |
51 | 50 | |
52 | 51 | /** |
53 | 52 | * Class that handles the actual Special:ProtectSite page |
54 | | - * This is a modified version of the old HTMLForm class. |
| 53 | + * This is a modified version of the ancient HTMLForm class. |
| 54 | + * @todo FIXME: could probably be rewritten to use the modern HTMLForm :) |
55 | 55 | */ |
56 | | -class ProtectsiteForm { |
| 56 | +class ProtectSiteForm { |
57 | 57 | var $mRequest, $action, $persist_data; |
58 | 58 | |
59 | 59 | /* Constructor */ |
— | — | @@ -100,23 +100,23 @@ |
101 | 101 | if( !$this->mRequest->wasPosted() ) { |
102 | 102 | /* If $value is an array, protection is set, allow unsetting */ |
103 | 103 | if( is_array( $prot ) ) { |
104 | | - $this->unProtectsiteForm( $prot ); |
| 104 | + $this->unProtectSiteForm( $prot ); |
105 | 105 | } else { |
106 | 106 | /* If $value is not an array, protection is not set */ |
107 | | - $this->setProtectsiteForm(); |
| 107 | + $this->setProtectSiteForm(); |
108 | 108 | } |
109 | 109 | } else { |
110 | 110 | /* If this was a POST request, process the data sent */ |
111 | 111 | if( $this->mRequest->getVal( 'protect' ) ) { |
112 | | - $this->setProtectsite(); |
| 112 | + $this->setProtectSite(); |
113 | 113 | } else { |
114 | | - $this->unProtectsite(); |
| 114 | + $this->unProtectSite(); |
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | | - function setProtectsite() { |
120 | | - global $wgOut, $wgMemc, $wgProtectsiteLimit; |
| 119 | + function setProtectSite() { |
| 120 | + global $wgOut, $wgMemc, $wgProtectSiteLimit; |
121 | 121 | |
122 | 122 | /* Get the request data */ |
123 | 123 | $request = $this->mRequest->getValues(); |
— | — | @@ -128,7 +128,7 @@ |
129 | 129 | ( $until < $curr_time ) |
130 | 130 | ) { |
131 | 131 | $wgOut->addWikiMsg( 'protectsite-timeout-error' ); |
132 | | - $this->setProtectsiteForm(); |
| 132 | + $this->setProtectSiteForm(); |
133 | 133 | } else { |
134 | 134 | /* Set the array values */ |
135 | 135 | $prot['createaccount'] = $request['createaccount']; |
— | — | @@ -138,10 +138,10 @@ |
139 | 139 | $prot['upload'] = $request['upload']; |
140 | 140 | $prot['comment'] = isset( $request['comment'] ) ? $request['comment'] : ''; |
141 | 141 | |
142 | | - if( isset( $wgProtectsiteLimit ) && |
143 | | - ( $until > strtotime( '+' . $wgProtectsiteLimit, $curr_time ) ) |
| 142 | + if( isset( $wgProtectSiteLimit ) && |
| 143 | + ( $until > strtotime( '+' . $wgProtectSiteLimit, $curr_time ) ) |
144 | 144 | ) { |
145 | | - $request['timeout'] = $wgProtectsiteLimit; |
| 145 | + $request['timeout'] = $wgProtectSiteLimit; |
146 | 146 | } |
147 | 147 | |
148 | 148 | /* Set the limits */ |
— | — | @@ -162,12 +162,13 @@ |
163 | 163 | ); |
164 | 164 | |
165 | 165 | /* Call the Unprotect Form function to display the current state. */ |
166 | | - $this->unProtectsiteForm( $prot ); |
| 166 | + $this->unProtectSiteForm( $prot ); |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | | - function unProtectsite() { |
| 170 | + function unProtectSite() { |
171 | 171 | global $wgMemc; |
| 172 | + |
172 | 173 | /* Get the request data */ |
173 | 174 | $request = $this->mRequest->getValues(); |
174 | 175 | |
— | — | @@ -184,7 +185,7 @@ |
185 | 186 | ); |
186 | 187 | |
187 | 188 | /* Call the Protect Form function to display the current state. */ |
188 | | - $this->setProtectsiteForm(); |
| 189 | + $this->setProtectSiteForm(); |
189 | 190 | } |
190 | 191 | |
191 | 192 | /** |
— | — | @@ -269,8 +270,8 @@ |
270 | 271 | ); |
271 | 272 | } |
272 | 273 | |
273 | | - function setProtectsiteForm() { |
274 | | - global $wgOut, $wgProtectsiteDefaultTimeout, $wgProtectsiteLimit; |
| 274 | + function setProtectSiteForm() { |
| 275 | + global $wgOut, $wgProtectSiteDefaultTimeout, $wgProtectSiteLimit; |
275 | 276 | |
276 | 277 | $request = $this->mRequest->getValues(); |
277 | 278 | $createaccount = array( 0 => false, 1 => false, 2 => false ); |
— | — | @@ -294,9 +295,9 @@ |
295 | 296 | $this->radiobox( 'edit', $edit ) . |
296 | 297 | $this->radiobox( 'move', $move ) . |
297 | 298 | $this->radiobox( 'upload', $upload ) . |
298 | | - $this->textbox( 'timeout', $wgProtectsiteDefaultTimeout, |
299 | | - ( isset( $wgProtectsiteLimit ) ? |
300 | | - ' (' . wfMsg( 'protectsite-maxtimeout', $wgProtectsiteLimit ) . ')' : |
| 299 | + $this->textbox( 'timeout', $wgProtectSiteDefaultTimeout, |
| 300 | + ( isset( $wgProtectSiteLimit ) ? |
| 301 | + ' (' . wfMsg( 'protectsite-maxtimeout', $wgProtectSiteLimit ) . ')' : |
301 | 302 | '' |
302 | 303 | )) . |
303 | 304 | "\n<br />" . |
Index: trunk/extensions/ProtectSite/ProtectSite.i18n.php |
— | — | @@ -178,7 +178,7 @@ |
179 | 179 | ); |
180 | 180 | |
181 | 181 | /** Finnish (Suomi) |
182 | | - * @author Jack Phoenix <jack@shoutwiki.com> |
| 182 | + * @author Jack Phoenix <jack@countervandalism.net> |
183 | 183 | */ |
184 | 184 | $messages['fi'] = array( |
185 | 185 | 'protectsite' => 'Suojaa sivusto', |
Index: trunk/extensions/ProtectSite/ProtectSite.php |
— | — | @@ -6,16 +6,16 @@ |
7 | 7 | * |
8 | 8 | * Knobs: |
9 | 9 | * 'protectsite' - Group permission to use the special page. |
10 | | - * $wgProtectsiteLimit - Maximum time allowed for protection of the site. |
11 | | - * $wgProtectsiteDefaultTimeout - Default protection time. |
12 | | - * $wgProtectsiteExempt - Array of non-sysop usergroups to be not effected by rights changes |
| 10 | + * $wgProtectSiteLimit - Maximum time allowed for protection of the site. |
| 11 | + * $wgProtectSiteDefaultTimeout - Default protection time. |
| 12 | + * $wgProtectSiteExempt - Array of non-sysop usergroups to be not effected by rights changes |
13 | 13 | * |
14 | 14 | * @file |
15 | 15 | * @ingroup Extensions |
16 | | - * @version 0.3.3 |
| 16 | + * @version 0.3.4 |
17 | 17 | * @author Eric Johnston <e.wolfie@gmail.com> |
18 | 18 | * @author Chris Stafford <c.stafford@gmail.com> |
19 | | - * @author Jack Phoenix <jack@shoutwiki.com> |
| 19 | + * @author Jack Phoenix <jack@countervandalism.net> |
20 | 20 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
21 | 21 | */ |
22 | 22 | |
— | — | @@ -30,12 +30,22 @@ |
31 | 31 | /* Extension Credits. Splarka wants me to be so UN:VAIN! Haet haet hat! */ |
32 | 32 | $wgExtensionCredits['specialpage'][] = array( |
33 | 33 | 'name' => 'Protect Site', |
34 | | - 'version' => '0.3.3', |
| 34 | + 'version' => '0.3.4', |
35 | 35 | 'author' => array( '[http://uncyclopedia.org/wiki/User:Dawg Eric Johnston]', 'Chris Stafford', 'Jack Phoenix' ), |
36 | 36 | 'description' => 'Allows a site administrator to temporarily block various site modifications', |
37 | 37 | 'url' => 'http://www.mediawiki.org/wiki/Extension:ProtectSite', |
38 | 38 | ); |
39 | 39 | |
| 40 | +# Configuration settings |
| 41 | +// Array of non-sysop user groups to be not effected by rights changes |
| 42 | +$wgProtectSiteExempt = array(); |
| 43 | + |
| 44 | +/* Set the default timeout. */ |
| 45 | +$wgProtectsiteDefaultTimeout = '1 hour'; |
| 46 | + |
| 47 | +// Maximum time allowed for protection of the site |
| 48 | +$wgProtectSiteLimit = '1 week'; |
| 49 | + |
40 | 50 | /* Register the new user rights level */ |
41 | 51 | $wgAvailableRights[] = 'protectsite'; |
42 | 52 | |
— | — | @@ -43,16 +53,13 @@ |
44 | 54 | $wgGroupPermissions['bureaucrat']['protectsite'] = true; |
45 | 55 | $wgGroupPermissions['staff']['protectsite'] = true; |
46 | 56 | |
47 | | -/* Add this Special page to the Special page listing array */ |
| 57 | +/* Add this special page to the special page listing array */ |
48 | 58 | $dir = dirname( __FILE__ ) . '/'; |
49 | 59 | $wgExtensionMessagesFiles['ProtectSite'] = $dir . 'ProtectSite.i18n.php'; |
50 | 60 | $wgExtensionAliasesFiles['ProtectSite'] = $dir . 'ProtectSite.alias.php'; |
51 | 61 | $wgAutoloadClasses['ProtectSite'] = $dir . 'ProtectSite.body.php'; |
52 | 62 | $wgSpecialPages['ProtectSite'] = 'ProtectSite'; |
53 | 63 | |
54 | | -/* Set the default timeout. */ |
55 | | -$wgProtectsiteDefaultTimeout = '1 hour'; |
56 | | - |
57 | 64 | /* Register initialization function */ |
58 | 65 | $wgExtensionFunctions[] = 'wfSetupProtectsite'; |
59 | 66 | |
— | — | @@ -65,16 +72,13 @@ |
66 | 73 | */ |
67 | 74 | function wfSetupProtectsite() { |
68 | 75 | /* Globals */ |
69 | | - global $wgGroupPermissions, $wgMemc, $wgProtectsiteExempt, $wgCommandLineMode; |
| 76 | + global $wgGroupPermissions, $wgMemc, $wgProtectSiteExempt, $wgCommandLineMode; |
70 | 77 | |
71 | 78 | // macbre: don't run code below when running in command line mode (memcache starts to act strange) |
72 | 79 | if ( !empty( $wgCommandLineMode ) ) { |
73 | 80 | return; |
74 | 81 | } |
75 | 82 | |
76 | | - /* Load i18n messages */ |
77 | | - wfLoadExtensionMessages( 'ProtectSite' ); |
78 | | - |
79 | 83 | /* Initialize Object */ |
80 | 84 | $persist_data = new MediaWikiBagOStuff(); |
81 | 85 | |
— | — | @@ -95,28 +99,28 @@ |
96 | 100 | } |
97 | 101 | |
98 | 102 | /* Protection-related code for MediaWiki 1.8+ */ |
99 | | - $wgGroupPermissions['*']['createaccount'] = !($prot['createaccount'] >= 1); |
100 | | - $wgGroupPermissions['user']['createaccount'] = !($prot['createaccount'] == 2); |
| 103 | + $wgGroupPermissions['*']['createaccount'] = !( $prot['createaccount'] >= 1 ); |
| 104 | + $wgGroupPermissions['user']['createaccount'] = !( $prot['createaccount'] == 2 ); |
101 | 105 | |
102 | | - $wgGroupPermissions['*']['createpage'] = !($prot['createpage'] >= 1); |
103 | | - $wgGroupPermissions['*']['createtalk'] = !($prot['createpage'] >= 1); |
104 | | - $wgGroupPermissions['user']['createpage'] = !($prot['createpage'] == 2); |
105 | | - $wgGroupPermissions['user']['createtalk'] = !($prot['createpage'] == 2); |
| 106 | + $wgGroupPermissions['*']['createpage'] = !( $prot['createpage'] >= 1 ); |
| 107 | + $wgGroupPermissions['*']['createtalk'] = !( $prot['createpage'] >= 1 ); |
| 108 | + $wgGroupPermissions['user']['createpage'] = !( $prot['createpage'] == 2 ); |
| 109 | + $wgGroupPermissions['user']['createtalk'] = !( $prot['createpage'] == 2 ); |
106 | 110 | |
107 | | - $wgGroupPermissions['*']['edit'] = !($prot['edit'] >= 1); |
108 | | - $wgGroupPermissions['user']['edit'] = !($prot['edit'] == 2); |
| 111 | + $wgGroupPermissions['*']['edit'] = !( $prot['edit'] >= 1 ); |
| 112 | + $wgGroupPermissions['user']['edit'] = !( $prot['edit'] == 2 ); |
109 | 113 | $wgGroupPermissions['sysop']['edit'] = true; |
110 | 114 | |
111 | | - $wgGroupPermissions['user']['move'] = !($prot['move'] == 1); |
112 | | - $wgGroupPermissions['user']['upload'] = !($prot['upload'] == 1); |
113 | | - $wgGroupPermissions['user']['reupload'] = !($prot['upload'] == 1); |
114 | | - $wgGroupPermissions['user']['reupload-shared'] = !($prot['upload'] == 1); |
| 115 | + $wgGroupPermissions['user']['move'] = !( $prot['move'] == 1 ); |
| 116 | + $wgGroupPermissions['user']['upload'] = !( $prot['upload'] == 1 ); |
| 117 | + $wgGroupPermissions['user']['reupload'] = !( $prot['upload'] == 1 ); |
| 118 | + $wgGroupPermissions['user']['reupload-shared'] = !( $prot['upload'] == 1 ); |
115 | 119 | |
116 | 120 | // are there any groups that should not get affected by ProtectSite's lockdown? |
117 | | - if( !empty( $wgProtectsiteExempt ) && is_array( $wgProtectsiteExempt ) ) { |
| 121 | + if( !empty( $wgProtectSiteExempt ) && is_array( $wgProtectSiteExempt ) ) { |
118 | 122 | // there are, so loop over them, and force these rights to be true |
119 | 123 | // will resolve any problems from inheriting rights from 'user' or 'sysop' |
120 | | - foreach( $wgProtectsiteExempt as $exemptGroup ) { |
| 124 | + foreach( $wgProtectSiteExempt as $exemptGroup ) { |
121 | 125 | $wgGroupPermissions[$exemptGroup]['edit'] = 1; |
122 | 126 | $wgGroupPermissions[$exemptGroup]['createpage'] = 1; |
123 | 127 | $wgGroupPermissions[$exemptGroup]['createtalk'] = 1; |