1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-01 18:30:59 +01:00
phorge-phorge/src/applications/people/controller/PhabricatorPeopleEmpowerController.php
epriestley 8efaaa188f Move user editing/management actions to a separate "Manage" item, like projects
Summary: This improves consistency (by making this UI more similar to the projects UI) and gives us more flexibility the next time we update user profiles.

Test Plan:
{F1068889}

Took all the actions (probably?) to check that all the redirects were updated.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D15104
2016-01-24 10:01:31 -08:00

70 lines
2.2 KiB
PHP

<?php
final class PhabricatorPeopleEmpowerController
extends PhabricatorPeopleController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$user) {
return new Aphront404Response();
}
$done_uri = $this->getApplicationURI("manage/{$id}/");
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
$viewer,
$request,
$done_uri);
if ($user->getPHID() == $viewer->getPHID()) {
return $this->newDialog()
->setTitle(pht('Your Way is Blocked'))
->appendParagraph(
pht(
'After a time, your efforts fail. You can not adjust your own '.
'status as an administrator.'))
->addCancelButton($done_uri, pht('Accept Fate'));
}
if ($request->isFormPost()) {
id(new PhabricatorUserEditor())
->setActor($viewer)
->makeAdminUser($user, !$user->getIsAdmin());
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
if ($user->getIsAdmin()) {
$title = pht('Remove as Administrator?');
$short = pht('Remove Administrator');
$body = pht(
'Remove %s as an administrator? They will no longer be able to '.
'perform administrative functions on this Phabricator install.',
phutil_tag('strong', array(), $user->getUsername()));
$submit = pht('Remove Administrator');
} else {
$title = pht('Make Administrator?');
$short = pht('Make Administrator');
$body = pht(
'Empower %s as an administrator? They will be able to create users, '.
'approve users, make and remove administrators, delete accounts, and '.
'perform other administrative functions on this Phabricator install.',
phutil_tag('strong', array(), $user->getUsername()));
$submit = pht('Make Administrator');
}
return $this->newDialog()
->setTitle($title)
->setShortTitle($short)
->appendParagraph($body)
->addCancelButton($done_uri)
->addSubmitButton($submit);
}
}