Implement most of the administrative UI for approval queues

Summary:
Nothing fancy here, just:

  - UI to show users needing approval.
  - "Approve" and "Disable" actions.
  - Send "Approved" email on approve.
  - "Approve" edit + log operations.
  - "Wait for Approval" state for users who need approval.

There's still no natural way for users to end up not-approved -- you have to write directly to the database.

Test Plan: See screenshots.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7573
This commit is contained in:
epriestley
2013-11-13 11:24:18 -08:00
parent a3c811f281
commit c8320923c4
11 changed files with 269 additions and 10 deletions

View File

@@ -0,0 +1,66 @@
<?php
final class PhabricatorPeopleApproveController
extends PhabricatorPeopleController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$admin = $request->getUser();
$user = id(new PhabricatorPeopleQuery())
->setViewer($admin)
->withIDs(array($this->id))
->executeOne();
if (!$user) {
return new Aphront404Response();
}
$done_uri = $this->getApplicationURI('query/approval/');
if ($request->isFormPost()) {
id(new PhabricatorUserEditor())
->setActor($admin)
->approveUser($user, true);
$title = pht(
'Phabricator Account "%s" Approved',
$user->getUsername(),
$admin->getUsername());
$body = pht(
"Your Phabricator account (%s) has been approved by %s. You can ".
"login here:\n\n %s\n\n",
$user->getUsername(),
$admin->getUsername(),
PhabricatorEnv::getProductionURI('/'));
$mail = id(new PhabricatorMetaMTAMail())
->addTos(array($user->getPHID()))
->addCCs(array($admin->getPHID()))
->setSubject('[Phabricator] '.$title)
->setBody($body)
->saveAndSend();
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
$dialog = id(new AphrontDialogView())
->setUser($admin)
->setTitle(pht('Confirm Approval'))
->appendChild(
pht(
'Allow %s to access this Phabricator install?',
phutil_tag('strong', array(), $user->getUsername())))
->addCancelButton($done_uri)
->addSubmitButton(pht('Approve Account'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}

View File

@@ -0,0 +1,48 @@
<?php
final class PhabricatorPeopleDisableController
extends PhabricatorPeopleController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$admin = $request->getUser();
$user = id(new PhabricatorPeopleQuery())
->setViewer($admin)
->withIDs(array($this->id))
->executeOne();
if (!$user) {
return new Aphront404Response();
}
$done_uri = $this->getApplicationURI('query/approval/');
if ($request->isFormPost()) {
id(new PhabricatorUserEditor())
->setActor($admin)
->disableUser($user, true);
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
$dialog = id(new AphrontDialogView())
->setUser($admin)
->setTitle(pht('Confirm Disable'))
->appendChild(
pht(
'Disable %s? They will no longer be able to access Phabricator or '.
'receive email.',
phutil_tag('strong', array(), $user->getUsername())))
->addCancelButton($done_uri)
->addSubmitButton(pht('Disable Account'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}

View File

@@ -38,6 +38,8 @@ final class PhabricatorPeopleListController extends PhabricatorPeopleController
$list = new PHUIObjectItemListView();
$is_approval = ($query->getQueryKey() == 'approval');
foreach ($users as $user) {
$primary_email = $user->loadPrimaryEmail();
if ($primary_email && $primary_email->getIsVerified()) {
@@ -61,8 +63,10 @@ final class PhabricatorPeopleListController extends PhabricatorPeopleController
$item->addIcon('disable', pht('Disabled'));
}
if (!$user->getIsApproved()) {
$item->addIcon('raise-priority', pht('Not Approved'));
if (!$is_approval) {
if (!$user->getIsApproved()) {
$item->addIcon('perflab-grey', pht('Needs Approval'));
}
}
if ($user->getIsAdmin()) {
@@ -74,11 +78,26 @@ final class PhabricatorPeopleListController extends PhabricatorPeopleController
}
if ($viewer->getIsAdmin()) {
$uid = $user->getID();
$item->addAction(
id(new PHUIListItemView())
->setIcon('edit')
->setHref($this->getApplicationURI('edit/'.$uid.'/')));
$user_id = $user->getID();
if ($is_approval) {
$item->addAction(
id(new PHUIListItemView())
->setIcon('disable')
->setName(pht('Disable'))
->setWorkflow(true)
->setHref($this->getApplicationURI('disable/'.$user_id.'/')));
$item->addAction(
id(new PHUIListItemView())
->setIcon('like')
->setName(pht('Approve'))
->setWorkflow(true)
->setHref($this->getApplicationURI('approve/'.$user_id.'/')));
} else {
$item->addAction(
id(new PHUIListItemView())
->setIcon('edit')
->setHref($this->getApplicationURI('edit/'.$user_id.'/')));
}
}
$list->addItem($item);