Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/conduit/UserConduitAPIMethod.php
12256 views
1
<?php
2
3
abstract class UserConduitAPIMethod extends ConduitAPIMethod {
4
5
final public function getApplication() {
6
return PhabricatorApplication::getByClass('PhabricatorPeopleApplication');
7
}
8
9
protected function buildUserInformationDictionary(
10
PhabricatorUser $user,
11
$with_email = false,
12
$with_availability = false) {
13
14
$roles = array();
15
if ($user->getIsDisabled()) {
16
$roles[] = 'disabled';
17
}
18
if ($user->getIsSystemAgent()) {
19
$roles[] = 'agent';
20
}
21
if ($user->getIsMailingList()) {
22
$roles[] = 'list';
23
}
24
if ($user->getIsAdmin()) {
25
$roles[] = 'admin';
26
}
27
28
$primary = $user->loadPrimaryEmail();
29
if ($primary && $primary->getIsVerified()) {
30
$email = $primary->getAddress();
31
$roles[] = 'verified';
32
} else {
33
$email = null;
34
$roles[] = 'unverified';
35
}
36
37
if ($user->getIsApproved()) {
38
$roles[] = 'approved';
39
}
40
41
if ($user->isUserActivated()) {
42
$roles[] = 'activated';
43
}
44
45
$return = array(
46
'phid' => $user->getPHID(),
47
'userName' => $user->getUserName(),
48
'realName' => $user->getRealName(),
49
'image' => $user->getProfileImageURI(),
50
'uri' => PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'),
51
'roles' => $roles,
52
);
53
54
if ($with_email) {
55
$return['primaryEmail'] = $email;
56
}
57
58
if ($with_availability) {
59
// TODO: Modernize this once we have a more long-term view of what the
60
// data looks like.
61
$until = $user->getAwayUntil();
62
if ($until) {
63
$return['currentStatus'] = 'away';
64
$return['currentStatusUntil'] = $until;
65
}
66
}
67
68
return $return;
69
}
70
71
}
72
73