} // If there is a warning message and we are not editing a post we need to handle the warning. if (!empty($thresholdwarning) && !$edit) { // Here we want to throw an exception if they are no longer allowed to post. twf_check_blocking_threshold($thresholdwarning); } if (!empty($parent)) { if (!($discussion = $DB->get_record('twf_discussions', array('id' => $parent->discussion)))) { print_error('notpartofdiscussion', 'twf'); } twf_print_post($parent, $discussion, $twf, $cm, $course, false, false, false); if (empty($post->edit)) { if ($twf->type != 'qanda' || twf_user_can_see_discussion($twf, $discussion, $modcontext)) { $twftracked = twf_tp_is_tracked($twf); $posts = twf_get_all_discussion_posts($discussion->id, "created ASC", $twftracked); twf_print_posts_threaded($course, $cm, $twf, $discussion, $parent, 0, false, $twftracked, $posts); } } } else { if (!empty($twf->intro)) { echo $OUTPUT->box(format_module_intro('twf', $twf, $cm->id), 'generalbox', 'intro'); if (!empty($CFG->enableplagiarism)) { require_once $CFG->libdir . '/plagiarismlib.php'; echo plagiarism_print_disclosure($cm->id); } } } if (!empty($formheading)) { echo $OUTPUT->heading($formheading, 2, array('class' => 'accesshide')); } $mform_post->display();
/** * @todo Document this function * * @global object * @global object * @uses CONTEXT_MODULE * @return void */ function twf_print_posts_threaded($course, &$cm, $twf, $discussion, $parent, $depth, $reply, $twftracked, $posts) { global $USER, $CFG; $link = false; if (!empty($posts[$parent->id]->children)) { $posts = $posts[$parent->id]->children; $modcontext = context_module::instance($cm->id); $canviewfullnames = has_capability('moodle/site:viewfullnames', $modcontext); foreach ($posts as $post) { echo '<div class="indent">'; if ($depth > 0) { $ownpost = $USER->id == $post->userid; $post->subject = format_string($post->subject); $postread = !empty($post->postread); twf_print_post($post, $discussion, $twf, $cm, $course, $ownpost, $reply, $link, '', '', $postread, true, $twftracked); } else { if (!twf_user_can_see_post($twf, $discussion, $post, NULL, $cm)) { echo "</div>\n"; continue; } $by = new stdClass(); $by->name = fullname($post, $canviewfullnames); $by->date = userdate($post->modified); if ($twftracked) { if (!empty($post->postread)) { $style = '<span class="twfthread read">'; } else { $style = '<span class="twfthread unread">'; } } else { $style = '<span class="twfthread">'; } echo $style . "<a name=\"{$post->id}\"></a>" . "<a href=\"discuss.php?d={$post->discussion}&parent={$post->id}\">" . format_string($post->subject, true) . "</a> "; print_string("bynameondate", "twf", $by); echo "</span>"; } twf_print_posts_threaded($course, $cm, $twf, $discussion, $post, $depth - 1, $reply, $twftracked, $posts); echo "</div>\n"; } } }