1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Display user status on user profile

Test Plan:
Display users with:

- Title.
- Status.
- Title and status.

Also display project.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2491
This commit is contained in:
vrana 2012-05-17 15:13:33 -07:00
parent 2476c872ff
commit d9b4fcb336
5 changed files with 37 additions and 1 deletions

View file

@ -124,6 +124,17 @@ final class PhabricatorPeopleProfileController
->setName($user->getUserName().' ('.$user->getRealName().')')
->setDescription($profile->getTitle());
if ($user->getIsDisabled()) {
$header->setStatus('Disabled');
} else {
$status = id(new PhabricatorUserStatus())->loadOneWhere(
'userPHID = %s AND UNIX_TIMESTAMP() BETWEEN dateFrom AND dateTo',
$user->getPHID());
if ($status) {
$header->setStatus($status->getStatusDescription());
}
}
$header->appendChild($nav);
$nav->appendChild(
'<div style="padding: 1em;">'.$content.'</div>');

View file

@ -15,6 +15,7 @@ phutil_require_module('phabricator', 'applications/people/controller/base');
phutil_require_module('phabricator', 'applications/people/storage/profile');
phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'applications/people/storage/useroauthinfo');
phutil_require_module('phabricator', 'applications/people/storage/userstatus');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'view/layout/profileheader');
phutil_require_module('phabricator', 'view/layout/sidenavfilter');

View file

@ -35,6 +35,15 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
return self::$statusTexts[$this->status];
}
public function getStatusDescription(PhabricatorUser $viewer) {
$until = phabricator_date($this->dateTo, $viewer);
if ($this->status == PhabricatorUserStatus::STATUS_SPORADIC) {
return 'Sporadic until '.$until;
} else {
return 'Away until '.$until;
}
}
public function setTextStatus($status) {
$statuses = array_flip(self::$statusTexts);
return $this->setStatus($statuses[$status]);

View file

@ -7,6 +7,7 @@
phutil_require_module('phabricator', 'applications/people/storage/base');
phutil_require_module('phabricator', 'view/utils');
phutil_require_source('PhabricatorUserStatus.php');

View file

@ -22,6 +22,7 @@ final class PhabricatorProfileHeaderView extends AphrontView {
protected $profileName;
protected $profileDescription;
protected $profileActions = array();
protected $profileStatus;
public function setProfilePicture($picture) {
$this->profilePicture = $picture;
@ -43,6 +44,11 @@ final class PhabricatorProfileHeaderView extends AphrontView {
return $this;
}
public function setStatus($status) {
$this->profileStatus = $status;
return $this;
}
public function render() {
require_celerity_resource('phabricator-profile-header-css');
@ -57,6 +63,14 @@ final class PhabricatorProfileHeaderView extends AphrontView {
'');
}
$description = phutil_escape_html($this->profileDescription);
if ($this->profileStatus != '') {
$description =
'<strong>'.phutil_escape_html($this->profileStatus).'</strong>'.
($description != '' ? ' &mdash; ' : '').
$description;
}
return
'<table class="phabricator-profile-header">
<tr>
@ -72,7 +86,7 @@ final class PhabricatorProfileHeaderView extends AphrontView {
</tr>
<tr>
<td class="profile-header-description">'.
phutil_escape_html($this->profileDescription).
$description.
'</td>
</tr>
</table>'.