Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/xaction/PhabricatorCalendarEventRecurringTransaction.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarEventRecurringTransaction
4
extends PhabricatorCalendarEventTransactionType {
5
6
const TRANSACTIONTYPE = 'calendar.recurring';
7
8
public function generateOldValue($object) {
9
return (int)$object->getIsRecurring();
10
}
11
12
public function generateNewValue($object, $value) {
13
return (int)$value;
14
}
15
16
public function isInheritedEdit() {
17
return false;
18
}
19
20
public function shouldHide() {
21
// This event isn't interesting on its own, and is accompanied by an
22
// "alice set this event to repeat weekly." event in normal circumstances
23
// anyway.
24
return true;
25
}
26
27
public function applyInternalEffects($object, $value) {
28
$object->setIsRecurring($value);
29
}
30
31
public function validateTransactions($object, array $xactions) {
32
$errors = array();
33
34
$old = $object->getIsRecurring();
35
foreach ($xactions as $xaction) {
36
if ($this->isNewObject()) {
37
continue;
38
}
39
40
if ($xaction->getNewValue() == $old) {
41
continue;
42
}
43
44
if ($xaction->getNewValue()) {
45
continue;
46
}
47
48
$errors[] = $this->newInvalidError(
49
pht(
50
'An event can not be stopped from recurring once it has been '.
51
'made recurring. You can cancel the event.'),
52
$xaction);
53
}
54
55
return $errors;
56
}
57
58
}
59
60