1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +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',
'PhabricatorMentionableInterface',
'PhabricatorFlaggableInterface',
'PhabricatorSpacesInterface',
),
'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController',

View file

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

View file

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

View file

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