function onaccept($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;
        $newevent->fullmessage      = 'Pingpong hoorah! We are still playing! with '.$eventdata['cnt'].' goes';
        $newevent->subject          = $newevent->fullmessage;
        $newevent->icon             = 'objective-approve';

        // do the pingpong workflow event
        $onaccept = new stdClass();
        $onaccept->action = 'pingpong';
        $onaccept->text = 'To keep playing please press accept';
        $onaccept->data = array('forward_to' => $msg->useridto, 'cnt' => $eventdata['cnt'] + 1);
        $newevent->onaccept = $onaccept;
        $onreject = new stdClass();
        $onreject->action = 'pingpong';
        $onreject->text = 'To stop playing please press reject';
        $onreject->data = array('forward_to' => $msg->useridto, 'cnt' => $eventdata['cnt'] + 1);
        $newevent->onreject = $onreject;

        return tm_task_send($newevent);
    }
Beispiel #2
0
    /**
     * Send to a manager
     *
     * @access  public
     * @param   object  $event
     * @param   object  $user       User object
     * @param   int     $sessionid
     * @return  void
     */
    public function send_to_manager($event, $user, $sessionid) {
        global $CFG, $DB;

        if (defined('PHPUNIT_TEST') && PHPUNIT_TEST) {
            return true;
        }

        // Check if notification is to be cc'd to manager.
        if ($this->ccmanager && $manager = get_manager($user->id)) {
            $event->userto = $manager;
            $event->roleid = $CFG->managerroleid;
            $event->fullmessage = $event->managerprefix;
            $event->fullmessagehtml = '';

            if ($this->conditiontype == MDL_F2F_CONDITION_BOOKING_REQUEST) {
                // Do the facetoface workflow event.
                $strmgr = get_string_manager();
                $onaccept = new stdClass();
                $onaccept->action = 'facetoface';
                $onaccept->text = $strmgr->get_string('approveinstruction', 'facetoface', null, $manager->lang);
                $onaccept->data = array('userid' => $user->id, 'session' => $this->_sessions[$sessionid], 'facetoface' => $this->_facetoface);
                $event->onaccept = $onaccept;
                $onreject = new stdClass();
                $onreject->action = 'facetoface';
                $onreject->text = $strmgr->get_string('rejectinstruction', 'facetoface', null, $manager->lang);
                $onreject->data = array('userid' => $user->id, 'session' => $this->_sessions[$sessionid], 'facetoface' => $this->_facetoface);
                $event->onreject = $onreject;
                $event->sendemail = MSG_EMAIL_YES;

                tm_task_send($event);
            } else {
                tm_alert_send($event);
            }
        }
    }