Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php b/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php
index c382d1ebb0..daa2b37803 100644
--- a/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php
@@ -1,95 +1,99 @@
<?php
final class PhabricatorCalendarBrowseController
extends PhabricatorCalendarController {
+ public function shouldAllowPublic() {
+ return true;
+ }
+
public function processRequest() {
$now = time();
$request = $this->getRequest();
$user = $request->getUser();
$year_d = phabricator_format_local_time($now, $user, 'Y');
$year = $request->getInt('year', $year_d);
$month_d = phabricator_format_local_time($now, $user, 'm');
$month = $request->getInt('month', $month_d);
$day = phabricator_format_local_time($now, $user, 'j');
$holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere(
'day BETWEEN %s AND %s',
"{$year}-{$month}-01",
"{$year}-{$month}-31");
$statuses = id(new PhabricatorCalendarEventQuery())
->setViewer($user)
->withDateRange(
strtotime("{$year}-{$month}-01"),
strtotime("{$year}-{$month}-01 next month"))
->execute();
if ($month == $month_d && $year == $year_d) {
$month_view = new PHUICalendarMonthView($month, $year, $day);
} else {
$month_view = new PHUICalendarMonthView($month, $year);
}
$month_view->setBrowseURI($request->getRequestURI());
$month_view->setUser($user);
$month_view->setHolidays($holidays);
$phids = mpull($statuses, 'getUserPHID');
$handles = $this->loadViewerHandles($phids);
/* Assign Colors */
$unique = array_unique($phids);
$allblue = false;
$calcolors = CalendarColors::getColors();
if (count($unique) > count($calcolors)) {
$allblue = true;
}
$i = 0;
$eventcolor = array();
foreach ($unique as $phid) {
if ($allblue) {
$eventcolor[$phid] = CalendarColors::COLOR_SKY;
} else {
$eventcolor[$phid] = $calcolors[$i];
}
$i++;
}
foreach ($statuses as $status) {
$event = new AphrontCalendarEventView();
$event->setEpochRange($status->getDateFrom(), $status->getDateTo());
$name_text = $handles[$status->getUserPHID()]->getName();
$status_text = $status->getHumanStatus();
$event->setUserPHID($status->getUserPHID());
$event->setDescription(pht('%s (%s)', $name_text, $status_text));
$event->setName($status_text);
$event->setEventID($status->getID());
$event->setColor($eventcolor[$status->getUserPHID()]);
$month_view->addEvent($event);
}
$date = new DateTime("{$year}-{$month}-01");
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('All Events'));
$crumbs->addTextCrumb($date->format('F Y'));
$nav = $this->buildSideNavView();
$nav->selectFilter('all/');
$nav->appendChild(
array(
$crumbs,
$month_view,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('Calendar'),
'device' => true,
));
}
}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventListController.php b/src/applications/calendar/controller/PhabricatorCalendarEventListController.php
index 8a6f1331f9..d7b1019925 100644
--- a/src/applications/calendar/controller/PhabricatorCalendarEventListController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventListController.php
@@ -1,36 +1,40 @@
<?php
final class PhabricatorCalendarEventListController
extends PhabricatorCalendarController {
private $queryKey;
+ public function shouldAllowPublic() {
+ return true;
+ }
+
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new PhabricatorCalendarEventSearchEngine())
->setNavigation($this->buildSideNav());
return $this->delegateToController($controller);
}
public function buildSideNav() {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new PhabricatorCalendarEventSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
index fded32e162..772b75c3e4 100644
--- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -1,112 +1,116 @@
<?php
final class PhabricatorCalendarEventViewController
extends PhabricatorCalendarController {
private $id;
+ public function shouldAllowPublic() {
+ return true;
+ }
+
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$event = id(new PhabricatorCalendarEventQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->executeOne();
if (!$event) {
return new Aphront404Response();
}
$title = pht('Event %d', $event->getID());
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title);
$header = $this->buildHeaderView($event);
$actions = $this->buildActionView($event);
$properties = $this->buildPropertyView($event);
$properties->setActionList($actions);
$box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties);
return $this->buildApplicationPage(
array(
$crumbs,
$box,
),
array(
'title' => $title,
'device' => true,
));
}
private function buildHeaderView(PhabricatorCalendarEvent $event) {
$viewer = $this->getRequest()->getUser();
return id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($event->getTerseSummary($viewer))
->setPolicyObject($event);
}
private function buildActionView(PhabricatorCalendarEvent $event) {
$viewer = $this->getRequest()->getUser();
$id = $event->getID();
$actions = id(new PhabricatorActionListView())
->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$event,
PhabricatorPolicyCapability::CAN_EDIT);
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Event'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI("event/edit/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Cancel Event'))
->setIcon('fa-times')
->setHref($this->getApplicationURI("event/delete/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow(true));
return $actions;
}
private function buildPropertyView(PhabricatorCalendarEvent $event) {
$viewer = $this->getRequest()->getUser();
$properties = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($event);
$properties->addProperty(
pht('Starts'),
phabricator_datetime($event->getDateFrom(), $viewer));
$properties->addProperty(
pht('Ends'),
phabricator_datetime($event->getDateTo(), $viewer));
$properties->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($event->getDescription());
return $properties;
}
}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarViewController.php b/src/applications/calendar/controller/PhabricatorCalendarViewController.php
index 16cd41dffa..e14dc7073a 100644
--- a/src/applications/calendar/controller/PhabricatorCalendarViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarViewController.php
@@ -1,97 +1,114 @@
<?php
final class PhabricatorCalendarViewController
extends PhabricatorCalendarController {
+ public function shouldAllowPublic() {
+ return true;
+ }
+
public function processRequest() {
$user = $this->getRequest()->getUser();
$now = time();
$request = $this->getRequest();
$year_d = phabricator_format_local_time($now, $user, 'Y');
$year = $request->getInt('year', $year_d);
$month_d = phabricator_format_local_time($now, $user, 'm');
$month = $request->getInt('month', $month_d);
$day = phabricator_format_local_time($now, $user, 'j');
$holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere(
'day BETWEEN %s AND %s',
"{$year}-{$month}-01",
"{$year}-{$month}-31");
$statuses = id(new PhabricatorCalendarEventQuery())
->setViewer($user)
->withInvitedPHIDs(array($user->getPHID()))
->withDateRange(
strtotime("{$year}-{$month}-01"),
strtotime("{$year}-{$month}-01 next month"))
->execute();
if ($month == $month_d && $year == $year_d) {
$month_view = new PHUICalendarMonthView($month, $year, $day);
} else {
$month_view = new PHUICalendarMonthView($month, $year);
}
$month_view->setBrowseURI($request->getRequestURI());
$month_view->setUser($user);
$month_view->setHolidays($holidays);
$phids = mpull($statuses, 'getUserPHID');
$handles = $this->loadViewerHandles($phids);
foreach ($statuses as $status) {
$event = new AphrontCalendarEventView();
$event->setEpochRange($status->getDateFrom(), $status->getDateTo());
$event->setUserPHID($status->getUserPHID());
$event->setName($status->getHumanStatus());
$event->setDescription($status->getDescription());
$event->setEventID($status->getID());
$month_view->addEvent($event);
}
$date = new DateTime("{$year}-{$month}-01");
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('My Events'));
$crumbs->addTextCrumb($date->format('F Y'));
$nav = $this->buildSideNavView();
$nav->selectFilter('/');
$nav->appendChild(
array(
$crumbs,
$this->getNoticeView(),
$month_view,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('Calendar'),
'device' => true,
));
}
private function getNoticeView() {
$request = $this->getRequest();
$view = null;
if ($request->getExists('created')) {
$view = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setTitle(pht('Successfully created your status.'));
} else if ($request->getExists('updated')) {
$view = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setTitle(pht('Successfully updated your status.'));
} else if ($request->getExists('deleted')) {
$view = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setTitle(pht('Successfully deleted your status.'));
+ } else if (!$request->getUser()->isLoggedIn()) {
+ $login_uri = id(new PhutilURI('/auth/start/'))
+ ->setQueryParam('next', '/calendar/');
+ $view = id(new AphrontErrorView())
+ ->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
+ ->setTitle(
+ pht(
+ 'You are not logged in. %s to see your calendar events.',
+ phutil_tag(
+ 'a',
+ array(
+ 'href' => $login_uri),
+ pht('Log in'))));
}
return $view;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jul 27, 3:01 PM (1 w, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
185397
Default Alt Text
(12 KB)

Event Timeline