Page MenuHomePhabricator

D12617.diff
No OneTemporary

D12617.diff

diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
@@ -19,7 +19,6 @@
$user_phid = $user->getPHID();
$error_name = true;
$validation_exception = null;
- $invitees = null;
$start_time = id(new AphrontFormDateControl())
->setUser($user)
@@ -42,9 +41,7 @@
$page_title = pht('Create Event');
$redirect = 'created';
$subscribers = array();
- $invitees = array(
- $user_phid => PhabricatorCalendarEventInvitee::STATUS_ATTENDING,
- );
+ $invitees = array($user_phid);
} else {
$event = id(new PhabricatorCalendarEventQuery())
->setViewer($user)
@@ -68,6 +65,14 @@
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$event->getPHID());
+ $invitees = array();
+ foreach ($event->getInvitees() as $invitee) {
+ if ($invitee->isUninvited()) {
+ continue;
+ } else {
+ $invitees[] = $invitee->getInviteePHID();
+ }
+ }
}
$errors = array();
@@ -79,6 +84,16 @@
$end_value = $end_time->readValueFromRequest($request);
$description = $request->getStr('description');
$subscribers = $request->getArr('subscribers');
+ $invitees = $request->getArr('invitees');
+ $new_invitees = $this->getNewInviteeList($invitees, $event);
+
+ if ($this->isCreate()) {
+ $status = idx($new_invitees, $user->getPHID());
+ $status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
+ if ($status) {
+ $new_invitees[$user->getPHID()] = $status_attending;
+ }
+ }
if ($start_time->getError()) {
$errors[] = pht('Invalid start time; reset to default.');
@@ -114,17 +129,14 @@
$xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType(
+ PhabricatorCalendarEventTransaction::TYPE_INVITE)
+ ->setNewValue($new_invitees);
+
+ $xactions[] = id(new PhabricatorCalendarEventTransaction())
+ ->setTransactionType(
PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION)
->setNewValue($description);
- if ($invitees) {
- $xactions[] = id(new PhabricatorCalendarEventTransaction())
- ->setTransactionType(
- PhabricatorCalendarEventTransaction::TYPE_INVITE)
- ->setNewValue($invitees);
- }
-
-
$editor = id(new PhabricatorCalendarEventEditor())
->setActor($user)
->setContentSourceFromRequest($request)
@@ -173,6 +185,13 @@
->setUser($user)
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
+ $invitees = id(new AphrontFormTokenizerControl())
+ ->setLabel(pht('Invitees'))
+ ->setName('invitees')
+ ->setValue($invitees)
+ ->setUser($user)
+ ->setDatasource(new PhabricatorMetaMTAMailableDatasource());
+
$form = id(new AphrontFormView())
->setUser($user)
->appendChild($name)
@@ -180,6 +199,7 @@
->appendChild($start_time)
->appendChild($end_time)
->appendControl($subscribers)
+ ->appendControl($invitees)
->appendChild($description);
$submit = id(new AphrontFormSubmitControl())
@@ -226,4 +246,34 @@
));
}
+
+ public function getNewInviteeList(array $phids, $event) {
+ $invitees = $event->getInvitees();
+ $invitees = mpull($invitees, null, 'getInviteePHID');
+ $invited_status = PhabricatorCalendarEventInvitee::STATUS_INVITED;
+ $uninvited_status = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
+ $phids = array_fuse($phids);
+
+ $new = array();
+ foreach ($phids as $phid) {
+ $old_invitee = idx($invitees, $phid);
+ if ($old_invitee) {
+ $old_status = $old_invitee->getStatus();
+ if ($old_status != $uninvited_status) {
+ continue;
+ }
+ }
+ $new[$phid] = $invited_status;
+ }
+
+ foreach ($invitees as $invitee) {
+ $deleted_invitee = !idx($phids, $invitee->getInviteePHID());
+ if ($deleted_invitee) {
+ $new[$invitee->getInviteePHID()] = $uninvited_status;
+ }
+ }
+
+ return $new;
+ }
+
}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -130,9 +130,13 @@
$invitees = $event->getInvitees();
$invitee_list = new PHUIStatusListView();
foreach ($invitees as $invitee) {
+ if ($invitee->isUninvited()) {
+ continue;
+ }
$item = new PHUIStatusItemView();
$invitee_phid = $invitee->getInviteePHID();
$target = $viewer->renderHandle($invitee_phid);
+ $item->setNote($invitee->getStatus());
$item->setTarget($target);
$invitee_list->addItem($item);
}
diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
@@ -31,7 +31,8 @@
return id(new PhabricatorCalendarEvent())
->setUserPHID($actor->getPHID())
- ->setIsCancelled(0);
+ ->setIsCancelled(0)
+ ->attachInvitees(array());
}
private static $statusTexts = array(
diff --git a/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php b/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php
@@ -38,6 +38,14 @@
) + parent::getConfiguration();
}
+ public function isUninvited() {
+ if ($this->getStatus() == self::STATUS_UNINVITED) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 8:16 AM (20 h, 22 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6792907
Default Alt Text
D12617.diff (6 KB)

Event Timeline