Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / people / controller / PhabricatorPeopleApproveController.php
blobaf08a6fbdc9febb2d812ccd208c0575d3cd4753c
1 <?php
3 final class PhabricatorPeopleApproveController
4 extends PhabricatorPeopleController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
9 $user = id(new PhabricatorPeopleQuery())
10 ->setViewer($viewer)
11 ->withIDs(array($request->getURIData('id')))
12 ->executeOne();
13 if (!$user) {
14 return new Aphront404Response();
17 $via = $request->getURIData('via');
18 switch ($via) {
19 case 'profile':
20 $done_uri = urisprintf('/people/manage/%d/', $user->getID());
21 break;
22 default:
23 $done_uri = $this->getApplicationURI('query/approval/');
24 break;
27 if ($user->getIsApproved()) {
28 return $this->newDialog()
29 ->setTitle(pht('Already Approved'))
30 ->appendChild(pht('This user has already been approved.'))
31 ->addCancelButton($done_uri);
34 if ($request->isFormPost()) {
35 $xactions = array();
37 $xactions[] = id(new PhabricatorUserTransaction())
38 ->setTransactionType(PhabricatorUserApproveTransaction::TRANSACTIONTYPE)
39 ->setNewValue(true);
41 id(new PhabricatorUserTransactionEditor())
42 ->setActor($viewer)
43 ->setContentSourceFromRequest($request)
44 ->setContinueOnMissingFields(true)
45 ->setContinueOnNoEffect(true)
46 ->applyTransactions($user, $xactions);
48 return id(new AphrontRedirectResponse())->setURI($done_uri);
51 return $this->newDialog()
52 ->setTitle(pht('Confirm Approval'))
53 ->appendChild(
54 pht(
55 'Allow %s to access this Phabricator install?',
56 phutil_tag('strong', array(), $user->getUsername())))
57 ->addCancelButton($done_uri)
58 ->addSubmitButton(pht('Approve Account'));