Differential D20123 Diff 48061 src/applications/people/controller/PhabricatorPeopleProfileManageController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/controller/PhabricatorPeopleProfileManageController.php
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | private function buildCurtain(PhabricatorUser $user) { | ||||
$is_admin = $viewer->getIsAdmin(); | $is_admin = $viewer->getIsAdmin(); | ||||
$can_admin = ($is_admin && !$is_self); | $can_admin = ($is_admin && !$is_self); | ||||
$has_disable = $this->hasApplicationCapability( | $has_disable = $this->hasApplicationCapability( | ||||
PeopleDisableUsersCapability::CAPABILITY); | PeopleDisableUsersCapability::CAPABILITY); | ||||
$can_disable = ($has_disable && !$is_self); | $can_disable = ($has_disable && !$is_self); | ||||
$id = $user->getID(); | |||||
$welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine()) | $welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine()) | ||||
->setSender($viewer) | ->setSender($viewer) | ||||
->setRecipient($user); | ->setRecipient($user); | ||||
$can_welcome = $welcome_engine->canSendMail(); | $can_welcome = $welcome_engine->canSendMail(); | ||||
$curtain = $this->newCurtainView($user); | $curtain = $this->newCurtainView($user); | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
->setName(pht('Edit Profile')) | ->setName(pht('Edit Profile')) | ||||
->setHref($this->getApplicationURI('editprofile/'.$user->getID().'/')) | ->setHref($this->getApplicationURI('editprofile/'.$id.'/')) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setWorkflow(!$can_edit)); | ->setWorkflow(!$can_edit)); | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon('fa-picture-o') | ->setIcon('fa-picture-o') | ||||
->setName(pht('Edit Profile Picture')) | ->setName(pht('Edit Profile Picture')) | ||||
->setHref($this->getApplicationURI('picture/'.$user->getID().'/')) | ->setHref($this->getApplicationURI('picture/'.$id.'/')) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setWorkflow(!$can_edit)); | ->setWorkflow(!$can_edit)); | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon('fa-wrench') | ->setIcon('fa-wrench') | ||||
->setName(pht('Edit Settings')) | ->setName(pht('Edit Settings')) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
Show All 9 Lines | private function buildCurtain(PhabricatorUser $user) { | ||||
} | } | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon($empower_icon) | ->setIcon($empower_icon) | ||||
->setName($empower_name) | ->setName($empower_name) | ||||
->setDisabled(!$can_admin) | ->setDisabled(!$can_admin) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setHref($this->getApplicationURI('empower/'.$user->getID().'/'))); | ->setHref($this->getApplicationURI('empower/'.$id.'/'))); | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon('fa-tag') | ->setIcon('fa-tag') | ||||
->setName(pht('Change Username')) | ->setName(pht('Change Username')) | ||||
->setDisabled(!$is_admin) | ->setDisabled(!$is_admin) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setHref($this->getApplicationURI('rename/'.$user->getID().'/'))); | ->setHref($this->getApplicationURI('rename/'.$id.'/'))); | ||||
if ($user->getIsDisabled()) { | if ($user->getIsDisabled()) { | ||||
$disable_icon = 'fa-check-circle-o'; | $disable_icon = 'fa-check-circle-o'; | ||||
$disable_name = pht('Enable User'); | $disable_name = pht('Enable User'); | ||||
} else { | } else { | ||||
$disable_icon = 'fa-ban'; | $disable_icon = 'fa-ban'; | ||||
$disable_name = pht('Disable User'); | $disable_name = pht('Disable User'); | ||||
} | } | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon('fa-envelope') | ->setIcon('fa-envelope') | ||||
->setName(pht('Send Welcome Email')) | ->setName(pht('Send Welcome Email')) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setDisabled(!$can_welcome) | ->setDisabled(!$can_welcome) | ||||
->setHref($this->getApplicationURI('welcome/'.$user->getID().'/'))); | ->setHref($this->getApplicationURI('welcome/'.$id.'/'))); | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setType(PhabricatorActionView::TYPE_DIVIDER)); | ->setType(PhabricatorActionView::TYPE_DIVIDER)); | ||||
if (!$user->getIsApproved()) { | |||||
$approve_action = id(new PhabricatorActionView()) | |||||
->setIcon('fa-thumbs-up') | |||||
->setName(pht('Approve User')) | |||||
->setWorkflow(true) | |||||
->setDisabled(!$is_admin) | |||||
->setHref("/people/approve/{$id}/via/profile/"); | |||||
if ($is_admin) { | |||||
$approve_action->setColor(PhabricatorActionView::GREEN); | |||||
} | |||||
amckinley: Maybe also (or alternatively) check for `$is_admin` and visually call out the "Not Approved"… | |||||
$curtain->addAction($approve_action); | |||||
} | |||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon($disable_icon) | ->setIcon($disable_icon) | ||||
->setName($disable_name) | ->setName($disable_name) | ||||
->setDisabled(!$can_disable) | ->setDisabled(!$can_disable) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setHref($this->getApplicationURI('disable/'.$user->getID().'/'))); | ->setHref($this->getApplicationURI('disable/'.$id.'/'))); | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon('fa-times') | ->setIcon('fa-times') | ||||
->setName(pht('Delete User')) | ->setName(pht('Delete User')) | ||||
->setDisabled(!$can_admin) | ->setDisabled(!$can_admin) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setHref($this->getApplicationURI('delete/'.$user->getID().'/'))); | ->setHref($this->getApplicationURI('delete/'.$id.'/'))); | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setType(PhabricatorActionView::TYPE_DIVIDER)); | ->setType(PhabricatorActionView::TYPE_DIVIDER)); | ||||
return $curtain; | return $curtain; | ||||
} | } | ||||
} | } |
Maybe also (or alternatively) check for $is_admin and visually call out the "Not Approved" text in the header of this page? Or in the "Roles" property farther down the page.