Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104817800
PhabricatorAuthAccountView.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Mar 12, 15:44
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Mar 14, 15:44 (1 d, 19 h)
Engine
blob
Format
Raw Data
Handle
24860628
Attached To
rPH Phabricator
PhabricatorAuthAccountView.php
View Options
<?php
final
class
PhabricatorAuthAccountView
extends
AphrontView
{
private
$externalAccount
;
private
$provider
;
public
function
setExternalAccount
(
PhabricatorExternalAccount
$external_account
)
{
$this
->
externalAccount
=
$external_account
;
return
$this
;
}
public
function
setAuthProvider
(
PhabricatorAuthProvider
$provider
)
{
$this
->
provider
=
$provider
;
return
$this
;
}
public
function
render
()
{
$account
=
$this
->
externalAccount
;
$provider
=
$this
->
provider
;
require_celerity_resource
(
'auth-css'
);
$content
=
array
();
$dispname
=
$account
->
getDisplayName
();
$username
=
$account
->
getUsername
();
$realname
=
$account
->
getRealName
();
$use_name
=
null
;
if
(
strlen
(
$dispname
))
{
$use_name
=
$dispname
;
}
else
if
(
strlen
(
$username
)
&&
strlen
(
$realname
))
{
$use_name
=
$username
.
' ('
.
$realname
.
')'
;
}
else
if
(
strlen
(
$username
))
{
$use_name
=
$username
;
}
else
if
(
strlen
(
$realname
))
{
$use_name
=
$realname
;
}
else
{
$use_name
=
$account
->
getAccountID
();
}
$content
[]
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'auth-account-view-name'
,
),
$use_name
);
if
(
$provider
)
{
$prov_name
=
pht
(
'%s Account'
,
$provider
->
getProviderName
());
}
else
{
$prov_name
=
pht
(
'"%s" Account'
,
$account
->
getProviderType
());
}
$content
[]
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'auth-account-view-provider-name'
,
),
array
(
$prov_name
,
"
\x
C2
\x
B7 "
,
$account
->
getAccountID
(),
));
$account_uri
=
$account
->
getAccountURI
();
if
(
strlen
(
$account_uri
))
{
// Make sure we don't link a "javascript:" URI if a user somehow
// managed to get one here.
if
(
PhabricatorEnv
::
isValidRemoteWebResource
(
$account_uri
))
{
$account_uri
=
phutil_tag
(
'a'
,
array
(
'href'
=>
$account_uri
,
'target'
=>
'_blank'
,
),
$account_uri
);
}
$content
[]
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'auth-account-view-account-uri'
,
),
$account_uri
);
}
// TODO: This fetch is sketchy. We should probably build
// ExternalAccountQuery and move the logic there.
$image_uri
=
PhabricatorUser
::
getDefaultProfileImageURI
();
if
(
$account
->
getProfileImagePHID
())
{
$image
=
id
(
new
PhabricatorFileQuery
())
->
setUser
(
PhabricatorUser
::
getOmnipotentUser
())
->
withPHIDs
(
array
(
$account
->
getProfileImagePHID
()))
->
executeOne
();
if
(
$image
)
{
$image_uri
=
$image
->
getProfileThumbURI
();
}
}
return
phutil_tag
(
'div'
,
array
(
'class'
=>
'auth-account-view'
,
'style'
=>
'background-image: url('
.
$image_uri
.
')'
,
),
$content
);
}
}
Event Timeline
Log In to Comment