This is a list of known events and parameters; please add to it if
you're going to add events to the MediaWiki code.
+'BlockIp': before an IP address or user is blocked
+$block: the Block object about to be saved
+$user: the user _doing_ the block (not the one being blocked)
+
+'BlockIpComplete': after an IP address or user is blocked
+$block: the Block object that was saved
+$user: the user who did the block (not the one being blocked)
+
'UserLoginComplete': after a user has logged in
$user: the user object that was created on login
'UserLogoutComplete': after a user has logged out
$user: the user object _after_ logout (won't have name, ID, etc.)
-
syslog(LOG_INFO, "User '" . $user->getName() . "' logged out.");
return true;
}
+
+ function syslogBlockIp(&$block, &$user) {
+ syslog(LOG_INFO, "User '" . $user->getName() .
+ "' blocked '" . (($block->mUser) ? $block->mUser : $block->mAddress) .
+ "' for '" . $block->mReason . "' until '" . $block->mExpiry . "'");
+ return true;
+ }
# Setup -- called once environment is configured
$wgHooks['UserLoginComplete'][] = syslogUserLogin;
$wgHooks['UserLogout'][] = syslogUserLogout;
+ $wgHooks['BlockIpComplete'][] = syslogBlockIp;
return true;
}
return;
}
- $expiry = wfUnix2Timestamp( $expiry );
+ $expiry = wfTimestamp( TS_MW, $expiry );
}
$ban = new Block( $this->BlockAddress, $userId, $wgUser->getID(),
wfStrencode( $this->BlockReason ), wfTimestampNow(), 0, $expiry );
- $ban->insert();
-
- # Make log entry
- $log = new LogPage( 'block' );
- $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), $this->BlockReason );
+
+ if (wfRunHooks('BlockIp', $ban, $wgUser)) {
+
+ $ban->insert();
+
+ wfRunHooks('BlockIpComplete', $ban, $wgUser);
+
+ # Make log entry
+ $log = new LogPage( 'block' );
+ $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), $this->BlockReason );
- # Report to the user
- $titleObj = Title::makeTitle( NS_SPECIAL, 'Blockip' );
- $wgOut->redirect( $titleObj->getFullURL( 'action=success&ip='.$this->BlockAddress ) );
+ # Report to the user
+ $titleObj = Title::makeTitle( NS_SPECIAL, 'Blockip' );
+ $wgOut->redirect( $titleObj->getFullURL( 'action=success&ip='.$this->BlockAddress ) );
+ }
}
function showSuccess() {