@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorCalendarEventEditController
4 extends PhabricatorCalendarController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
8
9 $engine = id(new PhabricatorCalendarEventEditEngine())
10 ->setController($this);
11
12 $id = $request->getURIData('id');
13 if ($id) {
14 $event = id(new PhabricatorCalendarEventQuery())
15 ->setViewer($viewer)
16 ->withIDs(array($id))
17 ->executeOne();
18 $response = $this->newImportedEventResponse($event);
19 if ($response) {
20 return $response;
21 }
22
23 $cancel_uri = $event->getURI();
24
25 $page = $request->getURIData('pageKey');
26 if ($page == 'recurring') {
27 if ($event->isChildEvent()) {
28 return $this->newDialog()
29 ->setTitle(pht('Series Event'))
30 ->appendParagraph(
31 pht(
32 'This event is an instance in an event series. To change '.
33 'the behavior for the series, edit the parent event.'))
34 ->addCancelButton($cancel_uri);
35 }
36 } else if ($event->getIsRecurring()) {
37
38 // If the user submits a comment or makes an edit via comment actions,
39 // always target only the current event. It doesn't make sense to add
40 // comments to every instance of an event, and the other actions don't
41 // make much sense to apply to all instances either.
42 if ($engine->isCommentAction()) {
43 $mode = PhabricatorCalendarEventEditEngine::MODE_THIS;
44 } else {
45 $mode = $request->getStr('mode');
46 }
47
48 if (!$mode) {
49 $start_time = phutil_tag(
50 'strong',
51 array(),
52 phabricator_datetime($event->getStartDateTimeEpoch(), $viewer));
53
54 $form = id(new AphrontFormView())
55 ->setViewer($viewer)
56 ->appendControl(
57 id(new AphrontFormRadioButtonControl())
58 ->setName('mode')
59 ->setValue(PhabricatorCalendarEventEditEngine::MODE_THIS)
60 ->addButton(
61 PhabricatorCalendarEventEditEngine::MODE_THIS,
62 pht('Edit Only This Event'),
63 pht(
64 'Edit only the event which occurs at %s.',
65 $start_time))
66 ->addButton(
67 PhabricatorCalendarEventEditEngine::MODE_FUTURE,
68 pht('Edit This And All Later Events'),
69 pht(
70 'Edit this event and all events in the series which '.
71 'occur on or after %s. This will overwrite previous '.
72 'edits!',
73 $start_time)));
74 return $this->newDialog()
75 ->setTitle(pht('Edit Event'))
76 ->setWidth(AphrontDialogView::WIDTH_FORM)
77 ->appendParagraph(
78 pht(
79 'This event is part of a series. Which events do you '.
80 'want to edit?'))
81 ->appendForm($form)
82 ->addSubmitButton(pht('Continue'))
83 ->addCancelButton($cancel_uri)
84 ->setDisableWorkflowOnSubmit(true);
85 }
86
87 $engine
88 ->addContextParameter('mode', $mode)
89 ->setSeriesEditMode($mode);
90 }
91 }
92
93 return $engine->buildResponse();
94 }
95
96}