* @param $user int User id of user
* @param $killExpired bool Delete expired blocks on load
*/
- static function newFromDB( $address, $user = 0, $killExpired = true ) {
+ public static function newFromDB( $address, $user = 0, $killExpired = true ) {
$block = new Block;
$block->load( $address, $user, $killExpired );
if ( $block->isValid() ) {
* @return Block object
* @param $id int Block id to search for
*/
- static function newFromID( $id ) {
+ public static function newFromID( $id ) {
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->resultObject( $dbr->select( 'ipblocks', '*',
array( 'ipb_id' => $id ), __METHOD__ ) );
return null;
}
}
+
+ /**
+ * Check if two blocks are effectively equal
+ *
+ * @return bool
+ */
+ public function equals( Block $block ) {
+ return (
+ $this->mAddress == $block->mAddress
+ && $this->mUser == $block->mUser
+ && $this->mAuto == $block->mAuto
+ && $this->mAnonOnly == $block->mAnonOnly
+ && $this->mCreateAccount == $block->mCreateAccount
+ && $this->mExpiry == $block->mExpiry
+ && $this->mEnableAutoblock == $block->mEnableAutoblock
+ && $this->mHideName == $block->mHideName
+ && $this->mBlockEmail == $block->mBlockEmail
+ && $this->mAllowUsertalk == $block->mAllowUsertalk
+ );
+ }
/**
* Clear all member variables in the current object. Does not clear
* the block from the DB.
*/
- function clear() {
+ public function clear() {
$this->mAddress = $this->mReason = $this->mTimestamp = '';
$this->mId = $this->mAnonOnly = $this->mCreateAccount =
$this->mEnableAutoblock = $this->mAuto = $this->mUser =
* @return bool The user is blocked from editing
*
*/
- function load( $address = '', $user = 0, $killExpired = true ) {
+ public function load( $address = '', $user = 0, $killExpired = true ) {
wfDebug( "Block::load: '$address', '$user', $killExpired\n" );
$options = array();
* @return string
*/
static function formatExpiry( $encoded_expiry ) {
-
static $msg = null;
if( is_null( $msg ) ) {
</tr>"
);
}
- if ( $alreadyBlocked ) {
- $wgOut->addHTML("
- <tr id='wpChangeBlockRow'>
- <td> </td>
- <td class='mw-input'>" .
- Xml::checkLabel( wfMsg( 'ipb-change-block' ),
- 'wpChangeBlock', 'wpChangeBlock', $this->BlockReblock,
- array( 'tabindex' => '13' ) ) . "
- </td>
- </tr>"
- );
- }
$wgOut->addHTML("
<tr>
<td style='padding-top: 1em'> </td>
<td class='mw-submit' style='padding-top: 1em'>" .
- Xml::submitButton( wfMsg( 'ipbsubmit' ),
+ Xml::submitButton( wfMsg( $alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit' ),
array( 'name' => 'wpBlock', 'tabindex' => '13', 'accesskey' => 's' ) ) . "
</td>
</tr>" .
Xml::closeElement( 'table' ) .
Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
+ ( $alreadyBlocked ? Xml::hidden( 'wpChangeBlock', 1 ) : "" ) .
Xml::closeElement( 'fieldset' ) .
Xml::closeElement( 'form' ) .
Xml::tags( 'script', array( 'type' => 'text/javascript' ), 'updateBlockOptions()' ) . "\n"
if ( !$this->BlockReblock ) {
return array( 'ipb_already_blocked' );
} else {
- # This returns direct blocks before autoblocks/rangeblocks, since we should be sure the user is blocked by now it should work for our purposes
+ # This returns direct blocks before autoblocks/rangeblocks, since we should
+ # be sure the user is blocked by now it should work for our purposes
$currentBlock = Block::newFromDB( $this->BlockAddress, $userId );
+ if( $block->equals( $currentBlock ) ) {
+ return array( 'ipb_already_blocked' );
+ }
$currentBlock->delete();
$block->insert();
$log_action = 'reblock';