Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/command/PhabricatorCalendarEventRSVPEmailCommand.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarEventRSVPEmailCommand
4
extends PhabricatorCalendarEventEmailCommand {
5
6
public function getCommand() {
7
return 'rsvp';
8
}
9
10
public function getCommandSyntax() {
11
return '**!rsvp** //rsvp//';
12
}
13
14
public function getCommandSummary() {
15
return pht('RSVP to event.');
16
}
17
18
public function getCommandDescription() {
19
$status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
20
$status_declined = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
21
22
$yes_values = implode(', ', $this->getYesValues());
23
$no_values = implode(', ', $this->getNoValues());
24
25
$table = array();
26
$table[] = '| '.pht('RSVP').' | '.pht('Keywords');
27
$table[] = '|---|---|';
28
$table[] = '| '.$status_attending.' | '.$yes_values;
29
$table[] = '| '.$status_declined.' | '.$no_values;
30
$table = implode("\n", $table);
31
32
return pht(
33
'To RSVP to the event, specify the desired RSVP, like '.
34
'`!rsvp yes`. This table shows the configured names for rsvp\'s.'.
35
"\n\n%s\n\n".
36
'If you specify an invalid rsvp, the command is ignored. This '.
37
'command has no effect if you do not specify an rsvp.',
38
$table);
39
}
40
41
public function buildTransactions(
42
PhabricatorUser $viewer,
43
PhabricatorApplicationTransactionInterface $object,
44
PhabricatorMetaMTAReceivedMail $mail,
45
$command,
46
array $argv) {
47
48
$target = phutil_utf8_strtolower(implode(' ', $argv));
49
50
$yes_values = $this->getYesValues();
51
$no_values = $this->getNoValues();
52
53
if (in_array($target, $yes_values)) {
54
$rsvp = PhabricatorCalendarEventAcceptTransaction::TRANSACTIONTYPE;
55
} else if (in_array($target, $no_values)) {
56
$rsvp = PhabricatorCalendarEventDeclineTransaction::TRANSACTIONTYPE;
57
} else {
58
return array();
59
}
60
61
$xactions = array();
62
$xactions[] = $object->getApplicationTransactionTemplate()
63
->setTransactionType($rsvp)
64
->setNewValue(true);
65
return $xactions;
66
}
67
68
private function getYesValues() {
69
return array(
70
'yes',
71
'yep',
72
'sounds good',
73
'going',
74
'attending',
75
'will be there',
76
'sure',
77
'accept',
78
'ya',
79
'yeah',
80
'yuh',
81
'uhuh',
82
'ok',
83
'okay',
84
'yiss',
85
'aww yiss',
86
'attend',
87
'intend to attend',
88
'confirm',
89
'confirmed',
90
'bringing dessert',
91
'bringing desert',
92
'time2business',
93
'time4business',
94
);
95
}
96
97
private function getNoValues() {
98
return array(
99
'no',
100
'nope',
101
'no thank you',
102
'next time',
103
'nah',
104
'nuh',
105
'huh',
106
'wut',
107
'no way',
108
'nuhuh',
109
'decline',
110
'declined',
111
'leave',
112
'cancel',
113
);
114
}
115
116
}
117
118