Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / people / conduit / UserConduitAPIMethod.php
blob427e7f71e512a792a6e00e60449506540599eb9a
1 <?php
3 abstract class UserConduitAPIMethod extends ConduitAPIMethod {
5 final public function getApplication() {
6 return PhabricatorApplication::getByClass('PhabricatorPeopleApplication');
9 protected function buildUserInformationDictionary(
10 PhabricatorUser $user,
11 $with_email = false,
12 $with_availability = false) {
14 $roles = array();
15 if ($user->getIsDisabled()) {
16 $roles[] = 'disabled';
18 if ($user->getIsSystemAgent()) {
19 $roles[] = 'agent';
21 if ($user->getIsMailingList()) {
22 $roles[] = 'list';
24 if ($user->getIsAdmin()) {
25 $roles[] = 'admin';
28 $primary = $user->loadPrimaryEmail();
29 if ($primary && $primary->getIsVerified()) {
30 $email = $primary->getAddress();
31 $roles[] = 'verified';
32 } else {
33 $email = null;
34 $roles[] = 'unverified';
37 if ($user->getIsApproved()) {
38 $roles[] = 'approved';
41 if ($user->isUserActivated()) {
42 $roles[] = 'activated';
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,
54 if ($with_email) {
55 $return['primaryEmail'] = $email;
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;
68 return $return;