Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/conpherence/xaction/ConpherenceThreadTopicTransaction.php
12256 views
1
<?php
2
3
final class ConpherenceThreadTopicTransaction
4
extends ConpherenceThreadTransactionType {
5
6
const TRANSACTIONTYPE = 'topic';
7
8
public function generateOldValue($object) {
9
return $object->getTopic();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$object->setTopic($value);
14
}
15
16
public function getTitle() {
17
$old = $this->getOldValue();
18
$new = $this->getNewValue();
19
20
if (strlen($new)) {
21
return pht(
22
'%s set the room topic to %s.',
23
$this->renderAuthor(),
24
$this->renderNewValue());
25
} else {
26
return pht(
27
'%s removed the room topic.',
28
$this->renderAuthor());
29
}
30
31
}
32
33
public function getTitleForFeed() {
34
$old = $this->getOldValue();
35
$new = $this->getNewValue();
36
37
if (strlen($new)) {
38
return pht(
39
'%s set the room topic to %s in %s.',
40
$this->renderAuthor(),
41
$this->renderNewValue(),
42
$this->renderObject());
43
} else {
44
return pht(
45
'%s removed the room topic for %s.',
46
$this->renderAuthor(),
47
$this->renderObject());
48
}
49
50
}
51
52
public function validateTransactions($object, array $xactions) {
53
$errors = array();
54
55
$max_length = $object->getColumnMaximumByteLength('topic');
56
foreach ($xactions as $xaction) {
57
$new_value = $xaction->getNewValue();
58
$new_length = strlen($new_value);
59
if ($new_length > $max_length) {
60
$errors[] = $this->newInvalidError(
61
pht('The topic can be no longer than %s characters.',
62
new PhutilNumber($max_length)));
63
}
64
}
65
66
return $errors;
67
}
68
69
}
70
71