* Fix location of $ip check
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 14 Aug 2008 00:18:21 +0000 (00:18 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 14 Aug 2008 00:18:21 +0000 (00:18 +0000)
* Add User::mailPasswordInternal hook for bug 14630

docs/hooks.txt
includes/specials/SpecialUserlogin.php

index 7c9218a..caec458 100644 (file)
@@ -1262,6 +1262,11 @@ string &$error: output: HTML error to show if upload canceled by returning false
 'UploadComplete': Upon completion of a file upload
 $uploadForm: Upload form object. File can be accessed by $uploadForm->mLocalFile.
 
+'User::mailPasswordInternal': before creation and mailing of a user's new temporary password
+$user: the user who sent the message out
+$ip: IP of the user who sent the message out
+$u: the account whose new password will be set
+
 'UserArrayFromResult': called when creating an UserArray object from a database result
 &$userArray: set this to an object to override the default object returned
 $res: database result used to create the object
index 13df18a..cc9c927 100644 (file)
@@ -640,21 +640,21 @@ class LoginForm {
         */
        function mailPasswordInternal( $u, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) {
                global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure;
-               global $wgServer, $wgScript;
+               global $wgServer, $wgScript, $wgUser;
 
                if ( '' == $u->getEmail() ) {
                        return new WikiError( wfMsg( 'noemail', $u->getName() ) );
                }
-
-               $np = $u->randomPassword();
-               $u->setNewpassword( $np, $throttle );
-               $u->saveSettings();
-
                $ip = wfGetIP();
                if( !$ip ) {
                        return new WikiError( wfMsg( 'badipaddress' ) );
                }
-               #if ( '' == $ip ) { $ip = '(Unknown)'; }
+               
+               wfRunHooks( 'User::mailPasswordInternal', array(&$wgUser, &$ip, &$u) );
+
+               $np = $u->randomPassword();
+               $u->setNewpassword( $np, $throttle );
+               $u->saveSettings();
 
                $m = wfMsg( $emailText, $ip, $u->getName(), $np, $wgServer . $wgScript );
                $result = $u->sendMail( wfMsg( $emailTitle ), $m );