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

Remove "status" field from events

Summary:
Ref T8183. See that task for discussion.

- For now, events always mark users as "Away".
- In the future, we may reintroduce "sporradic" or other more complicated availability states, but they would be properties of the invitee, not of the event itself.
- This also removes the long-deprecated `user.addstatus` and `user.removestatus` Conduit calls.

Test Plan:
- Created, edited, viewed events.
- Grepped for removed symbols.
- Viewed profile calendar.
- Viewed Conpherence calendar.
- Load Conduit console.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8183

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

+43 -265
+2
resources/sql/autopatches/20150514.calendar.status.sql
··· 1 + ALTER TABLE {$NAMESPACE}_calendar.calendar_event 2 + DROP status;
-4
src/__phutil_library_map__.php
··· 3200 3200 'TokenGiveConduitAPIMethod' => 'applications/tokens/conduit/TokenGiveConduitAPIMethod.php', 3201 3201 'TokenGivenConduitAPIMethod' => 'applications/tokens/conduit/TokenGivenConduitAPIMethod.php', 3202 3202 'TokenQueryConduitAPIMethod' => 'applications/tokens/conduit/TokenQueryConduitAPIMethod.php', 3203 - 'UserAddStatusConduitAPIMethod' => 'applications/people/conduit/UserAddStatusConduitAPIMethod.php', 3204 3203 'UserConduitAPIMethod' => 'applications/people/conduit/UserConduitAPIMethod.php', 3205 3204 'UserDisableConduitAPIMethod' => 'applications/people/conduit/UserDisableConduitAPIMethod.php', 3206 3205 'UserEnableConduitAPIMethod' => 'applications/people/conduit/UserEnableConduitAPIMethod.php', 3207 3206 'UserFindConduitAPIMethod' => 'applications/people/conduit/UserFindConduitAPIMethod.php', 3208 3207 'UserQueryConduitAPIMethod' => 'applications/people/conduit/UserQueryConduitAPIMethod.php', 3209 - 'UserRemoveStatusConduitAPIMethod' => 'applications/people/conduit/UserRemoveStatusConduitAPIMethod.php', 3210 3208 'UserWhoAmIConduitAPIMethod' => 'applications/people/conduit/UserWhoAmIConduitAPIMethod.php', 3211 3209 ), 3212 3210 'function' => array( ··· 6781 6779 'TokenGiveConduitAPIMethod' => 'TokenConduitAPIMethod', 6782 6780 'TokenGivenConduitAPIMethod' => 'TokenConduitAPIMethod', 6783 6781 'TokenQueryConduitAPIMethod' => 'TokenConduitAPIMethod', 6784 - 'UserAddStatusConduitAPIMethod' => 'UserConduitAPIMethod', 6785 6782 'UserConduitAPIMethod' => 'ConduitAPIMethod', 6786 6783 'UserDisableConduitAPIMethod' => 'UserConduitAPIMethod', 6787 6784 'UserEnableConduitAPIMethod' => 'UserConduitAPIMethod', 6788 6785 'UserFindConduitAPIMethod' => 'UserConduitAPIMethod', 6789 6786 'UserQueryConduitAPIMethod' => 'UserConduitAPIMethod', 6790 - 'UserRemoveStatusConduitAPIMethod' => 'UserConduitAPIMethod', 6791 6787 'UserWhoAmIConduitAPIMethod' => 'UserConduitAPIMethod', 6792 6788 ), 6793 6789 ));
-14
src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
··· 73 73 74 74 $name = $event->getName(); 75 75 $description = $event->getDescription(); 76 - $type = $event->getStatus(); 77 76 $is_all_day = $event->getIsAllDay(); 78 77 79 78 $current_policies = id(new PhabricatorPolicyQuery()) ··· 84 83 if ($request->isFormPost()) { 85 84 $xactions = array(); 86 85 $name = $request->getStr('name'); 87 - $type = $request->getInt('status'); 88 86 89 87 $start_value = AphrontFormDateControlValue::newFromRequest( 90 88 $request, ··· 127 125 ->setTransactionType( 128 126 PhabricatorCalendarEventTransaction::TYPE_END_DATE) 129 127 ->setNewValue($end_value); 130 - 131 - $xactions[] = id(new PhabricatorCalendarEventTransaction()) 132 - ->setTransactionType( 133 - PhabricatorCalendarEventTransaction::TYPE_STATUS) 134 - ->setNewValue($type); 135 128 136 129 $xactions[] = id(new PhabricatorCalendarEventTransaction()) 137 130 ->setTransactionType( ··· 195 188 ->setValue($name) 196 189 ->setError($error_name); 197 190 198 - $status_select = id(new AphrontFormSelectControl()) 199 - ->setLabel(pht('Status')) 200 - ->setName('status') 201 - ->setValue($type) 202 - ->setOptions($event->getStatusOptions()); 203 - 204 191 $all_day_checkbox = id(new AphrontFormCheckboxControl()) 205 192 ->addCheckbox( 206 193 'isAllDay', ··· 262 249 $form = id(new AphrontFormView()) 263 250 ->setUser($user) 264 251 ->appendChild($name) 265 - ->appendChild($status_select) 266 252 ->appendChild($all_day_checkbox) 267 253 ->appendChild($start_control) 268 254 ->appendChild($end_control)
+3 -14
src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
··· 17 17 $types[] = PhabricatorCalendarEventTransaction::TYPE_NAME; 18 18 $types[] = PhabricatorCalendarEventTransaction::TYPE_START_DATE; 19 19 $types[] = PhabricatorCalendarEventTransaction::TYPE_END_DATE; 20 - $types[] = PhabricatorCalendarEventTransaction::TYPE_STATUS; 21 20 $types[] = PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION; 22 21 $types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL; 23 22 $types[] = PhabricatorCalendarEventTransaction::TYPE_INVITE; ··· 40 39 return $object->getDateFrom(); 41 40 case PhabricatorCalendarEventTransaction::TYPE_END_DATE: 42 41 return $object->getDateTo(); 43 - case PhabricatorCalendarEventTransaction::TYPE_STATUS: 44 - $status = $object->getStatus(); 45 - if ($status === null) { 46 - return null; 47 - } 48 - return (int)$status; 49 42 case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION: 50 43 return $object->getDescription(); 51 44 case PhabricatorCalendarEventTransaction::TYPE_CANCEL: ··· 82 75 case PhabricatorCalendarEventTransaction::TYPE_INVITE: 83 76 return $xaction->getNewValue(); 84 77 case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: 85 - return (int)$xaction->getNewValue(); 86 - case PhabricatorCalendarEventTransaction::TYPE_STATUS: 87 78 return (int)$xaction->getNewValue(); 88 79 case PhabricatorCalendarEventTransaction::TYPE_START_DATE: 89 80 case PhabricatorCalendarEventTransaction::TYPE_END_DATE: ··· 107 98 case PhabricatorCalendarEventTransaction::TYPE_END_DATE: 108 99 $object->setDateTo($xaction->getNewValue()); 109 100 return; 110 - case PhabricatorCalendarEventTransaction::TYPE_STATUS: 111 - $object->setStatus($xaction->getNewValue()); 112 - return; 113 101 case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION: 114 102 $object->setDescription($xaction->getNewValue()); 115 103 return; ··· 139 127 case PhabricatorCalendarEventTransaction::TYPE_NAME: 140 128 case PhabricatorCalendarEventTransaction::TYPE_START_DATE: 141 129 case PhabricatorCalendarEventTransaction::TYPE_END_DATE: 142 - case PhabricatorCalendarEventTransaction::TYPE_STATUS: 143 130 case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION: 144 131 case PhabricatorCalendarEventTransaction::TYPE_CANCEL: 145 132 case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: ··· 184 171 return $xactions; 185 172 } 186 173 187 - protected function applyFinalEffects($object, array $xactions) { 174 + protected function applyFinalEffects( 175 + PhabricatorLiskDAO $object, 176 + array $xactions) { 188 177 189 178 // Clear the availability caches for users whose availability is affected 190 179 // by this edit.
-46
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 14 14 protected $userPHID; 15 15 protected $dateFrom; 16 16 protected $dateTo; 17 - protected $status; 18 17 protected $description; 19 18 protected $isCancelled; 20 19 protected $isAllDay; ··· 25 24 26 25 private $invitees = self::ATTACHABLE; 27 26 private $appliedViewer; 28 - 29 - const STATUS_AWAY = 1; 30 - const STATUS_SPORADIC = 2; 31 27 32 28 public static function initializeNewCalendarEvent(PhabricatorUser $actor) { 33 29 $app = id(new PhabricatorApplicationQuery()) ··· 160 156 return ($this->getDateFrom() - phutil_units('15 minutes in seconds')); 161 157 } 162 158 163 - private static $statusTexts = array( 164 - self::STATUS_AWAY => 'away', 165 - self::STATUS_SPORADIC => 'sporadic', 166 - ); 167 - 168 - public function setTextStatus($status) { 169 - $statuses = array_flip(self::$statusTexts); 170 - return $this->setStatus($statuses[$status]); 171 - } 172 - 173 - public function getTextStatus() { 174 - return self::$statusTexts[$this->status]; 175 - } 176 - 177 - public function getStatusOptions() { 178 - return array( 179 - self::STATUS_AWAY => pht('Away'), 180 - self::STATUS_SPORADIC => pht('Sporadic'), 181 - ); 182 - } 183 - 184 159 protected function getConfiguration() { 185 160 return array( 186 161 self::CONFIG_AUX_PHID => true, ··· 188 163 'name' => 'text', 189 164 'dateFrom' => 'epoch', 190 165 'dateTo' => 'epoch', 191 - 'status' => 'uint32', 192 166 'description' => 'text', 193 167 'isCancelled' => 'bool', 194 168 'isAllDay' => 'bool', ··· 209 183 210 184 public function getMonogram() { 211 185 return 'E'.$this->getID(); 212 - } 213 - 214 - public function getTerseSummary(PhabricatorUser $viewer) { 215 - $until = phabricator_date($this->dateTo, $viewer); 216 - if ($this->status == self::STATUS_SPORADIC) { 217 - return pht('Sporadic until %s', $until); 218 - } else { 219 - return pht('Away until %s', $until); 220 - } 221 - } 222 - 223 - public static function getNameForStatus($value) { 224 - switch ($value) { 225 - case self::STATUS_AWAY: 226 - return pht('Away'); 227 - case self::STATUS_SPORADIC: 228 - return pht('Sporadic'); 229 - default: 230 - return pht('Unknown'); 231 - } 232 186 } 233 187 234 188 public function getInvitees() {
-23
src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
··· 6 6 const TYPE_NAME = 'calendar.name'; 7 7 const TYPE_START_DATE = 'calendar.startdate'; 8 8 const TYPE_END_DATE = 'calendar.enddate'; 9 - const TYPE_STATUS = 'calendar.status'; 10 9 const TYPE_DESCRIPTION = 'calendar.description'; 11 10 const TYPE_CANCEL = 'calendar.cancel'; 12 11 const TYPE_ALL_DAY = 'calendar.allday'; ··· 35 34 case self::TYPE_NAME: 36 35 case self::TYPE_START_DATE: 37 36 case self::TYPE_END_DATE: 38 - case self::TYPE_STATUS: 39 37 case self::TYPE_DESCRIPTION: 40 38 case self::TYPE_CANCEL: 41 39 case self::TYPE_ALL_DAY: ··· 57 55 switch ($this->getTransactionType()) { 58 56 case self::TYPE_START_DATE: 59 57 case self::TYPE_END_DATE: 60 - case self::TYPE_STATUS: 61 58 case self::TYPE_DESCRIPTION: 62 59 case self::TYPE_CANCEL: 63 60 case self::TYPE_ALL_DAY: ··· 72 69 case self::TYPE_NAME: 73 70 case self::TYPE_START_DATE: 74 71 case self::TYPE_END_DATE: 75 - case self::TYPE_STATUS: 76 72 case self::TYPE_DESCRIPTION: 77 73 case self::TYPE_ALL_DAY: 78 74 case self::TYPE_CANCEL: ··· 120 116 $this->renderHandleLink($author_phid)); 121 117 } 122 118 break; 123 - case self::TYPE_STATUS: 124 - $old_name = PhabricatorCalendarEvent::getNameForStatus($old); 125 - $new_name = PhabricatorCalendarEvent::getNameForStatus($new); 126 - return pht( 127 - '%s updated the event status from %s to %s.', 128 - $this->renderHandleLink($author_phid), 129 - $old_name, 130 - $new_name); 131 119 case self::TYPE_DESCRIPTION: 132 120 return pht( 133 121 "%s updated the event's description.", ··· 287 275 $new); 288 276 } 289 277 break; 290 - case self::TYPE_STATUS: 291 - $old_name = PhabricatorCalendarEvent::getNameForStatus($old); 292 - $new_name = PhabricatorCalendarEvent::getNameForStatus($new); 293 - return pht( 294 - '%s updated the status of %s from %s to %s.', 295 - $this->renderHandleLink($author_phid), 296 - $this->renderHandleLink($object_phid), 297 - $old_name, 298 - $new_name); 299 278 case self::TYPE_DESCRIPTION: 300 279 return pht( 301 280 '%s updated the description of %s.', ··· 430 409 case self::TYPE_NAME: 431 410 case self::TYPE_START_DATE: 432 411 case self::TYPE_END_DATE: 433 - case self::TYPE_STATUS: 434 412 case self::TYPE_DESCRIPTION: 435 413 case self::TYPE_CANCEL: 436 414 case self::TYPE_INVITE: ··· 469 447 $tags = array(); 470 448 switch ($this->getTransactionType()) { 471 449 case self::TYPE_NAME: 472 - case self::TYPE_STATUS: 473 450 case self::TYPE_DESCRIPTION: 474 451 case self::TYPE_INVITE: 475 452 $tags[] = self::MAILTAG_CONTENT;
+8 -6
src/applications/conpherence/controller/ConpherenceWidgetController.php
··· 218 218 $conpherence = $this->getConpherence(); 219 219 $participants = $conpherence->getParticipants(); 220 220 $widget_data = $conpherence->getWidgetData(); 221 - $statuses = $widget_data['statuses']; 221 + 222 + // TODO: This panel is built around an outdated notion of events and isn't 223 + // invitee-aware. 224 + 225 + $statuses = $widget_data['events']; 222 226 $handles = $conpherence->getHandles(); 223 227 $content = array(); 224 228 $layout = id(new AphrontMultiColumnView()) ··· 312 316 $content[] = phutil_tag( 313 317 'div', 314 318 array( 315 - 'class' => 'user-status '.$status->getTextStatus().$top_border, 319 + 'class' => 'user-status '.$top_border, 316 320 ), 317 321 array( 318 322 phutil_tag( ··· 327 331 'class' => 'description', 328 332 ), 329 333 array( 330 - $status->getTerseSummary($user), 334 + $status->getName(), 331 335 phutil_tag( 332 336 'div', 333 337 array( ··· 359 363 if ($status) { 360 364 $inner_layout[] = phutil_tag( 361 365 'div', 362 - array( 363 - 'class' => $status->getTextStatus(), 364 - ), 366 + array(), 365 367 ''); 366 368 } else { 367 369 $inner_layout[] = phutil_tag(
+30 -11
src/applications/conpherence/query/ConpherenceThreadQuery.php
··· 354 354 $this->getViewer()); 355 355 $start_epoch = $epochs['start_epoch']; 356 356 $end_epoch = $epochs['end_epoch']; 357 - $statuses = id(new PhabricatorCalendarEventQuery()) 358 - ->setViewer($this->getViewer()) 359 - ->withInvitedPHIDs($participant_phids) 360 - ->withDateRange($start_epoch, $end_epoch) 361 - ->execute(); 357 + 358 + if ($participant_phids) { 359 + $events = id(new PhabricatorCalendarEventQuery()) 360 + ->setViewer($this->getViewer()) 361 + ->withInvitedPHIDs($participant_phids) 362 + ->withIsCancelled(false) 363 + ->withDateRange($start_epoch, $end_epoch) 364 + ->execute(); 365 + $events = mpull($events, null, 'getPHID'); 366 + } else { 367 + $events = null; 368 + } 362 369 363 - $statuses = mgroup($statuses, 'getUserPHID'); 370 + $invitees = array(); 371 + foreach ($events as $event_phid => $event) { 372 + foreach ($event->getInvitees() as $invitee) { 373 + $invitees[$invitee->getInviteePHID()][$event_phid] = true; 374 + } 375 + } 364 376 365 377 // attached files 366 378 $files = array(); ··· 382 394 383 395 foreach ($conpherences as $phid => $conpherence) { 384 396 $participant_phids = array_keys($conpherence->getParticipants()); 385 - $statuses = array_select_keys($statuses, $participant_phids); 386 - $statuses = array_mergev($statuses); 387 - $statuses = msort($statuses, 'getDateFrom'); 397 + $widget_data = array(); 398 + 399 + $event_phids = array(); 400 + $participant_invites = array_select_keys($invitees, $participant_phids); 401 + foreach ($participant_invites as $invite_set) { 402 + $event_phids += $invite_set; 403 + } 404 + $thread_events = array_select_keys($events, array_keys($event_phids)); 405 + $thread_events = msort($thread_events, 'getDateFrom'); 406 + $widget_data['events'] = $thread_events; 388 407 389 408 $conpherence_files = array(); 390 409 $files_authors = array(); ··· 404 423 } 405 424 $files_authors[$curr_phid] = $current_author; 406 425 } 407 - $widget_data = array( 408 - 'statuses' => $statuses, 426 + $widget_data += array( 409 427 'files' => $conpherence_files, 410 428 'files_authors' => $files_authors, 411 429 ); 430 + 412 431 $conpherence->attachWidgetData($widget_data); 413 432 } 414 433
-62
src/applications/people/conduit/UserAddStatusConduitAPIMethod.php
··· 1 - <?php 2 - 3 - final class UserAddStatusConduitAPIMethod extends UserConduitAPIMethod { 4 - 5 - public function getAPIMethodName() { 6 - return 'user.addstatus'; 7 - } 8 - 9 - public function getMethodStatus() { 10 - return self::METHOD_STATUS_DEPRECATED; 11 - } 12 - 13 - public function getMethodDescription() { 14 - return pht('Add status information to the logged-in user.'); 15 - } 16 - 17 - public function getMethodStatusDescription() { 18 - return pht( 19 - 'Statuses are becoming full-fledged events as part of the '. 20 - 'Calendar application.'); 21 - } 22 - 23 - protected function defineParamTypes() { 24 - $status_const = $this->formatStringConstants(array('away', 'sporadic')); 25 - 26 - return array( 27 - 'fromEpoch' => 'required int', 28 - 'toEpoch' => 'required int', 29 - 'status' => 'required '.$status_const, 30 - 'description' => 'optional string', 31 - ); 32 - } 33 - 34 - protected function defineReturnType() { 35 - return 'void'; 36 - } 37 - 38 - protected function defineErrorTypes() { 39 - return array( 40 - 'ERR-BAD-EPOCH' => "'toEpoch' must be bigger than 'fromEpoch'.", 41 - 'ERR-OVERLAP' => 42 - 'There must be no status in any part of the specified epoch.', 43 - ); 44 - } 45 - 46 - protected function execute(ConduitAPIRequest $request) { 47 - $user_phid = $request->getUser()->getPHID(); 48 - $from = $request->getValue('fromEpoch'); 49 - $to = $request->getValue('toEpoch'); 50 - $status = $request->getValue('status'); 51 - $description = $request->getValue('description', ''); 52 - 53 - id(new PhabricatorCalendarEvent()) 54 - ->setUserPHID($user_phid) 55 - ->setDateFrom($from) 56 - ->setDateTo($to) 57 - ->setTextStatus($status) 58 - ->setDescription($description) 59 - ->save(); 60 - } 61 - 62 - }
-85
src/applications/people/conduit/UserRemoveStatusConduitAPIMethod.php
··· 1 - <?php 2 - 3 - final class UserRemoveStatusConduitAPIMethod extends UserConduitAPIMethod { 4 - 5 - public function getAPIMethodName() { 6 - return 'user.removestatus'; 7 - } 8 - 9 - public function getMethodStatus() { 10 - return self::METHOD_STATUS_DEPRECATED; 11 - } 12 - 13 - public function getMethodDescription() { 14 - return pht('Delete status information of the logged-in user.'); 15 - } 16 - 17 - public function getMethodStatusDescription() { 18 - return pht( 19 - 'Statuses are becoming full-fledged events as part of the '. 20 - 'Calendar application.'); 21 - } 22 - 23 - protected function defineParamTypes() { 24 - return array( 25 - 'fromEpoch' => 'required int', 26 - 'toEpoch' => 'required int', 27 - ); 28 - } 29 - 30 - protected function defineReturnType() { 31 - return 'int'; 32 - } 33 - 34 - protected function defineErrorTypes() { 35 - return array( 36 - 'ERR-BAD-EPOCH' => "'toEpoch' must be bigger than 'fromEpoch'.", 37 - ); 38 - } 39 - 40 - protected function execute(ConduitAPIRequest $request) { 41 - $user_phid = $request->getUser()->getPHID(); 42 - $from = $request->getValue('fromEpoch'); 43 - $to = $request->getValue('toEpoch'); 44 - 45 - if ($to <= $from) { 46 - throw new ConduitException('ERR-BAD-EPOCH'); 47 - } 48 - 49 - $table = new PhabricatorCalendarEvent(); 50 - $table->openTransaction(); 51 - $table->beginReadLocking(); 52 - 53 - $overlap = $table->loadAllWhere( 54 - 'userPHID = %s AND dateFrom < %d AND dateTo > %d', 55 - $user_phid, 56 - $to, 57 - $from); 58 - foreach ($overlap as $status) { 59 - if ($status->getDateFrom() < $from) { 60 - if ($status->getDateTo() > $to) { 61 - // Split the interval. 62 - id(new PhabricatorCalendarEvent()) 63 - ->setUserPHID($user_phid) 64 - ->setDateFrom($to) 65 - ->setDateTo($status->getDateTo()) 66 - ->setStatus($status->getStatus()) 67 - ->setDescription($status->getDescription()) 68 - ->save(); 69 - } 70 - $status->setDateTo($from); 71 - $status->save(); 72 - } else if ($status->getDateTo() > $to) { 73 - $status->setDateFrom($to); 74 - $status->save(); 75 - } else { 76 - $status->delete(); 77 - } 78 - } 79 - 80 - $table->endReadLocking(); 81 - $table->saveTransaction(); 82 - return count($overlap); 83 - } 84 - 85 - }