@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Ability to invite users, but no RSVP capability yet.

Summary: Ref T7986, Ability to invite users, but not RSVP yet.

Test Plan: Open event, add invitees, save, event detail view should show invitees.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7986

Differential Revision: https://secure.phabricator.com/D12617

+76 -13
+62 -12
src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
··· 19 19 $user_phid = $user->getPHID(); 20 20 $error_name = true; 21 21 $validation_exception = null; 22 - $invitees = null; 23 22 24 23 $start_time = id(new AphrontFormDateControl()) 25 24 ->setUser($user) ··· 42 41 $page_title = pht('Create Event'); 43 42 $redirect = 'created'; 44 43 $subscribers = array(); 45 - $invitees = array( 46 - $user_phid => PhabricatorCalendarEventInvitee::STATUS_ATTENDING, 47 - ); 44 + $invitees = array($user_phid); 48 45 } else { 49 46 $event = id(new PhabricatorCalendarEventQuery()) 50 47 ->setViewer($user) ··· 68 65 69 66 $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID( 70 67 $event->getPHID()); 68 + $invitees = array(); 69 + foreach ($event->getInvitees() as $invitee) { 70 + if ($invitee->isUninvited()) { 71 + continue; 72 + } else { 73 + $invitees[] = $invitee->getInviteePHID(); 74 + } 75 + } 71 76 } 72 77 73 78 $errors = array(); ··· 79 84 $end_value = $end_time->readValueFromRequest($request); 80 85 $description = $request->getStr('description'); 81 86 $subscribers = $request->getArr('subscribers'); 87 + $invitees = $request->getArr('invitees'); 88 + $new_invitees = $this->getNewInviteeList($invitees, $event); 89 + 90 + if ($this->isCreate()) { 91 + $status = idx($new_invitees, $user->getPHID()); 92 + $status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING; 93 + if ($status) { 94 + $new_invitees[$user->getPHID()] = $status_attending; 95 + } 96 + } 82 97 83 98 if ($start_time->getError()) { 84 99 $errors[] = pht('Invalid start time; reset to default.'); ··· 114 129 115 130 $xactions[] = id(new PhabricatorCalendarEventTransaction()) 116 131 ->setTransactionType( 132 + PhabricatorCalendarEventTransaction::TYPE_INVITE) 133 + ->setNewValue($new_invitees); 134 + 135 + $xactions[] = id(new PhabricatorCalendarEventTransaction()) 136 + ->setTransactionType( 117 137 PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION) 118 138 ->setNewValue($description); 119 - 120 - if ($invitees) { 121 - $xactions[] = id(new PhabricatorCalendarEventTransaction()) 122 - ->setTransactionType( 123 - PhabricatorCalendarEventTransaction::TYPE_INVITE) 124 - ->setNewValue($invitees); 125 - } 126 - 127 139 128 140 $editor = id(new PhabricatorCalendarEventEditor()) 129 141 ->setActor($user) ··· 173 185 ->setUser($user) 174 186 ->setDatasource(new PhabricatorMetaMTAMailableDatasource()); 175 187 188 + $invitees = id(new AphrontFormTokenizerControl()) 189 + ->setLabel(pht('Invitees')) 190 + ->setName('invitees') 191 + ->setValue($invitees) 192 + ->setUser($user) 193 + ->setDatasource(new PhabricatorMetaMTAMailableDatasource()); 194 + 176 195 $form = id(new AphrontFormView()) 177 196 ->setUser($user) 178 197 ->appendChild($name) ··· 180 199 ->appendChild($start_time) 181 200 ->appendChild($end_time) 182 201 ->appendControl($subscribers) 202 + ->appendControl($invitees) 183 203 ->appendChild($description); 184 204 185 205 $submit = id(new AphrontFormSubmitControl()) ··· 224 244 array( 225 245 'title' => $page_title, 226 246 )); 247 + } 248 + 249 + 250 + public function getNewInviteeList(array $phids, $event) { 251 + $invitees = $event->getInvitees(); 252 + $invitees = mpull($invitees, null, 'getInviteePHID'); 253 + $invited_status = PhabricatorCalendarEventInvitee::STATUS_INVITED; 254 + $uninvited_status = PhabricatorCalendarEventInvitee::STATUS_UNINVITED; 255 + $phids = array_fuse($phids); 256 + 257 + $new = array(); 258 + foreach ($phids as $phid) { 259 + $old_invitee = idx($invitees, $phid); 260 + if ($old_invitee) { 261 + $old_status = $old_invitee->getStatus(); 262 + if ($old_status != $uninvited_status) { 263 + continue; 264 + } 265 + } 266 + $new[$phid] = $invited_status; 267 + } 268 + 269 + foreach ($invitees as $invitee) { 270 + $deleted_invitee = !idx($phids, $invitee->getInviteePHID()); 271 + if ($deleted_invitee) { 272 + $new[$invitee->getInviteePHID()] = $uninvited_status; 273 + } 274 + } 275 + 276 + return $new; 227 277 } 228 278 229 279 }
+4
src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
··· 130 130 $invitees = $event->getInvitees(); 131 131 $invitee_list = new PHUIStatusListView(); 132 132 foreach ($invitees as $invitee) { 133 + if ($invitee->isUninvited()) { 134 + continue; 135 + } 133 136 $item = new PHUIStatusItemView(); 134 137 $invitee_phid = $invitee->getInviteePHID(); 135 138 $target = $viewer->renderHandle($invitee_phid); 139 + $item->setNote($invitee->getStatus()); 136 140 $item->setTarget($target); 137 141 $invitee_list->addItem($item); 138 142 }
+2 -1
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 31 31 32 32 return id(new PhabricatorCalendarEvent()) 33 33 ->setUserPHID($actor->getPHID()) 34 - ->setIsCancelled(0); 34 + ->setIsCancelled(0) 35 + ->attachInvitees(array()); 35 36 } 36 37 37 38 private static $statusTexts = array(
+8
src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php
··· 38 38 ) + parent::getConfiguration(); 39 39 } 40 40 41 + public function isUninvited() { 42 + if ($this->getStatus() == self::STATUS_UNINVITED) { 43 + return true; 44 + } else { 45 + return false; 46 + } 47 + } 48 + 41 49 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 42 50 43 51