Example #1
0
 /**
  * Returns the gender for given username.
  * @param $username String: username
  * @param $caller String: the calling method
  * @return String
  */
 public function getGenderOf($username, $caller = '')
 {
     global $wgUser;
     $username = strtr($username, '_', ' ');
     if (!isset($this->cache[$username])) {
         if ($this->misses >= $this->missLimit && $wgUser->getName() !== $username) {
             if ($this->misses === $this->missLimit) {
                 $this->misses++;
                 wfDebug(__METHOD__ . ": too many misses, returning default onwards\n");
             }
             return $this->getDefault();
         } else {
             $this->misses++;
             if (!User::isValidUserName($username)) {
                 $this->cache[$username] = $this->getDefault();
             } else {
                 $this->doQuery($username, $caller);
             }
         }
     }
     /* Undefined if there is a valid username which for some reason doesn't
      * exist in the database.
      */
     return isset($this->cache[$username]) ? $this->cache[$username] : $this->getDefault();
 }
 public static function getInstance($n = null)
 {
     global $wgUser;
     if (is_null($n)) {
         return new SSPUser($wgUser->getName());
     } elseif ($wgUser->getName() == $n && User::isValidUserName($n)) {
         return new SSPUser($n);
     } else {
         return null;
     }
 }
Example #3
0
 function execute()
 {
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('user', array('user_id', 'user_name'), null, __METHOD__);
     foreach ($res as $row) {
         if (!User::isValidUserName($row->user_name)) {
             $this->error(sprintf("%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name));
             wfDebugLog('checkUsernames', $out);
         }
     }
 }
Example #4
0
 function main()
 {
     $fname = 'checkUsernames::main';
     $dbr =& wfGetDB(DB_SLAVE);
     $res = $dbr->select('user', array('user_id', 'user_name'), null, $fname);
     while ($row = $dbr->fetchObject($res)) {
         if (!User::isValidUserName($row->user_name)) {
             $out = sprintf("%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name);
             fwrite($this->stderr, $out);
             fwrite($this->log, $out);
         }
     }
 }
 function execute()
 {
     $dbr = wfGetDB(DB_SLAVE);
     $maxUserId = 0;
     do {
         $res = $dbr->select('user', array('user_id', 'user_name'), array('user_id > ' . $maxUserId), __METHOD__, array('ORDER BY' => 'user_id', 'LIMIT' => $this->mBatchSize));
         foreach ($res as $row) {
             if (!User::isValidUserName($row->user_name)) {
                 $this->output(sprintf("Found: %6d: '%s'\n", $row->user_id, $row->user_name));
                 wfDebugLog('checkUsernames', $row->user_name);
             }
         }
         $maxUserId = $row->user_id;
     } while ($res->numRows());
 }
function AutoAuthenticateBLTI($user, &$result)
{
    global $_pwdSecret;
    if (isset($_REQUEST['BLTI'])) {
        //$lg = Language::factory($wgLanguageCode);
        if ($_REQUEST['BLTI'] == 'yes') {
            global $wgContLang;
            // Let's get the username from BLTI and give it MW's usual first capital
            $name = $wgContLang->ucfirst($_REQUEST['BLTIusername']);
            // Clean up name according to title rules
            $t = Title::newFromText($name);
            if (is_null($t)) {
                return true;
            }
            $canonicalName = $t->getText();
            if (!User::isValidUserName($canonicalName)) {
                return true;
            }
            //--------------------------------------------------------------------------
            // Create a new MediaWiki user if not exists
            //--------------------------------------------------------------------------
            $u = User::newFromName($canonicalName);
            $uid = $u->getID();
            if (0 == $uid) {
                // create a new user
                $u->addToDatabase();
                $u->setPassword(genPassBLTI($_REQUEST['BLTIfullname'], $_pwdSecret));
                $u->setEmail($_REQUEST['BLTIemail']);
                $u->setRealName($_REQUEST['BLTIfullname']);
                $u->setToken();
                $u->setOption('rememberpassword', 0);
                $u->setOption('nocache', 1);
                $u->saveSettings();
            }
            $u->setCookies();
            $user = $u;
        }
    } else {
        if ($_REQUEST['title'] == 'Special:Userlogout') {
            $user->logout();
        }
    }
    return true;
}
Example #7
0
 /**
  * Static factory method
  * @param string $name Username, validated by Title:newFromText()
  * @return User
  * @static
  */
 function newFromName($name)
 {
     # Force usernames to capital
     global $wgContLang;
     $name = $wgContLang->ucfirst($name);
     # Clean up name according to title rules
     $t = Title::newFromText($name);
     if (is_null($t)) {
         return null;
     }
     # Reject various classes of invalid names
     $canonicalName = $t->getText();
     global $wgAuth;
     $canonicalName = $wgAuth->getCanonicalName($t->getText());
     if (!User::isValidUserName($canonicalName)) {
         return null;
     }
     $u = new User();
     $u->setName($canonicalName);
     $u->setId($u->idFromName($canonicalName));
     return $u;
 }
Example #8
0
 /**
  * Given unvalidated user input, return a canonical username, or false if
  * the username is invalid.
  * @param $name String User input
  * @param $validate String|Bool type of validation to use:
  *                - false        No validation
  *                - 'valid'      Valid for batch processes
  *                - 'usable'     Valid for batch processes and login
  *                - 'creatable'  Valid for batch processes, login and account creation
  *
  * @return bool|string
  */
 public static function getCanonicalName($name, $validate = 'valid')
 {
     # Force usernames to capital
     global $wgContLang;
     $name = $wgContLang->ucfirst($name);
     # Reject names containing '#'; these will be cleaned up
     # with title normalisation, but then it's too late to
     # check elsewhere
     if (strpos($name, '#') !== false) {
         return false;
     }
     # Clean up name according to title rules
     $t = $validate === 'valid' ? Title::newFromText($name) : Title::makeTitle(NS_USER, $name);
     # Check for invalid titles
     if (is_null($t)) {
         return false;
     }
     # Reject various classes of invalid names
     global $wgAuth;
     $name = $wgAuth->getCanonicalName($t->getText());
     switch ($validate) {
         case false:
             break;
         case 'valid':
             if (!User::isValidUserName($name)) {
                 $name = false;
             }
             break;
         case 'usable':
             if (!User::isUsableName($name)) {
                 $name = false;
             }
             break;
         case 'creatable':
             if (!User::isCreatableName($name)) {
                 $name = false;
             }
             break;
         default:
             throw new MWException('Invalid parameter value for $validate in ' . __METHOD__);
     }
     return $name;
 }
Example #9
0
            $profName = $fname . '-extensions-' . get_class($func[0]) . '::' . $func[1];
        } else {
            $profName = $fname . '-extensions-' . implode('::', $func);
        }
    } else {
        $profName = $fname . '-extensions-' . strval($func);
    }
    $ps_ext_func = Profiler::instance()->scopedProfileIn($profName);
    call_user_func($func);
    Profiler::instance()->scopedProfileOut($ps_ext_func);
}
// If the session user has a 0 id but a valid name, that means we need to
// autocreate it.
if (!defined('MW_NO_SESSION') && !$wgCommandLineMode) {
    $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
    if ($sessionUser->getId() === 0 && User::isValidUserName($sessionUser->getName())) {
        $ps_autocreate = Profiler::instance()->scopedProfileIn($fname . '-autocreate');
        $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser($sessionUser, MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION, true);
        Profiler::instance()->scopedProfileOut($ps_autocreate);
        \MediaWiki\Logger\LoggerFactory::getInstance('authevents')->info('Autocreation attempt', ['event' => 'autocreate', 'status' => $res]);
        unset($res);
    }
    unset($sessionUser);
}
if (!$wgCommandLineMode) {
    Pingback::schedulePingback();
}
wfDebug("Fully initialised\n");
$wgFullyInitialised = true;
Profiler::instance()->scopedProfileOut($ps_extensions);
Profiler::instance()->scopedProfileOut($ps_setup);
Example #10
0
 /**
  * Preloads genders for given list of users.
  * @param $users List|String: usernames
  * @param $caller String: the calling method
  */
 public function doQuery($users, $caller = '')
 {
     $default = $this->getDefault();
     $usersToCheck = array();
     foreach ((array) $users as $value) {
         $name = self::normalizeUsername($value);
         // Skip users whose gender setting we already know
         if (!isset($this->cache[$name])) {
             // For existing users, this value will be overwritten by the correct value
             $this->cache[$name] = $default;
             // query only for valid names, which can be in the database
             if (User::isValidUserName($name)) {
                 $usersToCheck[] = $name;
             }
         }
     }
     if (count($usersToCheck) === 0) {
         return;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $table = array('user', 'user_properties');
     $fields = array('user_name', 'up_value');
     $conds = array('user_name' => $usersToCheck);
     $joins = array('user_properties' => array('LEFT JOIN', array('user_id = up_user', 'up_property' => 'gender')));
     $comment = __METHOD__;
     if (strval($caller) !== '') {
         $comment .= "/{$caller}";
     }
     $res = $dbr->select($table, $fields, $conds, $comment, array(), $joins);
     foreach ($res as $row) {
         $this->cache[$row->user_name] = $row->up_value ? $row->up_value : $default;
     }
 }
Example #11
0
 /**
  * @dataProvider provideUserNames
  * @covers User::isValidUserName
  */
 public function testIsValidUserName($username, $result, $message)
 {
     $this->assertEquals($this->user->isValidUserName($username), $result, $message);
 }
Example #12
0
 /**
  * Given unvalidated user input, return a canonical username, or false if 
  * the username is invalid.
  * @param string $name
  * @param mixed $validate Type of validation to use:
  *                         false        No validation
  *                         'valid'      Valid for batch processes
  *                         'usable'     Valid for batch processes and login
  *                         'creatable'  Valid for batch processes, login and account creation
  */
 static function getCanonicalName($name, $validate = 'valid')
 {
     # Force usernames to capital
     global $wgContLang;
     $name = $wgContLang->ucfirst($name);
     # Clean up name according to title rules
     $t = Title::newFromText($name);
     if (is_null($t)) {
         return false;
     }
     # Reject various classes of invalid names
     $name = $t->getText();
     global $wgAuth;
     $name = $wgAuth->getCanonicalName($t->getText());
     switch ($validate) {
         case false:
             break;
         case 'valid':
             if (!User::isValidUserName($name)) {
                 $name = false;
             }
             break;
         case 'usable':
             if (!User::isUsableName($name)) {
                 $name = false;
             }
             break;
         case 'creatable':
             if (!User::isCreatableName($name)) {
                 $name = false;
             }
             break;
         default:
             throw new MWException('Invalid parameter value for $validate in ' . __METHOD__);
     }
     return $name;
 }
Example #13
0
 /**
  * Attempt to add a user to the database
  * Does the required authentication checks and updates for auto-creation
  * @param $user User
  * @param $userName string
  * @return bool Success
  */
 static function attemptAddUser($user, $userName)
 {
     global $wgAuth, $wgCentralAuthCreateOnView;
     // Denied by configuration?
     if (!$wgAuth->autoCreate()) {
         wfDebug(__METHOD__ . ": denied by configuration\n");
         return false;
     }
     if (!$wgCentralAuthCreateOnView) {
         // Only create local accounts when we perform an active login...
         // Don't freak people out on every page view
         wfDebug(__METHOD__ . ": denied by \$wgCentralAuthCreateOnView\n");
         return false;
     }
     // Is the user blacklisted by the session?
     // This is just a cache to avoid expensive DB queries in $user->isAllowedToCreateAccount().
     // The user can log in via Special:UserLogin to bypass the blacklist and get a proper
     // error message.
     $session = CentralAuthUser::getSession();
     if (isset($session['auto-create-blacklist']) && in_array(wfWikiID(), (array) $session['auto-create-blacklist'])) {
         wfDebug(__METHOD__ . ": blacklisted by session\n");
         return false;
     }
     // Is the user blocked?
     $anon = new User();
     if (!$anon->isAllowedAny('createaccount', 'centralauth-autoaccount') || $anon->isBlockedFromCreateAccount()) {
         // Blacklist the user to avoid repeated DB queries subsequently
         // First load the session again in case it changed while the above DB query was in progress
         wfDebug(__METHOD__ . ": user is blocked from this wiki, blacklisting\n");
         $session = CentralAuthUser::getSession();
         $session['auto-create-blacklist'][] = wfWikiID();
         CentralAuthUser::setSession($session);
         return false;
     }
     // Check for validity of username
     if (!User::isValidUserName($userName)) {
         wfDebug(__METHOD__ . ": Invalid username\n");
         $session = CentralAuthUser::getSession();
         $session['auto-create-blacklist'][] = wfWikiID();
         CentralAuthUser::setSession($session);
         return false;
     }
     // Give other extensions a chance to stop auto creation, but they cannot
     // change $userName, because CentralAuth expects user names on all wikis
     // are the same.
     //
     // * $user (and usually $wgUser) is the half-created User object and
     //   should not be accessed in any way since calling any User methods
     //   in its half-initialised state will give incorrect results.
     //
     // * $userName is the new user name
     //
     // * $anon is an anonymous user object which can be safely used for
     //   permissions checks.
     if (!wfRunHooks('CentralAuthAutoCreate', array($user, $userName, $anon))) {
         wfDebug(__METHOD__ . ": denied by other extensions\n");
         return false;
     }
     $abortMessage = '';
     if (!wfRunHooks('AbortAutoAccount', array($user, &$abortMessage))) {
         // In this case we have no way to return the message to the user,
         // but we can log it.
         wfDebug(__METHOD__ . ": denied by other extension: {$abortMessage}\n");
         return false;
     }
     // Checks passed, create the user
     wfDebug(__METHOD__ . ": creating new user\n");
     $user->loadDefaults($userName);
     $user->addToDatabase();
     $user->addNewUserLogEntryAutoCreate();
     $wgAuth->initUser($user, true);
     $wgAuth->updateUser($user);
     # Notify hooks (e.g. Newuserlog)
     wfRunHooks('AuthPluginAutoCreate', array($user));
     # Update user count
     $ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
     $ssUpdate->doUpdate();
     return true;
 }
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgExternalAuthType;
     // Set page title and other stuff
     $this->setHeaders();
     $user = $this->getUser();
     $output = $this->getOutput();
     # If the user isn't permitted to access this special page, display an error
     if (!$user->isAllowed('editaccount')) {
         throw new PermissionsError('editaccount');
     }
     # Show a message if the database is in read-only mode
     if (wfReadOnly()) {
         $output->readOnlyPage();
         return;
     }
     # If user is blocked, s/he doesn't need to access this page
     if ($user->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     $output->addModuleStyles('ext.editAccount');
     $request = $this->getRequest();
     $action = $request->getVal('wpAction');
     #get name to work on. subpage is supported, but form submit name trumps
     $userName = $request->getVal('wpUserName', $par);
     if ($userName !== null) {
         #got a name, clean it up
         $userName = str_replace("_", " ", trim($userName));
         $userName = ucfirst($userName);
         # user names begin with a capital letter
         // check if user name is an existing user
         if (User::isValidUserName($userName)) {
             // BugId:CE-11
             // If the user account has just been enabled with Special:EditAccount
             // and the 'wikicities_c1' database (local for Community Central)
             // has lagged compared to the 'wikicities' database (the shared one)
             // the next action done with Special:EditAccount will fail and the
             // correct user data will be replaced by the temp user cache.
             // In other words: LOST.
             //
             // In order to prevent that we have to do the following two steps:
             //
             // 1) REMOVED: invalidate temp user cache
             //
             // 2) and copy the data from the shared to the local database
             $oUser = User::newFromName($userName);
             wfRunHooks('UserNameLoadFromId', array($userName, &$oUser, true));
             $id = 0;
             $this->mUser = $oUser;
             if (!empty($this->mUser)) {
                 $id = $this->mUser->getId();
             }
             if (empty($action)) {
                 $action = 'displayuser';
             }
             if (empty($id)) {
                 $this->mUser = null;
                 $this->mStatus = false;
                 $this->mStatusMsg = wfMsg('editaccount-nouser', $userName);
             }
         }
     }
     // FB:23860
     if (!$this->mUser instanceof User) {
         $action = '';
     }
     // CSRF protection for EditAccount (CE-774)
     if ($action !== '' && $action !== 'displayuser' && $action !== 'closeaccount' && (!$request->wasPosted() || !$user->matchEditToken($request->getVal('wpToken')))) {
         $output->addHTML(Xml::element('p', ['class' => 'error'], $this->msg('sessionfailure')->text()));
         return;
     }
     $changeReason = $request->getVal('wpReason');
     switch ($action) {
         case 'setemail':
             $newEmail = $request->getVal('wpNewEmail');
             $this->mStatus = $this->setEmail($newEmail, $changeReason);
             $template = 'displayuser';
             break;
         case 'setpass':
             $newPass = $request->getVal('wpNewPass');
             $this->mStatus = $this->setPassword($newPass, $changeReason);
             $template = 'displayuser';
             break;
         case 'setrealname':
             $newRealName = $request->getVal('wpNewRealName');
             $this->mStatus = $this->setRealName($newRealName, $changeReason);
             $template = 'displayuser';
             break;
         case 'closeaccount':
             $template = 'closeaccount';
             $this->mStatus = (bool) $this->mUser->getGlobalFlag('requested-closure', 0);
             $this->mStatusMsg = $this->mStatus ? wfMsg('editaccount-requested') : wfMsg('editaccount-not-requested');
             break;
         case 'closeaccountconfirm':
             $keepEmail = !$request->getBool('clearemail', false);
             $this->mStatus = self::closeAccount($this->mUser, $changeReason, $this->mStatusMsg, $this->mStatusMsg2, $keepEmail);
             $template = $this->mStatus ? 'selectuser' : 'displayuser';
             break;
         case 'clearunsub':
             $this->mStatus = $this->clearUnsubscribe();
             $template = 'displayuser';
             break;
         case 'cleardisable':
             $this->mStatus = $this->clearDisable();
             $template = 'displayuser';
             break;
         case 'clearclosurerequest':
             $this->mStatus = $this->clearClosureRequest();
             $template = 'displayuser';
             break;
         case 'toggleadopter':
             $this->mStatus = $this->toggleAdopterStatus();
             $template = 'displayuser';
             break;
         case 'displayuser':
             $template = 'displayuser';
             break;
         default:
             $template = 'selectuser';
     }
     $output->setPageTitle($this->msg('editaccount-title')->plain());
     $oTmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $oTmpl->set_Vars(array('status' => $this->mStatus, 'statusMsg' => $this->mStatusMsg, 'statusMsg2' => $this->mStatusMsg2, 'user' => $userName, 'userEmail' => null, 'userRealName' => null, 'userEncoded' => urlencode($userName), 'user_hsc' => htmlspecialchars($userName), 'userId' => null, 'userReg' => null, 'isUnsub' => null, 'isDisabled' => null, 'isAdopter' => null, 'returnURL' => $this->getTitle()->getFullURL(), 'logLink' => Linker::linkKnown(SpecialPage::getTitleFor('Log', 'editaccnt'), $this->msg('editaccount-log')->escaped()), 'userStatus' => null, 'emailStatus' => null, 'disabled' => null, 'changeEmailRequested' => null, 'editToken' => $user->getEditToken()));
     if (is_object($this->mUser)) {
         $userStatus = wfMsg('editaccount-status-realuser');
         $this->mUser->load();
         // get new email (unconfirmed)
         $optionNewEmail = $this->mUser->getGlobalAttribute('new_email');
         $changeEmailRequested = empty($optionNewEmail) ? '' : wfMsg('editaccount-email-change-requested', $optionNewEmail);
         // emailStatus is the status of the email in the "Set new email address" field
         $emailStatus = $this->mUser->isEmailConfirmed() ? wfMsg('editaccount-status-confirmed') : wfMsg('editaccount-status-unconfirmed');
         $oTmpl->set_Vars(array('userEmail' => $this->mUser->getEmail(), 'userRealName' => $this->mUser->getRealName(), 'userId' => $this->mUser->getID(), 'userReg' => date('r', strtotime($this->mUser->getRegistration())), 'isUnsub' => $this->mUser->getGlobalPreference('unsubscribed'), 'isDisabled' => $this->mUser->getGlobalFlag('disabled'), 'isClosureRequested' => $this->isClosureRequested(), 'isAdopter' => $this->mUser->getGlobalFlag('AllowAdoption', 1), 'userStatus' => $userStatus, 'emailStatus' => $emailStatus, 'changeEmailRequested' => $changeEmailRequested));
     }
     // HTML output
     $output->addHTML($oTmpl->render($template));
 }
Example #15
0
 /**
  * Given unvalidated user input, return a canonical username, or false if
  * the username is invalid.
  * @param string $name User input
  * @param string|bool $validate Type of validation to use:
  *   - false        No validation
  *   - 'valid'      Valid for batch processes
  *   - 'usable'     Valid for batch processes and login
  *   - 'creatable'  Valid for batch processes, login and account creation
  *
  * @throws InvalidArgumentException
  * @return bool|string
  */
 public static function getCanonicalName($name, $validate = 'valid')
 {
     // Force usernames to capital
     global $wgContLang;
     $name = $wgContLang->ucfirst($name);
     # Reject names containing '#'; these will be cleaned up
     # with title normalisation, but then it's too late to
     # check elsewhere
     if (strpos($name, '#') !== false) {
         return false;
     }
     // Clean up name according to title rules,
     // but only when validation is requested (bug 12654)
     $t = $validate !== false ? Title::newFromText($name, NS_USER) : Title::makeTitle(NS_USER, $name);
     // Check for invalid titles
     if (is_null($t) || $t->getNamespace() !== NS_USER || $t->isExternal()) {
         return false;
     }
     // Reject various classes of invalid names
     $name = AuthManager::callLegacyAuthPlugin('getCanonicalName', [$t->getText()], $t->getText());
     switch ($validate) {
         case false:
             break;
         case 'valid':
             if (!User::isValidUserName($name)) {
                 $name = false;
             }
             break;
         case 'usable':
             if (!User::isUsableName($name)) {
                 $name = false;
             }
             break;
         case 'creatable':
             if (!User::isCreatableName($name)) {
                 $name = false;
             }
             break;
         default:
             throw new InvalidArgumentException('Invalid parameter value for $validate in ' . __METHOD__);
     }
     return $name;
 }
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgOut, $wgUser, $wgRequest, $wgEnableUserLoginExt;
     // Set page title and other stuff
     $this->setHeaders();
     # If the user isn't permitted to access this special page, display an error
     if (!$wgUser->isAllowed('editaccount')) {
         throw new PermissionsError('editaccount');
     }
     # Show a message if the database is in read-only mode
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     # If user is blocked, s/he doesn't need to access this page
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     $action = $wgRequest->getVal('wpAction');
     #get name to work on. subpage is supported, but form submit name trumps
     $userName = $wgRequest->getVal('wpUserName', $par);
     if ($userName !== null) {
         #got a name, clean it up
         $userName = str_replace("_", " ", trim($userName));
         $userName = ucfirst($userName);
         # user names begin with a capital letter
         // check if user name is an existing user
         if (User::isValidUserName($userName)) {
             $this->mUser = User::newFromName($userName);
             $id = $this->mUser->idFromName($userName);
             if (empty($action)) {
                 $action = 'displayuser';
             }
             if (empty($id)) {
                 if (!empty($wgEnableUserLoginExt)) {
                     $this->mTempUser = TempUser::getTempUserFromName($userName);
                 }
                 if ($this->mTempUser) {
                     $id = $this->mTempUser->getId();
                     $this->mUser = User::newFromId($id);
                 } else {
                     $this->mStatus = false;
                     $this->mStatusMsg = wfMsg('editaccount-nouser', $userName);
                     $action = '';
                 }
             }
         }
     }
     // FB:23860
     if (!$this->mUser instanceof User) {
         $action = '';
     }
     switch ($action) {
         case 'setemail':
             $newEmail = $wgRequest->getVal('wpNewEmail');
             $this->mStatus = $this->setEmail($newEmail);
             $template = 'displayuser';
             break;
         case 'setpass':
             $newPass = $wgRequest->getVal('wpNewPass');
             $this->mStatus = $this->setPassword($newPass);
             $template = 'displayuser';
             break;
         case 'setrealname':
             $newRealName = $wgRequest->getVal('wpNewRealName');
             $this->mStatus = $this->setRealName($newRealName);
             $template = 'displayuser';
             break;
         case 'closeaccount':
             $template = 'closeaccount';
             $this->mStatus = (bool) $this->mUser->getOption('requested-closure', 0);
             $this->mStatusMsg = $this->mStatus ? wfMsg('editaccount-requested') : wfMsg('editaccount-not-requested');
             break;
         case 'closeaccountconfirm':
             $this->mStatus = $this->closeAccount();
             $template = $this->mStatus ? 'selectuser' : 'displayuser';
             break;
         case 'clearunsub':
             $this->mStatus = $this->clearUnsubscribe();
             $template = 'displayuser';
             break;
         case 'cleardisable':
             $this->mStatus = $this->clearDisable();
             $template = 'displayuser';
             break;
         case 'toggleadopter':
             $this->mStatus = $this->toggleAdopterStatus();
             $template = 'displayuser';
             break;
         case 'displayuser':
             $template = 'displayuser';
             break;
         default:
             $template = 'selectuser';
     }
     $wgOut->setPageTitle(wfMsg('editaccount-title'));
     $oTmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $oTmpl->set_Vars(array('status' => $this->mStatus, 'statusMsg' => $this->mStatusMsg, 'statusMsg2' => $this->mStatusMsg2, 'user' => $userName, 'userEmail' => null, 'userRealName' => null, 'userEncoded' => urlencode($userName), 'user_hsc' => htmlspecialchars($userName), 'userId' => null, 'userReg' => null, 'isUnsub' => null, 'isDisabled' => null, 'isAdopter' => null, 'returnURL' => $this->getTitle()->getFullURL(), 'userStatus' => null, 'emailStatus' => null, 'disabled' => null, 'changeEmailRequested' => null));
     if (is_object($this->mUser)) {
         if ($this->mTempUser) {
             $this->mUser = $this->mTempUser->mapTempUserToUser(false);
             $userStatus = wfMsg('editaccount-status-tempuser');
             $oTmpl->set_Vars(array('disabled' => 'disabled="disabled"'));
         } else {
             $userStatus = wfMsg('editaccount-status-realuser');
         }
         $this->mUser->load();
         // get new email (unconfirmed)
         $optionNewEmail = $this->mUser->getOption('new_email');
         $changeEmailRequested = empty($optionNewEmail) ? '' : wfMsg('editaccount-email-change-requested', $optionNewEmail);
         // emailStatus is the status of the email in the "Set new email address" field
         $emailStatus = $this->mUser->isEmailConfirmed() ? wfMsg('editaccount-status-confirmed') : wfMsg('editaccount-status-unconfirmed');
         $oTmpl->set_Vars(array('userEmail' => $this->mUser->getEmail(), 'userRealName' => $this->mUser->getRealName(), 'userId' => $this->mUser->getID(), 'userReg' => date('r', strtotime($this->mUser->getRegistration())), 'isUnsub' => $this->mUser->getOption('unsubscribed'), 'isDisabled' => $this->mUser->getOption('disabled'), 'isAdopter' => $this->mUser->getOption('AllowAdoption', 1), 'userStatus' => $userStatus, 'emailStatus' => $emailStatus, 'changeEmailRequested' => $changeEmailRequested));
     }
     // HTML output
     $wgOut->addHTML($oTmpl->render($template));
 }