@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+306 -173
+4
src/__phutil_library_map__.php
··· 2747 2747 'PhabricatorPeopleLogSearchEngine' => 'applications/people/query/PhabricatorPeopleLogSearchEngine.php', 2748 2748 'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php', 2749 2749 'PhabricatorPeopleMainMenuBarExtension' => 'applications/people/extension/PhabricatorPeopleMainMenuBarExtension.php', 2750 + 'PhabricatorPeopleManageProfilePanel' => 'applications/people/profilepanel/PhabricatorPeopleManageProfilePanel.php', 2750 2751 'PhabricatorPeopleNewController' => 'applications/people/controller/PhabricatorPeopleNewController.php', 2751 2752 'PhabricatorPeopleNoOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleNoOwnerDatasource.php', 2752 2753 'PhabricatorPeopleOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleOwnerDatasource.php', 2753 2754 'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php', 2754 2755 'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php', 2756 + 'PhabricatorPeopleProfileManageController' => 'applications/people/controller/PhabricatorPeopleProfileManageController.php', 2755 2757 'PhabricatorPeopleProfilePanelEngine' => 'applications/people/engine/PhabricatorPeopleProfilePanelEngine.php', 2756 2758 'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php', 2757 2759 'PhabricatorPeopleProfileViewController' => 'applications/people/controller/PhabricatorPeopleProfileViewController.php', ··· 7114 7116 'PhabricatorPeopleLogSearchEngine' => 'PhabricatorApplicationSearchEngine', 7115 7117 'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController', 7116 7118 'PhabricatorPeopleMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension', 7119 + 'PhabricatorPeopleManageProfilePanel' => 'PhabricatorProfilePanel', 7117 7120 'PhabricatorPeopleNewController' => 'PhabricatorPeopleController', 7118 7121 'PhabricatorPeopleNoOwnerDatasource' => 'PhabricatorTypeaheadDatasource', 7119 7122 'PhabricatorPeopleOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 7120 7123 'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController', 7121 7124 'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleProfileController', 7125 + 'PhabricatorPeopleProfileManageController' => 'PhabricatorPeopleProfileController', 7122 7126 'PhabricatorPeopleProfilePanelEngine' => 'PhabricatorProfilePanelEngine', 7123 7127 'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleProfileController', 7124 7128 'PhabricatorPeopleProfileViewController' => 'PhabricatorPeopleProfileController',
+2
src/applications/people/application/PhabricatorPeopleApplication.php
··· 62 62 'PhabricatorPeopleProfileEditController', 63 63 'picture/(?P<id>[1-9]\d*)/' => 64 64 'PhabricatorPeopleProfilePictureController', 65 + 'manage/(?P<id>[1-9]\d*)/' => 66 + 'PhabricatorPeopleProfileManageController', 65 67 ), 66 68 '/p/(?P<username>[\w._-]+)/' => array( 67 69 '' => 'PhabricatorPeopleProfileViewController',
+12 -18
src/applications/people/controller/PhabricatorPeopleDeleteController.php
··· 3 3 final class PhabricatorPeopleDeleteController 4 4 extends PhabricatorPeopleController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $admin = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getUser(); 8 + $id = $request->getURIData('id'); 15 9 16 10 $user = id(new PhabricatorPeopleQuery()) 17 - ->setViewer($admin) 18 - ->withIDs(array($this->id)) 11 + ->setViewer($viewer) 12 + ->withIDs(array($id)) 19 13 ->executeOne(); 20 14 if (!$user) { 21 15 return new Aphront404Response(); 22 16 } 23 17 24 - $profile_uri = '/p/'.$user->getUsername().'/'; 18 + $manage_uri = $this->getApplicationURI("manage/{$id}/"); 25 19 26 - if ($user->getPHID() == $admin->getPHID()) { 27 - return $this->buildDeleteSelfResponse($profile_uri); 20 + if ($user->getPHID() == $viewer->getPHID()) { 21 + return $this->buildDeleteSelfResponse($manage_uri); 28 22 } 29 23 30 24 $str1 = pht( ··· 47 41 $str4 = pht('To permanently destroy this user, run this command:'); 48 42 49 43 $form = id(new AphrontFormView()) 50 - ->setUser($admin) 44 + ->setUser($viewer) 51 45 ->appendRemarkupInstructions( 52 46 csprintf( 53 47 " phabricator/ $ ./bin/remove destroy %R\n", ··· 62 56 ->appendParagraph($str3) 63 57 ->appendParagraph($str4) 64 58 ->appendChild($form->buildLayoutView()) 65 - ->addCancelButton($profile_uri, pht('Close')); 59 + ->addCancelButton($manage_uri, pht('Close')); 66 60 } 67 61 68 - private function buildDeleteSelfResponse($profile_uri) { 62 + private function buildDeleteSelfResponse($cancel_uri) { 69 63 return $this->newDialog() 70 64 ->setTitle(pht('You Shall Journey No Farther')) 71 65 ->appendParagraph( ··· 73 67 'As you stare into the gaping maw of the abyss, something '. 74 68 'holds you back.')) 75 69 ->appendParagraph(pht('You can not delete your own account.')) 76 - ->addCancelButton($profile_uri, pht('Turn Back')); 70 + ->addCancelButton($cancel_uri, pht('Turn Back')); 77 71 } 78 72 79 73
+10 -17
src/applications/people/controller/PhabricatorPeopleDisableController.php
··· 3 3 final class PhabricatorPeopleDisableController 4 4 extends PhabricatorPeopleController { 5 5 6 - private $id; 7 - private $via; 8 - 9 - public function willProcessRequest(array $data) { 10 - $this->id = $data['id']; 11 - $this->via = $data['via']; 12 - } 13 - 14 - public function processRequest() { 15 - $request = $this->getRequest(); 16 - $admin = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $this->getViewer(); 8 + $id = $request->getURIData('id'); 9 + $via = $request->getURIData('id'); 17 10 18 11 $user = id(new PhabricatorPeopleQuery()) 19 - ->setViewer($admin) 20 - ->withIDs(array($this->id)) 12 + ->setViewer($viewer) 13 + ->withIDs(array($id)) 21 14 ->executeOne(); 22 15 if (!$user) { 23 16 return new Aphront404Response(); ··· 27 20 // on profiles and also via the "X" action on the approval queue. We do 28 21 // things slightly differently depending on the context the actor is in. 29 22 30 - $is_disapprove = ($this->via == 'disapprove'); 23 + $is_disapprove = ($via == 'disapprove'); 31 24 if ($is_disapprove) { 32 25 $done_uri = $this->getApplicationURI('query/approval/'); 33 26 $should_disable = true; 34 27 } else { 35 - $done_uri = '/p/'.$user->getUsername().'/'; 28 + $done_uri = $this->getApplicationURI("manage/{$id}/"); 36 29 $should_disable = !$user->getIsDisabled(); 37 30 } 38 31 39 - if ($admin->getPHID() == $user->getPHID()) { 32 + if ($viewer->getPHID() == $user->getPHID()) { 40 33 return $this->newDialog() 41 34 ->setTitle(pht('Something Stays Your Hand')) 42 35 ->appendParagraph( ··· 47 40 48 41 if ($request->isFormPost()) { 49 42 id(new PhabricatorUserEditor()) 50 - ->setActor($admin) 43 + ->setActor($viewer) 51 44 ->disableUser($user, $should_disable); 52 45 53 46 return id(new AphrontRedirectResponse())->setURI($done_uri);
+13 -19
src/applications/people/controller/PhabricatorPeopleEmpowerController.php
··· 3 3 final class PhabricatorPeopleEmpowerController 4 4 extends PhabricatorPeopleController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $admin = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $this->getViewer(); 8 + $id = $request->getURIData('id'); 15 9 16 10 $user = id(new PhabricatorPeopleQuery()) 17 - ->setViewer($admin) 18 - ->withIDs(array($this->id)) 11 + ->setViewer($viewer) 12 + ->withIDs(array($id)) 19 13 ->executeOne(); 20 14 if (!$user) { 21 15 return new Aphront404Response(); 22 16 } 23 17 24 - $profile_uri = '/p/'.$user->getUsername().'/'; 18 + $done_uri = $this->getApplicationURI("manage/{$id}/"); 25 19 26 20 id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( 27 - $admin, 21 + $viewer, 28 22 $request, 29 - $profile_uri); 23 + $done_uri); 30 24 31 - if ($user->getPHID() == $admin->getPHID()) { 25 + if ($user->getPHID() == $viewer->getPHID()) { 32 26 return $this->newDialog() 33 27 ->setTitle(pht('Your Way is Blocked')) 34 28 ->appendParagraph( 35 29 pht( 36 30 'After a time, your efforts fail. You can not adjust your own '. 37 31 'status as an administrator.')) 38 - ->addCancelButton($profile_uri, pht('Accept Fate')); 32 + ->addCancelButton($done_uri, pht('Accept Fate')); 39 33 } 40 34 41 35 if ($request->isFormPost()) { 42 36 id(new PhabricatorUserEditor()) 43 - ->setActor($admin) 37 + ->setActor($viewer) 44 38 ->makeAdminUser($user, !$user->getIsAdmin()); 45 39 46 - return id(new AphrontRedirectResponse())->setURI($profile_uri); 40 + return id(new AphrontRedirectResponse())->setURI($done_uri); 47 41 } 48 42 49 43 if ($user->getIsAdmin()) { ··· 69 63 ->setTitle($title) 70 64 ->setShortTitle($short) 71 65 ->appendParagraph($body) 72 - ->addCancelButton($profile_uri) 66 + ->addCancelButton($done_uri) 73 67 ->addSubmitButton($submit); 74 68 } 75 69
+3 -3
src/applications/people/controller/PhabricatorPeopleProfileEditController.php
··· 23 23 24 24 $this->setUser($user); 25 25 26 - $profile_uri = '/p/'.$user->getUsername().'/'; 26 + $done_uri = $this->getApplicationURI("manage/{$id}/"); 27 27 28 28 $field_list = PhabricatorCustomField::getObjectFields( 29 29 $user, ··· 46 46 47 47 try { 48 48 $editor->applyTransactions($user, $xactions); 49 - return id(new AphrontRedirectResponse())->setURI($profile_uri); 49 + return id(new AphrontRedirectResponse())->setURI($done_uri); 50 50 } catch (PhabricatorApplicationTransactionValidationException $ex) { 51 51 $validation_exception = $ex; 52 52 } ··· 61 61 $form 62 62 ->appendChild( 63 63 id(new AphrontFormSubmitControl()) 64 - ->addCancelButton($profile_uri) 64 + ->addCancelButton($done_uri) 65 65 ->setValue(pht('Save Profile'))); 66 66 67 67 $allow_public = PhabricatorEnv::getEnvConfig('policy.allow-public');
+185
src/applications/people/controller/PhabricatorPeopleProfileManageController.php
··· 1 + <?php 2 + 3 + final class PhabricatorPeopleProfileManageController 4 + extends PhabricatorPeopleProfileController { 5 + 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $this->getViewer(); 12 + $id = $request->getURIData('id'); 13 + 14 + $user = id(new PhabricatorPeopleQuery()) 15 + ->setViewer($viewer) 16 + ->withIDs(array($id)) 17 + ->needProfile(true) 18 + ->needProfileImage(true) 19 + ->executeOne(); 20 + if (!$user) { 21 + return new Aphront404Response(); 22 + } 23 + 24 + $this->setUser($user); 25 + 26 + $profile = $user->loadUserProfile(); 27 + $picture = $user->getProfileImageURI(); 28 + 29 + $profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon()); 30 + $profile_icon = id(new PHUIIconView()) 31 + ->setIconFont($profile_icon.' grey'); 32 + $profile_title = $profile->getDisplayTitle(); 33 + 34 + $header = id(new PHUIHeaderView()) 35 + ->setHeader($user->getFullName()) 36 + ->setSubheader(array($profile_icon, $profile_title)) 37 + ->setImage($picture); 38 + 39 + $actions = $this->buildActionList($user); 40 + $properties = $this->buildPropertyView($user); 41 + $properties->setActionList($actions); 42 + $name = $user->getUsername(); 43 + 44 + $object_box = id(new PHUIObjectBoxView()) 45 + ->setHeader($header) 46 + ->addPropertyList($properties); 47 + 48 + $nav = $this->getProfileMenu(); 49 + $nav->selectFilter(PhabricatorPeopleProfilePanelEngine::PANEL_MANAGE); 50 + 51 + $timeline = $this->buildTransactionTimeline( 52 + $user, 53 + new PhabricatorPeopleTransactionQuery()); 54 + $timeline->setShouldTerminate(true); 55 + 56 + $crumbs = $this->buildApplicationCrumbs(); 57 + $crumbs->addTextCrumb(pht('Manage')); 58 + 59 + return $this->newPage() 60 + ->setTitle( 61 + array( 62 + pht('Manage User'), 63 + $user->getUsername(), 64 + )) 65 + ->setNavigation($nav) 66 + ->setCrumbs($crumbs) 67 + ->appendChild( 68 + array( 69 + $object_box, 70 + $timeline, 71 + )); 72 + } 73 + 74 + private function buildPropertyView(PhabricatorUser $user) { 75 + 76 + $viewer = $this->getRequest()->getUser(); 77 + $view = id(new PHUIPropertyListView()) 78 + ->setUser($viewer) 79 + ->setObject($user); 80 + 81 + return $view; 82 + } 83 + 84 + private function buildActionList(PhabricatorUser $user) { 85 + $viewer = $this->getViewer(); 86 + 87 + $actions = id(new PhabricatorActionListView()) 88 + ->setUser($viewer); 89 + 90 + $can_edit = PhabricatorPolicyFilter::hasCapability( 91 + $viewer, 92 + $user, 93 + PhabricatorPolicyCapability::CAN_EDIT); 94 + 95 + $actions->addAction( 96 + id(new PhabricatorActionView()) 97 + ->setIcon('fa-pencil') 98 + ->setName(pht('Edit Profile')) 99 + ->setHref($this->getApplicationURI('editprofile/'.$user->getID().'/')) 100 + ->setDisabled(!$can_edit) 101 + ->setWorkflow(!$can_edit)); 102 + 103 + $actions->addAction( 104 + id(new PhabricatorActionView()) 105 + ->setIcon('fa-picture-o') 106 + ->setName(pht('Edit Profile Picture')) 107 + ->setHref($this->getApplicationURI('picture/'.$user->getID().'/')) 108 + ->setDisabled(!$can_edit) 109 + ->setWorkflow(!$can_edit)); 110 + 111 + $actions->addAction( 112 + id(new PhabricatorActionView()) 113 + ->setIcon('fa-wrench') 114 + ->setName(pht('Edit Settings')) 115 + ->setDisabled(!$can_edit) 116 + ->setWorkflow(!$can_edit) 117 + ->setHref('/settings/'.$user->getID().'/')); 118 + 119 + if ($user->getIsAdmin()) { 120 + $empower_icon = 'fa-arrow-circle-o-down'; 121 + $empower_name = pht('Remove Administrator'); 122 + } else { 123 + $empower_icon = 'fa-arrow-circle-o-up'; 124 + $empower_name = pht('Make Administrator'); 125 + } 126 + 127 + $is_admin = $viewer->getIsAdmin(); 128 + $is_self = ($user->getPHID() === $viewer->getPHID()); 129 + $can_admin = ($is_admin && !$is_self); 130 + 131 + $actions->addAction( 132 + id(new PhabricatorActionView()) 133 + ->setIcon($empower_icon) 134 + ->setName($empower_name) 135 + ->setDisabled(!$can_admin) 136 + ->setWorkflow(true) 137 + ->setHref($this->getApplicationURI('empower/'.$user->getID().'/'))); 138 + 139 + $actions->addAction( 140 + id(new PhabricatorActionView()) 141 + ->setIcon('fa-tag') 142 + ->setName(pht('Change Username')) 143 + ->setDisabled(!$is_admin) 144 + ->setWorkflow(true) 145 + ->setHref($this->getApplicationURI('rename/'.$user->getID().'/'))); 146 + 147 + if ($user->getIsDisabled()) { 148 + $disable_icon = 'fa-check-circle-o'; 149 + $disable_name = pht('Enable User'); 150 + } else { 151 + $disable_icon = 'fa-ban'; 152 + $disable_name = pht('Disable User'); 153 + } 154 + 155 + $actions->addAction( 156 + id(new PhabricatorActionView()) 157 + ->setIcon($disable_icon) 158 + ->setName($disable_name) 159 + ->setDisabled(!$can_admin) 160 + ->setWorkflow(true) 161 + ->setHref($this->getApplicationURI('disable/'.$user->getID().'/'))); 162 + 163 + $actions->addAction( 164 + id(new PhabricatorActionView()) 165 + ->setIcon('fa-times') 166 + ->setName(pht('Delete User')) 167 + ->setDisabled(!$can_admin) 168 + ->setWorkflow(true) 169 + ->setHref($this->getApplicationURI('delete/'.$user->getID().'/'))); 170 + 171 + $can_welcome = ($is_admin && $user->canEstablishWebSessions()); 172 + 173 + $actions->addAction( 174 + id(new PhabricatorActionView()) 175 + ->setIcon('fa-envelope') 176 + ->setName(pht('Send Welcome Email')) 177 + ->setWorkflow(true) 178 + ->setDisabled(!$can_welcome) 179 + ->setHref($this->getApplicationURI('welcome/'.$user->getID().'/'))); 180 + 181 + return $actions; 182 + } 183 + 184 + 185 + }
+3 -3
src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
··· 23 23 24 24 $this->setUser($user); 25 25 26 - $profile_uri = '/p/'.$user->getUsername().'/'; 26 + $done_uri = $this->getApplicationURI("manage/{$id}/"); 27 27 28 28 $supported_formats = PhabricatorFile::getTransformableImageFormats(); 29 29 $e_file = true; ··· 76 76 $xformed->attachToObject($user->getPHID()); 77 77 } 78 78 $user->save(); 79 - return id(new AphrontRedirectResponse())->setURI($profile_uri); 79 + return id(new AphrontRedirectResponse())->setURI($done_uri); 80 80 } 81 81 } 82 82 ··· 241 241 pht('Supported formats: %s', implode(', ', $supported_formats)))) 242 242 ->appendChild( 243 243 id(new AphrontFormSubmitControl()) 244 - ->addCancelButton($profile_uri) 244 + ->addCancelButton($done_uri) 245 245 ->setValue(pht('Upload Picture'))); 246 246 247 247 $upload_box = id(new PHUIObjectBoxView())
+2 -91
src/applications/people/controller/PhabricatorPeopleProfileViewController.php
··· 41 41 ->setObject($user) 42 42 ->setUser($viewer); 43 43 44 - $can_edit = PhabricatorPolicyFilter::hasCapability( 45 - $viewer, 46 - $user, 47 - PhabricatorPolicyCapability::CAN_EDIT); 48 - 49 - $actions->addAction( 50 - id(new PhabricatorActionView()) 51 - ->setIcon('fa-pencil') 52 - ->setName(pht('Edit Profile')) 53 - ->setHref($this->getApplicationURI('editprofile/'.$user->getID().'/')) 54 - ->setDisabled(!$can_edit) 55 - ->setWorkflow(!$can_edit)); 56 - 57 - $actions->addAction( 58 - id(new PhabricatorActionView()) 59 - ->setIcon('fa-picture-o') 60 - ->setName(pht('Edit Profile Picture')) 61 - ->setHref($this->getApplicationURI('picture/'.$user->getID().'/')) 62 - ->setDisabled(!$can_edit) 63 - ->setWorkflow(!$can_edit)); 64 - 65 44 $class = 'PhabricatorConpherenceApplication'; 66 45 if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { 67 46 $href = id(new PhutilURI('/conpherence/new/')) ··· 78 57 ->setHref($href)); 79 58 } 80 59 81 - if ($viewer->getIsAdmin()) { 82 - $actions->addAction( 83 - id(new PhabricatorActionView()) 84 - ->setIcon('fa-wrench') 85 - ->setName(pht('Edit Settings')) 86 - ->setDisabled(!$can_edit) 87 - ->setWorkflow(!$can_edit) 88 - ->setHref('/settings/'.$user->getID().'/')); 89 - 90 - if ($user->getIsAdmin()) { 91 - $empower_icon = 'fa-arrow-circle-o-down'; 92 - $empower_name = pht('Remove Administrator'); 93 - } else { 94 - $empower_icon = 'fa-arrow-circle-o-up'; 95 - $empower_name = pht('Make Administrator'); 96 - } 97 - 98 - $actions->addAction( 99 - id(new PhabricatorActionView()) 100 - ->setIcon($empower_icon) 101 - ->setName($empower_name) 102 - ->setDisabled(($user->getPHID() == $viewer->getPHID())) 103 - ->setWorkflow(true) 104 - ->setHref($this->getApplicationURI('empower/'.$user->getID().'/'))); 105 - 106 - $actions->addAction( 107 - id(new PhabricatorActionView()) 108 - ->setIcon('fa-tag') 109 - ->setName(pht('Change Username')) 110 - ->setWorkflow(true) 111 - ->setHref($this->getApplicationURI('rename/'.$user->getID().'/'))); 112 - 113 - if ($user->getIsDisabled()) { 114 - $disable_icon = 'fa-check-circle-o'; 115 - $disable_name = pht('Enable User'); 116 - } else { 117 - $disable_icon = 'fa-ban'; 118 - $disable_name = pht('Disable User'); 119 - } 120 - 121 - $actions->addAction( 122 - id(new PhabricatorActionView()) 123 - ->setIcon($disable_icon) 124 - ->setName($disable_name) 125 - ->setDisabled(($user->getPHID() == $viewer->getPHID())) 126 - ->setWorkflow(true) 127 - ->setHref($this->getApplicationURI('disable/'.$user->getID().'/'))); 128 - 129 - $actions->addAction( 130 - id(new PhabricatorActionView()) 131 - ->setIcon('fa-times') 132 - ->setName(pht('Delete User')) 133 - ->setDisabled(($user->getPHID() == $viewer->getPHID())) 134 - ->setWorkflow(true) 135 - ->setHref($this->getApplicationURI('delete/'.$user->getID().'/'))); 136 - 137 - $can_welcome = $user->canEstablishWebSessions(); 138 - 139 - $actions->addAction( 140 - id(new PhabricatorActionView()) 141 - ->setIcon('fa-envelope') 142 - ->setName(pht('Send Welcome Email')) 143 - ->setWorkflow(true) 144 - ->setDisabled(!$can_welcome) 145 - ->setHref($this->getApplicationURI('welcome/'.$user->getID().'/'))); 146 - } 147 60 148 61 $properties = $this->buildPropertyView($user, $actions); 149 62 $name = $user->getUsername(); 150 - 151 - $crumbs = $this->buildApplicationCrumbs(); 152 - $crumbs->addTextCrumb($name); 153 63 154 64 $object_box = id(new PHUIObjectBoxView()) 155 65 ->setHeader($header) ··· 225 135 $box = id(new PHUIObjectBoxView()) 226 136 ->setHeaderText(pht('Badges')) 227 137 ->appendChild($flex); 228 - } 229 138 } 139 + } 140 + 230 141 return $box; 231 142 } 232 143
+13 -22
src/applications/people/controller/PhabricatorPeopleRenameController.php
··· 3 3 final class PhabricatorPeopleRenameController 4 4 extends PhabricatorPeopleController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $admin = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $this->getViewer(); 8 + $id = $request->getURIData('id'); 15 9 16 10 $user = id(new PhabricatorPeopleQuery()) 17 - ->setViewer($admin) 18 - ->withIDs(array($this->id)) 11 + ->setViewer($viewer) 12 + ->withIDs(array($id)) 19 13 ->executeOne(); 20 14 if (!$user) { 21 15 return new Aphront404Response(); 22 16 } 23 17 24 - $profile_uri = '/p/'.$user->getUsername().'/'; 18 + $done_uri = $this->getApplicationURI("manage/{$id}/"); 25 19 26 20 id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( 27 - $admin, 21 + $viewer, 28 22 $request, 29 - $profile_uri); 23 + $done_uri); 30 24 31 25 $errors = array(); 32 26 ··· 34 28 $e_username = true; 35 29 if ($request->isFormPost()) { 36 30 $v_username = $request->getStr('username'); 37 - 38 31 39 32 if (!strlen($v_username)) { 40 33 $e_username = pht('Required'); ··· 50 43 if (!$errors) { 51 44 try { 52 45 id(new PhabricatorUserEditor()) 53 - ->setActor($admin) 46 + ->setActor($viewer) 54 47 ->changeUsername($user, $v_username); 55 48 56 - $new_uri = '/p/'.$v_username.'/'; 57 - 58 - return id(new AphrontRedirectResponse())->setURI($new_uri); 49 + return id(new AphrontRedirectResponse())->setURI($done_uri); 59 50 } catch (AphrontDuplicateKeyQueryException $ex) { 60 51 $e_username = pht('Not Unique'); 61 52 $errors[] = pht('Another user already has that username.'); ··· 88 79 'password if necessary.'); 89 80 90 81 $form = id(new AphrontFormView()) 91 - ->setUser($admin) 82 + ->setUser($viewer) 92 83 ->appendChild( 93 84 id(new AphrontFormStaticControl()) 94 85 ->setLabel(pht('Old Username')) ··· 114 105 ->appendParagraph($inst4) 115 106 ->appendParagraph($inst5) 116 107 ->appendParagraph(null) 117 - ->appendChild($form->buildLayoutView()) 108 + ->appendForm($form) 118 109 ->addSubmitButton(pht('Rename User')) 119 - ->addCancelButton($profile_uri); 110 + ->addCancelButton($done_uri); 120 111 } 121 112 122 113 }
+5
src/applications/people/engine/PhabricatorPeopleProfilePanelEngine.php
··· 4 4 extends PhabricatorProfilePanelEngine { 5 5 6 6 const PANEL_PROFILE = 'people.profile'; 7 + const PANEL_MANAGE = 'people.manage'; 7 8 8 9 protected function isPanelEngineConfigurable() { 9 10 return false; ··· 89 90 ->setPanelProperty('name', pht('Commits')) 90 91 ->setPanelProperty('uri', $uri); 91 92 } 93 + 94 + $panels[] = $this->newPanel() 95 + ->setBuiltinKey(self::PANEL_MANAGE) 96 + ->setPanelKey(PhabricatorPeopleManageProfilePanel::PANELKEY); 92 97 93 98 return $panels; 94 99 }
+54
src/applications/people/profilepanel/PhabricatorPeopleManageProfilePanel.php
··· 1 + <?php 2 + 3 + final class PhabricatorPeopleManageProfilePanel 4 + extends PhabricatorProfilePanel { 5 + 6 + const PANELKEY = 'people.manage'; 7 + 8 + public function getPanelTypeName() { 9 + return pht('Mangage User'); 10 + } 11 + 12 + private function getDefaultName() { 13 + return pht('Manage'); 14 + } 15 + 16 + public function getDisplayName( 17 + PhabricatorProfilePanelConfiguration $config) { 18 + $name = $config->getPanelProperty('name'); 19 + 20 + if (strlen($name)) { 21 + return $name; 22 + } 23 + 24 + return $this->getDefaultName(); 25 + } 26 + 27 + public function buildEditEngineFields( 28 + PhabricatorProfilePanelConfiguration $config) { 29 + return array( 30 + id(new PhabricatorTextEditField()) 31 + ->setKey('name') 32 + ->setLabel(pht('Name')) 33 + ->setPlaceholder($this->getDefaultName()) 34 + ->setValue($config->getPanelProperty('name')), 35 + ); 36 + } 37 + 38 + protected function newNavigationMenuItems( 39 + PhabricatorProfilePanelConfiguration $config) { 40 + 41 + $user = $config->getProfileObject(); 42 + $id = $user->getID(); 43 + 44 + $item = $this->newItem() 45 + ->setHref("/people/manage/{$id}/") 46 + ->setName($this->getDisplayName($config)) 47 + ->setIcon('fa-gears'); 48 + 49 + return array( 50 + $item, 51 + ); 52 + } 53 + 54 + }