r50864 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50863‎ | r50864 | r50865 >
Date:18:37, 21 May 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* add right- message
* remove trailing whitespace, update indentation, stylize.php
* bump version
Modified paths:
  • /trunk/extensions/Crosswiki/Block/CrosswikiBlock.class.php (modified) (history)
  • /trunk/extensions/Crosswiki/Block/CrosswikiBlock.i18n.php (modified) (history)
  • /trunk/extensions/Crosswiki/Block/CrosswikiBlock.page.php (modified) (history)
  • /trunk/extensions/Crosswiki/Block/CrosswikiBlock.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Crosswiki/Block/CrosswikiBlock.class.php
@@ -2,7 +2,7 @@
33
44 class CrosswikiBlock {
55 public static function normalizeOptions( $user, &$options ) {
6 - if( User::isIP( $user ) ) {
 6+ if ( User::isIP( $user ) ) {
77 $options['autoblock'] = false;
88 $options['noemail'] = false;
99 } else {
@@ -23,7 +23,7 @@
2424 $this->mOptions = $options;
2525 $this->mId = $id;
2626 }
27 -
 27+
2828 public static function newFromRow( $row, $db ) {
2929 $options = array();
3030 $options['anononly'] = $row->ipb_anon_only;
@@ -42,7 +42,7 @@
4343 global $wgDBname;
4444 $dbw = $this->getDB();
4545
46 - $ipb_id = $dbw->nextSequenceValue('ipblocks_ipb_id_val');
 46+ $ipb_id = $dbw->nextSequenceValue( 'ipblocks_ipb_id_val' );
4747 $values = array(
4848 'ipb_id' => $ipb_id,
4949 'ipb_address' => $this->mTarget,
@@ -67,7 +67,7 @@
6868
6969 return $affected;
7070 }
71 -
 71+
7272 public function remove() {
7373 $dbw = $this->getDB();
7474
@@ -98,48 +98,48 @@
9999
100100 static function formatLogOptions( $opts ) {
101101 $r = array();
102 - if( $opts['anononly'] )
 102+ if ( $opts['anononly'] )
103103 $r[] = 'anononly';
104 - if( $opts['nocreate'] )
 104+ if ( $opts['nocreate'] )
105105 $r[] = 'nocreate';
106 - if( !$opts['autoblock'] )
 106+ if ( !$opts['autoblock'] )
107107 $r[] = 'noautoblock';
108 - if( $opts['noemail'] )
 108+ if ( $opts['noemail'] )
109109 $r[] = 'blockemail';
110110 return implode( ',', $r );
111111 }
112 -
 112+
113113 static function parseBlockAddress( $addr ) {
114114 $r = array();
115115 $bits = explode( '@', $addr, 2 );
116 - if( count( $bits ) < 2 ) return array( 'error' => 'nowiki' );
 116+ if ( count( $bits ) < 2 ) return array( 'error' => 'nowiki' );
117117 list( $target, $wiki ) = $bits;
118 - if( !UserRightsProxy::validDatabase( $wiki ) ) {
 118+ if ( !UserRightsProxy::validDatabase( $wiki ) ) {
119119 return array( 'error' => 'invalidwiki', 'wiki' => $wiki );
120120 }
121 - if( preg_match( '/^#[0-9]+$/', $target ) ) {
 121+ if ( preg_match( '/^#[0-9]+$/', $target ) ) {
122122 return array( 'blockid' => substr( $target, 1 ), 'wiki' => $wiki );
123 - } elseif( User::isIP( $target ) ) {
 123+ } elseif ( User::isIP( $target ) ) {
124124 return array( 'ip' => $target, 'wiki' => $wiki );
125 - } elseif( User::isCreatableName( $target ) ) {
 125+ } elseif ( User::isCreatableName( $target ) ) {
126126 return array( 'username' => $target, 'wiki' => $wiki );
127127 } else {
128128 return array( 'error' => 'invalidusername', 'username' => $target );
129129 }
130130 }
131 -
 131+
132132 static function getBlockRow( $target ) {
133133 $dbw = UserRightsProxy::getDB( $target['wiki'] );
134134 $conds = array();
135 - if( isset( $target['blockid'] ) ) {
 135+ if ( isset( $target['blockid'] ) ) {
136136 $conds['ipb_id'] = $target['blockid'];
137137 }
138 - if( isset( $target['ip'] ) ) {
 138+ if ( isset( $target['ip'] ) ) {
139139 $conds['ipb_address'] = $target['ip'];
140140 }
141 - if( isset( $target['username'] ) ) {
 141+ if ( isset( $target['username'] ) ) {
142142 $conds['ipb_address'] = $target['username'];
143143 }
144144 return $dbw->selectRow( 'ipblocks', '*', $conds, __METHOD__ );
145145 }
146 -}
\ No newline at end of file
 146+}
Index: trunk/extensions/Crosswiki/Block/CrosswikiBlock.page.php
@@ -42,7 +42,7 @@
4343 }
4444
4545 $action = $wgRequest->getVal( 'action' );
46 - if( $action == 'submit' ) {
 46+ if ( $action == 'submit' ) {
4747 $blockAddress = $wgRequest->getVal( 'wpBlockAddress' );
4848 $expiryStr = $wgRequest->getVal( 'wpBlockExpiry' );
4949 $reason = $wgRequest->getVal( 'wpBlockReason' );
@@ -52,21 +52,21 @@
5353 'autoblock' => $wgRequest->getCheck( 'wpEnableAutoblock' ),
5454 'noemail' => $wgRequest->getCheck( 'wpEmailBan' ),
5555 );
56 - if( !$blockAddress ) {
 56+ if ( !$blockAddress ) {
5757 $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 ) ) ) {
6060 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noexpiry', htmlspecialchars( $expiryStr ) ) );
61 - } else if( !$reason ) {
 61+ } else if ( !$reason ) {
6262 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noreason', htmlspecialchars( $reason ) ) );
63 - } else if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
 63+ } else if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
6464 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-notoken' ) );
6565 } else {
6666 CrosswikiBlock::normalizeOptions( $this->mUsername, $options );
6767 $block = new CrosswikiBlock( $this->mDatabase, $this->mUsername, $this->mUserProxy,
6868 $wgUser, $expiry, $reason, wfTimestampNow(), 0, $options );
6969 $affected = $block->commit();
70 - if( $affected ) {
 70+ if ( $affected ) {
7171 $wgOut->addHTML( wfMsgWikiHtml( 'crosswikiblock-success',
7272 htmlspecialchars( $this->mUsername ),
7373 htmlspecialchars( $this->mDatabase ),
@@ -88,29 +88,29 @@
8989 public function checkUser( $username, $output = false ) {
9090 global $wgOut;
9191 $bits = explode( '@', $username, 2 );
92 - if( count( $bits ) == 1 ) {
93 - if( $output )
 92+ if ( count( $bits ) == 1 ) {
 93+ if ( $output )
9494 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-local' ) );
9595 return array( 'local' );
9696 }
9797
9898 list( $name, $db ) = $bits;
99 - if( !UserRightsProxy::validDatabase( $db ) ) {
100 - if( $output )
 99+ if ( !UserRightsProxy::validDatabase( $db ) ) {
 100+ if ( $output )
101101 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-dbnotfound', htmlspecialchars( $db ) ) );
102102 return array( 'dbnotfound', $db );
103103 }
104 - if( !User::isIP( $name ) && !User::isCreatableName( $name ) ) {
105 - if( $output )
 104+ if ( !User::isIP( $name ) && !User::isCreatableName( $name ) ) {
 105+ if ( $output )
106106 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noname', htmlspecialchars( $name ) ) );
107107 return array( 'invalidname', $name );
108108 }
109109
110 - if( !User::isIP( $name ) ) {
 110+ if ( !User::isIP( $name ) ) {
111111 $userProxy = UserRightsProxy::newFromName( $db, $name );
112112 $this->mUserProxy = $userProxy;
113 - if( !$userProxy ) {
114 - if( $output )
 113+ if ( !$userProxy ) {
 114+ if ( $output )
115115 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-nouser',
116116 htmlspecialchars( $name ), htmlspecialchars( $db ), htmlspecialchars( $username ) ) );
117117 return array( 'usernotfound', $name, $db, $username );
@@ -159,7 +159,7 @@
160160 }
161161
162162 $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}\">
164164 <table border='0'>
165165 <tr>
166166 <td align=\"$alignRight\">{$mIpaddress}</td>
@@ -180,9 +180,15 @@
181181 <tr id=\"wpBlockReason\">
182182 <td align=\"$alignRight\">{$mIpbreason}</td>
183183 <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+ ) ) . "
187193 </td>
188194 </tr>
189195 <tr id='wpAnonOnlyRow'>
@@ -212,19 +218,19 @@
213219
214220 global $wgSysopEmailBans;
215221 if ( $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) {
216 - $wgOut->addHTML("
 222+ $wgOut->addHTML( "
217223 <tr id='wpEnableEmailBan'>
218224 <td>&nbsp;</td>
219225 <td>
220226 " . Xml::checkLabel( wfMsgHtml( 'crosswikiblock-noemail' ),
221227 'wpEmailBan', 'wpEmailBan', $wgRequest->getCheck( 'wpEmailBan' ),
222 - array( 'tabindex' => '10' )) . "
 228+ array( 'tabindex' => '10' ) ) . "
223229 </td>
224230 </tr>
225 - ");
 231+ " );
226232 }
227233
228 - $wgOut->addHTML("
 234+ $wgOut->addHTML( "
229235 <tr>
230236 <td style='padding-top: 1em'>&nbsp;</td>
231237 <td style='padding-top: 1em'>
@@ -236,7 +242,8 @@
237243 $token = $wgUser->editToken();
238244 $wgOut->addHTML( Xml::hidden( 'wpEditToken', $token ) );
239245
240 - $wgOut->addHTML( '</table></form>' );
 246+ $wgOut->addHTML( ' </table>
 247+ </form>' );
241248 }
242249 }
243250
@@ -275,11 +282,11 @@
276283 }
277284
278285 $action = $wgRequest->getVal( 'action' );
279 - if( $action == 'submit' ) {
 286+ if ( $action == 'submit' ) {
280287 $target = $wgRequest->getVal( 'wpUnblockTarget' );
281288 $reason = $wgRequest->getVal( 'wpUnblockReason' );
282289 $parsedUsername = CrosswikiBlock::parseBlockAddress( $target );
283 - if( isset( $parsedUsername['error'] ) ) {
 290+ if ( isset( $parsedUsername['error'] ) ) {
284291 switch( $parsedUsername['error'] ) {
285292 case 'nowiki':
286293 $this->showForm( wfMsgWikiHtml( 'crosswikiunblock-local' ) );
@@ -295,17 +302,17 @@
296303 }
297304 } else {
298305 $blockRow = CrosswikiBlock::getBlockRow( $parsedUsername );
299 - if( !$blockRow ) {
 306+ if ( !$blockRow ) {
300307 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noblock' ) );
301308 return;
302309 }
303310 $block = CrosswikiBlock::newFromRow( $blockRow, $parsedUsername['wiki'] );
304311 $result = $block->remove();
305 - if( !$result ) {
 312+ if ( !$result ) {
306313 $this->showForm( wfMsgWikiHtml( 'crosswikiblock-noblock' ) );
307314 } else {
308315 $block->logUnblock( $reason );
309 - $wgOut->addHTML( wfMsgWikiHtml( 'crosswikiunblock-success', htmlspecialchars($target),
 316+ $wgOut->addHTML( wfMsgWikiHtml( 'crosswikiunblock-success', htmlspecialchars( $target ),
310317 Title::newMainPage()->getFullText() ) );
311318 }
312319 }
@@ -346,12 +353,15 @@
347354 <td align=\"$alignRight\">{$mIpbreason}</td>
348355 <td>
349356 " . 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+ ) ) . "
352362 </td>
353363 </tr>" );
354364
355 - $wgOut->addHTML("
 365+ $wgOut->addHTML( "
356366 <tr>
357367 <td style='padding-top: 1em'>&nbsp;</td>
358368 <td style='padding-top: 1em'>
Index: trunk/extensions/Crosswiki/Block/CrosswikiBlock.i18n.php
@@ -52,6 +52,9 @@
5353 * [[Special:CrosswikiBlock|Block form]]
5454 * [[$4]]",
5555 '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',
5659 );
5760
5861 /** Message documentation (Message documentation)
@@ -1483,7 +1486,7 @@
14841487 $messages['nn'] = array(
14851488 'crosswikiblock-desc' => 'Gjer det mogleg å blokkera brukarar på andre wikiar ved å nytta ei [[Special:Crosswikiblock|spesialsida]]',
14861489 '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.
14881491 Sjekk at du har løyve til gjera det på denne wikien, og at du følgjer alle retningslinene.',
14891492 'crosswikiblock-target' => 'IP-adressa eller brukarnamn og målwiki:',
14901493 'crosswikiblock-expiry' => 'Opphøyrstid:',
Index: trunk/extensions/Crosswiki/Block/CrosswikiBlock.php
@@ -1,19 +1,19 @@
22 <?php
33 if ( !defined( 'MEDIAWIKI' ) ) {
4 - exit(1);
 4+ exit( 1 );
55 }
66
77 $wgExtensionCredits['specialpage'][] = array(
88 'path' => __FILE__,
99 'name' => 'Crosswiki Blocking',
1010 'author' => 'VasilievVV',
11 - 'version' => '1.0alpha',
 11+ 'version' => '1.0.1alpha',
1212 'url' => 'http://www.mediawiki.org/wiki/Extension:Crosswiki_Blocking',
1313 'description' => 'Allows to (un)block users on other wikis',
1414 'descriptionmsg' => 'crosswikiblock-desc',
1515 );
1616
17 -$dir = dirname(__FILE__) . '/';
 17+$dir = dirname( __FILE__ ) . '/';
1818 $wgExtensionMessagesFiles['CrosswikiBlock'] = $dir . 'CrosswikiBlock.i18n.php';
1919 $wgAutoloadClasses['SpecialCrosswikiBlock'] = $dir . 'CrosswikiBlock.page.php';
2020 $wgAutoloadClasses['SpecialCrosswikiUnblock'] = $dir . 'CrosswikiBlock.page.php';

Status & tagging log