Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/controller/PhabricatorPeopleApproveController.php
12256 views
1
<?php
2
3
final class PhabricatorPeopleApproveController
4
extends PhabricatorPeopleController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $request->getViewer();
8
9
$user = id(new PhabricatorPeopleQuery())
10
->setViewer($viewer)
11
->withIDs(array($request->getURIData('id')))
12
->executeOne();
13
if (!$user) {
14
return new Aphront404Response();
15
}
16
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;
25
}
26
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);
32
}
33
34
if ($request->isFormPost()) {
35
$xactions = array();
36
37
$xactions[] = id(new PhabricatorUserTransaction())
38
->setTransactionType(PhabricatorUserApproveTransaction::TRANSACTIONTYPE)
39
->setNewValue(true);
40
41
id(new PhabricatorUserTransactionEditor())
42
->setActor($viewer)
43
->setContentSourceFromRequest($request)
44
->setContinueOnMissingFields(true)
45
->setContinueOnNoEffect(true)
46
->applyTransactions($user, $xactions);
47
48
return id(new AphrontRedirectResponse())->setURI($done_uri);
49
}
50
51
return $this->newDialog()
52
->setTitle(pht('Confirm Approval'))
53
->appendChild(
54
pht(
55
'Allow %s to access this server?',
56
phutil_tag('strong', array(), $user->getUsername())))
57
->addCancelButton($done_uri)
58
->addSubmitButton(pht('Approve Account'));
59
}
60
}
61
62