1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-14 16:51:08 +01:00

Events should offer Spaces as the view policy options

Summary: Ref T8687, Events should offer Spaces as the view policy options

Test Plan: Create event, choose default Space, save, edit, choose different Space, save, new policy should be reflected on Event.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T8687

Differential Revision: https://secure.phabricator.com/D13459
This commit is contained in:
lkassianik 2015-06-27 10:26:24 -07:00
parent 109fa94011
commit 76e69f0be5
5 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
ADD spacePHID VARBINARY(64);

View file

@ -5124,6 +5124,7 @@ phutil_register_library_map(array(
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
'PhabricatorMentionableInterface', 'PhabricatorMentionableInterface',
'PhabricatorFlaggableInterface', 'PhabricatorFlaggableInterface',
'PhabricatorSpacesInterface',
), ),
'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController',

View file

@ -158,6 +158,7 @@ final class PhabricatorCalendarEventEditController
$icon = $event->getIcon(); $icon = $event->getIcon();
$edit_policy = $event->getEditPolicy(); $edit_policy = $event->getEditPolicy();
$view_policy = $event->getViewPolicy(); $view_policy = $event->getViewPolicy();
$space = $event->getSpacePHID();
if ($request->isFormPost()) { if ($request->isFormPost()) {
$xactions = array(); $xactions = array();
@ -178,6 +179,7 @@ final class PhabricatorCalendarEventEditController
$subscribers = $request->getArr('subscribers'); $subscribers = $request->getArr('subscribers');
$edit_policy = $request->getStr('editPolicy'); $edit_policy = $request->getStr('editPolicy');
$view_policy = $request->getStr('viewPolicy'); $view_policy = $request->getStr('viewPolicy');
$space = $request->getStr('spacePHID');
$is_recurring = $request->getStr('isRecurring') ? 1 : 0; $is_recurring = $request->getStr('isRecurring') ? 1 : 0;
$frequency = $request->getStr('frequency'); $frequency = $request->getStr('frequency');
$is_all_day = $request->getStr('isAllDay'); $is_all_day = $request->getStr('isAllDay');
@ -263,6 +265,10 @@ final class PhabricatorCalendarEventEditController
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
->setNewValue($request->getStr('editPolicy')); ->setNewValue($request->getStr('editPolicy'));
$xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_SPACE)
->setNewValue($space);
$editor = id(new PhabricatorCalendarEventEditor()) $editor = id(new PhabricatorCalendarEventEditor())
->setActor($viewer) ->setActor($viewer)
->setContentSourceFromRequest($request) ->setContentSourceFromRequest($request)
@ -471,6 +477,7 @@ final class PhabricatorCalendarEventEditController
->setCapability(PhabricatorPolicyCapability::CAN_VIEW) ->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setPolicyObject($event) ->setPolicyObject($event)
->setPolicies($current_policies) ->setPolicies($current_policies)
->setSpacePHID($space)
->setName('viewPolicy'); ->setName('viewPolicy');
$edit_policies = id(new AphrontFormPolicyControl()) $edit_policies = id(new AphrontFormPolicyControl())
->setUser($viewer) ->setUser($viewer)

View file

@ -288,6 +288,8 @@ final class PhabricatorCalendarEventSearchEngine
} }
$item = id(new PHUIObjectItemView()) $item = id(new PHUIObjectItemView())
->setUser($viewer)
->setObject($event)
->setHeader($viewer->renderHandle($event->getPHID())->render()) ->setHeader($viewer->renderHandle($event->getPHID())->render())
->addAttribute($event_date_info) ->addAttribute($event_date_info)
->addAttribute($attendees) ->addAttribute($attendees)

View file

@ -9,7 +9,8 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
PhabricatorTokenReceiverInterface, PhabricatorTokenReceiverInterface,
PhabricatorDestructibleInterface, PhabricatorDestructibleInterface,
PhabricatorMentionableInterface, PhabricatorMentionableInterface,
PhabricatorFlaggableInterface { PhabricatorFlaggableInterface,
PhabricatorSpacesInterface {
protected $name; protected $name;
protected $userPHID; protected $userPHID;
@ -32,6 +33,8 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
protected $viewPolicy; protected $viewPolicy;
protected $editPolicy; protected $editPolicy;
protected $spacePHID;
const DEFAULT_ICON = 'fa-calendar'; const DEFAULT_ICON = 'fa-calendar';
private $parentEvent = self::ATTACHABLE; private $parentEvent = self::ATTACHABLE;
@ -71,6 +74,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
->setIcon(self::DEFAULT_ICON) ->setIcon(self::DEFAULT_ICON)
->setViewPolicy($view_policy) ->setViewPolicy($view_policy)
->setEditPolicy($actor->getPHID()) ->setEditPolicy($actor->getPHID())
->setSpacePHID($actor->getDefaultSpacePHID())
->attachInvitees(array()) ->attachInvitees(array())
->applyViewerTimezone($actor); ->applyViewerTimezone($actor);
} }
@ -551,4 +555,11 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
$this->delete(); $this->delete();
$this->saveTransaction(); $this->saveTransaction();
} }
/* -( PhabricatorSpacesInterface )----------------------------------------- */
public function getSpacePHID() {
return $this->spacePHID;
}
} }