function execute($subpage)
 {
     global $wgContLang;
     $this->setHeaders();
     $this->mCanUnmerge = $this->getUser()->isAllowed('centralauth-unmerge');
     $this->mCanLock = $this->getUser()->isAllowed('centralauth-lock');
     $this->mCanOversight = $this->getUser()->isAllowed('centralauth-oversight');
     $this->mCanEdit = $this->mCanUnmerge || $this->mCanLock || $this->mCanOversight;
     $this->getOutput()->addModules('ext.centralauth');
     $this->getOutput()->addModuleStyles('ext.centralauth.noflash');
     $this->addMergeMethodDescriptions();
     $this->mUserName = trim(str_replace('_', ' ', $this->getRequest()->getText('target', $subpage)));
     $this->mUserName = $wgContLang->ucfirst($this->mUserName);
     $this->mPosted = $this->getRequest()->wasPosted();
     $this->mMethod = $this->getRequest()->getVal('wpMethod');
     $this->mWikis = (array) $this->getRequest()->getArray('wpWikis');
     // Possible demo states
     // success, all accounts merged
     // successful login, some accounts merged, others left
     // successful login, others left
     // not account owner, others left
     // is owner / is not owner
     // did / did not merge some accounts
     // do / don't have more accounts to merge
     if ($this->mUserName === '') {
         # First time through
         $this->getOutput()->addWikiMsg('centralauth-admin-intro');
         $this->showUsernameForm();
         return;
     }
     $this->mGlobalUser = $globalUser = new CentralAuthUser($this->mUserName);
     if (!$globalUser->exists() || $globalUser->isOversighted() && !$this->mCanOversight) {
         $this->showError('centralauth-admin-nonexistent', $this->mUserName);
         $this->showUsernameForm();
         return;
     }
     $continue = true;
     if ($this->mCanEdit && $this->mPosted) {
         $continue = $this->doSubmit();
     }
     $this->mAttachedLocalAccounts = $this->mGlobalUser->queryAttached();
     $this->mUnattachedLocalAccounts = $this->mGlobalUser->queryUnattached();
     $this->showUsernameForm();
     if ($continue) {
         $this->showInfo();
         if ($this->mCanLock) {
             $this->showStatusForm();
         }
         if ($this->mCanUnmerge) {
             $this->showActionForm('delete');
         }
         if ($this->mCanEdit) {
             $this->showLogExtract();
         }
         $this->showWikiLists();
     }
 }
 /**
  * Get the CentralAuthUser from a line of text
  *
  * @param $username string
  * @return CentralAuthUser|string User object, or a string containing the error
  */
 private function getGlobalUser($username)
 {
     $username = trim($username);
     if ($username === '') {
         return false;
     }
     $username = $this->getLanguage()->ucfirst($username);
     $globalUser = new CentralAuthUser($username);
     if (!$globalUser->exists() || !$this->mCanOversight && ($globalUser->isOversighted() || $globalUser->isHidden())) {
         return $this->msg('centralauth-admin-nonexistent', $username)->parse();
     }
     return $globalUser;
 }
 public function execute()
 {
     $globalUser = new CentralAuthUser($this->getParameter('user'));
     if (!$this->getUser()->isAllowed('centralauth-lock')) {
         $this->dieUsageMsg(array('badaccess-groups'));
     } elseif (!$globalUser->exists()) {
         $this->dieUsageMsg(array('nosuchuser', $globalUser->getName()));
     } elseif ($globalUser->isOversighted() && !$this->getUser()->isAllowed('centralauth-oversight')) {
         $this->dieUsageMsg(array('nosuchuser', $globalUser->getName()));
     } elseif (!$this->getRequest()->getCheck('locked') && $this->getParameter('hidden') === null) {
         $this->dieUsage("At least one of the parameters locked, hidden is required", "missingparam");
     }
     $setLocked = $this->getParameter('locked');
     if (!$setLocked) {
         // Don't lock or unlock
         $setLocked = null;
     } else {
         $setLocked = $setLocked === 'lock';
     }
     $setHidden = $this->getParameter('hidden');
     $reason = $this->getParameter('reason');
     $stateCheck = $this->getParameter('statecheck');
     if ($stateCheck && $stateCheck !== $globalUser->getStateHash(true)) {
         $this->dieUsage('Edit conflict detected, Aborting.', 'editconflict');
     }
     $status = $globalUser->adminLockHide($setLocked, $setHidden, $reason, $this->getContext());
     // Logging etc
     if ($status->isGood()) {
         $this->getResult()->addValue(null, $this->getModuleName(), array('user' => $globalUser->getName(), 'locked' => $globalUser->isLocked(), 'hidden' => $globalUser->getHiddenLevel(), 'reason' => $reason));
     } else {
         if (is_callable(array($this, 'getErrorFormatter'))) {
             $error = $this->getErrorFormatter()->arrayFromStatus($status);
         } else {
             $error = $this->getResult()->convertStatusToArray($status);
         }
         $this->getResult()->addValue('error', null, $error);
         $this->getResult()->addValue(null, $this->getModuleName(), array('user' => $globalUser->getName(), 'locked' => $globalUser->isLocked(), 'hidden' => $globalUser->getHiddenLevel()));
     }
 }
 public function execute()
 {
     if (!$this->getUser()->isAllowed('centralauth-unmerge')) {
         $this->dieUsageMsg(array('badaccess-groups'));
     }
     $params = $this->extractRequestParams();
     $globalUser = new CentralAuthUser($params['user']);
     if (!$globalUser->exists()) {
         $this->dieUsageMsg(array('nosuchuser', $globalUser->getName()));
     } elseif ($globalUser->isOversighted() && !$this->getUser()->isAllowed('centralauth-oversight')) {
         $this->dieUsageMsg(array('nosuchuser', $globalUser->getName()));
     }
     $status = $globalUser->adminDelete($params['reason']);
     if ($status->isGood()) {
         $this->getResult()->addValue(null, $this->getModuleName(), array('user' => $globalUser->getName(), 'reason' => $params['reason']));
     } else {
         if (is_callable(array($this, 'getErrorFormatter'))) {
             $error = $this->getErrorFormatter()->arrayFromStatus($status);
         } else {
             $error = $this->getResult()->convertStatusToArray($status);
         }
         $this->getResult()->addValue('error', null, $error);
     }
 }
 public function execute($subpage)
 {
     global $wgContLang;
     $this->setHeaders();
     $this->mCanUnmerge = $this->getUser()->isAllowed('centralauth-unmerge');
     $this->mCanLock = $this->getUser()->isAllowed('centralauth-lock');
     $this->mCanOversight = $this->getUser()->isAllowed('centralauth-oversight');
     $this->mCanEdit = $this->mCanUnmerge || $this->mCanLock || $this->mCanOversight;
     $this->getOutput()->setPageTitle($this->msg($this->mCanEdit ? 'centralauth' : 'centralauth-ro'));
     $this->getOutput()->addModules('ext.centralauth');
     $this->getOutput()->addModules('ext.centralauth.globaluserautocomplete');
     $this->getOutput()->addModuleStyles('ext.centralauth.noflash');
     $this->getOutput()->addJsConfigVars('wgMergeMethodDescriptions', $this->getMergeMethodDescriptions());
     $this->mUserName = trim(str_replace('_', ' ', $this->getRequest()->getText('target', $subpage)));
     $this->mUserName = $wgContLang->ucfirst($this->mUserName);
     $this->mPosted = $this->getRequest()->wasPosted();
     $this->mMethod = $this->getRequest()->getVal('wpMethod');
     $this->mWikis = (array) $this->getRequest()->getArray('wpWikis');
     // Possible demo states
     // success, all accounts merged
     // successful login, some accounts merged, others left
     // successful login, others left
     // not account owner, others left
     // is owner / is not owner
     // did / did not merge some accounts
     // do / don't have more accounts to merge
     if ($this->mUserName === '') {
         # First time through
         $this->getOutput()->addWikiMsg('centralauth-admin-intro');
         $this->showUsernameForm();
         return;
     }
     // per bug 47991
     $this->getOutput()->setHTMLTitle($this->msg('pagetitle', $this->msg($this->mCanEdit ? 'centralauth-admin-title' : 'centralauth-admin-title-ro', $this->mUserName)->plain()));
     $this->mGlobalUser = $globalUser = new CentralAuthUser($this->mUserName);
     if (($globalUser->isOversighted() || $globalUser->isHidden()) && !$this->mCanOversight) {
         // Claim that there's nothing if the global account is hidden and the user is not
         // allowed to see it.
         $this->showNonexistentError();
         return;
     }
     $continue = true;
     if ($this->mCanEdit && $this->mPosted) {
         $continue = $this->doSubmit();
     }
     // Show just a user friendly message when a rename is in progress
     try {
         $this->mAttachedLocalAccounts = $globalUser->queryAttached();
     } catch (Exception $e) {
         if ($globalUser->renameInProgress()) {
             $this->showRenameInProgressError();
             return;
         }
         // Rethrow
         throw $e;
     }
     $this->mUnattachedLocalAccounts = $globalUser->queryUnattached();
     if (!$globalUser->exists() && !count($this->mUnattachedLocalAccounts)) {
         // Nothing to see here
         $this->showNonexistentError();
         return;
     }
     $this->showUsernameForm();
     if ($continue && $globalUser->exists()) {
         $this->showInfo();
         if ($this->mCanLock) {
             $this->showStatusForm();
         }
         if ($this->mCanUnmerge) {
             $this->showActionForm('delete');
         }
         $this->showLogExtract();
         $this->showWikiLists();
     } elseif ($continue && !$globalUser->exists()) {
         // No global account, but we can still list the local ones
         $this->showError('centralauth-admin-nonexistent', $this->mUserName);
         $this->showWikiLists();
     }
 }
 /**
  * @covers CentralAuthUser::isHidden
  * @covers CentralAuthUser::isOversighted
  * @covers CentralAuthUser::getHiddenLevel
  */
 public function testHidden()
 {
     $caUser = new CentralAuthUser('GlobalSuppressedUser');
     $this->assertSame(true, $caUser->exists());
     $this->assertSame(true, $caUser->isHidden());
     $this->assertSame(true, $caUser->isOversighted());
     $this->assertEquals(CentralAuthUser::HIDDEN_OVERSIGHT, $caUser->getHiddenLevel());
 }