extensions, and documented in hooks.doc.
This is a list of known events and parameters; please add to it if
you're going to add events to the MediaWiki code.
+'ArticleProtect': before an article is protected
+$article: the article being protected
+$user: the user doing the protection
+$protect: boolean whether this is a protect or an unprotect
+$reason: Reason for protect
+$moveonly: boolean whether this is for move only or not
+
+'ArticleProtectComplete': after an article is protected
+$article: the article that was protected
+$user: the user who did the protection
+$protect: boolean whether it was a protect or an unprotect
+$reason: Reason for protect
+$moveonly: boolean whether it was for move only or not
+
'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)
}
function syslogBlockIp(&$block, &$user) {
- syslog(LOG_INFO, "User '" . $user->getName() .
+ syslog(LOG_NOTICE, "User '" . $user->getName() .
"' blocked '" . (($block->mUser) ? $block->mUser : $block->mAddress) .
"' for '" . $block->mReason . "' until '" . $block->mExpiry . "'");
return true;
}
+
+ function syslogArticleProtect(&$article, &$user, $protect, &$reason, &$moveonly) {
+ $title = $article->mTitle;
+ syslog(LOG_NOTICE, "User '" . $user->getName() . "' " .
+ (($protect) ? "protected" : "unprotected") . " article '" .
+ $title->getPrefixedText() .
+ "' for '" . $reason . "' " . (($moveonly) ? "(moves only)" : "") );
+ return true;
+ }
# Setup -- called once environment is configured
$wgHooks['UserLoginComplete'][] = syslogUserLogin;
$wgHooks['UserLogout'][] = syslogUserLogout;
$wgHooks['BlockIpComplete'][] = syslogBlockIp;
+ $wgHooks['ArticleProtectComplete'][] = syslogArticleProtect;
return true;
}
$reason = $wgRequest->getText( 'wpReasonProtect' );
if ( $confirm ) {
+
$restrictions = "move=" . $limit;
if( !$moveonly ) {
$restrictions .= ":edit=" . $limit;
}
-
- $dbw =& wfGetDB( DB_MASTER );
- $dbw->update( 'cur',
- array( /* SET */
- 'cur_touched' => $dbw->timestamp(),
- 'cur_restrictions' => $restrictions
- ), array( /* WHERE */
- 'cur_id' => $id
- ), 'Article::protect'
- );
-
- $log = new LogPage( 'protect' );
- if ( $limit === '' ) {
+ if (wfRunHooks('ArticleProtect', $this, $wgUser, $limit == 'sysop', $reason, $moveonly)) {
+
+ $dbw =& wfGetDB( DB_MASTER );
+ $dbw->update( 'cur',
+ array( /* SET */
+ 'cur_touched' => $dbw->timestamp(),
+ 'cur_restrictions' => $restrictions
+ ), array( /* WHERE */
+ 'cur_id' => $id
+ ), 'Article::protect'
+ );
+
+ wfRunHooks('ArticleProtectComplete', $this, $wgUser, $limit == 'sysop', $reason, $moveonly);
+
+ $log = new LogPage( 'protect' );
+ if ( $limit === '' ) {
$log->addEntry( 'unprotect', $this->mTitle, $reason );
- } else {
+ } else {
$log->addEntry( 'protect', $this->mTitle, $reason );
+ }
+ $wgOut->redirect( $this->mTitle->getFullURL() );
}
- $wgOut->redirect( $this->mTitle->getFullURL() );
return;
} else {
$reason = htmlspecialchars( wfMsg( 'protectreason' ) );