Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F568475
PHUIUserAvailabilityView.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PHUIUserAvailabilityView.php
View Options
<?php
final
class
PHUIUserAvailabilityView
extends
AphrontTagView
{
private
$user
;
public
function
setAvailableUser
(
PhabricatorUser
$user
)
{
$this
->
user
=
$user
;
return
$this
;
}
public
function
getAvailableUser
()
{
return
$this
->
user
;
}
protected
function
getTagContent
()
{
$viewer
=
$this
->
getViewer
();
$user
=
$this
->
getAvailableUser
();
$until
=
$user
->
getAwayUntil
();
if
(!
$until
)
{
return
pht
(
'Available'
);
}
$const
=
$user
->
getDisplayAvailability
();
$name
=
PhabricatorCalendarEventInvitee
::
getAvailabilityName
(
$const
);
$color
=
PhabricatorCalendarEventInvitee
::
getAvailabilityColor
(
$const
);
$away_tag
=
id
(
new
PHUITagView
())
->
setType
(
PHUITagView
::
TYPE_SHADE
)
->
setColor
(
$color
)
->
setName
(
$name
)
->
setDotColor
(
$color
);
$now
=
PhabricatorTime
::
getNow
();
// Try to load the event handle. If it's invalid or the user can't see it,
// we'll just render a generic message.
$object_phid
=
$user
->
getAvailabilityEventPHID
();
$handle
=
null
;
if
(
$object_phid
)
{
$handles
=
$viewer
->
loadHandles
(
array
(
$object_phid
));
$handle
=
$handles
[
$object_phid
];
if
(!
$handle
->
isComplete
()
||
$handle
->
getPolicyFiltered
())
{
$handle
=
null
;
}
}
switch
(
$const
)
{
case
PhabricatorCalendarEventInvitee
::
AVAILABILITY_AWAY
:
if
(
$handle
)
{
$description
=
pht
(
'Away at %s until %s.'
,
$handle
->
renderLink
(),
$viewer
->
formatShortDateTime
(
$until
,
$now
));
}
else
{
$description
=
pht
(
'Away until %s.'
,
$viewer
->
formatShortDateTime
(
$until
,
$now
));
}
break
;
case
PhabricatorCalendarEventInvitee
::
AVAILABILITY_BUSY
:
default
:
if
(
$handle
)
{
$description
=
pht
(
'Busy at %s until %s.'
,
$handle
->
renderLink
(),
$viewer
->
formatShortDateTime
(
$until
,
$now
));
}
else
{
$description
=
pht
(
'Busy until %s.'
,
$viewer
->
formatShortDateTime
(
$until
,
$now
));
}
break
;
}
return
array
(
$away_tag
,
' '
,
$description
,
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 13, 1:28 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
104238
Default Alt Text
PHUIUserAvailabilityView.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment