function onreject($eventdata, $msg) { global $USER, $DB; // can manipulate the language by setting $SESSION->lang temporarily $newevent = new stdClass(); $newevent->userfrom = $USER; $user = $DB->get_record('user', array('id' => $msg->useridfrom), '*', MUST_EXIST); $newevent->userto = $user; $cnt = isset($eventdata['cnt']) ? $eventdata['cnt'] : 0; $newevent->fullmessage = 'You stopped playing :-( after '.$cnt.' goes'; $newevent->subject = $newevent->fullmessage; $newevent->urgency = MSG_URGENCY_NORMAL; $newevent->icon = 'objective-fail'; return tm_alert_send($newevent); }
/** * Send to a third party * * @access public * @param object $event * @param object $user User object * @param int $sessionid * @return void */ public function send_to_thirdparty($event, $user, $sessionid) { if (defined('PHPUNIT_TEST') && PHPUNIT_TEST) { return true; } // Third-party notification. if (!empty($this->_facetoface->thirdparty) && ($this->_sessions[$sessionid]->datetimeknown || !empty($this->_facetoface->thirdpartywaitlist))) { $event->attachment = null; // Leave out the ical attachments in the third-parties notification. $recipients = array_map('trim', explode(',', $this->_facetoface->thirdparty)); $thirdparty = clone $user; $thirdparty->firstname = ''; $thirdparty->lastname = ''; // Avoid showing user's name to third-party recipient. foreach ($recipients as $recipient) { $thirdparty->email = $recipient; $event->userto = $thirdparty; $event->fullmessagehtml = ''; // Avoid repeating footer at the end of the email. tm_alert_send($event); } } }
/** * Send the accept or reject notification to the user * * @param int $userid * @param object $facetoface * @param object $session * @param string $langkey */ private function acceptreject_notification($userid, $facetoface, $session, $langkey) { global $CFG, $DB; $stringmanager = get_string_manager(); $newevent = new stdClass(); $newevent->userfrom = NULL; $user = $DB->get_record('user', array('id' => $userid)); $newevent->userto = $user; $approvedstr = $stringmanager->get_string($langkey, 'facetoface', null, $user->lang); $url = new moodle_url('/mod/facetoface/view.php', array('f' => $facetoface->id)); $newevent->fullmessage = $stringmanager->get_string('requestattendsession', 'facetoface', html_writer::link($url, $facetoface->name), $user->lang) . ' ' . $approvedstr; $newevent->subject = $stringmanager->get_string('requestattendsession', 'facetoface', $facetoface->name, $user->lang) . ' ' . $approvedstr; $newevent->urgency = MSG_URGENCY_NORMAL; return tm_alert_send($newevent); }