mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +01:00
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
This commit is contained in:
parent
06aa207960
commit
8efaaa188f
12 changed files with 306 additions and 173 deletions
|
@ -2747,11 +2747,13 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPeopleLogSearchEngine' => 'applications/people/query/PhabricatorPeopleLogSearchEngine.php',
|
||||
'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php',
|
||||
'PhabricatorPeopleMainMenuBarExtension' => 'applications/people/extension/PhabricatorPeopleMainMenuBarExtension.php',
|
||||
'PhabricatorPeopleManageProfilePanel' => 'applications/people/profilepanel/PhabricatorPeopleManageProfilePanel.php',
|
||||
'PhabricatorPeopleNewController' => 'applications/people/controller/PhabricatorPeopleNewController.php',
|
||||
'PhabricatorPeopleNoOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleNoOwnerDatasource.php',
|
||||
'PhabricatorPeopleOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleOwnerDatasource.php',
|
||||
'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php',
|
||||
'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php',
|
||||
'PhabricatorPeopleProfileManageController' => 'applications/people/controller/PhabricatorPeopleProfileManageController.php',
|
||||
'PhabricatorPeopleProfilePanelEngine' => 'applications/people/engine/PhabricatorPeopleProfilePanelEngine.php',
|
||||
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
|
||||
'PhabricatorPeopleProfileViewController' => 'applications/people/controller/PhabricatorPeopleProfileViewController.php',
|
||||
|
@ -7114,11 +7116,13 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPeopleLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController',
|
||||
'PhabricatorPeopleMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension',
|
||||
'PhabricatorPeopleManageProfilePanel' => 'PhabricatorProfilePanel',
|
||||
'PhabricatorPeopleNewController' => 'PhabricatorPeopleController',
|
||||
'PhabricatorPeopleNoOwnerDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'PhabricatorPeopleOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
|
||||
'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleProfileController',
|
||||
'PhabricatorPeopleProfileManageController' => 'PhabricatorPeopleProfileController',
|
||||
'PhabricatorPeopleProfilePanelEngine' => 'PhabricatorProfilePanelEngine',
|
||||
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleProfileController',
|
||||
'PhabricatorPeopleProfileViewController' => 'PhabricatorPeopleProfileController',
|
||||
|
|
|
@ -62,6 +62,8 @@ final class PhabricatorPeopleApplication extends PhabricatorApplication {
|
|||
'PhabricatorPeopleProfileEditController',
|
||||
'picture/(?P<id>[1-9]\d*)/' =>
|
||||
'PhabricatorPeopleProfilePictureController',
|
||||
'manage/(?P<id>[1-9]\d*)/' =>
|
||||
'PhabricatorPeopleProfileManageController',
|
||||
),
|
||||
'/p/(?P<username>[\w._-]+)/' => array(
|
||||
'' => 'PhabricatorPeopleProfileViewController',
|
||||
|
|
|
@ -3,28 +3,22 @@
|
|||
final class PhabricatorPeopleDeleteController
|
||||
extends PhabricatorPeopleController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$admin = $request->getUser();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getUser();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$user = id(new PhabricatorPeopleQuery())
|
||||
->setViewer($admin)
|
||||
->withIDs(array($this->id))
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$user) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
||||
$manage_uri = $this->getApplicationURI("manage/{$id}/");
|
||||
|
||||
if ($user->getPHID() == $admin->getPHID()) {
|
||||
return $this->buildDeleteSelfResponse($profile_uri);
|
||||
if ($user->getPHID() == $viewer->getPHID()) {
|
||||
return $this->buildDeleteSelfResponse($manage_uri);
|
||||
}
|
||||
|
||||
$str1 = pht(
|
||||
|
@ -47,7 +41,7 @@ final class PhabricatorPeopleDeleteController
|
|||
$str4 = pht('To permanently destroy this user, run this command:');
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($admin)
|
||||
->setUser($viewer)
|
||||
->appendRemarkupInstructions(
|
||||
csprintf(
|
||||
" phabricator/ $ ./bin/remove destroy %R\n",
|
||||
|
@ -62,10 +56,10 @@ final class PhabricatorPeopleDeleteController
|
|||
->appendParagraph($str3)
|
||||
->appendParagraph($str4)
|
||||
->appendChild($form->buildLayoutView())
|
||||
->addCancelButton($profile_uri, pht('Close'));
|
||||
->addCancelButton($manage_uri, pht('Close'));
|
||||
}
|
||||
|
||||
private function buildDeleteSelfResponse($profile_uri) {
|
||||
private function buildDeleteSelfResponse($cancel_uri) {
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('You Shall Journey No Farther'))
|
||||
->appendParagraph(
|
||||
|
@ -73,7 +67,7 @@ final class PhabricatorPeopleDeleteController
|
|||
'As you stare into the gaping maw of the abyss, something '.
|
||||
'holds you back.'))
|
||||
->appendParagraph(pht('You can not delete your own account.'))
|
||||
->addCancelButton($profile_uri, pht('Turn Back'));
|
||||
->addCancelButton($cancel_uri, pht('Turn Back'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,21 +3,14 @@
|
|||
final class PhabricatorPeopleDisableController
|
||||
extends PhabricatorPeopleController {
|
||||
|
||||
private $id;
|
||||
private $via;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
$this->via = $data['via'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$admin = $request->getUser();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
$via = $request->getURIData('id');
|
||||
|
||||
$user = id(new PhabricatorPeopleQuery())
|
||||
->setViewer($admin)
|
||||
->withIDs(array($this->id))
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$user) {
|
||||
return new Aphront404Response();
|
||||
|
@ -27,16 +20,16 @@ final class PhabricatorPeopleDisableController
|
|||
// on profiles and also via the "X" action on the approval queue. We do
|
||||
// things slightly differently depending on the context the actor is in.
|
||||
|
||||
$is_disapprove = ($this->via == 'disapprove');
|
||||
$is_disapprove = ($via == 'disapprove');
|
||||
if ($is_disapprove) {
|
||||
$done_uri = $this->getApplicationURI('query/approval/');
|
||||
$should_disable = true;
|
||||
} else {
|
||||
$done_uri = '/p/'.$user->getUsername().'/';
|
||||
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||
$should_disable = !$user->getIsDisabled();
|
||||
}
|
||||
|
||||
if ($admin->getPHID() == $user->getPHID()) {
|
||||
if ($viewer->getPHID() == $user->getPHID()) {
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Something Stays Your Hand'))
|
||||
->appendParagraph(
|
||||
|
@ -47,7 +40,7 @@ final class PhabricatorPeopleDisableController
|
|||
|
||||
if ($request->isFormPost()) {
|
||||
id(new PhabricatorUserEditor())
|
||||
->setActor($admin)
|
||||
->setActor($viewer)
|
||||
->disableUser($user, $should_disable);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||
|
|
|
@ -3,47 +3,41 @@
|
|||
final class PhabricatorPeopleEmpowerController
|
||||
extends PhabricatorPeopleController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$admin = $request->getUser();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$user = id(new PhabricatorPeopleQuery())
|
||||
->setViewer($admin)
|
||||
->withIDs(array($this->id))
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$user) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
||||
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||
|
||||
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
|
||||
$admin,
|
||||
$viewer,
|
||||
$request,
|
||||
$profile_uri);
|
||||
$done_uri);
|
||||
|
||||
if ($user->getPHID() == $admin->getPHID()) {
|
||||
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($profile_uri, pht('Accept Fate'));
|
||||
->addCancelButton($done_uri, pht('Accept Fate'));
|
||||
}
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
id(new PhabricatorUserEditor())
|
||||
->setActor($admin)
|
||||
->setActor($viewer)
|
||||
->makeAdminUser($user, !$user->getIsAdmin());
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($profile_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||
}
|
||||
|
||||
if ($user->getIsAdmin()) {
|
||||
|
@ -69,7 +63,7 @@ final class PhabricatorPeopleEmpowerController
|
|||
->setTitle($title)
|
||||
->setShortTitle($short)
|
||||
->appendParagraph($body)
|
||||
->addCancelButton($profile_uri)
|
||||
->addCancelButton($done_uri)
|
||||
->addSubmitButton($submit);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ final class PhabricatorPeopleProfileEditController
|
|||
|
||||
$this->setUser($user);
|
||||
|
||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
||||
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||
|
||||
$field_list = PhabricatorCustomField::getObjectFields(
|
||||
$user,
|
||||
|
@ -46,7 +46,7 @@ final class PhabricatorPeopleProfileEditController
|
|||
|
||||
try {
|
||||
$editor->applyTransactions($user, $xactions);
|
||||
return id(new AphrontRedirectResponse())->setURI($profile_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
||||
$validation_exception = $ex;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ final class PhabricatorPeopleProfileEditController
|
|||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($profile_uri)
|
||||
->addCancelButton($done_uri)
|
||||
->setValue(pht('Save Profile')));
|
||||
|
||||
$allow_public = PhabricatorEnv::getEnvConfig('policy.allow-public');
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorPeopleProfileManageController
|
||||
extends PhabricatorPeopleProfileController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$user = id(new PhabricatorPeopleQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->needProfile(true)
|
||||
->needProfileImage(true)
|
||||
->executeOne();
|
||||
if (!$user) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$this->setUser($user);
|
||||
|
||||
$profile = $user->loadUserProfile();
|
||||
$picture = $user->getProfileImageURI();
|
||||
|
||||
$profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon());
|
||||
$profile_icon = id(new PHUIIconView())
|
||||
->setIconFont($profile_icon.' grey');
|
||||
$profile_title = $profile->getDisplayTitle();
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($user->getFullName())
|
||||
->setSubheader(array($profile_icon, $profile_title))
|
||||
->setImage($picture);
|
||||
|
||||
$actions = $this->buildActionList($user);
|
||||
$properties = $this->buildPropertyView($user);
|
||||
$properties->setActionList($actions);
|
||||
$name = $user->getUsername();
|
||||
|
||||
$object_box = id(new PHUIObjectBoxView())
|
||||
->setHeader($header)
|
||||
->addPropertyList($properties);
|
||||
|
||||
$nav = $this->getProfileMenu();
|
||||
$nav->selectFilter(PhabricatorPeopleProfilePanelEngine::PANEL_MANAGE);
|
||||
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$user,
|
||||
new PhabricatorPeopleTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Manage'));
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle(
|
||||
array(
|
||||
pht('Manage User'),
|
||||
$user->getUsername(),
|
||||
))
|
||||
->setNavigation($nav)
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
$object_box,
|
||||
$timeline,
|
||||
));
|
||||
}
|
||||
|
||||
private function buildPropertyView(PhabricatorUser $user) {
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
$view = id(new PHUIPropertyListView())
|
||||
->setUser($viewer)
|
||||
->setObject($user);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
private function buildActionList(PhabricatorUser $user) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$actions = id(new PhabricatorActionListView())
|
||||
->setUser($viewer);
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
$user,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-pencil')
|
||||
->setName(pht('Edit Profile'))
|
||||
->setHref($this->getApplicationURI('editprofile/'.$user->getID().'/'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-picture-o')
|
||||
->setName(pht('Edit Profile Picture'))
|
||||
->setHref($this->getApplicationURI('picture/'.$user->getID().'/'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-wrench')
|
||||
->setName(pht('Edit Settings'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit)
|
||||
->setHref('/settings/'.$user->getID().'/'));
|
||||
|
||||
if ($user->getIsAdmin()) {
|
||||
$empower_icon = 'fa-arrow-circle-o-down';
|
||||
$empower_name = pht('Remove Administrator');
|
||||
} else {
|
||||
$empower_icon = 'fa-arrow-circle-o-up';
|
||||
$empower_name = pht('Make Administrator');
|
||||
}
|
||||
|
||||
$is_admin = $viewer->getIsAdmin();
|
||||
$is_self = ($user->getPHID() === $viewer->getPHID());
|
||||
$can_admin = ($is_admin && !$is_self);
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon($empower_icon)
|
||||
->setName($empower_name)
|
||||
->setDisabled(!$can_admin)
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getApplicationURI('empower/'.$user->getID().'/')));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-tag')
|
||||
->setName(pht('Change Username'))
|
||||
->setDisabled(!$is_admin)
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getApplicationURI('rename/'.$user->getID().'/')));
|
||||
|
||||
if ($user->getIsDisabled()) {
|
||||
$disable_icon = 'fa-check-circle-o';
|
||||
$disable_name = pht('Enable User');
|
||||
} else {
|
||||
$disable_icon = 'fa-ban';
|
||||
$disable_name = pht('Disable User');
|
||||
}
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon($disable_icon)
|
||||
->setName($disable_name)
|
||||
->setDisabled(!$can_admin)
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getApplicationURI('disable/'.$user->getID().'/')));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-times')
|
||||
->setName(pht('Delete User'))
|
||||
->setDisabled(!$can_admin)
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getApplicationURI('delete/'.$user->getID().'/')));
|
||||
|
||||
$can_welcome = ($is_admin && $user->canEstablishWebSessions());
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-envelope')
|
||||
->setName(pht('Send Welcome Email'))
|
||||
->setWorkflow(true)
|
||||
->setDisabled(!$can_welcome)
|
||||
->setHref($this->getApplicationURI('welcome/'.$user->getID().'/')));
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -23,7 +23,7 @@ final class PhabricatorPeopleProfilePictureController
|
|||
|
||||
$this->setUser($user);
|
||||
|
||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
||||
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||
|
||||
$supported_formats = PhabricatorFile::getTransformableImageFormats();
|
||||
$e_file = true;
|
||||
|
@ -76,7 +76,7 @@ final class PhabricatorPeopleProfilePictureController
|
|||
$xformed->attachToObject($user->getPHID());
|
||||
}
|
||||
$user->save();
|
||||
return id(new AphrontRedirectResponse())->setURI($profile_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ final class PhabricatorPeopleProfilePictureController
|
|||
pht('Supported formats: %s', implode(', ', $supported_formats))))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($profile_uri)
|
||||
->addCancelButton($done_uri)
|
||||
->setValue(pht('Upload Picture')));
|
||||
|
||||
$upload_box = id(new PHUIObjectBoxView())
|
||||
|
|
|
@ -41,27 +41,6 @@ final class PhabricatorPeopleProfileViewController
|
|||
->setObject($user)
|
||||
->setUser($viewer);
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
$user,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-pencil')
|
||||
->setName(pht('Edit Profile'))
|
||||
->setHref($this->getApplicationURI('editprofile/'.$user->getID().'/'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-picture-o')
|
||||
->setName(pht('Edit Profile Picture'))
|
||||
->setHref($this->getApplicationURI('picture/'.$user->getID().'/'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$class = 'PhabricatorConpherenceApplication';
|
||||
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
||||
$href = id(new PhutilURI('/conpherence/new/'))
|
||||
|
@ -78,79 +57,10 @@ final class PhabricatorPeopleProfileViewController
|
|||
->setHref($href));
|
||||
}
|
||||
|
||||
if ($viewer->getIsAdmin()) {
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-wrench')
|
||||
->setName(pht('Edit Settings'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit)
|
||||
->setHref('/settings/'.$user->getID().'/'));
|
||||
|
||||
if ($user->getIsAdmin()) {
|
||||
$empower_icon = 'fa-arrow-circle-o-down';
|
||||
$empower_name = pht('Remove Administrator');
|
||||
} else {
|
||||
$empower_icon = 'fa-arrow-circle-o-up';
|
||||
$empower_name = pht('Make Administrator');
|
||||
}
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon($empower_icon)
|
||||
->setName($empower_name)
|
||||
->setDisabled(($user->getPHID() == $viewer->getPHID()))
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getApplicationURI('empower/'.$user->getID().'/')));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-tag')
|
||||
->setName(pht('Change Username'))
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getApplicationURI('rename/'.$user->getID().'/')));
|
||||
|
||||
if ($user->getIsDisabled()) {
|
||||
$disable_icon = 'fa-check-circle-o';
|
||||
$disable_name = pht('Enable User');
|
||||
} else {
|
||||
$disable_icon = 'fa-ban';
|
||||
$disable_name = pht('Disable User');
|
||||
}
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon($disable_icon)
|
||||
->setName($disable_name)
|
||||
->setDisabled(($user->getPHID() == $viewer->getPHID()))
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getApplicationURI('disable/'.$user->getID().'/')));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-times')
|
||||
->setName(pht('Delete User'))
|
||||
->setDisabled(($user->getPHID() == $viewer->getPHID()))
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getApplicationURI('delete/'.$user->getID().'/')));
|
||||
|
||||
$can_welcome = $user->canEstablishWebSessions();
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-envelope')
|
||||
->setName(pht('Send Welcome Email'))
|
||||
->setWorkflow(true)
|
||||
->setDisabled(!$can_welcome)
|
||||
->setHref($this->getApplicationURI('welcome/'.$user->getID().'/')));
|
||||
}
|
||||
|
||||
$properties = $this->buildPropertyView($user, $actions);
|
||||
$name = $user->getUsername();
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($name);
|
||||
|
||||
$object_box = id(new PHUIObjectBoxView())
|
||||
->setHeader($header)
|
||||
->addPropertyList($properties);
|
||||
|
@ -227,6 +137,7 @@ final class PhabricatorPeopleProfileViewController
|
|||
->appendChild($flex);
|
||||
}
|
||||
}
|
||||
|
||||
return $box;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,30 +3,24 @@
|
|||
final class PhabricatorPeopleRenameController
|
||||
extends PhabricatorPeopleController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$admin = $request->getUser();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$user = id(new PhabricatorPeopleQuery())
|
||||
->setViewer($admin)
|
||||
->withIDs(array($this->id))
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$user) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
||||
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||
|
||||
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
|
||||
$admin,
|
||||
$viewer,
|
||||
$request,
|
||||
$profile_uri);
|
||||
$done_uri);
|
||||
|
||||
$errors = array();
|
||||
|
||||
|
@ -35,7 +29,6 @@ final class PhabricatorPeopleRenameController
|
|||
if ($request->isFormPost()) {
|
||||
$v_username = $request->getStr('username');
|
||||
|
||||
|
||||
if (!strlen($v_username)) {
|
||||
$e_username = pht('Required');
|
||||
$errors[] = pht('New username is required.');
|
||||
|
@ -50,12 +43,10 @@ final class PhabricatorPeopleRenameController
|
|||
if (!$errors) {
|
||||
try {
|
||||
id(new PhabricatorUserEditor())
|
||||
->setActor($admin)
|
||||
->setActor($viewer)
|
||||
->changeUsername($user, $v_username);
|
||||
|
||||
$new_uri = '/p/'.$v_username.'/';
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($new_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||
} catch (AphrontDuplicateKeyQueryException $ex) {
|
||||
$e_username = pht('Not Unique');
|
||||
$errors[] = pht('Another user already has that username.');
|
||||
|
@ -88,7 +79,7 @@ final class PhabricatorPeopleRenameController
|
|||
'password if necessary.');
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($admin)
|
||||
->setUser($viewer)
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel(pht('Old Username'))
|
||||
|
@ -114,9 +105,9 @@ final class PhabricatorPeopleRenameController
|
|||
->appendParagraph($inst4)
|
||||
->appendParagraph($inst5)
|
||||
->appendParagraph(null)
|
||||
->appendChild($form->buildLayoutView())
|
||||
->appendForm($form)
|
||||
->addSubmitButton(pht('Rename User'))
|
||||
->addCancelButton($profile_uri);
|
||||
->addCancelButton($done_uri);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ final class PhabricatorPeopleProfilePanelEngine
|
|||
extends PhabricatorProfilePanelEngine {
|
||||
|
||||
const PANEL_PROFILE = 'people.profile';
|
||||
const PANEL_MANAGE = 'people.manage';
|
||||
|
||||
protected function isPanelEngineConfigurable() {
|
||||
return false;
|
||||
|
@ -90,6 +91,10 @@ final class PhabricatorPeopleProfilePanelEngine
|
|||
->setPanelProperty('uri', $uri);
|
||||
}
|
||||
|
||||
$panels[] = $this->newPanel()
|
||||
->setBuiltinKey(self::PANEL_MANAGE)
|
||||
->setPanelKey(PhabricatorPeopleManageProfilePanel::PANELKEY);
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorPeopleManageProfilePanel
|
||||
extends PhabricatorProfilePanel {
|
||||
|
||||
const PANELKEY = 'people.manage';
|
||||
|
||||
public function getPanelTypeName() {
|
||||
return pht('Mangage User');
|
||||
}
|
||||
|
||||
private function getDefaultName() {
|
||||
return pht('Manage');
|
||||
}
|
||||
|
||||
public function getDisplayName(
|
||||
PhabricatorProfilePanelConfiguration $config) {
|
||||
$name = $config->getPanelProperty('name');
|
||||
|
||||
if (strlen($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return $this->getDefaultName();
|
||||
}
|
||||
|
||||
public function buildEditEngineFields(
|
||||
PhabricatorProfilePanelConfiguration $config) {
|
||||
return array(
|
||||
id(new PhabricatorTextEditField())
|
||||
->setKey('name')
|
||||
->setLabel(pht('Name'))
|
||||
->setPlaceholder($this->getDefaultName())
|
||||
->setValue($config->getPanelProperty('name')),
|
||||
);
|
||||
}
|
||||
|
||||
protected function newNavigationMenuItems(
|
||||
PhabricatorProfilePanelConfiguration $config) {
|
||||
|
||||
$user = $config->getProfileObject();
|
||||
$id = $user->getID();
|
||||
|
||||
$item = $this->newItem()
|
||||
->setHref("/people/manage/{$id}/")
|
||||
->setName($this->getDisplayName($config))
|
||||
->setIcon('fa-gears');
|
||||
|
||||
return array(
|
||||
$item,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue