From 1e5da17de557bc9b72355c88302d04b7814f2711 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 29 Jan 2006 07:35:28 +0000 Subject: [PATCH] * Adjust user login/creation form hooks to work with a captcha plugin --- RELEASE-NOTES | 2 ++ docs/hooks.txt | 7 +++++++ includes/SpecialUserlogin.php | 12 +++++++++++- includes/templates/Userlogin.php | 1 + skins/monobook/main.css | 6 ++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7df1839c7e..20a3fbb115 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -582,6 +582,8 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 4469) Namespace-specific notice to be displayed below site-notice Edit messages like "MediaWiki:Namespacenotice-" plus namespace name which is blank for main namespace, or like e.g. "User_talk" +* Adjust user login/creation form hooks to work with a captcha plugin + === Caveats === diff --git a/docs/hooks.txt b/docs/hooks.txt index d05b064f4e..3db2668612 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -239,6 +239,7 @@ you're going to add events to the MediaWiki code. 'AbortNewAccount': Return false to cancel account creation. $user: the User object about to be created (read-only, incomplete) +$message: out parameter: error message to display on abort 'AddNewAccount': after a user account is created null: This hook passes null as an argument @@ -379,9 +380,15 @@ string $saveName: destination file name string $tempName: filesystem path to the temporary file for checks string &$error: output: HTML error to show if upload canceled by returning false +'UserCreateForm': change to manipulate the login form +$template: SimpleTemplate instance for the form + 'UserLoginComplete': after a user has logged in $user: the user object that was created on login +'UserLoginForm': change to manipulate the login form +$template: SimpleTemplate instance for the form + 'UserLogout': before a user logs out $user: the user object that is about to be logged out diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 6a5053684f..fb36df6819 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -238,9 +238,11 @@ class LoginForm { } } - if( !wfRunHooks( 'AbortNewAccount', array( $u ) ) ) { + $abortError = ''; + if( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError ) ) ) { // Hook point to add extra creation throttles and blocks wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" ); + $this->mainLoginForm( $abortError ); return false; } @@ -479,6 +481,7 @@ class LoginForm { $link .= ''; $template->set( 'link', wfMsgHtml( $linkmsg, $link ) ); + $template->set( 'header', '' ); $template->set( 'name', $this->mName ); $template->set( 'password', $this->mPassword ); @@ -495,7 +498,14 @@ class LoginForm { $template->set( 'userealname', $wgAllowRealName ); $template->set( 'useemail', $wgEnableEmail ); $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember ); + + // Give authentication and captcha plugins a chance to modify the form $wgAuth->modifyUITemplate( $template ); + if ( $this->mType == 'signup' ) { + wfRunHooks( 'UserCreateForm', array( &$template ) ); + } else { + wfRunHooks( 'UserLoginForm', array( &$template ) ); + } $wgOut->setPageTitle( wfMsg( 'userlogin' ) ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); diff --git a/includes/templates/Userlogin.php b/includes/templates/Userlogin.php index f8a12c037c..915857dba9 100644 --- a/includes/templates/Userlogin.php +++ b/includes/templates/Userlogin.php @@ -105,6 +105,7 @@ class UsercreateTemplate extends QuickTemplate {

msg('createaccount') ?>

+ html('header'); /* pre-table point for form plugins... */ ?> diff --git a/skins/monobook/main.css b/skins/monobook/main.css index 69183bad3a..238352d593 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -1085,6 +1085,12 @@ div#userlogin form#userlogin2 h2 { padding-top: 0; } +div#userlogin .captcha { + border: 1px solid #bbb; + padding: 1.5em 2em; + width: 400px; + background-color: white; +} #userloginprompt { -- 2.20.1