Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / auth / view / PhabricatorAuthAccountView.php
blob9746be784118481db03a7727d5ebd72c5439e56b
1 <?php
3 final class PhabricatorAuthAccountView extends AphrontView {
5 private $externalAccount;
6 private $provider;
8 public function setExternalAccount(
9 PhabricatorExternalAccount $external_account) {
10 $this->externalAccount = $external_account;
11 return $this;
14 public function setAuthProvider(PhabricatorAuthProvider $provider) {
15 $this->provider = $provider;
16 return $this;
19 public function render() {
20 $account = $this->externalAccount;
21 $provider = $this->provider;
23 require_celerity_resource('auth-css');
25 $content = array();
27 $dispname = $account->getDisplayName();
28 $username = $account->getUsername();
29 $realname = $account->getRealName();
31 $use_name = null;
32 if (strlen($dispname)) {
33 $use_name = $dispname;
34 } else if (strlen($username) && strlen($realname)) {
35 $use_name = $username.' ('.$realname.')';
36 } else if (strlen($username)) {
37 $use_name = $username;
38 } else if (strlen($realname)) {
39 $use_name = $realname;
42 $content[] = phutil_tag(
43 'div',
44 array(
45 'class' => 'auth-account-view-name',
47 $use_name);
49 if ($provider) {
50 $prov_name = pht('%s Account', $provider->getProviderName());
51 } else {
52 $prov_name = pht('"%s" Account', $account->getProviderType());
55 $content[] = phutil_tag(
56 'div',
57 array(
58 'class' => 'auth-account-view-provider-name',
60 array(
61 $prov_name,
62 ));
64 $account_uri = $account->getAccountURI();
65 if (strlen($account_uri)) {
67 // Make sure we don't link a "javascript:" URI if a user somehow
68 // managed to get one here.
70 if (PhabricatorEnv::isValidRemoteURIForLink($account_uri)) {
71 $account_uri = phutil_tag(
72 'a',
73 array(
74 'href' => $account_uri,
75 'target' => '_blank',
76 'rel' => 'noreferrer',
78 $account_uri);
81 $content[] = phutil_tag(
82 'div',
83 array(
84 'class' => 'auth-account-view-account-uri',
86 $account_uri);
89 $image_file = $account->getProfileImageFile();
90 $xform = PhabricatorFileTransform::getTransformByKey(
91 PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
92 $image_uri = $image_file->getURIForTransform($xform);
93 list($x, $y) = $xform->getTransformedDimensions($image_file);
95 $profile_image = phutil_tag(
96 'div',
97 array(
98 'class' => 'auth-account-view-profile-image',
99 'style' => 'background-image: url('.$image_uri.');',
102 return phutil_tag(
103 'div',
104 array(
105 'class' => 'auth-account-view',
107 array(
108 $profile_image,
109 $content,