Example #1
0
$PAGE->requires->jquery_plugin('ui');
$PAGE->requires->jquery_plugin('ui-css');
$PAGE->requires->js(new moodle_url($CFG->wwwroot . '/local/simple_message/js/sm.js'));
// Import strings for dialog boxes
$PAGE->requires->string_for_js('cantsendempty', 'local_simple_message');
$PAGE->requires->string_for_js('wannadiscard', 'local_simple_message');
$PAGE->requires->string_for_js('wannadelete', 'local_simple_message');
// Initialize $PAGE
$PAGE->set_url('/local/simple_message/message.php');
$PAGE->set_title(get_string('title', 'local_simple_message'));
$PAGE->set_heading(get_string('title', 'local_simple_message'));
$renderer = $PAGE->get_renderer('local_simple_message');
/// Print the page header
echo $OUTPUT->header();
echo "<div id='sm-wrapper' class='clearfix'>";
echo $renderer->render_navigation();
if ($conversationid >= 0) {
    global $DB;
    if ($DB->count_records('sm_conversation_users', array('conversationid' => $conversationid, 'userid' => $USER->id)) == 0) {
        // no entry for current user in conversation, so user can't view messages
        error('You cannot view this conversation.');
    }
    $conversation = local_simple_message_conversation::find_converstation_by_id($conversationid);
    // print_r($conversation);
    echo $renderer->render_conversation($conversation);
    $conversation->update_last_read();
} else {
    echo $renderer->render_welcome_message();
}
echo "</div>";
echo $OUTPUT->footer();