Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/controller/PhabricatorCalendarEventDragController.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarEventDragController
4
extends PhabricatorCalendarController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $request->getViewer();
8
9
$event = id(new PhabricatorCalendarEventQuery())
10
->setViewer($viewer)
11
->withIDs(array($request->getURIData('id')))
12
->requireCapabilities(
13
array(
14
PhabricatorPolicyCapability::CAN_VIEW,
15
PhabricatorPolicyCapability::CAN_EDIT,
16
))
17
->executeOne();
18
if (!$event) {
19
return new Aphront404Response();
20
}
21
22
if (!$request->validateCSRF()) {
23
return new Aphront400Response();
24
}
25
26
if ($event->getIsAllDay()) {
27
return new Aphront400Response();
28
}
29
30
$xactions = array();
31
32
$duration = $event->getDuration();
33
34
$start = $request->getInt('start');
35
$start_value = id(AphrontFormDateControlValue::newFromEpoch(
36
$viewer,
37
$start));
38
39
$end = $start + $duration;
40
$end_value = id(AphrontFormDateControlValue::newFromEpoch(
41
$viewer,
42
$end));
43
44
$xactions[] = id(new PhabricatorCalendarEventTransaction())
45
->setTransactionType(
46
PhabricatorCalendarEventStartDateTransaction::TRANSACTIONTYPE)
47
->setNewValue($start_value);
48
49
$xactions[] = id(new PhabricatorCalendarEventTransaction())
50
->setTransactionType(
51
PhabricatorCalendarEventEndDateTransaction::TRANSACTIONTYPE)
52
->setNewValue($end_value);
53
54
$editor = id(new PhabricatorCalendarEventEditor())
55
->setActor($viewer)
56
->setContinueOnMissingFields(true)
57
->setContentSourceFromRequest($request)
58
->setContinueOnNoEffect(true);
59
60
$xactions = $editor->applyTransactions($event, $xactions);
61
62
return id(new AphrontReloadResponse());
63
}
64
}
65
66