mirror of
https://we.phorge.it/source/phorge.git
synced 2025-04-04 00:18:21 +02:00
Summary: Ref T8568, First pass at event modal create options. Test Plan: {nav Calendar > Create} should offer three options: Create Event, Create Public Event, Create Recurring Event. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T8568 Differential Revision: https://secure.phabricator.com/D13309
76 lines
2.1 KiB
PHP
76 lines
2.1 KiB
PHP
<?php
|
|
|
|
abstract class PhabricatorCalendarController extends PhabricatorController {
|
|
|
|
protected function buildApplicationCrumbs() {
|
|
$crumbs = parent::buildApplicationCrumbs();
|
|
|
|
$actions = id(new PhabricatorActionListView())
|
|
->setUser($this->getViewer())
|
|
->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Create Event'))
|
|
->setHref('/calendar/event/create/'))
|
|
->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Create Public Event'))
|
|
->setHref('/calendar/event/create/?mode=public'))
|
|
->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Create Recurring Event'))
|
|
->setHref('/calendar/event/create/?mode=recurring'));
|
|
|
|
$crumbs->addAction(
|
|
id(new PHUIListItemView())
|
|
->setName(pht('Create Event'))
|
|
->setHref($this->getApplicationURI().'event/create/')
|
|
->setIcon('fa-plus-square')
|
|
->setDropdownMenu($actions));
|
|
|
|
return $crumbs;
|
|
}
|
|
|
|
protected function getEventAtIndexForGhostPHID($viewer, $phid, $index) {
|
|
$result = id(new PhabricatorCalendarEventQuery())
|
|
->setViewer($viewer)
|
|
->withInstanceSequencePairs(
|
|
array(
|
|
array(
|
|
$phid,
|
|
$index,
|
|
),
|
|
))
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->executeOne();
|
|
|
|
return $result;
|
|
}
|
|
|
|
protected function createEventFromGhost($viewer, $event, $index) {
|
|
$invitees = $event->getInvitees();
|
|
|
|
$new_ghost = $event->generateNthGhost($index, $viewer);
|
|
$new_ghost->attachParentEvent($event);
|
|
|
|
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
|
$new_ghost
|
|
->setID(null)
|
|
->setPHID(null)
|
|
->removeViewerTimezone($viewer)
|
|
->save();
|
|
$ghost_invitees = array();
|
|
foreach ($invitees as $invitee) {
|
|
$ghost_invitee = clone $invitee;
|
|
$ghost_invitee
|
|
->setID(null)
|
|
->setEventPHID($new_ghost->getPHID())
|
|
->save();
|
|
}
|
|
unset($unguarded);
|
|
return $new_ghost;
|
|
}
|
|
}
|