Example #1
0
} else {
    $parent = $discussion->firstpost;
}
if (!($post = twf_get_post_full($parent))) {
    print_error("notexists", 'twf', "{$CFG->wwwroot}/mod/twf/view.php?f={$twf->id}");
}
if (!twf_user_can_see_post($twf, $discussion, $post, null, $cm)) {
    print_error('noviewdiscussionspermission', 'twf', "{$CFG->wwwroot}/mod/twf/view.php?id={$twf->id}");
}
if ($mark == 'read' or $mark == 'unread') {
    if ($CFG->twf_usermarksread && twf_tp_can_track_twfs($twf) && twf_tp_is_tracked($twf)) {
        if ($mark == 'read') {
            twf_tp_add_read_record($USER->id, $postid);
        } else {
            // unread
            twf_tp_delete_read_records($USER->id, $postid);
        }
    }
}
$searchform = twf_search_form($course);
$twfnode = $PAGE->navigation->find($cm->id, navigation_node::TYPE_ACTIVITY);
if (empty($twfnode)) {
    $twfnode = $PAGE->navbar;
} else {
    $twfnode->make_active();
}
$node = $twfnode->add(format_string($discussion->name), new moodle_url('/mod/twf/discuss.php', array('d' => $discussion->id)));
$node->display = false;
if ($node && $post->id != $discussion->firstpost) {
    $node->add(format_string($post->subject), $PAGE->url);
}
Example #2
0
/**
 * @global object
 * @global object
 * @param int $twfid
 * @param int $userid
 */
function twf_tp_stop_tracking($twfid, $userid = false)
{
    global $USER, $DB;
    if ($userid === false) {
        $userid = $USER->id;
    }
    if (!$DB->record_exists('twf_track_prefs', array('userid' => $userid, 'twfid' => $twfid))) {
        $track_prefs = new stdClass();
        $track_prefs->userid = $userid;
        $track_prefs->twfid = $twfid;
        $DB->insert_record('twf_track_prefs', $track_prefs);
    }
    return twf_tp_delete_read_records($userid, -1, -1, $twfid);
}