Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/storage/PhabricatorCalendarEvent.php
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO | ||||
const FREQUENCY_YEARLY = 'yearly'; | const FREQUENCY_YEARLY = 'yearly'; | ||||
public static function initializeNewCalendarEvent(PhabricatorUser $actor) { | public static function initializeNewCalendarEvent(PhabricatorUser $actor) { | ||||
$app = id(new PhabricatorApplicationQuery()) | $app = id(new PhabricatorApplicationQuery()) | ||||
->setViewer($actor) | ->setViewer($actor) | ||||
->withClasses(array('PhabricatorCalendarApplication')) | ->withClasses(array('PhabricatorCalendarApplication')) | ||||
->executeOne(); | ->executeOne(); | ||||
$view_policy = PhabricatorPolicies::getMostOpenPolicy(); | $view_default = PhabricatorCalendarEventDefaultViewCapability::CAPABILITY; | ||||
$edit_default = PhabricatorCalendarEventDefaultEditCapability::CAPABILITY; | |||||
$view_policy = $app->getPolicy($view_default); | |||||
$edit_policy = $app->getPolicy($edit_default); | |||||
$start = new DateTime('@'.PhabricatorTime::getNow()); | $start = new DateTime('@'.PhabricatorTime::getNow()); | ||||
$start->setTimeZone($actor->getTimeZone()); | $start->setTimeZone($actor->getTimeZone()); | ||||
$start->setTime($start->format('H'), 0, 0); | $start->setTime($start->format('H'), 0, 0); | ||||
$start->modify('+1 hour'); | $start->modify('+1 hour'); | ||||
$end = id(clone $start)->modify('+1 hour'); | $end = id(clone $start)->modify('+1 hour'); | ||||
Show All 9 Lines | return id(new PhabricatorCalendarEvent()) | ||||
->setIsStub(0) | ->setIsStub(0) | ||||
->setIsRecurring(0) | ->setIsRecurring(0) | ||||
->setRecurrenceFrequency( | ->setRecurrenceFrequency( | ||||
array( | array( | ||||
'rule' => self::FREQUENCY_WEEKLY, | 'rule' => self::FREQUENCY_WEEKLY, | ||||
)) | )) | ||||
->setIcon($default_icon) | ->setIcon($default_icon) | ||||
->setViewPolicy($view_policy) | ->setViewPolicy($view_policy) | ||||
->setEditPolicy($actor->getPHID()) | ->setEditPolicy($edit_policy) | ||||
->setSpacePHID($actor->getDefaultSpacePHID()) | ->setSpacePHID($actor->getDefaultSpacePHID()) | ||||
->attachInvitees(array()) | ->attachInvitees(array()) | ||||
->setDateFrom($epoch_min) | ->setDateFrom($epoch_min) | ||||
->setDateTo($epoch_max) | ->setDateTo($epoch_max) | ||||
->applyViewerTimezone($actor); | ->applyViewerTimezone($actor); | ||||
} | } | ||||
private function newChild(PhabricatorUser $actor, $sequence) { | private function newChild(PhabricatorUser $actor, $sequence) { | ||||
▲ Show 20 Lines • Show All 569 Lines • Show Last 20 Lines |