From b1a843b21a38a9600c2c2bd2fccbce5b69fd7fdd Mon Sep 17 00:00:00 2001 From: lkassianik Date: Fri, 26 Jun 2015 10:41:26 -0700 Subject: [PATCH] Set event policies like other event properties Summary: Closes T8028, Set event policies like other event properties Test Plan: Create and edit events, make sure edit and view policies get populated and saved correctly. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T8028 Differential Revision: https://secure.phabricator.com/D13415 --- .../PhabricatorCalendarController.php | 2 ++ .../PhabricatorCalendarEventEditController.php | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/applications/calendar/controller/PhabricatorCalendarController.php b/src/applications/calendar/controller/PhabricatorCalendarController.php index 6cba6d8fa7..9df28c8ddc 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarController.php @@ -61,6 +61,8 @@ abstract class PhabricatorCalendarController extends PhabricatorController { ->setID(null) ->setPHID(null) ->removeViewerTimezone($viewer) + ->setViewPolicy($event->getViewPolicy()) + ->setEditPolicy($event->getEditPolicy()) ->save(); $ghost_invitees = array(); foreach ($invitees as $invitee) { diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php index 68e119f2bd..d54643c786 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php @@ -156,11 +156,8 @@ final class PhabricatorCalendarEventEditController $is_parent = $event->getIsRecurrenceParent(); $frequency = idx($event->getRecurrenceFrequency(), 'rule'); $icon = $event->getIcon(); - - $current_policies = id(new PhabricatorPolicyQuery()) - ->setViewer($viewer) - ->setObject($event) - ->execute(); + $edit_policy = $event->getEditPolicy(); + $view_policy = $event->getViewPolicy(); if ($request->isFormPost()) { $xactions = array(); @@ -306,9 +303,6 @@ final class PhabricatorCalendarEventEditController PhabricatorCalendarEventTransaction::TYPE_END_DATE); $error_recurrence_end_date = $ex->getShortMessage( PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE); - - $event->setViewPolicy($view_policy); - $event->setEditPolicy($edit_policy); } } @@ -322,6 +316,11 @@ final class PhabricatorCalendarEventEditController $recurring_date_edit_label = null; + $current_policies = id(new PhabricatorPolicyQuery()) + ->setViewer($viewer) + ->setObject($event) + ->execute(); + $name = id(new AphrontFormTextControl()) ->setLabel(pht('Name')) ->setName('name') @@ -468,12 +467,14 @@ final class PhabricatorCalendarEventEditController $view_policies = id(new AphrontFormPolicyControl()) ->setUser($viewer) + ->setValue($view_policy) ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) ->setPolicyObject($event) ->setPolicies($current_policies) ->setName('viewPolicy'); $edit_policies = id(new AphrontFormPolicyControl()) ->setUser($viewer) + ->setValue($edit_policy) ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) ->setPolicyObject($event) ->setPolicies($current_policies)