Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/xaction/PhabricatorCalendarEventHostTransaction.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarEventHostTransaction
4
extends PhabricatorCalendarEventTransactionType {
5
6
const TRANSACTIONTYPE = 'calendar.host';
7
8
public function generateOldValue($object) {
9
return $object->getHostPHID();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$object->setHostPHID($value);
14
}
15
16
public function getTitle() {
17
return pht(
18
'%s changed the host of this event from %s to %s.',
19
$this->renderAuthor(),
20
$this->renderOldHandle(),
21
$this->renderNewHandle());
22
}
23
24
public function getTitleForFeed() {
25
return pht(
26
'%s changed the host of %s from %s to %s.',
27
$this->renderAuthor(),
28
$this->renderObject(),
29
$this->renderOldHandle(),
30
$this->renderNewHandle());
31
}
32
33
public function validateTransactions($object, array $xactions) {
34
$errors = array();
35
36
foreach ($xactions as $xaction) {
37
$host_phid = $xaction->getNewValue();
38
if (!$host_phid) {
39
$errors[] = $this->newRequiredError(
40
pht('Event host is required.'));
41
continue;
42
}
43
44
$user = id(new PhabricatorPeopleQuery())
45
->setViewer($this->getActor())
46
->withPHIDs(array($host_phid))
47
->executeOne();
48
if (!$user) {
49
$errors[] = $this->newInvalidError(
50
pht(
51
'Host PHID "%s" is not a valid user PHID.',
52
$host_phid));
53
}
54
}
55
56
return $errors;
57
}
58
59
}
60
61