Path: blob/master/src/applications/calendar/command/PhabricatorCalendarEventRSVPEmailCommand.php
12256 views
<?php12final class PhabricatorCalendarEventRSVPEmailCommand3extends PhabricatorCalendarEventEmailCommand {45public function getCommand() {6return 'rsvp';7}89public function getCommandSyntax() {10return '**!rsvp** //rsvp//';11}1213public function getCommandSummary() {14return pht('RSVP to event.');15}1617public function getCommandDescription() {18$status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;19$status_declined = PhabricatorCalendarEventInvitee::STATUS_DECLINED;2021$yes_values = implode(', ', $this->getYesValues());22$no_values = implode(', ', $this->getNoValues());2324$table = array();25$table[] = '| '.pht('RSVP').' | '.pht('Keywords');26$table[] = '|---|---|';27$table[] = '| '.$status_attending.' | '.$yes_values;28$table[] = '| '.$status_declined.' | '.$no_values;29$table = implode("\n", $table);3031return pht(32'To RSVP to the event, specify the desired RSVP, like '.33'`!rsvp yes`. This table shows the configured names for rsvp\'s.'.34"\n\n%s\n\n".35'If you specify an invalid rsvp, the command is ignored. This '.36'command has no effect if you do not specify an rsvp.',37$table);38}3940public function buildTransactions(41PhabricatorUser $viewer,42PhabricatorApplicationTransactionInterface $object,43PhabricatorMetaMTAReceivedMail $mail,44$command,45array $argv) {4647$target = phutil_utf8_strtolower(implode(' ', $argv));4849$yes_values = $this->getYesValues();50$no_values = $this->getNoValues();5152if (in_array($target, $yes_values)) {53$rsvp = PhabricatorCalendarEventAcceptTransaction::TRANSACTIONTYPE;54} else if (in_array($target, $no_values)) {55$rsvp = PhabricatorCalendarEventDeclineTransaction::TRANSACTIONTYPE;56} else {57return array();58}5960$xactions = array();61$xactions[] = $object->getApplicationTransactionTemplate()62->setTransactionType($rsvp)63->setNewValue(true);64return $xactions;65}6667private function getYesValues() {68return array(69'yes',70'yep',71'sounds good',72'going',73'attending',74'will be there',75'sure',76'accept',77'ya',78'yeah',79'yuh',80'uhuh',81'ok',82'okay',83'yiss',84'aww yiss',85'attend',86'intend to attend',87'confirm',88'confirmed',89'bringing dessert',90'bringing desert',91'time2business',92'time4business',93);94}9596private function getNoValues() {97return array(98'no',99'nope',100'no thank you',101'next time',102'nah',103'nuh',104'huh',105'wut',106'no way',107'nuhuh',108'decline',109'declined',110'leave',111'cancel',112);113}114115}116117118