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

View file

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

View file

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

View file

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

View file

@ -3,7 +3,8 @@
final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
implements PhabricatorPolicyInterface,
PhabricatorMarkupInterface,
PhabricatorApplicationTransactionInterface {
PhabricatorApplicationTransactionInterface,
PhabricatorSubscribableInterface {
protected $name;
protected $userPHID;
@ -30,6 +31,11 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
self::STATUS_SPORADIC => 'sporadic',
);
public function setTextStatus($status) {
$statuses = array_flip(self::$statusTexts);
return $this->setStatus($statuses[$status]);
}
public function getTextStatus() {
return self::$statusTexts[$this->status];
}
@ -82,9 +88,15 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
}
}
public function setTextStatus($status) {
$statuses = array_flip(self::$statusTexts);
return $this->setStatus($statuses[$status]);
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');
}
}
public function loadCurrentStatuses($user_phids) {
@ -99,17 +111,6 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
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
* windows
@ -219,4 +220,18 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return $timeline;
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */
public function isAutomaticallySubscribed($phid) {
return ($phid == $this->getUserPHID());
}
public function shouldShowSubscribersProperty() {
return true;
}
public function shouldAllowSubscription($phid) {
return true;
}
}