Differential D20827 Diff 49657 src/applications/people/controller/PhabricatorPeopleRenameController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/controller/PhabricatorPeopleRenameController.php
<?php | <?php | ||||
final class PhabricatorPeopleRenameController | final class PhabricatorPeopleRenameController | ||||
extends PhabricatorPeopleController { | extends PhabricatorPeopleController { | ||||
public function shouldRequireAdmin() { | |||||
return false; | |||||
} | |||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$id = $request->getURIData('id'); | $id = $request->getURIData('id'); | ||||
$user = id(new PhabricatorPeopleQuery()) | $user = id(new PhabricatorPeopleQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIDs(array($id)) | ->withIDs(array($id)) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$user) { | if (!$user) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$done_uri = $this->getApplicationURI("manage/{$id}/"); | $done_uri = $this->getApplicationURI("manage/{$id}/"); | ||||
if (!$viewer->getIsAdmin()) { | |||||
return $this->newDialog() | |||||
->setTitle(pht('Change Username')) | |||||
->appendParagraph( | |||||
pht( | |||||
'You can not change usernames because you are not an '. | |||||
'administrator. Only administrators can change usernames.')) | |||||
->addCancelButton($done_uri, pht('Okay')); | |||||
} | |||||
$validation_exception = null; | $validation_exception = null; | ||||
$username = $user->getUsername(); | $username = $user->getUsername(); | ||||
if ($request->isFormOrHisecPost()) { | if ($request->isFormOrHisecPost()) { | ||||
$username = $request->getStr('username'); | $username = $request->getStr('username'); | ||||
$xactions = array(); | $xactions = array(); | ||||
$xactions[] = id(new PhabricatorUserTransaction()) | $xactions[] = id(new PhabricatorUserTransaction()) | ||||
->setTransactionType( | ->setTransactionType( | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |