Index: trunk/extensions/CentralAuth/central-auth.sql |
— | — | @@ -134,3 +134,24 @@ |
135 | 135 | KEY (ggp_group), |
136 | 136 | KEY (ggp_permission) |
137 | 137 | ) /*$wgDBTableOptions*/; |
| 138 | + |
| 139 | +-- Blocks of global users |
| 140 | +CREATE TABLE /*$wgDBprefix*/globalblock ( |
| 141 | + gb_id int NOT NULL auto_increment, |
| 142 | + gb_user int unsigned NOT NULL default '0', |
| 143 | + gb_user_text tinyblob NOT NULL, |
| 144 | + gb_by_text varchar(255) binary NOT NULL default '', |
| 145 | + gb_reason tinyblob NOT NULL, |
| 146 | + gb_timestamp binary(14) NOT NULL default '', |
| 147 | + -- May be "infinity" |
| 148 | + gb_expiry varbinary(14) NOT NULL default '', |
| 149 | + gb_block_email bool NOT NULL default 0, |
| 150 | + |
| 151 | + PRIMARY KEY gb_id (gb_id), |
| 152 | + UNIQUE INDEX gb_user_text (gb_user_text(255), gb_user), |
| 153 | + |
| 154 | + INDEX gb_user (gb_user), |
| 155 | + INDEX gb_timestamp (gb_timestamp), |
| 156 | + INDEX gb_expiry (gb_expiry) |
| 157 | + |
| 158 | +) /*$wgDBTableOptions*/; |
Index: trunk/extensions/CentralAuth/db_patches/patch-globalblocks.sql |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +CREATE TABLE /*$wgDBprefix*/globalblock ( |
| 3 | + gb_id int NOT NULL auto_increment, |
| 4 | + gb_user int unsigned NOT NULL default '0', |
| 5 | + gb_user_text tinyblob NOT NULL, |
| 6 | + gb_by_text varchar(255) binary NOT NULL default '', |
| 7 | + gb_reason tinyblob NOT NULL, |
| 8 | + gb_timestamp binary(14) NOT NULL default '', |
| 9 | + -- May be "infinity" |
| 10 | + gb_expiry varbinary(14) NOT NULL default '', |
| 11 | + gb_block_email bool NOT NULL default 0, |
| 12 | + |
| 13 | + PRIMARY KEY gb_id (gb_id), |
| 14 | + UNIQUE INDEX gb_user_text (gb_user_text(255), gb_user), |
| 15 | + |
| 16 | + INDEX gb_user (gb_user), |
| 17 | + INDEX gb_timestamp (gb_timestamp), |
| 18 | + INDEX gb_expiry (gb_expiry) |
| 19 | + |
| 20 | +) /*$wgDBTableOptions*/; |
\ No newline at end of file |
Property changes on: trunk/extensions/CentralAuth/db_patches/patch-globalblocks.sql |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 21 | + native |
Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | /*private*/ var $mStateDirty = false; |
22 | 22 | /*private*/ var $mVersion = 1; |
23 | 23 | /*private*/ var $mDelayInvalidation = 0; |
| 24 | + /*private*/ var $mBlock = false; |
24 | 25 | |
25 | 26 | static $mCacheVars = array( |
26 | 27 | 'mGlobalId', |
— | — | @@ -33,6 +34,7 @@ |
34 | 35 | 'mAuthenticationTimestamp', |
35 | 36 | 'mGroups', |
36 | 37 | 'mRights', |
| 38 | + 'mBlock', |
37 | 39 | |
38 | 40 | # Store the string list instead of the array, to save memory, and |
39 | 41 | # avoid unserialize() overhead |
— | — | @@ -140,6 +142,7 @@ |
141 | 143 | $dbr->freeResult( $result ); |
142 | 144 | |
143 | 145 | $this->loadFromRow( $row, true ); |
| 146 | + $this->mBlock = CentralAuthBlock::newFromUser( $this ); |
144 | 147 | $this->saveToCache(); |
145 | 148 | wfProfileOut( __METHOD__ ); |
146 | 149 | } |
— | — | @@ -1829,4 +1832,14 @@ |
1830 | 1833 | public function attachedOn( $wiki ) { |
1831 | 1834 | return $this->exists() && in_array( $wiki, $this->mAttachedArray ); |
1832 | 1835 | } |
| 1836 | + |
| 1837 | + public function isBlocked() { |
| 1838 | + $this->loadState(); |
| 1839 | + return (bool)$this->mBlock; |
| 1840 | + } |
| 1841 | + |
| 1842 | + public function getBlock() { |
| 1843 | + $this->loadState(); |
| 1844 | + return $this->mBlock; |
| 1845 | + } |
1833 | 1846 | } |
Index: trunk/extensions/CentralAuth/CentralAuth.php |
— | — | @@ -121,6 +121,7 @@ |
122 | 122 | $wgAutoloadClasses['CentralAuthUser'] = "$caBase/CentralAuthUser.php"; |
123 | 123 | $wgAutoloadClasses['CentralAuthPlugin'] = "$caBase/CentralAuthPlugin.php"; |
124 | 124 | $wgAutoloadClasses['CentralAuthHooks'] = "$caBase/CentralAuthHooks.php"; |
| 125 | +$wgAutoloadClasses['CentralAuthBlock'] = "$caBase/CentralAuthBlock.php"; |
125 | 126 | $wgAutoloadClasses['WikiMap'] = "$caBase/WikiMap.php"; |
126 | 127 | $wgAutoloadClasses['WikiReference'] = "$caBase/WikiMap.php"; |
127 | 128 | $wgAutoloadClasses['SpecialAutoLogin'] = "$caBase/SpecialAutoLogin.php"; |
— | — | @@ -171,17 +172,31 @@ |
172 | 173 | $wgSpecialPages['GlobalUsers'] = 'SpecialGlobalUsers'; |
173 | 174 | $wgSpecialPageGroups['GlobalUsers'] = 'users'; |
174 | 175 | |
175 | | -$wgLogTypes[] = 'globalauth'; |
176 | | -$wgLogNames['globalauth'] = 'centralauth-log-name'; |
177 | | -$wgLogHeaders['globalauth'] = 'centralauth-log-header'; |
178 | | -$wgLogActions['globalauth/delete'] = 'centralauth-log-entry-delete'; |
179 | | -$wgLogActions['globalauth/lock'] = 'centralauth-log-entry-lock'; |
180 | | -$wgLogActions['globalauth/unlock'] = 'centralauth-log-entry-unlock'; |
181 | | -$wgLogActions['globalauth/hide'] = 'centralauth-log-entry-hide'; |
182 | | -$wgLogActions['globalauth/unhide'] = 'centralauth-log-entry-unhide'; |
| 176 | +$wgLogTypes[] = 'globalauth'; |
| 177 | +$wgLogNames['globalauth'] = 'centralauth-log-name'; |
| 178 | +$wgLogHeaders['globalauth'] = 'centralauth-log-header'; |
| 179 | +$wgLogActions['globalauth/delete'] = 'centralauth-log-entry-delete'; |
| 180 | +$wgLogActions['globalauth/lock'] = 'centralauth-log-entry-lock'; |
| 181 | +$wgLogActions['globalauth/unlock'] = 'centralauth-log-entry-unlock'; |
| 182 | +$wgLogActions['globalauth/hide'] = 'centralauth-log-entry-hide'; |
| 183 | +$wgLogActions['globalauth/unhide'] = 'centralauth-log-entry-unhide'; |
| 184 | +$wgLogActions['globalauth/unblock'] = 'centralauth-log-entry-unblock'; |
| 185 | +$wgLogActionsHandlers['globalauth/block'] = 'efCentralAuthBlockLogHandler'; |
183 | 186 | |
184 | 187 | $wgLogTypes[] = 'gblrights'; |
185 | 188 | $wgLogNames['gblrights'] = 'centralauth-rightslog-name'; |
186 | 189 | $wgLogHeaders['gblrights'] = 'centralauth-rightslog-header'; |
187 | 190 | $wgLogActions['gblrights/usergroups'] = 'centralauth-rightslog-entry-usergroups'; |
188 | 191 | $wgLogActions['gblrights/groupperms'] = 'centralauth-rightslog-entry-groupperms'; |
| 192 | + |
| 193 | +function efCentralAuthBlockLogHandler( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false ) { |
| 194 | + global $wgLang, $wgContLang; |
| 195 | + $expiry = @$params[0]; //Giving some weird notices while $params[0] is set |
| 196 | + $msgParams = array( $title, '' ); |
| 197 | + if ( $skin ) { |
| 198 | + $msgParams[1] = '<span title="' . htmlspecialchars( $expiry ). '">' . $wgLang->translateBlockExpiry( $expiry ) . '</span>'; |
| 199 | + } else { |
| 200 | + $msgParams[1] = $wgContLang->translateBlockExpiry( $expiry ); |
| 201 | + } |
| 202 | + return wfMsgReal( 'centralauth-log-entry-block', $msgParams, true, !$skin ); |
| 203 | +} |
Index: trunk/extensions/CentralAuth/SpecialCentralAuth.php |
— | — | @@ -66,7 +66,8 @@ |
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | | - $deleted = $locked = $unlocked = $hidden = $unhidden = false; |
| 70 | + $deleted = $locked = $unlocked = $hidden = |
| 71 | + $unhidden = $blocked = $unblocked = false; |
71 | 72 | |
72 | 73 | if( $this->mPosted ) { |
73 | 74 | if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
— | — | @@ -86,7 +87,6 @@ |
87 | 88 | if ( !$status->isGood() ) { |
88 | 89 | $this->showStatusError( $status->getWikiText() ); |
89 | 90 | } else { |
90 | | - global $wgLang; |
91 | 91 | $this->showSuccess( 'centralauth-admin-delete-success', $this->mUserName ); |
92 | 92 | $deleted = true; |
93 | 93 | $this->logAction( 'delete', $this->mUserName, $wgRequest->getVal( 'reason' ) ); |
— | — | @@ -96,7 +96,6 @@ |
97 | 97 | if ( !$status->isGood() ) { |
98 | 98 | $this->showStatusError( $status->getWikiText() ); |
99 | 99 | } else { |
100 | | - global $wgLang; |
101 | 100 | $this->showSuccess( 'centralauth-admin-lock-success', $this->mUserName ); |
102 | 101 | $locked = true; |
103 | 102 | $this->logAction( 'lock', $this->mUserName, $wgRequest->getVal( 'reason' ) ); |
— | — | @@ -106,7 +105,6 @@ |
107 | 106 | if ( !$status->isGood() ) { |
108 | 107 | $this->showStatusError( $status->getWikiText() ); |
109 | 108 | } else { |
110 | | - global $wgLang; |
111 | 109 | $this->showSuccess( 'centralauth-admin-unlock-success', $this->mUserName ); |
112 | 110 | $unlocked = true; |
113 | 111 | $this->logAction( 'unlock', $this->mUserName, $wgRequest->getVal( 'reason' ) ); |
— | — | @@ -116,7 +114,6 @@ |
117 | 115 | if ( !$status->isGood() ) { |
118 | 116 | $this->showStatusError( $status->getWikiText() ); |
119 | 117 | } else { |
120 | | - global $wgLang; |
121 | 118 | $this->showSuccess( 'centralauth-admin-hide-success', $this->mUserName ); |
122 | 119 | $hidden = true; |
123 | 120 | $this->logAction( 'hide', $this->mUserName, $wgRequest->getVal( 'reason' ) ); |
— | — | @@ -126,11 +123,43 @@ |
127 | 124 | if ( !$status->isGood() ) { |
128 | 125 | $this->showStatusError( $status->getWikiText() ); |
129 | 126 | } else { |
130 | | - global $wgLang; |
131 | 127 | $this->showSuccess( 'centralauth-admin-unhide-success', $this->mUserName ); |
132 | 128 | $unhidden = true; |
133 | 129 | $this->logAction( 'unhide', $this->mUserName, $wgRequest->getVal( 'reason' ) ); |
134 | 130 | } |
| 131 | + } elseif( $this->mMethod == 'block' ) { |
| 132 | + $block = new CentralAuthBlock(); |
| 133 | + $block->setUser( $globalUser ); |
| 134 | + $block->setBy( $wgUser->getName() . '@' . wfWikiID() ); |
| 135 | + $block->setReason( $wgRequest->getVal( 'reason' ) ); |
| 136 | + $expiry = Block::parseExpiryInput( $wgRequest->getVal( 'expiry' ) ); |
| 137 | + if( $expiry === false ) { |
| 138 | + $this->showError( 'centralauth-admin-block-badexpiry' ); |
| 139 | + } else { |
| 140 | + $block->setExpiry( $expiry ); |
| 141 | + $result = $block->insert(); |
| 142 | + if( $result ) { |
| 143 | + $this->showSuccess( 'centralauth-admin-block-success', $this->mUserName ); |
| 144 | + $blocked = true; |
| 145 | + $globalUser->invalidateCache(); |
| 146 | + $globalUser->mBlock = $block; |
| 147 | + $this->logAction( 'block', $this->mUserName, $wgRequest->getVal( 'reason' ), |
| 148 | + array( $wgRequest->getVal( 'expiry' ) ) ); |
| 149 | + } else { |
| 150 | + $this->showError( 'centralauth-admin-block-already', $this->mUserName ); |
| 151 | + } |
| 152 | + } |
| 153 | + } elseif( $this->mMethod == 'unblock' ) { |
| 154 | + $block = $globalUser->getBlock(); |
| 155 | + if( !$block || $block->deleteIfExpired() ) { |
| 156 | + $this->showError( 'centralauth-admin-unblock-notblocked', $this->mUserName ); |
| 157 | + } |
| 158 | + $block->delete(); |
| 159 | + $unblocked = true; |
| 160 | + $globalUser->invalidateCache(); |
| 161 | + $globalUser->mBlock = null; |
| 162 | + $this->showSuccess( 'centralauth-admin-unblock-success', $this->mUserName ); |
| 163 | + $this->logAction( 'unblock', $this->mUserName, $wgRequest->getVal( 'reason' ) ); |
135 | 164 | } else { |
136 | 165 | $this->showError( 'centralauth-admin-bad-input' ); |
137 | 166 | } |
— | — | @@ -141,6 +170,10 @@ |
142 | 171 | if ( !$deleted ) { |
143 | 172 | $this->showInfo(); |
144 | 173 | $this->showActionForm( 'delete' ); |
| 174 | + if( !$globalUser->isBlocked() && !$blocked ) |
| 175 | + $this->showBlockForm(); |
| 176 | + if( $globalUser->isBlocked() && !$unblocked ) |
| 177 | + $this->showActionForm( 'unblock' ); |
145 | 178 | if( !$globalUser->isLocked() && !$locked ) |
146 | 179 | $this->showActionForm( 'lock' ); |
147 | 180 | if( $globalUser->isLocked() && !$unlocked ) |
— | — | @@ -336,27 +369,57 @@ |
337 | 370 | } |
338 | 371 | |
339 | 372 | function showActionForm( $action ) { |
340 | | - global $wgOut, $wgUser; |
| 373 | + global $wgOut, $wgUser, $wgContLang; |
| 374 | + $td1 = "<td align=\"" . ( $wgContLang->isRTL() ? 'left' : 'right' ) . "\">"; |
| 375 | + $td2 = "<td align=\"" . ( $wgContLang->isRTL() ? 'right' : 'left' ) . "\">"; |
341 | 376 | $wgOut->addHtml( |
342 | 377 | Xml::element( 'h2', array(), wfMsg( "centralauth-admin-{$action}-title" ) ) . |
343 | 378 | Xml::openElement( 'form', array( |
344 | 379 | 'method' => 'POST', |
345 | 380 | 'action' => $this->getTitle()->getFullUrl( 'target=' . urlencode( $this->mUserName ) ) ) ) . |
346 | 381 | Xml::hidden( 'wpMethod', $action ) . |
| 382 | + wfMsgExt( "centralauth-admin-{$action}-description", 'parse' ) . |
| 383 | + '<table>' . |
| 384 | + '<tr>' . |
| 385 | + $td1 . Xml::label( wfMsgHtml( 'centralauth-admin-reason' ), "{$action}-reason" ) . '</td>' . |
| 386 | + $td2 . Xml::input( 'reason', false, false, array( 'id' => "{$action}-reason" ) ) . '</td>' . |
| 387 | + '</tr>' . |
| 388 | + '<tr>' . $td1 . '</td>' . |
| 389 | + $td2 . Xml::submitButton( wfMsg( "centralauth-admin-{$action}-button" ) ) . '</td>' . |
347 | 390 | Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
348 | | - wfMsgExt( "centralauth-admin-{$action}-description", 'parse' ) . |
349 | | - '<p>' . |
350 | | - Xml::label( wfMsgHtml( 'centralauth-admin-reason' ), "{$action}-reason" ) . ' ' . |
351 | | - Xml::input( 'reason', false, false, array( 'id' => "{$action}-reason" ) ) . |
352 | | - '</p>' . |
353 | | - '<p>' . |
354 | | - Xml::submitButton( wfMsg( "centralauth-admin-{$action}-button" ) ) . |
355 | | - '</p>' . |
356 | | - '</form>' ); |
| 391 | + '</tr>' . |
| 392 | + '</table></form>' ); |
357 | 393 | } |
358 | 394 | |
359 | | - function logAction( $action, $target, $reason = '' ) { |
| 395 | + function showBlockForm() { |
| 396 | + global $wgOut, $wgUser, $wgContLang; |
| 397 | + $td1 = "<td align=\"" . ( $wgContLang->isRTL() ? 'left' : 'right' ) . "\">"; |
| 398 | + $td2 = "<td align=\"" . ( $wgContLang->isRTL() ? 'right' : 'left' ) . "\">"; |
| 399 | + $wgOut->addHtml( |
| 400 | + Xml::element( 'h2', array(), wfMsg( "centralauth-admin-block-title" ) ) . |
| 401 | + Xml::openElement( 'form', array( |
| 402 | + 'method' => 'POST', |
| 403 | + 'action' => $this->getTitle()->getFullUrl( 'target=' . urlencode( $this->mUserName ) ) ) ) . |
| 404 | + Xml::hidden( 'wpMethod', 'block' ) . |
| 405 | + wfMsgExt( "centralauth-admin-block-description", 'parse' ) . |
| 406 | + '<table>' . |
| 407 | + '<tr>' . |
| 408 | + $td1 . Xml::label( wfMsgHtml( 'centralauth-admin-reason' ), "block-reason" ) . '</td>' . |
| 409 | + $td2 . Xml::input( 'reason', false, false, array( 'id' => "block-reason" ) ) . '</td>' . |
| 410 | + '</tr>' . |
| 411 | + '<tr>' . |
| 412 | + $td1 . Xml::label( wfMsgHtml( 'centralauth-admin-expiry' ), "block-expiry" ) . '</td>' . |
| 413 | + $td2 . Xml::input( 'expiry', false, false, array( 'id' => "block-expiry" ) ) . '</td>' . |
| 414 | + '</tr>' . |
| 415 | + '<tr>' . $td1 . '</td>' . |
| 416 | + $td2 . Xml::submitButton( wfMsg( "centralauth-admin-block-button" ) ) . '</td>' . |
| 417 | + Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
| 418 | + '</tr>' . |
| 419 | + '</table></form>' ); |
| 420 | + } |
| 421 | + |
| 422 | + function logAction( $action, $target, $reason = '', $params = array() ) { |
360 | 423 | $log = new LogPage( 'globalauth' ); //Not centralauth because of some weird length limitiations |
361 | | - $log->addEntry( $action, Title::newFromText( "User:{$target}@global" ), $reason ); |
| 424 | + $log->addEntry( $action, Title::newFromText( "User:{$target}@global" ), $reason, $params ); |
362 | 425 | } |
363 | 426 | } |
Index: trunk/extensions/CentralAuth/CentralAuthHooks.php |
— | — | @@ -473,6 +473,7 @@ |
474 | 474 | } |
475 | 475 | |
476 | 476 | static function onGetUserPermissionsErrorsExpensive( $title, $user, $action, &$result ) { |
| 477 | + global $wgLang; |
477 | 478 | if( $action == 'read' || $user->isAnon() ) { |
478 | 479 | return true; |
479 | 480 | } |
— | — | @@ -484,6 +485,24 @@ |
485 | 486 | $result = 'centralauth-error-locked'; |
486 | 487 | return false; |
487 | 488 | } |
| 489 | + if( $centralUser->isBlocked() ) { |
| 490 | + $block = $centralUser->getBlock(); |
| 491 | + if( $block->deleteIfExpired() ) { |
| 492 | + return true; |
| 493 | + } |
| 494 | + wfLoadExtensionMessages( 'SpecialCentralAuth' ); |
| 495 | + $result = array( |
| 496 | + 'centralauth-blocked', |
| 497 | + $block->getBy(), |
| 498 | + $block->getReason(), |
| 499 | + $block->getUser()->getName(), |
| 500 | + $block->getId(), |
| 501 | + $wgLang->timeanddate( wfTimestamp( TS_MW, $block->getExpiry() ), true ), |
| 502 | + $wgLang->timeanddate( wfTimestamp( TS_MW, $block->getTimestamp() ), true ), |
| 503 | + $block->getByStripped(), |
| 504 | + ); |
| 505 | + return false; |
| 506 | + } |
488 | 507 | return true; |
489 | 508 | } |
490 | 509 | } |
Index: trunk/extensions/CentralAuth/CentralAuthBlock.php |
— | — | @@ -0,0 +1,145 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class CentralAuthBlock { |
| 5 | + private $mId, $mUser, $mUserText, $mUserObj, |
| 6 | + $mByText, $mReason, $mTimestamp, |
| 7 | + $mExpiry, $mBlockEmail; // @fixme we need to implement email blocks |
| 8 | + |
| 9 | + public function __construct() { |
| 10 | + $this->mId = |
| 11 | + $this->mUser = |
| 12 | + $this->mBlockEmail = |
| 13 | + 0; |
| 14 | + $this->mUserText = |
| 15 | + $this->mByText = |
| 16 | + $this->mReason = |
| 17 | + $this->mExpire = |
| 18 | + ''; |
| 19 | + $this->mUserObj = |
| 20 | + null; |
| 21 | + } |
| 22 | + |
| 23 | + /** Constructors */ |
| 24 | + public static function newFromRow( $row ) { |
| 25 | + if( !$row ) |
| 26 | + return null; |
| 27 | + |
| 28 | + $block = new CentralAuthBlock(); |
| 29 | + $block->mId = $row->gb_id; |
| 30 | + $block->mUser = $row->gb_user; |
| 31 | + $block->mUserText = $row->gb_user_text; |
| 32 | + $block->mByText = $row->gb_by_text; |
| 33 | + $block->mReason = $row->gb_reason; |
| 34 | + $block->mTimestamp = $row->gb_timestamp; |
| 35 | + $block->mExpiry = Block::decodeExpiry( $row->gb_expiry ); |
| 36 | + $block->mBlockEmail = (bool)$row->gb_block_email; |
| 37 | + return $block; |
| 38 | + } |
| 39 | + |
| 40 | + public static function newFromUser( CentralAuthUser $u ) { |
| 41 | + $dbr = CentralAuthUser::getCentralSlaveDB(); |
| 42 | + $r = $dbr->select( 'globalblock', '*', array( 'gb_user' => $u->getId() ), __METHOD__ ); |
| 43 | + $row = $dbr->fetchObject( $r ); |
| 44 | + $dbr->freeResult( $r ); |
| 45 | + return self::newFromRow( $row ); |
| 46 | + } |
| 47 | + |
| 48 | + /** Getters/setters block */ |
| 49 | + public function getId() { return $this->mId; } |
| 50 | + public function getUserText() { return $this->mUserText; } |
| 51 | + public function getUserId() { return $this->mUser; } |
| 52 | + public function getBy() { return $this->mByText; } |
| 53 | + public function setBy($s) { $this->mByText = $s; } |
| 54 | + public function getReason() { return $this->mReason; } |
| 55 | + public function setReason($r) { $this->mReason = $r; } |
| 56 | + public function getTimestamp() { return $this->mTimestamp; } |
| 57 | + public function getExpiry() { return $this->mExpiry; } |
| 58 | + public function getBlockEmail() { return $this->mBlockEmail; } |
| 59 | + public function setBlockEmail($b) { $this->mBlockEmail = $b; } |
| 60 | + public function setUser( CentralAuthUser $u ) { |
| 61 | + $this->mUserObj = $u; |
| 62 | + $this->mUser = $u->getId(); |
| 63 | + $this->mUserText = $u->getName(); |
| 64 | + } |
| 65 | + public function setExpiry( $expiry ) { |
| 66 | + $this->mExpiry = $expiry; |
| 67 | + } |
| 68 | + public function getUser() { |
| 69 | + return $this->mUserObj ? $this->mUserObj : new CentralAuthUser( $this->mUserText ); |
| 70 | + } |
| 71 | + public function getByStripped() { |
| 72 | + $bits = explode( '@', $this->mByText, 2 ); |
| 73 | + return $bits[0]; |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Deletes block if it exists |
| 78 | + * @return false on failure, true on success |
| 79 | + */ |
| 80 | + public function delete() { |
| 81 | + if( wfReadOnly() ) |
| 82 | + return false; |
| 83 | + |
| 84 | + $dbw = CentralAuthUser::getCentralDB(); |
| 85 | + $dbw->delete( 'globalblock', array( 'gb_id' => $this->mId ), __METHOD__ ); |
| 86 | + $dbw->commit(); |
| 87 | + return $dbw->affectedRows() > 0; |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Inserts a new block into the globalblock table. |
| 92 | + * @return false on failure, true on success |
| 93 | + */ |
| 94 | + public function insert() { |
| 95 | + if( wfReadOnly() ) |
| 96 | + return false; |
| 97 | + |
| 98 | + self::purgeExpired(); |
| 99 | + $dbw = CentralAuthUser::getCentralDB(); |
| 100 | + $dbw->insert( 'globalblock', |
| 101 | + array( |
| 102 | + 'gb_id' => 0, |
| 103 | + 'gb_user' => $this->mUser, |
| 104 | + 'gb_user_text' => $this->mUserText, |
| 105 | + 'gb_by_text' => $this->mByText, |
| 106 | + 'gb_reason' => $this->mReason, |
| 107 | + 'gb_timestamp' => $dbw->timestamp(), |
| 108 | + 'gb_expiry' => Block::encodeExpiry( $this->mExpiry, $dbw ), |
| 109 | + 'gb_block_email' => 0, //is not implemented yet |
| 110 | + ), __METHOD__, array( 'IGNORE' ) |
| 111 | + ); |
| 112 | + return $dbw->affectedRows() > 0; |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Checks if block is expired. |
| 117 | + * @return boolean |
| 118 | + */ |
| 119 | + public function isExpired() { |
| 120 | + if( !$this->mExpiry ) { |
| 121 | + return false; |
| 122 | + } |
| 123 | + return wfTimestampNow() > $this->mExpiry; |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Deletes block if it's expired |
| 128 | + * @return boolean |
| 129 | + */ |
| 130 | + public function deleteIfExpired() { |
| 131 | + if( $this->isExpired() ) { |
| 132 | + $this->delete(); |
| 133 | + return true; |
| 134 | + } else { |
| 135 | + return false; |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Deletes all expired blocks. |
| 141 | + */ |
| 142 | + public static function purgeExpired() { |
| 143 | + $dbw = CentralAuthUser::getCentralDB(); |
| 144 | + $dbw->delete( 'globalblock', array( 'gb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ ); |
| 145 | + } |
| 146 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/CentralAuth/CentralAuthBlock.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 147 | + native |
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php |
— | — | @@ -70,7 +70,17 @@ |
71 | 71 | |
72 | 72 | 'centralauth-disabled-dryrun' => "Account unification is currently in a demo / debugging mode, so actual merging operations are disabled. Sorry!", |
73 | 73 | 'centralauth-error-locked' => 'You cannot edit because your account is locked.', |
| 74 | + 'centralauth-blocked' => "<big>'''Your account has been blocked globally.'''</big> |
74 | 75 | |
| 76 | +The block was made by $1. The reason given is ''$2''. |
| 77 | + |
| 78 | +* Start of block: $6 |
| 79 | +* Expiry of block: $5 |
| 80 | +* Intended blockee: $3 |
| 81 | + |
| 82 | +You can contact $7 or another steward to discuss the block. |
| 83 | +You cannot use the 'e-mail this user' feature unless a valid e-mail address is specified in your [[Special:Preferences|account preferences]] and you have not been blocked from using it.", |
| 84 | + |
75 | 85 | // Appended to various messages above |
76 | 86 | 'centralauth-readmore-text' => ":''[[meta:Help:Unified login|Read more about '''unified login''']]…''", |
77 | 87 | |
— | — | @@ -146,32 +156,45 @@ |
147 | 157 | 'centralauth-admin-delete-description' => 'Deleting the global account will delete any global preferences, unattach all local accounts, and leave the global name free for another user to take. |
148 | 158 | All local accounts will continue to exist. |
149 | 159 | The passwords for local accounts created before the merge will revert to their pre-merge values.', |
150 | | - 'centralauth-admin-delete-button' => 'Delete this account', |
151 | | - 'centralauth-admin-delete-success' => 'Successfully deleted the global account for "<nowiki>$1</nowiki>"', |
152 | | - 'centralauth-admin-nonexistent' => 'There is no global account for "<nowiki>$1</nowiki>"', |
153 | | - 'centralauth-admin-delete-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
154 | | - 'centralauth-token-mismatch' => 'Sorry, we could not process your form submission due to a loss of session data.', |
155 | | - 'centralauth-admin-lock-title' => 'Lock account', |
156 | | - 'centralauth-admin-lock-description' => 'Locking account will make impossible to log under it in any wiki.', |
157 | | - 'centralauth-admin-lock-button' => 'Lock this account', |
158 | | - 'centralauth-admin-lock-success' => 'Successfully locked the global account for "<nowiki>$1</nowiki>"', |
159 | | - 'centralauth-admin-lock-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
160 | | - 'centralauth-admin-unlock-title' => 'Unlock account', |
161 | | - 'centralauth-admin-unlock-description' => 'Unlocking account will make it possible again to log under it.', |
162 | | - 'centralauth-admin-unlock-button' => 'Unlock this account', |
163 | | - 'centralauth-admin-unlock-success' => 'Successfully unlocked the global account for "<nowiki>$1</nowiki>"', |
164 | | - 'centralauth-admin-unlock-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
165 | | - 'centralauth-admin-hide-title' => 'Hide account', |
166 | | - 'centralauth-admin-hide-description' => 'Hidden accounts are not shown on [[Special:GlobalUsers|Global users]].', |
167 | | - 'centralauth-admin-hide-button' => 'Hide this account', |
168 | | - 'centralauth-admin-hide-success' => 'Successfully hid the global account for "<nowiki>$1</nowiki>"', |
169 | | - 'centralauth-admin-hide-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
170 | | - 'centralauth-admin-unhide-title' => 'Unhide account', |
171 | | - 'centralauth-admin-unhide-description' => 'Unhiding account will make it again appear on [[Special:GlobalUsers|Global users]].', |
172 | | - 'centralauth-admin-unhide-button' => 'Unhide this account', |
173 | | - 'centralauth-admin-unhide-success' => 'Successfully unhid the global account for "<nowiki>$1</nowiki>"', |
174 | | - 'centralauth-admin-unhide-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
175 | | - 'centralauth-admin-reason' => 'Reason:', |
| 160 | + 'centralauth-admin-delete-button' => 'Delete this account', |
| 161 | + 'centralauth-admin-delete-success' => 'Successfully deleted the global account for "<nowiki>$1</nowiki>"', |
| 162 | + 'centralauth-admin-nonexistent' => 'There is no global account for "<nowiki>$1</nowiki>"', |
| 163 | + 'centralauth-admin-delete-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
| 164 | + 'centralauth-token-mismatch' => 'Sorry, we could not process your form submission due to a loss of session data.', |
| 165 | + 'centralauth-admin-lock-title' => 'Lock account', |
| 166 | + 'centralauth-admin-lock-description' => 'Locking account will make impossible to log under it in any wiki.', |
| 167 | + 'centralauth-admin-lock-button' => 'Lock this account', |
| 168 | + 'centralauth-admin-lock-success' => 'Successfully locked the global account for "<nowiki>$1</nowiki>"', |
| 169 | + 'centralauth-admin-lock-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
| 170 | + 'centralauth-admin-unlock-title' => 'Unlock account', |
| 171 | + 'centralauth-admin-unlock-description' => 'Unlocking account will make it possible again to log under it.', |
| 172 | + 'centralauth-admin-unlock-button' => 'Unlock this account', |
| 173 | + 'centralauth-admin-unlock-success' => 'Successfully unlocked the global account for "<nowiki>$1</nowiki>"', |
| 174 | + 'centralauth-admin-unlock-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
| 175 | + 'centralauth-admin-hide-title' => 'Hide account', |
| 176 | + 'centralauth-admin-hide-description' => 'Hidden accounts are not shown on [[Special:GlobalUsers|Global users]].', |
| 177 | + 'centralauth-admin-hide-button' => 'Hide this account', |
| 178 | + 'centralauth-admin-hide-success' => 'Successfully hid the global account for "<nowiki>$1</nowiki>"', |
| 179 | + 'centralauth-admin-hide-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
| 180 | + 'centralauth-admin-unhide-title' => 'Unhide account', |
| 181 | + 'centralauth-admin-unhide-description' => 'Unhiding account will make it again appear on [[Special:GlobalUsers|Global users]].', |
| 182 | + 'centralauth-admin-unhide-button' => 'Unhide this account', |
| 183 | + 'centralauth-admin-unhide-success' => 'Successfully unhid the global account for "<nowiki>$1</nowiki>"', |
| 184 | + 'centralauth-admin-unhide-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.', |
| 185 | + 'centralauth-admin-block-title' => 'Block account', |
| 186 | + 'centralauth-admin-block-description' => 'This forms allows you to block SUL account. Blocked SUL accounts will be still able to log in, |
| 187 | +but they will not be able to edit.', |
| 188 | + 'centralauth-admin-block-button' => 'Block this account', |
| 189 | + 'centralauth-admin-block-success' => 'Successfully blocked the global account for "<nowiki>$1</nowiki>"', |
| 190 | + 'centralauth-admin-block-already' => 'Error: the global account "<nowiki>$1</nowiki>" is already blocked.', |
| 191 | + 'centralauth-admin-block-badexpiry' => 'Error: bad expiry.', |
| 192 | + 'centralauth-admin-unblock-title' => 'Unblock account', |
| 193 | + 'centralauth-admin-unblock-description' => 'Unblocking account will make it possible again to edit under it.', |
| 194 | + 'centralauth-admin-unblock-button' => 'Unblock this account', |
| 195 | + 'centralauth-admin-unblock-success' => 'Successfully unblocked the global account for "<nowiki>$1</nowiki>"', |
| 196 | + 'centralauth-admin-unblock-notblocked' => 'Error: the global account "<nowiki>$1</nowiki>" is not blocked.', |
| 197 | + 'centralauth-admin-reason' => 'Reason:', |
| 198 | + 'centralauth-admin-expiry' => 'Expiry:', |
176 | 199 | |
177 | 200 | // List of global users |
178 | 201 | 'globalusers' => 'Global user list', |
— | — | @@ -212,13 +235,15 @@ |
213 | 236 | 'centralauth-logout-progress' => 'Logging you out from Wikimedia\'s other projects:', |
214 | 237 | |
215 | 238 | // Logging |
216 | | - 'centralauth-log-name' => 'Global account log', |
217 | | - 'centralauth-log-header' => 'This log contains operations under global accounts: deletions, locking and unlocking.', |
218 | | - 'centralauth-log-entry-delete' => 'deleted global account "<nowiki>$1</nowiki>"', |
219 | | - 'centralauth-log-entry-lock' => 'locked global account "<nowiki>$1</nowiki>"', |
220 | | - 'centralauth-log-entry-unlock' => 'unlocked global account "<nowiki>$1</nowiki>"', |
221 | | - 'centralauth-log-entry-hide' => 'hid global account "<nowiki>$1</nowiki>"', |
222 | | - 'centralauth-log-entry-unhide' => 'unhid global account "<nowiki>$1</nowiki>"', |
| 239 | + 'centralauth-log-name' => 'Global account log', |
| 240 | + 'centralauth-log-header' => 'This log contains operations under global accounts: deletions, locking and unlocking.', |
| 241 | + 'centralauth-log-entry-delete' => 'deleted global account "<nowiki>$1</nowiki>"', |
| 242 | + 'centralauth-log-entry-lock' => 'locked global account "<nowiki>$1</nowiki>"', |
| 243 | + 'centralauth-log-entry-unlock' => 'unlocked global account "<nowiki>$1</nowiki>"', |
| 244 | + 'centralauth-log-entry-hide' => 'hid global account "<nowiki>$1</nowiki>"', |
| 245 | + 'centralauth-log-entry-unhide' => 'unhid global account "<nowiki>$1</nowiki>"', |
| 246 | + 'centralauth-log-entry-block' => 'blocked global account "<nowiki>$1</nowiki>" with an expiry time of $2', |
| 247 | + 'centralauth-log-entry-unblock' => 'unblocked global account "<nowiki>$1</nowiki>"', |
223 | 248 | |
224 | 249 | 'centralauth-rightslog-name' => 'Global rights log', |
225 | 250 | 'centralauth-rightslog-entry-usergroups' => 'changed global group membership for $1 from $2 to $3', |