mediawiki-extensions-Confir.../ConfirmEditHooks.php
Brion Vibber 19dcbb6fa2 Update ConfirmEdit to return Status object on AbortNewAccount hook
Requires core update I6ae34c0 to actually send the message key back
in the error response. On older MediaWiki versions, behavior should
remain unchanged.

Bug: 60008
Change-Id: If9cc08e44d1d2efacf817b8c6cbb2d71a4e8b692
2014-01-17 13:38:51 -08:00

97 lines
2.6 KiB
PHP

<?php
class ConfirmEditHooks {
/**
* Get the global Captcha instance
*
* @return Captcha|SimpleCaptcha
*/
static function getInstance() {
global $wgCaptcha, $wgCaptchaClass;
static $done = false;
if ( !$done ) {
$done = true;
$wgCaptcha = new $wgCaptchaClass;
}
return $wgCaptcha;
}
static function confirmEditMerged( $editPage, $newtext ) {
return self::getInstance()->confirmEditMerged( $editPage, $newtext );
}
static function confirmEditAPI( $editPage, $newtext, &$resultArr ) {
return self::getInstance()->confirmEditAPI( $editPage, $newtext, $resultArr );
}
static function addNewAccountApiForm( $apiModule, $loginForm ) {
return self::getInstance()->addNewAccountApiForm( $apiModule, $loginForm );
}
static function addNewAccountApiResult( $apiModule, $loginPage, &$result ) {
return self::getInstance()->addNewAccountApiResult( $apiModule, $loginPage, $result );
}
static function injectUserCreate( &$template ) {
return self::getInstance()->injectUserCreate( $template );
}
static function confirmUserCreate( $u, &$message, &$status = null ) {
return self::getInstance()->confirmUserCreate( $u, $message, $status );
}
static function triggerUserLogin( $user, $password, $retval ) {
return self::getInstance()->triggerUserLogin( $user, $password, $retval );
}
static function injectUserLogin( &$template ) {
return self::getInstance()->injectUserLogin( $template );
}
static function confirmUserLogin( $u, $pass, &$retval ) {
return self::getInstance()->confirmUserLogin( $u, $pass, $retval );
}
static function injectEmailUser( &$form ) {
return self::getInstance()->injectEmailUser( $form );
}
static function confirmEmailUser( $from, $to, $subject, $text, &$error ) {
return self::getInstance()->confirmEmailUser( $from, $to, $subject, $text, $error );
}
// Default $flags to 1 for backwards-compatible behavior
public static function APIGetAllowedParams( &$module, &$params, $flags = 1 ) {
return self::getInstance()->APIGetAllowedParams( $module, $params, $flags );
}
public static function APIGetParamDescription( &$module, &$desc ) {
return self::getInstance()->APIGetParamDescription( $module, $desc );
}
}
class CaptchaSpecialPage extends UnlistedSpecialPage {
public function __construct() {
parent::__construct( 'Captcha' );
}
function execute( $par ) {
$this->setHeaders();
$instance = ConfirmEditHooks::getInstance();
switch( $par ) {
case "image":
if ( method_exists( $instance, 'showImage' ) ) {
return $instance->showImage();
}
case "help":
default:
return $instance->showHelp();
}
}
}