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

Calendar events should support subscribers, for possible future uses.

Summary: Closes T7974, Calendar events support subscribers.

Test Plan: Create or update calendar event, add subscribers, save, event detail view should show subscribers, and timeline should reflect the action.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7974

Differential Revision: https://secure.phabricator.com/D12595
This commit is contained in:
lkassianik 2015-04-28 10:40:35 -07:00
parent 4da2e7efd8
commit c6fa4355cc
5 changed files with 56 additions and 17 deletions

View file

@ -40,6 +40,7 @@ final class PhabricatorCalendarEventEditController
$filter = 'event/create/'; $filter = 'event/create/';
$page_title = pht('Create Event'); $page_title = pht('Create Event');
$redirect = 'created'; $redirect = 'created';
$subscribers = array();
} else { } else {
$event = id(new PhabricatorCalendarEventQuery()) $event = id(new PhabricatorCalendarEventQuery())
->setViewer($user) ->setViewer($user)
@ -60,6 +61,9 @@ final class PhabricatorCalendarEventEditController
$filter = 'event/edit/'.$event->getID().'/'; $filter = 'event/edit/'.$event->getID().'/';
$page_title = pht('Update Event'); $page_title = pht('Update Event');
$redirect = 'updated'; $redirect = 'updated';
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$event->getPHID());
} }
$errors = array(); $errors = array();
@ -70,6 +74,7 @@ final class PhabricatorCalendarEventEditController
$start_value = $start_time->readValueFromRequest($request); $start_value = $start_time->readValueFromRequest($request);
$end_value = $end_time->readValueFromRequest($request); $end_value = $end_time->readValueFromRequest($request);
$description = $request->getStr('description'); $description = $request->getStr('description');
$subscribers = $request->getArr('subscribers');
if ($start_time->getError()) { if ($start_time->getError()) {
$errors[] = pht('Invalid start time; reset to default.'); $errors[] = pht('Invalid start time; reset to default.');
@ -98,6 +103,11 @@ final class PhabricatorCalendarEventEditController
PhabricatorCalendarEventTransaction::TYPE_STATUS) PhabricatorCalendarEventTransaction::TYPE_STATUS)
->setNewValue($type); ->setNewValue($type);
$xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType(
PhabricatorTransactions::TYPE_SUBSCRIBERS)
->setNewValue(array('=' => array_fuse($subscribers)));
$xactions[] = id(new PhabricatorCalendarEventTransaction()) $xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType( ->setTransactionType(
PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION) PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION)
@ -144,12 +154,21 @@ final class PhabricatorCalendarEventEditController
->setName('description') ->setName('description')
->setValue($event->getDescription()); ->setValue($event->getDescription());
$subscribers = id(new AphrontFormTokenizerControl())
->setLabel(pht('Subscribers'))
->setName('subscribers')
->setValue($subscribers)
->setUser($user)
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($user)
->appendChild($name) ->appendChild($name)
->appendChild($status_select) ->appendChild($status_select)
->appendChild($start_time) ->appendChild($start_time)
->appendChild($end_time) ->appendChild($end_time)
->appendControl($subscribers)
->appendChild($description); ->appendChild($description);
$submit = id(new AphrontFormSubmitControl()) $submit = id(new AphrontFormSubmitControl())

View file

@ -69,7 +69,8 @@ final class PhabricatorCalendarEventViewController
$actions = id(new PhabricatorActionListView()) $actions = id(new PhabricatorActionListView())
->setObjectURI($this->getApplicationURI('event/'.$id.'/')) ->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
->setUser($viewer); ->setUser($viewer)
->setObject($event);
$can_edit = PhabricatorPolicyFilter::hasCapability( $can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer, $viewer,
@ -110,6 +111,8 @@ final class PhabricatorCalendarEventViewController
pht('Ends'), pht('Ends'),
phabricator_datetime($event->getDateTo(), $viewer)); phabricator_datetime($event->getDateTo(), $viewer));
$properties->invokeWillRenderEvent();
$properties->addSectionHeader( $properties->addSectionHeader(
pht('Description'), pht('Description'),
PHUIPropertyListView::ICON_SUMMARY); PHUIPropertyListView::ICON_SUMMARY);

View file

@ -89,6 +89,7 @@ final class PhabricatorCalendarEventEditor
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_EDGE: case PhabricatorTransactions::TYPE_EDGE:
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return; return;
} }
@ -108,6 +109,7 @@ final class PhabricatorCalendarEventEditor
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_EDGE: case PhabricatorTransactions::TYPE_EDGE:
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return; return;
} }

View file

@ -171,7 +171,7 @@ final class PhabricatorCalendarEventSearchEngine
$list = new PHUIObjectItemListView(); $list = new PHUIObjectItemListView();
foreach ($events as $event) { foreach ($events as $event) {
if ($event->getUserPHID() == $viewer->getPHID()) { if ($event->getUserPHID() == $viewer->getPHID()) {
$href = $this->getApplicationURI('/event/edit/'.$event->getID().'/'); $href = '/E'.$event->getID();
} else { } else {
$from = $event->getDateFrom(); $from = $event->getDateFrom();
$month = phabricator_format_local_time($from, $viewer, 'm'); $month = phabricator_format_local_time($from, $viewer, 'm');

View file

@ -3,7 +3,8 @@
final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
implements PhabricatorPolicyInterface, implements PhabricatorPolicyInterface,
PhabricatorMarkupInterface, PhabricatorMarkupInterface,
PhabricatorApplicationTransactionInterface { PhabricatorApplicationTransactionInterface,
PhabricatorSubscribableInterface {
protected $name; protected $name;
protected $userPHID; protected $userPHID;
@ -30,6 +31,11 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
self::STATUS_SPORADIC => 'sporadic', self::STATUS_SPORADIC => 'sporadic',
); );
public function setTextStatus($status) {
$statuses = array_flip(self::$statusTexts);
return $this->setStatus($statuses[$status]);
}
public function getTextStatus() { public function getTextStatus() {
return self::$statusTexts[$this->status]; return self::$statusTexts[$this->status];
} }
@ -82,9 +88,15 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
} }
} }
public function setTextStatus($status) { public static function getNameForStatus($value) {
$statuses = array_flip(self::$statusTexts); switch ($value) {
return $this->setStatus($statuses[$status]); case self::STATUS_AWAY:
return pht('Away');
case self::STATUS_SPORADIC:
return pht('Sporadic');
default:
return pht('Unknown');
}
} }
public function loadCurrentStatuses($user_phids) { public function loadCurrentStatuses($user_phids) {
@ -99,17 +111,6 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return mpull($statuses, null, 'getUserPHID'); return mpull($statuses, null, 'getUserPHID');
} }
public static function getNameForStatus($value) {
switch ($value) {
case self::STATUS_AWAY:
return pht('Away');
case self::STATUS_SPORADIC:
return pht('Sporadic');
default:
return pht('Unknown');
}
}
/** /**
* Validates data and throws exceptions for non-sensical status * Validates data and throws exceptions for non-sensical status
* windows * windows
@ -219,4 +220,18 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return $timeline; return $timeline;
} }
/* -( PhabricatorSubscribableInterface )----------------------------------- */
public function isAutomaticallySubscribed($phid) {
return ($phid == $this->getUserPHID());
}
public function shouldShowSubscribersProperty() {
return true;
}
public function shouldAllowSubscription($phid) {
return true;
}
} }