Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2895656
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/people/storage/PhabricatorUserStatus.php b/src/applications/people/storage/PhabricatorUserStatus.php
index 8b771ae33d..ea1d7406a9 100644
--- a/src/applications/people/storage/PhabricatorUserStatus.php
+++ b/src/applications/people/storage/PhabricatorUserStatus.php
@@ -1,90 +1,95 @@
<?php
final class PhabricatorUserStatus extends PhabricatorUserDAO {
protected $userPHID;
protected $dateFrom;
protected $dateTo;
protected $status;
protected $description;
const STATUS_AWAY = 1;
const STATUS_SPORADIC = 2;
private static $statusTexts = array(
self::STATUS_AWAY => 'away',
self::STATUS_SPORADIC => 'sporadic',
);
public function getTextStatus() {
return self::$statusTexts[$this->status];
}
public function getStatusOptions() {
return array(
self::STATUS_AWAY => pht('Away'),
self::STATUS_SPORADIC => pht('Sporadic'),
);
}
public function getHumanStatus() {
$options = $this->getStatusOptions();
return $options[$this->status];
}
public function getTerseSummary(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]);
}
public function loadCurrentStatuses($user_phids) {
+ if (!$user_phids) {
+ return array();
+ }
+
$statuses = $this->loadAllWhere(
'userPHID IN (%Ls) AND UNIX_TIMESTAMP() BETWEEN dateFrom AND dateTo',
$user_phids);
+
return mpull($statuses, null, 'getUserPHID');
}
/**
* Validates data and throws exceptions for non-sensical status
* windows and attempts to create an overlapping status.
*/
public function save() {
if ($this->getDateTo() <= $this->getDateFrom()) {
throw new PhabricatorUserStatusInvalidEpochException();
}
$this->openTransaction();
$this->beginWriteLocking();
if ($this->shouldInsertWhenSaved()) {
$overlap = $this->loadAllWhere(
'userPHID = %s AND dateFrom < %d AND dateTo > %d',
$this->getUserPHID(),
$this->getDateTo(),
$this->getDateFrom());
if ($overlap) {
$this->endWriteLocking();
$this->killTransaction();
throw new PhabricatorUserStatusOverlapException();
}
}
parent::save();
$this->endWriteLocking();
return $this->saveTransaction();
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jan 19 2025, 21:50 (6 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129108
Default Alt Text
(2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment