http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96606

Revision: 96606
Author:   laner
Date:     2011-09-08 19:54:32 +0000 (Thu, 08 Sep 2011)
Log Message:
-----------
Adding support for domains in SpecialPasswordReset.php.

Modified Paths:
--------------
    trunk/phase3/includes/AuthPlugin.php
    trunk/phase3/includes/specials/SpecialPasswordReset.php
    trunk/phase3/languages/messages/MessagesEn.php

Modified: trunk/phase3/includes/AuthPlugin.php
===================================================================
--- trunk/phase3/includes/AuthPlugin.php        2011-09-08 19:48:18 UTC (rev 
96605)
+++ trunk/phase3/includes/AuthPlugin.php        2011-09-08 19:54:32 UTC (rev 
96606)
@@ -262,6 +262,15 @@
        public function getUserInstance( User &$user ) {
                return new AuthPluginUser( $user );
        }
+
+       /**
+        * Get a list of domains (in HTMLForm options format) used.
+        *
+        * @return array
+        */
+       public function domainList() {
+               return array();
+       }
 }
 
 class AuthPluginUser {

Modified: trunk/phase3/includes/specials/SpecialPasswordReset.php
===================================================================
--- trunk/phase3/includes/specials/SpecialPasswordReset.php     2011-09-08 
19:48:18 UTC (rev 96605)
+++ trunk/phase3/includes/specials/SpecialPasswordReset.php     2011-09-08 
19:54:32 UTC (rev 96606)
@@ -44,7 +44,7 @@
        }
 
        protected function getFormFields() {
-               global $wgPasswordResetRoutes;
+               global $wgPasswordResetRoutes, $wgAuth;
                $a = array();
                if ( isset( $wgPasswordResetRoutes['username'] ) && 
$wgPasswordResetRoutes['username'] ) {
                        $a['Username'] = array(
@@ -60,6 +60,15 @@
                        );
                }
 
+               if ( isset( $wgPasswordResetRoutes['domain'] ) && 
$wgPasswordResetRoutes['domain'] ) {
+                       $domains = $wgAuth->domainList();
+                       $a['Domain'] = array(
+                               'type' => 'select',
+                               'options' => $domains,
+                               'label-message' => 'passwordreset-domain',
+                       );
+               }
+
                return $a;
        }
 
@@ -76,6 +85,9 @@
                if ( isset( $wgPasswordResetRoutes['email'] ) && 
$wgPasswordResetRoutes['email'] ) {
                        $i++;
                }
+               if ( isset( $wgPasswordResetRoutes['domain'] ) && 
$wgPasswordResetRoutes['domain'] ) {
+                       $i++;
+               }
                return wfMessage( 'passwordreset-pretext', $i )->parseAsBlock();
        }
 
@@ -87,7 +99,16 @@
         * @return Bool|Array
         */
        public function onSubmit( array $data ) {
+               global $wgAuth;
 
+               if ( isset( $data['Domain'] ) ) {
+                       if ( $wgAuth->validDomain( $data['Domain'] ) ) {
+                               $wgAuth->setDomain( $data['Domain'] );
+                       } else {
+                               $wgAuth->setDomain( 'invaliddomain' );
+                       }
+               }
+
                if ( isset( $data['Username'] ) && $data['Username'] !== '' ) {
                        $method = 'username';
                        $users = array( User::newFromName( $data['Username'] ) 
);

Modified: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php      2011-09-08 19:48:18 UTC 
(rev 96605)
+++ trunk/phase3/languages/messages/MessagesEn.php      2011-09-08 19:54:32 UTC 
(rev 96606)
@@ -1180,6 +1180,7 @@
 'passwordreset-disabled'       => 'Password resets have been disabled on this 
wiki.',
 'passwordreset-pretext'        => '{{PLURAL:$1||Enter one of the pieces of 
data below}}',
 'passwordreset-username'       => 'Username:',
+'passwordreset-domain'         => 'Domain:',
 'passwordreset-email'          => 'E-mail address:',
 'passwordreset-emailtitle'     => 'Account details on {{SITENAME}}',
 'passwordreset-emailtext-ip'   => 'Someone (probably you, from IP address $1) 
requested a reminder of your


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to