* Adjust user login/creation form hooks to work with a captcha plugin
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 29 Jan 2006 07:35:28 +0000 (07:35 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 29 Jan 2006 07:35:28 +0000 (07:35 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/SpecialUserlogin.php
includes/templates/Userlogin.php
skins/monobook/main.css

index 7df1839..20a3fbb 100644 (file)
@@ -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 ===
 
index d05b064..3db2668 100644 (file)
@@ -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
        
index 6a50536..fb36df6 100644 (file)
@@ -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 .= '</a>';
 
                $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' );
index f8a12c0..915857d 100644 (file)
@@ -105,6 +105,7 @@ class UsercreateTemplate extends QuickTemplate {
 <form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
        <h2><?php $this->msg('createaccount') ?></h2>
        <p id="userloginlink"><?php $this->html('link') ?></p>
+       <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
        <table>
                <tr>
                        <td align='right'><label for='wpName2'><?php $this->msg('yourname') ?>:</label></td>
index 69183ba..238352d 100644 (file)
@@ -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 {