Index: trunk/extensions/Crosswiki/Block/CrosswikiBlock.class.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | class CrosswikiBlock { |
5 | 5 | public static function normalizeOptions( $user, &$options ) { |
6 | | - if( User::isIP( $user ) ) { |
| 6 | + if ( User::isIP( $user ) ) { |
7 | 7 | $options['autoblock'] = false; |
8 | 8 | $options['noemail'] = false; |
9 | 9 | } else { |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | $this->mOptions = $options; |
25 | 25 | $this->mId = $id; |
26 | 26 | } |
27 | | - |
| 27 | + |
28 | 28 | public static function newFromRow( $row, $db ) { |
29 | 29 | $options = array(); |
30 | 30 | $options['anononly'] = $row->ipb_anon_only; |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | global $wgDBname; |
44 | 44 | $dbw = $this->getDB(); |
45 | 45 | |
46 | | - $ipb_id = $dbw->nextSequenceValue('ipblocks_ipb_id_val'); |
| 46 | + $ipb_id = $dbw->nextSequenceValue( 'ipblocks_ipb_id_val' ); |
47 | 47 | $values = array( |
48 | 48 | 'ipb_id' => $ipb_id, |
49 | 49 | 'ipb_address' => $this->mTarget, |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | |
69 | 69 | return $affected; |
70 | 70 | } |
71 | | - |
| 71 | + |
72 | 72 | public function remove() { |
73 | 73 | $dbw = $this->getDB(); |
74 | 74 | |
— | — | @@ -98,48 +98,48 @@ |
99 | 99 | |
100 | 100 | static function formatLogOptions( $opts ) { |
101 | 101 | $r = array(); |
102 | | - if( $opts['anononly'] ) |
| 102 | + if ( $opts['anononly'] ) |
103 | 103 | $r[] = 'anononly'; |
104 | | - if( $opts['nocreate'] ) |
| 104 | + if ( $opts['nocreate'] ) |
105 | 105 | $r[] = 'nocreate'; |
106 | | - if( !$opts['autoblock'] ) |
| 106 | + if ( !$opts['autoblock'] ) |
107 | 107 | $r[] = 'noautoblock'; |
108 | | - if( $opts['noemail'] ) |
| 108 | + if ( $opts['noemail'] ) |
109 | 109 | $r[] = 'blockemail'; |
110 | 110 | return implode( ',', $r ); |
111 | 111 | } |
112 | | - |
| 112 | + |
113 | 113 | static function parseBlockAddress( $addr ) { |
114 | 114 | $r = array(); |
115 | 115 | $bits = explode( '@', $addr, 2 ); |
116 | | - if( count( $bits ) < 2 ) return array( 'error' => 'nowiki' ); |
| 116 | + if ( count( $bits ) < 2 ) return array( 'error' => 'nowiki' ); |
117 | 117 | list( $target, $wiki ) = $bits; |
118 | | - if( !UserRightsProxy::validDatabase( $wiki ) ) { |
| 118 | + if ( !UserRightsProxy::validDatabase( $wiki ) ) { |
119 | 119 | return array( 'error' => 'invalidwiki', 'wiki' => $wiki ); |
120 | 120 | } |
121 | | - if( preg_match( '/^#[0-9]+$/', $target ) ) { |
| 121 | + if ( preg_match( '/^#[0-9]+$/', $target ) ) { |
122 | 122 | return array( 'blockid' => substr( $target, 1 ), 'wiki' => $wiki ); |
123 | | - } elseif( User::isIP( $target ) ) { |
| 123 | + } elseif ( User::isIP( $target ) ) { |
124 | 124 | return array( 'ip' => $target, 'wiki' => $wiki ); |
125 | | - } elseif( User::isCreatableName( $target ) ) { |
| 125 | + } elseif ( User::isCreatableName( $target ) ) { |
126 | 126 | return array( 'username' => $target, 'wiki' => $wiki ); |
127 | 127 | } else { |
128 | 128 | return array( 'error' => 'invalidusername', 'username' => $target ); |
129 | 129 | } |
130 | 130 | } |
131 | | - |
| 131 | + |
132 | 132 | static function getBlockRow( $target ) { |
133 | 133 | $dbw = UserRightsProxy::getDB( $target['wiki'] ); |
134 | 134 | $conds = array(); |
135 | | - if( isset( $target['blockid'] ) ) { |
| 135 | + if ( isset( $target['blockid'] ) ) { |
136 | 136 | $conds['ipb_id'] = $target['blockid']; |
137 | 137 | } |
138 | | - if( isset( $target['ip'] ) ) { |
| 138 | + if ( isset( $target['ip'] ) ) { |
139 | 139 | $conds['ipb_address'] = $target['ip']; |
140 | 140 | } |
141 | | - if( isset( $target['username'] ) ) { |
| 141 | + if ( isset( $target['username'] ) ) { |
142 | 142 | $conds['ipb_address'] = $target['username']; |
143 | 143 | } |
144 | 144 | return $dbw->selectRow( 'ipblocks', '*', $conds, __METHOD__ ); |
145 | 145 | } |
146 | | -} |
\ No newline at end of file |
| 146 | +} |
Index: trunk/extensions/Crosswiki/Block/CrosswikiBlock.page.php |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | } |
44 | 44 | |
45 | 45 | $action = $wgRequest->getVal( 'action' ); |
46 | | - if( $action == 'submit' ) { |
| 46 | + if ( $action == 'submit' ) { |
47 | 47 | $blockAddress = $wgRequest->getVal( 'wpBlockAddress' ); |
48 | 48 | $expiryStr = $wgRequest->getVal( 'wpBlockExpiry' ); |
49 | 49 | $reason = $wgRequest->getVal( 'wpBlockReason' ); |
— | — | @@ -52,21 +52,21 @@ |
53 | 53 | 'autoblock' => $wgRequest->getCheck( 'wpEnableAutoblock' ), |
54 | 54 | 'noemail' => $wgRequest->getCheck( 'wpEmailBan' ), |
55 | 55 | ); |
56 | | - if( !$blockAddress ) { |
| 56 | + if ( !$blockAddress ) { |
57 | 57 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-nousername' ) ); |
58 | | - } else if( $this->checkUser( $blockAddress, true ) ) { |
59 | | - } else if( !( $expiry = $this->convertExpiry( $expiryStr ) ) ) { |
| 58 | + } else if ( $this->checkUser( $blockAddress, true ) ) { |
| 59 | + } else if ( !( $expiry = $this->convertExpiry( $expiryStr ) ) ) { |
60 | 60 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noexpiry', htmlspecialchars( $expiryStr ) ) ); |
61 | | - } else if( !$reason ) { |
| 61 | + } else if ( !$reason ) { |
62 | 62 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noreason', htmlspecialchars( $reason ) ) ); |
63 | | - } else if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 63 | + } else if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
64 | 64 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-notoken' ) ); |
65 | 65 | } else { |
66 | 66 | CrosswikiBlock::normalizeOptions( $this->mUsername, $options ); |
67 | 67 | $block = new CrosswikiBlock( $this->mDatabase, $this->mUsername, $this->mUserProxy, |
68 | 68 | $wgUser, $expiry, $reason, wfTimestampNow(), 0, $options ); |
69 | 69 | $affected = $block->commit(); |
70 | | - if( $affected ) { |
| 70 | + if ( $affected ) { |
71 | 71 | $wgOut->addHTML( wfMsgWikiHtml( 'crosswikiblock-success', |
72 | 72 | htmlspecialchars( $this->mUsername ), |
73 | 73 | htmlspecialchars( $this->mDatabase ), |
— | — | @@ -88,29 +88,29 @@ |
89 | 89 | public function checkUser( $username, $output = false ) { |
90 | 90 | global $wgOut; |
91 | 91 | $bits = explode( '@', $username, 2 ); |
92 | | - if( count( $bits ) == 1 ) { |
93 | | - if( $output ) |
| 92 | + if ( count( $bits ) == 1 ) { |
| 93 | + if ( $output ) |
94 | 94 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-local' ) ); |
95 | 95 | return array( 'local' ); |
96 | 96 | } |
97 | 97 | |
98 | 98 | list( $name, $db ) = $bits; |
99 | | - if( !UserRightsProxy::validDatabase( $db ) ) { |
100 | | - if( $output ) |
| 99 | + if ( !UserRightsProxy::validDatabase( $db ) ) { |
| 100 | + if ( $output ) |
101 | 101 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-dbnotfound', htmlspecialchars( $db ) ) ); |
102 | 102 | return array( 'dbnotfound', $db ); |
103 | 103 | } |
104 | | - if( !User::isIP( $name ) && !User::isCreatableName( $name ) ) { |
105 | | - if( $output ) |
| 104 | + if ( !User::isIP( $name ) && !User::isCreatableName( $name ) ) { |
| 105 | + if ( $output ) |
106 | 106 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noname', htmlspecialchars( $name ) ) ); |
107 | 107 | return array( 'invalidname', $name ); |
108 | 108 | } |
109 | 109 | |
110 | | - if( !User::isIP( $name ) ) { |
| 110 | + if ( !User::isIP( $name ) ) { |
111 | 111 | $userProxy = UserRightsProxy::newFromName( $db, $name ); |
112 | 112 | $this->mUserProxy = $userProxy; |
113 | | - if( !$userProxy ) { |
114 | | - if( $output ) |
| 113 | + if ( !$userProxy ) { |
| 114 | + if ( $output ) |
115 | 115 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-nouser', |
116 | 116 | htmlspecialchars( $name ), htmlspecialchars( $db ), htmlspecialchars( $username ) ) ); |
117 | 117 | return array( 'usernotfound', $name, $db, $username ); |
— | — | @@ -159,7 +159,7 @@ |
160 | 160 | } |
161 | 161 | |
162 | 162 | $wgOut->addHTML( wfMsgWikiHtml( 'crosswikiblock-header' ) ); |
163 | | - $wgOut->addHTML( "<form id=\"blockip\" method=\"post\" action=\"{$action}\"> |
| 163 | + $wgOut->addHTML( " <form id=\"blockip\" method=\"post\" action=\"{$action}\"> |
164 | 164 | <table border='0'> |
165 | 165 | <tr> |
166 | 166 | <td align=\"$alignRight\">{$mIpaddress}</td> |
— | — | @@ -180,9 +180,15 @@ |
181 | 181 | <tr id=\"wpBlockReason\"> |
182 | 182 | <td align=\"$alignRight\">{$mIpbreason}</td> |
183 | 183 | <td> |
184 | | - " . Xml::input( 'wpBlockReason', 45, htmlspecialchars( strval( $wgRequest->getVal( 'wpBlockReason' ) ) ), |
185 | | - array( 'tabindex' => '5', 'id' => 'mw-bi-reason', |
186 | | - 'maxlength'=> '200' ) ) . " |
| 184 | + " . Xml::input( |
| 185 | + 'wpBlockReason', |
| 186 | + 45, |
| 187 | + htmlspecialchars( strval( $wgRequest->getVal( 'wpBlockReason' ) ) ), |
| 188 | + array( |
| 189 | + 'tabindex' => '5', |
| 190 | + 'id' => 'mw-bi-reason', |
| 191 | + 'maxlength' => '200' |
| 192 | + ) ) . " |
187 | 193 | </td> |
188 | 194 | </tr> |
189 | 195 | <tr id='wpAnonOnlyRow'> |
— | — | @@ -212,19 +218,19 @@ |
213 | 219 | |
214 | 220 | global $wgSysopEmailBans; |
215 | 221 | if ( $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) { |
216 | | - $wgOut->addHTML(" |
| 222 | + $wgOut->addHTML( " |
217 | 223 | <tr id='wpEnableEmailBan'> |
218 | 224 | <td> </td> |
219 | 225 | <td> |
220 | 226 | " . Xml::checkLabel( wfMsgHtml( 'crosswikiblock-noemail' ), |
221 | 227 | 'wpEmailBan', 'wpEmailBan', $wgRequest->getCheck( 'wpEmailBan' ), |
222 | | - array( 'tabindex' => '10' )) . " |
| 228 | + array( 'tabindex' => '10' ) ) . " |
223 | 229 | </td> |
224 | 230 | </tr> |
225 | | - "); |
| 231 | + " ); |
226 | 232 | } |
227 | 233 | |
228 | | - $wgOut->addHTML(" |
| 234 | + $wgOut->addHTML( " |
229 | 235 | <tr> |
230 | 236 | <td style='padding-top: 1em'> </td> |
231 | 237 | <td style='padding-top: 1em'> |
— | — | @@ -236,7 +242,8 @@ |
237 | 243 | $token = $wgUser->editToken(); |
238 | 244 | $wgOut->addHTML( Xml::hidden( 'wpEditToken', $token ) ); |
239 | 245 | |
240 | | - $wgOut->addHTML( '</table></form>' ); |
| 246 | + $wgOut->addHTML( ' </table> |
| 247 | + </form>' ); |
241 | 248 | } |
242 | 249 | } |
243 | 250 | |
— | — | @@ -275,11 +282,11 @@ |
276 | 283 | } |
277 | 284 | |
278 | 285 | $action = $wgRequest->getVal( 'action' ); |
279 | | - if( $action == 'submit' ) { |
| 286 | + if ( $action == 'submit' ) { |
280 | 287 | $target = $wgRequest->getVal( 'wpUnblockTarget' ); |
281 | 288 | $reason = $wgRequest->getVal( 'wpUnblockReason' ); |
282 | 289 | $parsedUsername = CrosswikiBlock::parseBlockAddress( $target ); |
283 | | - if( isset( $parsedUsername['error'] ) ) { |
| 290 | + if ( isset( $parsedUsername['error'] ) ) { |
284 | 291 | switch( $parsedUsername['error'] ) { |
285 | 292 | case 'nowiki': |
286 | 293 | $this->showForm( wfMsgWikiHtml( 'crosswikiunblock-local' ) ); |
— | — | @@ -295,17 +302,17 @@ |
296 | 303 | } |
297 | 304 | } else { |
298 | 305 | $blockRow = CrosswikiBlock::getBlockRow( $parsedUsername ); |
299 | | - if( !$blockRow ) { |
| 306 | + if ( !$blockRow ) { |
300 | 307 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noblock' ) ); |
301 | 308 | return; |
302 | 309 | } |
303 | 310 | $block = CrosswikiBlock::newFromRow( $blockRow, $parsedUsername['wiki'] ); |
304 | 311 | $result = $block->remove(); |
305 | | - if( !$result ) { |
| 312 | + if ( !$result ) { |
306 | 313 | $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noblock' ) ); |
307 | 314 | } else { |
308 | 315 | $block->logUnblock( $reason ); |
309 | | - $wgOut->addHTML( wfMsgWikiHtml( 'crosswikiunblock-success', htmlspecialchars($target), |
| 316 | + $wgOut->addHTML( wfMsgWikiHtml( 'crosswikiunblock-success', htmlspecialchars( $target ), |
310 | 317 | Title::newMainPage()->getFullText() ) ); |
311 | 318 | } |
312 | 319 | } |
— | — | @@ -346,12 +353,15 @@ |
347 | 354 | <td align=\"$alignRight\">{$mIpbreason}</td> |
348 | 355 | <td> |
349 | 356 | " . Xml::input( 'wpUnblockReason', 45, htmlspecialchars( strval( $wgRequest->getVal( 'wpUnblockReason' ) ) ), |
350 | | - array( 'tabindex' => '5', 'id' => 'mw-bi-reason', |
351 | | - 'maxlength'=> '200' ) ) . " |
| 357 | + array( |
| 358 | + 'tabindex' => '5', |
| 359 | + 'id' => 'mw-bi-reason', |
| 360 | + 'maxlength' => '200' |
| 361 | + ) ) . " |
352 | 362 | </td> |
353 | 363 | </tr>" ); |
354 | 364 | |
355 | | - $wgOut->addHTML(" |
| 365 | + $wgOut->addHTML( " |
356 | 366 | <tr> |
357 | 367 | <td style='padding-top: 1em'> </td> |
358 | 368 | <td style='padding-top: 1em'> |
Index: trunk/extensions/Crosswiki/Block/CrosswikiBlock.i18n.php |
— | — | @@ -52,6 +52,9 @@ |
53 | 53 | * [[Special:CrosswikiBlock|Block form]] |
54 | 54 | * [[$4]]", |
55 | 55 | 'crosswikiunblock-local' => 'Local unblocks are not supported via this interface. Use [[Special:IPBlockList|{{int:ipblocklist}}]]', |
| 56 | + |
| 57 | + # Rights |
| 58 | + 'right-crosswikiblock' => 'Block and unblock users on other wikis', |
56 | 59 | ); |
57 | 60 | |
58 | 61 | /** Message documentation (Message documentation) |
— | — | @@ -1483,7 +1486,7 @@ |
1484 | 1487 | $messages['nn'] = array( |
1485 | 1488 | 'crosswikiblock-desc' => 'Gjer det mogleg å blokkera brukarar på andre wikiar ved å nytta ei [[Special:Crosswikiblock|spesialsida]]', |
1486 | 1489 | 'crosswikiblock' => 'Blokker brukar på annan wiki', |
1487 | | - 'crosswikiblock-header' => 'Denne sida gjer at ein kan blokkera brukarar på andre wikiar. |
| 1490 | + 'crosswikiblock-header' => 'Denne sida gjer at ein kan blokkera brukarar på andre wikiar. |
1488 | 1491 | Sjekk at du har løyve til gjera det på denne wikien, og at du følgjer alle retningslinene.', |
1489 | 1492 | 'crosswikiblock-target' => 'IP-adressa eller brukarnamn og målwiki:', |
1490 | 1493 | 'crosswikiblock-expiry' => 'Opphøyrstid:', |
Index: trunk/extensions/Crosswiki/Block/CrosswikiBlock.php |
— | — | @@ -1,19 +1,19 @@ |
2 | 2 | <?php |
3 | 3 | if ( !defined( 'MEDIAWIKI' ) ) { |
4 | | - exit(1); |
| 4 | + exit( 1 ); |
5 | 5 | } |
6 | 6 | |
7 | 7 | $wgExtensionCredits['specialpage'][] = array( |
8 | 8 | 'path' => __FILE__, |
9 | 9 | 'name' => 'Crosswiki Blocking', |
10 | 10 | 'author' => 'VasilievVV', |
11 | | - 'version' => '1.0alpha', |
| 11 | + 'version' => '1.0.1alpha', |
12 | 12 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Crosswiki_Blocking', |
13 | 13 | 'description' => 'Allows to (un)block users on other wikis', |
14 | 14 | 'descriptionmsg' => 'crosswikiblock-desc', |
15 | 15 | ); |
16 | 16 | |
17 | | -$dir = dirname(__FILE__) . '/'; |
| 17 | +$dir = dirname( __FILE__ ) . '/'; |
18 | 18 | $wgExtensionMessagesFiles['CrosswikiBlock'] = $dir . 'CrosswikiBlock.i18n.php'; |
19 | 19 | $wgAutoloadClasses['SpecialCrosswikiBlock'] = $dir . 'CrosswikiBlock.page.php'; |
20 | 20 | $wgAutoloadClasses['SpecialCrosswikiUnblock'] = $dir . 'CrosswikiBlock.page.php'; |