Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/conduit/UserDisableConduitAPIMethod.php
12256 views
1
<?php
2
3
final class UserDisableConduitAPIMethod extends UserConduitAPIMethod {
4
5
public function getAPIMethodName() {
6
return 'user.disable';
7
}
8
9
public function getMethodDescription() {
10
return pht('Permanently disable specified users (admin only).');
11
}
12
13
public function getMethodStatus() {
14
return self::METHOD_STATUS_DEPRECATED;
15
}
16
17
public function getMethodStatusDescription() {
18
return pht('Obsoleted by method "user.edit".');
19
}
20
21
protected function defineParamTypes() {
22
return array(
23
'phids' => 'required list<phid>',
24
);
25
}
26
27
protected function defineReturnType() {
28
return 'void';
29
}
30
31
protected function defineErrorTypes() {
32
return array(
33
'ERR-PERMISSIONS' => pht('Only admins can call this method.'),
34
'ERR-BAD-PHID' => pht('Non existent user PHID.'),
35
);
36
}
37
38
protected function execute(ConduitAPIRequest $request) {
39
$actor = $request->getUser();
40
if (!$actor->getIsAdmin()) {
41
throw new ConduitException('ERR-PERMISSIONS');
42
}
43
44
$phids = $request->getValue('phids');
45
46
$users = id(new PhabricatorUser())->loadAllWhere(
47
'phid IN (%Ls)',
48
$phids);
49
50
if (count($phids) != count($users)) {
51
throw new ConduitException('ERR-BAD-PHID');
52
}
53
54
foreach ($phids as $phid) {
55
$params = array(
56
'transactions' => array(
57
array(
58
'type' => 'disabled',
59
'value' => true,
60
),
61
),
62
'objectIdentifier' => $phid,
63
);
64
65
id(new ConduitCall('user.edit', $params))
66
->setUser($actor)
67
->execute();
68
}
69
70
return null;
71
}
72
73
}
74
75