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',
|
'PhabricatorPeopleLogSearchEngine' => 'applications/people/query/PhabricatorPeopleLogSearchEngine.php',
|
||||||
'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php',
|
'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php',
|
||||||
'PhabricatorPeopleMainMenuBarExtension' => 'applications/people/extension/PhabricatorPeopleMainMenuBarExtension.php',
|
'PhabricatorPeopleMainMenuBarExtension' => 'applications/people/extension/PhabricatorPeopleMainMenuBarExtension.php',
|
||||||
|
'PhabricatorPeopleManageProfilePanel' => 'applications/people/profilepanel/PhabricatorPeopleManageProfilePanel.php',
|
||||||
'PhabricatorPeopleNewController' => 'applications/people/controller/PhabricatorPeopleNewController.php',
|
'PhabricatorPeopleNewController' => 'applications/people/controller/PhabricatorPeopleNewController.php',
|
||||||
'PhabricatorPeopleNoOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleNoOwnerDatasource.php',
|
'PhabricatorPeopleNoOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleNoOwnerDatasource.php',
|
||||||
'PhabricatorPeopleOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleOwnerDatasource.php',
|
'PhabricatorPeopleOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleOwnerDatasource.php',
|
||||||
'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php',
|
'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php',
|
||||||
'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php',
|
'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php',
|
||||||
|
'PhabricatorPeopleProfileManageController' => 'applications/people/controller/PhabricatorPeopleProfileManageController.php',
|
||||||
'PhabricatorPeopleProfilePanelEngine' => 'applications/people/engine/PhabricatorPeopleProfilePanelEngine.php',
|
'PhabricatorPeopleProfilePanelEngine' => 'applications/people/engine/PhabricatorPeopleProfilePanelEngine.php',
|
||||||
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
|
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
|
||||||
'PhabricatorPeopleProfileViewController' => 'applications/people/controller/PhabricatorPeopleProfileViewController.php',
|
'PhabricatorPeopleProfileViewController' => 'applications/people/controller/PhabricatorPeopleProfileViewController.php',
|
||||||
|
@ -7114,11 +7116,13 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPeopleLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'PhabricatorPeopleLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController',
|
||||||
'PhabricatorPeopleMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension',
|
'PhabricatorPeopleMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension',
|
||||||
|
'PhabricatorPeopleManageProfilePanel' => 'PhabricatorProfilePanel',
|
||||||
'PhabricatorPeopleNewController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleNewController' => 'PhabricatorPeopleController',
|
||||||
'PhabricatorPeopleNoOwnerDatasource' => 'PhabricatorTypeaheadDatasource',
|
'PhabricatorPeopleNoOwnerDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'PhabricatorPeopleOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
'PhabricatorPeopleOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||||
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
|
||||||
'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleProfileController',
|
'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleProfileController',
|
||||||
|
'PhabricatorPeopleProfileManageController' => 'PhabricatorPeopleProfileController',
|
||||||
'PhabricatorPeopleProfilePanelEngine' => 'PhabricatorProfilePanelEngine',
|
'PhabricatorPeopleProfilePanelEngine' => 'PhabricatorProfilePanelEngine',
|
||||||
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleProfileController',
|
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleProfileController',
|
||||||
'PhabricatorPeopleProfileViewController' => 'PhabricatorPeopleProfileController',
|
'PhabricatorPeopleProfileViewController' => 'PhabricatorPeopleProfileController',
|
||||||
|
|
|
@ -62,6 +62,8 @@ final class PhabricatorPeopleApplication extends PhabricatorApplication {
|
||||||
'PhabricatorPeopleProfileEditController',
|
'PhabricatorPeopleProfileEditController',
|
||||||
'picture/(?P<id>[1-9]\d*)/' =>
|
'picture/(?P<id>[1-9]\d*)/' =>
|
||||||
'PhabricatorPeopleProfilePictureController',
|
'PhabricatorPeopleProfilePictureController',
|
||||||
|
'manage/(?P<id>[1-9]\d*)/' =>
|
||||||
|
'PhabricatorPeopleProfileManageController',
|
||||||
),
|
),
|
||||||
'/p/(?P<username>[\w._-]+)/' => array(
|
'/p/(?P<username>[\w._-]+)/' => array(
|
||||||
'' => 'PhabricatorPeopleProfileViewController',
|
'' => 'PhabricatorPeopleProfileViewController',
|
||||||
|
|
|
@ -3,28 +3,22 @@
|
||||||
final class PhabricatorPeopleDeleteController
|
final class PhabricatorPeopleDeleteController
|
||||||
extends PhabricatorPeopleController {
|
extends PhabricatorPeopleController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getUser();
|
||||||
public function willProcessRequest(array $data) {
|
$id = $request->getURIData('id');
|
||||||
$this->id = $data['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$admin = $request->getUser();
|
|
||||||
|
|
||||||
$user = id(new PhabricatorPeopleQuery())
|
$user = id(new PhabricatorPeopleQuery())
|
||||||
->setViewer($admin)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
$manage_uri = $this->getApplicationURI("manage/{$id}/");
|
||||||
|
|
||||||
if ($user->getPHID() == $admin->getPHID()) {
|
if ($user->getPHID() == $viewer->getPHID()) {
|
||||||
return $this->buildDeleteSelfResponse($profile_uri);
|
return $this->buildDeleteSelfResponse($manage_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
$str1 = pht(
|
$str1 = pht(
|
||||||
|
@ -47,7 +41,7 @@ final class PhabricatorPeopleDeleteController
|
||||||
$str4 = pht('To permanently destroy this user, run this command:');
|
$str4 = pht('To permanently destroy this user, run this command:');
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($admin)
|
->setUser($viewer)
|
||||||
->appendRemarkupInstructions(
|
->appendRemarkupInstructions(
|
||||||
csprintf(
|
csprintf(
|
||||||
" phabricator/ $ ./bin/remove destroy %R\n",
|
" phabricator/ $ ./bin/remove destroy %R\n",
|
||||||
|
@ -62,10 +56,10 @@ final class PhabricatorPeopleDeleteController
|
||||||
->appendParagraph($str3)
|
->appendParagraph($str3)
|
||||||
->appendParagraph($str4)
|
->appendParagraph($str4)
|
||||||
->appendChild($form->buildLayoutView())
|
->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()
|
return $this->newDialog()
|
||||||
->setTitle(pht('You Shall Journey No Farther'))
|
->setTitle(pht('You Shall Journey No Farther'))
|
||||||
->appendParagraph(
|
->appendParagraph(
|
||||||
|
@ -73,7 +67,7 @@ final class PhabricatorPeopleDeleteController
|
||||||
'As you stare into the gaping maw of the abyss, something '.
|
'As you stare into the gaping maw of the abyss, something '.
|
||||||
'holds you back.'))
|
'holds you back.'))
|
||||||
->appendParagraph(pht('You can not delete your own account.'))
|
->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
|
final class PhabricatorPeopleDisableController
|
||||||
extends PhabricatorPeopleController {
|
extends PhabricatorPeopleController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
private $via;
|
$viewer = $this->getViewer();
|
||||||
|
$id = $request->getURIData('id');
|
||||||
public function willProcessRequest(array $data) {
|
$via = $request->getURIData('id');
|
||||||
$this->id = $data['id'];
|
|
||||||
$this->via = $data['via'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$admin = $request->getUser();
|
|
||||||
|
|
||||||
$user = id(new PhabricatorPeopleQuery())
|
$user = id(new PhabricatorPeopleQuery())
|
||||||
->setViewer($admin)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
|
@ -27,16 +20,16 @@ final class PhabricatorPeopleDisableController
|
||||||
// on profiles and also via the "X" action on the approval queue. We do
|
// 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.
|
// things slightly differently depending on the context the actor is in.
|
||||||
|
|
||||||
$is_disapprove = ($this->via == 'disapprove');
|
$is_disapprove = ($via == 'disapprove');
|
||||||
if ($is_disapprove) {
|
if ($is_disapprove) {
|
||||||
$done_uri = $this->getApplicationURI('query/approval/');
|
$done_uri = $this->getApplicationURI('query/approval/');
|
||||||
$should_disable = true;
|
$should_disable = true;
|
||||||
} else {
|
} else {
|
||||||
$done_uri = '/p/'.$user->getUsername().'/';
|
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||||
$should_disable = !$user->getIsDisabled();
|
$should_disable = !$user->getIsDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($admin->getPHID() == $user->getPHID()) {
|
if ($viewer->getPHID() == $user->getPHID()) {
|
||||||
return $this->newDialog()
|
return $this->newDialog()
|
||||||
->setTitle(pht('Something Stays Your Hand'))
|
->setTitle(pht('Something Stays Your Hand'))
|
||||||
->appendParagraph(
|
->appendParagraph(
|
||||||
|
@ -47,7 +40,7 @@ final class PhabricatorPeopleDisableController
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
id(new PhabricatorUserEditor())
|
id(new PhabricatorUserEditor())
|
||||||
->setActor($admin)
|
->setActor($viewer)
|
||||||
->disableUser($user, $should_disable);
|
->disableUser($user, $should_disable);
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||||
|
|
|
@ -3,47 +3,41 @@
|
||||||
final class PhabricatorPeopleEmpowerController
|
final class PhabricatorPeopleEmpowerController
|
||||||
extends PhabricatorPeopleController {
|
extends PhabricatorPeopleController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
public function willProcessRequest(array $data) {
|
$id = $request->getURIData('id');
|
||||||
$this->id = $data['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$admin = $request->getUser();
|
|
||||||
|
|
||||||
$user = id(new PhabricatorPeopleQuery())
|
$user = id(new PhabricatorPeopleQuery())
|
||||||
->setViewer($admin)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||||
|
|
||||||
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
|
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
|
||||||
$admin,
|
$viewer,
|
||||||
$request,
|
$request,
|
||||||
$profile_uri);
|
$done_uri);
|
||||||
|
|
||||||
if ($user->getPHID() == $admin->getPHID()) {
|
if ($user->getPHID() == $viewer->getPHID()) {
|
||||||
return $this->newDialog()
|
return $this->newDialog()
|
||||||
->setTitle(pht('Your Way is Blocked'))
|
->setTitle(pht('Your Way is Blocked'))
|
||||||
->appendParagraph(
|
->appendParagraph(
|
||||||
pht(
|
pht(
|
||||||
'After a time, your efforts fail. You can not adjust your own '.
|
'After a time, your efforts fail. You can not adjust your own '.
|
||||||
'status as an administrator.'))
|
'status as an administrator.'))
|
||||||
->addCancelButton($profile_uri, pht('Accept Fate'));
|
->addCancelButton($done_uri, pht('Accept Fate'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
id(new PhabricatorUserEditor())
|
id(new PhabricatorUserEditor())
|
||||||
->setActor($admin)
|
->setActor($viewer)
|
||||||
->makeAdminUser($user, !$user->getIsAdmin());
|
->makeAdminUser($user, !$user->getIsAdmin());
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($profile_uri);
|
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->getIsAdmin()) {
|
if ($user->getIsAdmin()) {
|
||||||
|
@ -69,7 +63,7 @@ final class PhabricatorPeopleEmpowerController
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->setShortTitle($short)
|
->setShortTitle($short)
|
||||||
->appendParagraph($body)
|
->appendParagraph($body)
|
||||||
->addCancelButton($profile_uri)
|
->addCancelButton($done_uri)
|
||||||
->addSubmitButton($submit);
|
->addSubmitButton($submit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ final class PhabricatorPeopleProfileEditController
|
||||||
|
|
||||||
$this->setUser($user);
|
$this->setUser($user);
|
||||||
|
|
||||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||||
|
|
||||||
$field_list = PhabricatorCustomField::getObjectFields(
|
$field_list = PhabricatorCustomField::getObjectFields(
|
||||||
$user,
|
$user,
|
||||||
|
@ -46,7 +46,7 @@ final class PhabricatorPeopleProfileEditController
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$editor->applyTransactions($user, $xactions);
|
$editor->applyTransactions($user, $xactions);
|
||||||
return id(new AphrontRedirectResponse())->setURI($profile_uri);
|
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||||
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
||||||
$validation_exception = $ex;
|
$validation_exception = $ex;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ final class PhabricatorPeopleProfileEditController
|
||||||
$form
|
$form
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->addCancelButton($profile_uri)
|
->addCancelButton($done_uri)
|
||||||
->setValue(pht('Save Profile')));
|
->setValue(pht('Save Profile')));
|
||||||
|
|
||||||
$allow_public = PhabricatorEnv::getEnvConfig('policy.allow-public');
|
$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);
|
$this->setUser($user);
|
||||||
|
|
||||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||||
|
|
||||||
$supported_formats = PhabricatorFile::getTransformableImageFormats();
|
$supported_formats = PhabricatorFile::getTransformableImageFormats();
|
||||||
$e_file = true;
|
$e_file = true;
|
||||||
|
@ -76,7 +76,7 @@ final class PhabricatorPeopleProfilePictureController
|
||||||
$xformed->attachToObject($user->getPHID());
|
$xformed->attachToObject($user->getPHID());
|
||||||
}
|
}
|
||||||
$user->save();
|
$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))))
|
pht('Supported formats: %s', implode(', ', $supported_formats))))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->addCancelButton($profile_uri)
|
->addCancelButton($done_uri)
|
||||||
->setValue(pht('Upload Picture')));
|
->setValue(pht('Upload Picture')));
|
||||||
|
|
||||||
$upload_box = id(new PHUIObjectBoxView())
|
$upload_box = id(new PHUIObjectBoxView())
|
||||||
|
|
|
@ -41,27 +41,6 @@ final class PhabricatorPeopleProfileViewController
|
||||||
->setObject($user)
|
->setObject($user)
|
||||||
->setUser($viewer);
|
->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';
|
$class = 'PhabricatorConpherenceApplication';
|
||||||
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
||||||
$href = id(new PhutilURI('/conpherence/new/'))
|
$href = id(new PhutilURI('/conpherence/new/'))
|
||||||
|
@ -78,79 +57,10 @@ final class PhabricatorPeopleProfileViewController
|
||||||
->setHref($href));
|
->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);
|
$properties = $this->buildPropertyView($user, $actions);
|
||||||
$name = $user->getUsername();
|
$name = $user->getUsername();
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
|
||||||
$crumbs->addTextCrumb($name);
|
|
||||||
|
|
||||||
$object_box = id(new PHUIObjectBoxView())
|
$object_box = id(new PHUIObjectBoxView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->addPropertyList($properties);
|
->addPropertyList($properties);
|
||||||
|
@ -225,8 +135,9 @@ final class PhabricatorPeopleProfileViewController
|
||||||
$box = id(new PHUIObjectBoxView())
|
$box = id(new PHUIObjectBoxView())
|
||||||
->setHeaderText(pht('Badges'))
|
->setHeaderText(pht('Badges'))
|
||||||
->appendChild($flex);
|
->appendChild($flex);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $box;
|
return $box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,30 +3,24 @@
|
||||||
final class PhabricatorPeopleRenameController
|
final class PhabricatorPeopleRenameController
|
||||||
extends PhabricatorPeopleController {
|
extends PhabricatorPeopleController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
public function willProcessRequest(array $data) {
|
$id = $request->getURIData('id');
|
||||||
$this->id = $data['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$admin = $request->getUser();
|
|
||||||
|
|
||||||
$user = id(new PhabricatorPeopleQuery())
|
$user = id(new PhabricatorPeopleQuery())
|
||||||
->setViewer($admin)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile_uri = '/p/'.$user->getUsername().'/';
|
$done_uri = $this->getApplicationURI("manage/{$id}/");
|
||||||
|
|
||||||
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
|
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
|
||||||
$admin,
|
$viewer,
|
||||||
$request,
|
$request,
|
||||||
$profile_uri);
|
$done_uri);
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
|
@ -35,7 +29,6 @@ final class PhabricatorPeopleRenameController
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$v_username = $request->getStr('username');
|
$v_username = $request->getStr('username');
|
||||||
|
|
||||||
|
|
||||||
if (!strlen($v_username)) {
|
if (!strlen($v_username)) {
|
||||||
$e_username = pht('Required');
|
$e_username = pht('Required');
|
||||||
$errors[] = pht('New username is required.');
|
$errors[] = pht('New username is required.');
|
||||||
|
@ -50,12 +43,10 @@ final class PhabricatorPeopleRenameController
|
||||||
if (!$errors) {
|
if (!$errors) {
|
||||||
try {
|
try {
|
||||||
id(new PhabricatorUserEditor())
|
id(new PhabricatorUserEditor())
|
||||||
->setActor($admin)
|
->setActor($viewer)
|
||||||
->changeUsername($user, $v_username);
|
->changeUsername($user, $v_username);
|
||||||
|
|
||||||
$new_uri = '/p/'.$v_username.'/';
|
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($new_uri);
|
|
||||||
} catch (AphrontDuplicateKeyQueryException $ex) {
|
} catch (AphrontDuplicateKeyQueryException $ex) {
|
||||||
$e_username = pht('Not Unique');
|
$e_username = pht('Not Unique');
|
||||||
$errors[] = pht('Another user already has that username.');
|
$errors[] = pht('Another user already has that username.');
|
||||||
|
@ -88,7 +79,7 @@ final class PhabricatorPeopleRenameController
|
||||||
'password if necessary.');
|
'password if necessary.');
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($admin)
|
->setUser($viewer)
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormStaticControl())
|
id(new AphrontFormStaticControl())
|
||||||
->setLabel(pht('Old Username'))
|
->setLabel(pht('Old Username'))
|
||||||
|
@ -114,9 +105,9 @@ final class PhabricatorPeopleRenameController
|
||||||
->appendParagraph($inst4)
|
->appendParagraph($inst4)
|
||||||
->appendParagraph($inst5)
|
->appendParagraph($inst5)
|
||||||
->appendParagraph(null)
|
->appendParagraph(null)
|
||||||
->appendChild($form->buildLayoutView())
|
->appendForm($form)
|
||||||
->addSubmitButton(pht('Rename User'))
|
->addSubmitButton(pht('Rename User'))
|
||||||
->addCancelButton($profile_uri);
|
->addCancelButton($done_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ final class PhabricatorPeopleProfilePanelEngine
|
||||||
extends PhabricatorProfilePanelEngine {
|
extends PhabricatorProfilePanelEngine {
|
||||||
|
|
||||||
const PANEL_PROFILE = 'people.profile';
|
const PANEL_PROFILE = 'people.profile';
|
||||||
|
const PANEL_MANAGE = 'people.manage';
|
||||||
|
|
||||||
protected function isPanelEngineConfigurable() {
|
protected function isPanelEngineConfigurable() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -90,6 +91,10 @@ final class PhabricatorPeopleProfilePanelEngine
|
||||||
->setPanelProperty('uri', $uri);
|
->setPanelProperty('uri', $uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$panels[] = $this->newPanel()
|
||||||
|
->setBuiltinKey(self::PANEL_MANAGE)
|
||||||
|
->setPanelKey(PhabricatorPeopleManageProfilePanel::PANELKEY);
|
||||||
|
|
||||||
return $panels;
|
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