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

Make "My Events" default on Calendar

Summary: Moves Browse to "View All" and makes "My Events" the default on Calendar.

Test Plan: Browse both pages.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

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

+105 -25
+2
src/__phutil_library_map__.php
··· 1317 1317 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php', 1318 1318 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', 1319 1319 'PhabricatorCalendarPHIDTypeEvent' => 'applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php', 1320 + 'PhabricatorCalendarViewController' => 'applications/calendar/controller/PhabricatorCalendarViewController.php', 1320 1321 'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php', 1321 1322 'PhabricatorChangeParserTestCase' => 'applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php', 1322 1323 'PhabricatorChangesetResponse' => 'infrastructure/diff/PhabricatorChangesetResponse.php', ··· 4032 4033 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 4033 4034 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', 4034 4035 'PhabricatorCalendarPHIDTypeEvent' => 'PhabricatorPHIDType', 4036 + 'PhabricatorCalendarViewController' => 'PhabricatorCalendarController', 4035 4037 'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter', 4036 4038 'PhabricatorChangeParserTestCase' => 'PhabricatorWorkingCopyTestCase', 4037 4039 'PhabricatorChangesetResponse' => 'AphrontProxyResponse',
+2 -1
src/applications/calendar/application/PhabricatorApplicationCalendar.php
··· 35 35 public function getRoutes() { 36 36 return array( 37 37 '/calendar/' => array( 38 - '' => 'PhabricatorCalendarBrowseController', 38 + '' => 'PhabricatorCalendarViewController', 39 + 'all/' => 'PhabricatorCalendarBrowseController', 39 40 'event/' => array( 40 41 '(?:query/(?P<queryKey>[^/]+)/)?' => 41 42 'PhabricatorCalendarEventListController',
+2 -23
src/applications/calendar/controller/PhabricatorCalendarBrowseController.php
··· 73 73 74 74 $date = new DateTime("{$year}-{$month}-01"); 75 75 $crumbs = $this->buildApplicationCrumbs(); 76 + $crumbs->addTextCrumb(pht('All Events')); 76 77 $crumbs->addTextCrumb($date->format('F Y')); 77 78 78 79 $nav = $this->buildSideNavView(); 79 - $nav->selectFilter('/'); 80 + $nav->selectFilter('all/'); 80 81 $nav->appendChild( 81 82 array( 82 83 $crumbs, 83 - $this->getNoticeView(), 84 84 $month_view, 85 85 )); 86 86 ··· 90 90 'title' => pht('Calendar'), 91 91 'device' => true, 92 92 )); 93 - } 94 - 95 - private function getNoticeView() { 96 - $request = $this->getRequest(); 97 - $view = null; 98 - 99 - if ($request->getExists('created')) { 100 - $view = id(new AphrontErrorView()) 101 - ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 102 - ->setTitle(pht('Successfully created your status.')); 103 - } else if ($request->getExists('updated')) { 104 - $view = id(new AphrontErrorView()) 105 - ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 106 - ->setTitle(pht('Successfully updated your status.')); 107 - } else if ($request->getExists('deleted')) { 108 - $view = id(new AphrontErrorView()) 109 - ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 110 - ->setTitle(pht('Successfully deleted your status.')); 111 - } 112 - 113 - return $view; 114 93 } 115 94 116 95 }
+2 -1
src/applications/calendar/controller/PhabricatorCalendarController.php
··· 8 8 $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 9 9 10 10 $nav->addLabel(pht('Calendar')); 11 - $nav->addFilter('/', pht('View All')); 11 + $nav->addFilter('/', pht('My Events')); 12 + $nav->addFilter('all/', pht('View All')); 12 13 $nav->addFilter('event/create/', pht('Create Event')); 13 14 14 15 if ($status && $status->getID()) {
+97
src/applications/calendar/controller/PhabricatorCalendarViewController.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarViewController 4 + extends PhabricatorCalendarController { 5 + 6 + public function processRequest() { 7 + $user = $this->getRequest()->getUser(); 8 + 9 + $now = time(); 10 + $request = $this->getRequest(); 11 + $year_d = phabricator_format_local_time($now, $user, 'Y'); 12 + $year = $request->getInt('year', $year_d); 13 + $month_d = phabricator_format_local_time($now, $user, 'm'); 14 + $month = $request->getInt('month', $month_d); 15 + $day = phabricator_format_local_time($now, $user, 'j'); 16 + 17 + 18 + $holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere( 19 + 'day BETWEEN %s AND %s', 20 + "{$year}-{$month}-01", 21 + "{$year}-{$month}-31"); 22 + 23 + $statuses = id(new PhabricatorCalendarEventQuery()) 24 + ->setViewer($user) 25 + ->withInvitedPHIDs(array($user->getPHID())) 26 + ->withDateRange( 27 + strtotime("{$year}-{$month}-01"), 28 + strtotime("{$year}-{$month}-01 next month")) 29 + ->execute(); 30 + 31 + if ($month == $month_d && $year == $year_d) { 32 + $month_view = new PHUICalendarMonthView($month, $year, $day); 33 + } else { 34 + $month_view = new PHUICalendarMonthView($month, $year); 35 + } 36 + 37 + $month_view->setBrowseURI($request->getRequestURI()); 38 + $month_view->setUser($user); 39 + $month_view->setHolidays($holidays); 40 + 41 + $phids = mpull($statuses, 'getUserPHID'); 42 + $handles = $this->loadViewerHandles($phids); 43 + 44 + foreach ($statuses as $status) { 45 + $event = new AphrontCalendarEventView(); 46 + $event->setEpochRange($status->getDateFrom(), $status->getDateTo()); 47 + $event->setUserPHID($status->getUserPHID()); 48 + $event->setName($status->getHumanStatus()); 49 + $event->setDescription($status->getDescription()); 50 + $event->setEventID($status->getID()); 51 + $month_view->addEvent($event); 52 + } 53 + 54 + $date = new DateTime("{$year}-{$month}-01"); 55 + $crumbs = $this->buildApplicationCrumbs(); 56 + $crumbs->addTextCrumb(pht('My Events')); 57 + $crumbs->addTextCrumb($date->format('F Y')); 58 + 59 + $nav = $this->buildSideNavView(); 60 + $nav->selectFilter('/'); 61 + $nav->appendChild( 62 + array( 63 + $crumbs, 64 + $this->getNoticeView(), 65 + $month_view, 66 + )); 67 + 68 + return $this->buildApplicationPage( 69 + $nav, 70 + array( 71 + 'title' => pht('Calendar'), 72 + 'device' => true, 73 + )); 74 + } 75 + 76 + private function getNoticeView() { 77 + $request = $this->getRequest(); 78 + $view = null; 79 + 80 + if ($request->getExists('created')) { 81 + $view = id(new AphrontErrorView()) 82 + ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 83 + ->setTitle(pht('Successfully created your status.')); 84 + } else if ($request->getExists('updated')) { 85 + $view = id(new AphrontErrorView()) 86 + ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 87 + ->setTitle(pht('Successfully updated your status.')); 88 + } else if ($request->getExists('deleted')) { 89 + $view = id(new AphrontErrorView()) 90 + ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 91 + ->setTitle(pht('Successfully deleted your status.')); 92 + } 93 + 94 + return $view; 95 + } 96 + 97 + }