2013-01-25 02:23:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ConpherenceParticipant extends ConpherenceDAO {
|
|
|
|
|
|
|
|
protected $participantPHID;
|
|
|
|
protected $conpherencePHID;
|
|
|
|
protected $participationStatus;
|
|
|
|
protected $behindTransactionPHID;
|
2013-04-05 01:57:38 +02:00
|
|
|
protected $seenMessageCount;
|
2013-01-25 02:23:05 +01:00
|
|
|
protected $dateTouched;
|
2013-03-26 21:30:35 +01:00
|
|
|
protected $settings = array();
|
|
|
|
|
|
|
|
public function getConfiguration() {
|
|
|
|
return array(
|
|
|
|
self::CONFIG_SERIALIZATION => array(
|
|
|
|
'settings' => self::SERIALIZATION_JSON,
|
|
|
|
),
|
2014-09-18 20:15:38 +02:00
|
|
|
self::CONFIG_COLUMN_SCHEMA => array(
|
|
|
|
'participationStatus' => 'uint32',
|
|
|
|
'dateTouched' => 'epoch',
|
|
|
|
'seenMessageCount' => 'uint64',
|
|
|
|
),
|
|
|
|
self::CONFIG_KEY_SCHEMA => array(
|
|
|
|
'conpherencePHID' => array(
|
|
|
|
'columns' => array('conpherencePHID', 'participantPHID'),
|
2014-10-01 16:53:50 +02:00
|
|
|
'unique' => true,
|
|
|
|
),
|
|
|
|
'unreadCount' => array(
|
|
|
|
'columns' => array('participantPHID', 'participationStatus'),
|
|
|
|
),
|
|
|
|
'participationIndex' => array(
|
|
|
|
'columns' => array('participantPHID', 'dateTouched', 'id'),
|
2014-09-18 20:15:38 +02:00
|
|
|
),
|
|
|
|
),
|
2013-03-26 21:30:35 +01:00
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSettings() {
|
|
|
|
return nonempty($this->settings, array());
|
|
|
|
}
|
2013-01-25 02:23:05 +01:00
|
|
|
|
2013-04-05 01:57:38 +02:00
|
|
|
public function markUpToDate(
|
|
|
|
ConpherenceThread $conpherence,
|
|
|
|
ConpherenceTransaction $xaction) {
|
2013-04-08 22:41:34 +02:00
|
|
|
if (!$this->isUpToDate($conpherence)) {
|
2013-01-25 02:23:05 +01:00
|
|
|
$this->setParticipationStatus(ConpherenceParticipationStatus::UP_TO_DATE);
|
2013-01-27 03:53:30 +01:00
|
|
|
$this->setBehindTransactionPHID($xaction->getPHID());
|
2013-04-05 01:57:38 +02:00
|
|
|
$this->setSeenMessageCount($conpherence->getMessageCount());
|
2013-01-25 02:23:05 +01:00
|
|
|
$this->save();
|
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-04-08 22:41:34 +02:00
|
|
|
private function isUpToDate(ConpherenceThread $conpherence) {
|
|
|
|
return
|
|
|
|
($this->getSeenMessageCount() == $conpherence->getMessageCount())
|
|
|
|
&&
|
|
|
|
($this->getParticipationStatus() ==
|
|
|
|
ConpherenceParticipationStatus::UP_TO_DATE);
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|