/**
     * Action called on accept for plan action
     *
     * @param array $eventdata
     * @param object $msg
     */
    function onaccept($eventdata, $msg) {
        global $USER, $CFG;
        $url = $eventdata['redirect'];

        // dismiss myself as will not reach the end
        // because of the redirect
        $result = tm_message_mark_message_read($msg, time());

        redirect($url);
        die(); // should not get here
    }
Esempio n. 2
0
/**
 * marks ALL messages being sent from $fromuserid to $touserid as read
 * @param int $touserid the id of the message recipient
 * @param int $fromuserid the id of the message sender
 * @return void
 */
function tm_message_mark_messages_read($touserid, $fromuserid) {
    global $DB;

    $sql = 'SELECT m.* FROM {message} m WHERE m.useridto=:useridto AND m.useridfrom=:useridfrom';
    $messages = $DB->get_recordset_sql($sql, array('useridto' => $touserid, 'useridfrom' => $fromuserid));

    foreach ($messages as $message) {
        tm_message_mark_message_read($message, time());
    }
    $messages->close();
}
Esempio n. 3
0
/**
 * For listing message histories between any two users
 */

require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once('lib.php');

require_login();
$PAGE->set_context(context_system::instance());

if (isguestuser()) {
    redirect($CFG->wwwroot);
}

/// Script parameters
$msgid = required_param('id', PARAM_INT);
$returnto = optional_param('returnto', NULL, PARAM_LOCALURL);

// check message ownership
$message = $DB->get_record('message', array('id' => $msgid));
if (!$message || $message->useridto != $USER->id) {
    print_error('notyours', 'local_message', null, $msgid);
}

tm_message_mark_message_read($message, time());

if ($returnto) {
    redirect($returnto);
}