@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.

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

+56 -17
+19
src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
··· 40 40 $filter = 'event/create/'; 41 41 $page_title = pht('Create Event'); 42 42 $redirect = 'created'; 43 + $subscribers = array(); 43 44 } else { 44 45 $event = id(new PhabricatorCalendarEventQuery()) 45 46 ->setViewer($user) ··· 60 61 $filter = 'event/edit/'.$event->getID().'/'; 61 62 $page_title = pht('Update Event'); 62 63 $redirect = 'updated'; 64 + 65 + $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID( 66 + $event->getPHID()); 63 67 } 64 68 65 69 $errors = array(); ··· 70 74 $start_value = $start_time->readValueFromRequest($request); 71 75 $end_value = $end_time->readValueFromRequest($request); 72 76 $description = $request->getStr('description'); 77 + $subscribers = $request->getArr('subscribers'); 73 78 74 79 if ($start_time->getError()) { 75 80 $errors[] = pht('Invalid start time; reset to default.'); ··· 97 102 ->setTransactionType( 98 103 PhabricatorCalendarEventTransaction::TYPE_STATUS) 99 104 ->setNewValue($type); 105 + 106 + $xactions[] = id(new PhabricatorCalendarEventTransaction()) 107 + ->setTransactionType( 108 + PhabricatorTransactions::TYPE_SUBSCRIBERS) 109 + ->setNewValue(array('=' => array_fuse($subscribers))); 100 110 101 111 $xactions[] = id(new PhabricatorCalendarEventTransaction()) 102 112 ->setTransactionType( ··· 144 154 ->setName('description') 145 155 ->setValue($event->getDescription()); 146 156 157 + $subscribers = id(new AphrontFormTokenizerControl()) 158 + ->setLabel(pht('Subscribers')) 159 + ->setName('subscribers') 160 + ->setValue($subscribers) 161 + ->setUser($user) 162 + ->setDatasource(new PhabricatorMetaMTAMailableDatasource()); 163 + 164 + 147 165 $form = id(new AphrontFormView()) 148 166 ->setUser($user) 149 167 ->appendChild($name) 150 168 ->appendChild($status_select) 151 169 ->appendChild($start_time) 152 170 ->appendChild($end_time) 171 + ->appendControl($subscribers) 153 172 ->appendChild($description); 154 173 155 174 $submit = id(new AphrontFormSubmitControl())
+4 -1
src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
··· 69 69 70 70 $actions = id(new PhabricatorActionListView()) 71 71 ->setObjectURI($this->getApplicationURI('event/'.$id.'/')) 72 - ->setUser($viewer); 72 + ->setUser($viewer) 73 + ->setObject($event); 73 74 74 75 $can_edit = PhabricatorPolicyFilter::hasCapability( 75 76 $viewer, ··· 109 110 $properties->addProperty( 110 111 pht('Ends'), 111 112 phabricator_datetime($event->getDateTo(), $viewer)); 113 + 114 + $properties->invokeWillRenderEvent(); 112 115 113 116 $properties->addSectionHeader( 114 117 pht('Description'),
+2
src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
··· 89 89 case PhabricatorTransactions::TYPE_VIEW_POLICY: 90 90 case PhabricatorTransactions::TYPE_EDIT_POLICY: 91 91 case PhabricatorTransactions::TYPE_EDGE: 92 + case PhabricatorTransactions::TYPE_SUBSCRIBERS: 92 93 return; 93 94 } 94 95 ··· 108 109 case PhabricatorTransactions::TYPE_VIEW_POLICY: 109 110 case PhabricatorTransactions::TYPE_EDIT_POLICY: 110 111 case PhabricatorTransactions::TYPE_EDGE: 112 + case PhabricatorTransactions::TYPE_SUBSCRIBERS: 111 113 return; 112 114 } 113 115
+1 -1
src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
··· 171 171 $list = new PHUIObjectItemListView(); 172 172 foreach ($events as $event) { 173 173 if ($event->getUserPHID() == $viewer->getPHID()) { 174 - $href = $this->getApplicationURI('/event/edit/'.$event->getID().'/'); 174 + $href = '/E'.$event->getID(); 175 175 } else { 176 176 $from = $event->getDateFrom(); 177 177 $month = phabricator_format_local_time($from, $viewer, 'm');
+30 -15
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 3 3 final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO 4 4 implements PhabricatorPolicyInterface, 5 5 PhabricatorMarkupInterface, 6 - PhabricatorApplicationTransactionInterface { 6 + PhabricatorApplicationTransactionInterface, 7 + PhabricatorSubscribableInterface { 7 8 8 9 protected $name; 9 10 protected $userPHID; ··· 29 30 self::STATUS_AWAY => 'away', 30 31 self::STATUS_SPORADIC => 'sporadic', 31 32 ); 33 + 34 + public function setTextStatus($status) { 35 + $statuses = array_flip(self::$statusTexts); 36 + return $this->setStatus($statuses[$status]); 37 + } 32 38 33 39 public function getTextStatus() { 34 40 return self::$statusTexts[$this->status]; ··· 82 88 } 83 89 } 84 90 85 - public function setTextStatus($status) { 86 - $statuses = array_flip(self::$statusTexts); 87 - return $this->setStatus($statuses[$status]); 91 + public static function getNameForStatus($value) { 92 + switch ($value) { 93 + case self::STATUS_AWAY: 94 + return pht('Away'); 95 + case self::STATUS_SPORADIC: 96 + return pht('Sporadic'); 97 + default: 98 + return pht('Unknown'); 99 + } 88 100 } 89 101 90 102 public function loadCurrentStatuses($user_phids) { ··· 99 111 return mpull($statuses, null, 'getUserPHID'); 100 112 } 101 113 102 - public static function getNameForStatus($value) { 103 - switch ($value) { 104 - case self::STATUS_AWAY: 105 - return pht('Away'); 106 - case self::STATUS_SPORADIC: 107 - return pht('Sporadic'); 108 - default: 109 - return pht('Unknown'); 110 - } 111 - } 112 - 113 114 /** 114 115 * Validates data and throws exceptions for non-sensical status 115 116 * windows ··· 219 220 return $timeline; 220 221 } 221 222 223 + /* -( PhabricatorSubscribableInterface )----------------------------------- */ 224 + 225 + 226 + public function isAutomaticallySubscribed($phid) { 227 + return ($phid == $this->getUserPHID()); 228 + } 229 + 230 + public function shouldShowSubscribersProperty() { 231 + return true; 232 + } 233 + 234 + public function shouldAllowSubscription($phid) { 235 + return true; 236 + } 222 237 }