Adding support for domains in SpecialPasswordReset.php.
authorRyan Lane <laner@users.mediawiki.org>
Thu, 8 Sep 2011 19:54:32 +0000 (19:54 +0000)
committerRyan Lane <laner@users.mediawiki.org>
Thu, 8 Sep 2011 19:54:32 +0000 (19:54 +0000)
includes/AuthPlugin.php
includes/specials/SpecialPasswordReset.php
languages/messages/MessagesEn.php

index fd0624a..2fdba79 100644 (file)
@@ -262,6 +262,15 @@ class AuthPlugin {
        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 {
index 5cdb1c0..b7aabc0 100644 (file)
@@ -44,7 +44,7 @@ class SpecialPasswordReset extends FormSpecialPage {
        }
 
        protected function getFormFields() {
-               global $wgPasswordResetRoutes;
+               global $wgPasswordResetRoutes, $wgAuth;
                $a = array();
                if ( isset( $wgPasswordResetRoutes['username'] ) && $wgPasswordResetRoutes['username'] ) {
                        $a['Username'] = array(
@@ -60,6 +60,15 @@ class SpecialPasswordReset extends FormSpecialPage {
                        );
                }
 
+               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 @@ class SpecialPasswordReset extends FormSpecialPage {
                if ( isset( $wgPasswordResetRoutes['email'] ) && $wgPasswordResetRoutes['email'] ) {
                        $i++;
                }
+               if ( isset( $wgPasswordResetRoutes['domain'] ) && $wgPasswordResetRoutes['domain'] ) {
+                       $i++;
+               }
                return wfMessage( 'passwordreset-pretext', $i )->parseAsBlock();
        }
 
@@ -87,6 +99,15 @@ class SpecialPasswordReset extends FormSpecialPage {
         * @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';
index 4912d39..3460e4b 100644 (file)
@@ -1180,6 +1180,7 @@ You may have already successfully changed your password or requested a new tempo
 '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