Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15360764
D12640.id30351.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D12640.id30351.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1483,6 +1483,7 @@
'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php',
'PhabricatorCalendarEvent' => 'applications/calendar/storage/PhabricatorCalendarEvent.php',
'PhabricatorCalendarEventCancelController' => 'applications/calendar/controller/PhabricatorCalendarEventCancelController.php',
+ 'PhabricatorCalendarEventCommentController' => 'applications/calendar/controller/PhabricatorCalendarEventCommentController.php',
'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php',
'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php',
'PhabricatorCalendarEventInvalidEpochException' => 'applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php',
@@ -4818,6 +4819,7 @@
'PhabricatorFlaggableInterface',
),
'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController',
+ 'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorCalendarEventInvalidEpochException' => 'Exception',
diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php
--- a/src/applications/calendar/application/PhabricatorCalendarApplication.php
+++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php
@@ -55,6 +55,8 @@
=> 'PhabricatorCalendarEventCancelController',
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
=> 'PhabricatorCalendarEventJoinController',
+ 'comment/(?P<id>[1-9]\d*)/'
+ => 'PhabricatorCalendarEventCommentController',
),
),
);
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventCommentController.php b/src/applications/calendar/controller/PhabricatorCalendarEventCommentController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventCommentController.php
@@ -0,0 +1,70 @@
+<?php
+
+final class PhabricatorCalendarEventCommentController
+ extends PhabricatorCalendarController {
+
+ private $id;
+
+ public function willProcessRequest(array $data) {
+ $this->id = idx($data, 'id');
+ var_dump($this->id);
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $user = $request->getUser();
+
+ if (!$request->isFormPost()) {
+ return new Aphront400Response();
+ }
+
+ $event = id(new PhabricatorCalendarEventQuery())
+ ->setViewer($user)
+ ->withIDs(array($this->id))
+ ->executeOne();
+ if (!$event) {
+ return new Aphront404Response();
+ }
+
+ $is_preview = $request->isPreviewRequest();
+ $draft = PhabricatorDraft::buildFromRequest($request);
+
+ $view_uri = '/'.$event->getMonogram();
+
+ $xactions = array();
+ $xactions[] = id(new PhabricatorCalendarEventTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
+ ->attachComment(
+ id(new PhabricatorCalendarEventTransactionComment())
+ ->setContent($request->getStr('comment')));
+
+ $editor = id(new PhabricatorCalendarEventEditor())
+ ->setActor($user)
+ ->setContinueOnNoEffect($request->isContinueRequest())
+ ->setContentSourceFromRequest($request)
+ ->setIsPreview($is_preview);
+
+ try {
+ $xactions = $editor->applyTransactions($event, $xactions);
+ } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
+ return id(new PhabricatorApplicationTransactionNoEffectResponse())
+ ->setCancelURI($view_uri)
+ ->setException($ex);
+ }
+
+ if ($draft) {
+ $draft->replaceOrDelete();
+ }
+
+ if ($request->isAjax() && $is_preview) {
+ return id(new PhabricatorApplicationTransactionResponse())
+ ->setViewer($user)
+ ->setTransactions($xactions)
+ ->setIsPreview($is_preview);
+ } else {
+ return id(new AphrontRedirectResponse())
+ ->setURI($view_uri);
+ }
+ }
+
+}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -43,11 +43,26 @@
->setHeader($header)
->addPropertyList($properties);
+ $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
+ $add_comment_header = $is_serious
+ ? pht('Add Comment')
+ : pht('Add To Plate');
+ $draft = PhabricatorDraft::newFromUserAndKey($viewer, $event->getPHID());
+ $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
+ ->setUser($viewer)
+ ->setObjectPHID($event->getPHID())
+ ->setDraft($draft)
+ ->setHeaderText($add_comment_header)
+ ->setAction(
+ $this->getApplicationURI('/event/comment/'.$event->getID().'/'))
+ ->setSubmitButtonName(pht('Add Comment'));
+
return $this->buildApplicationPage(
array(
$crumbs,
$box,
$timeline,
+ $add_comment_form,
),
array(
'title' => $page_title,
diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
--- a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
@@ -22,6 +22,7 @@
$types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL;
$types[] = PhabricatorCalendarEventTransaction::TYPE_INVITE;
+ $types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
@@ -119,6 +120,7 @@
$object->setIsCancelled((int)$xaction->getNewValue());
return;
case PhabricatorCalendarEventTransaction::TYPE_INVITE:
+ case PhabricatorTransactions::TYPE_COMMENT:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_EDGE:
@@ -167,6 +169,7 @@
->save();
}
return;
+ case PhabricatorTransactions::TYPE_COMMENT:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_EDGE:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 10:05 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7582699
Default Alt Text
D12640.id30351.diff (6 KB)
Attached To
Mode
D12640: Calendar events should support comments
Attached
Detach File
Event Timeline
Log In to Comment