Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/xaction/PhabricatorCalendarEventAllDayTransaction.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarEventAllDayTransaction
4
extends PhabricatorCalendarEventTransactionType {
5
6
const TRANSACTIONTYPE = 'calendar.allday';
7
8
public function generateOldValue($object) {
9
return (int)$object->getIsAllDay();
10
}
11
12
public function generateNewValue($object, $value) {
13
return (int)$value;
14
}
15
16
public function applyInternalEffects($object, $value) {
17
$object->setIsAllDay($value);
18
19
// Adjust the flags on any other dates the event has.
20
$keys = array(
21
'startDateTime',
22
'endDateTime',
23
'untilDateTime',
24
);
25
26
foreach ($keys as $key) {
27
$dict = $object->getParameter($key);
28
if (!$dict) {
29
continue;
30
}
31
32
$datetime = PhutilCalendarAbsoluteDateTime::newFromDictionary($dict);
33
$datetime->setIsAllDay($value);
34
35
$object->setParameter($key, $datetime->toDictionary());
36
}
37
}
38
39
public function getTitle() {
40
if ($this->getNewValue()) {
41
return pht(
42
'%s changed this to an all day event.',
43
$this->renderAuthor());
44
} else {
45
return pht(
46
'%s converted this from an all day event.',
47
$this->renderAuthor());
48
}
49
}
50
51
public function getTitleForFeed() {
52
if ($this->getNewValue()) {
53
return pht(
54
'%s changed %s to an all day event.',
55
$this->renderAuthor(),
56
$this->renderObject());
57
} else {
58
return pht(
59
'%s converted %s from an all day event.',
60
$this->renderAuthor(),
61
$this->renderObject());
62
}
63
}
64
65
}
66
67