1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 03:12:41 +01:00
phorge-phorge/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php
epriestley fef3c778fd Replace user "status" with "availability"
Summary:
Ref T7707. Ref T8183.

  - Currently, user status is derived by looking at events they //created//. Instead, look at non-cancelled invites they are attending.
  - Prepare for on-user caching.
  - Mostly remove "Sporradic" as a status, although I left room for adding more information later.

Test Plan:
- Called user.query.
- Viewed profile.
- Viewed hovercard.
- Used mentions.
- Saw status immediately update when attending/leaving/cancelling a current event.
- Created an event ending at 6 PM and an event from 6:10PM - 7PM, saw "Away until 7PM".

Reviewers: chad, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8183, T7707

Differential Revision: https://secure.phabricator.com/D12833
2015-05-14 11:15:04 -07:00

76 lines
1.9 KiB
PHP

<?php
final class PhabricatorCalendarEventInvitee extends PhabricatorCalendarDAO
implements PhabricatorPolicyInterface {
protected $eventPHID;
protected $inviteePHID;
protected $inviterPHID;
protected $status;
const STATUS_INVITED = 'invited';
const STATUS_ATTENDING = 'attending';
const STATUS_DECLINED = 'declined';
const STATUS_UNINVITED = 'uninvited';
public static function initializeNewCalendarEventInvitee(
PhabricatorUser $actor, $event) {
return id(new PhabricatorCalendarEventInvitee())
->setInviterPHID($actor->getPHID())
->setStatus(self::STATUS_INVITED)
->setEventPHID($event->getPHID());
}
protected function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'status' => 'text64',
),
self::CONFIG_KEY_SCHEMA => array(
'key_event' => array(
'columns' => array('eventPHID', 'inviteePHID'),
'unique' => true,
),
'key_invitee' => array(
'columns' => array('inviteePHID'),
),
),
) + parent::getConfiguration();
}
public function isAttending() {
return ($this->getStatus() == self::STATUS_ATTENDING);
}
public function isUninvited() {
if ($this->getStatus() == self::STATUS_UNINVITED) {
return true;
} else {
return false;
}
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
);
}
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return PhabricatorPolicies::getMostOpenPolicy();
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}