twf_set_return(); $PAGE->navbar->add(get_string('delete', 'twf')); $PAGE->set_title($course->shortname); $PAGE->set_heading($course->fullname); if ($replycount) { if (!has_capability('mod/twf:deleteanypost', $modcontext)) { print_error("couldnotdeletereplies", "twf", twf_go_back_to("discuss.php?d={$post->discussion}")); } echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($twf->name), 2); echo $OUTPUT->confirm(get_string("deletesureplural", "twf", $replycount + 1), "post.php?delete={$delete}&confirm={$delete}", $CFG->wwwroot . '/mod/twf/discuss.php?d=' . $post->discussion . '#p' . $post->id); twf_print_post($post, $discussion, $twf, $cm, $course, false, false, false); if (empty($post->edit)) { $twftracked = twf_tp_is_tracked($twf); $posts = twf_get_all_discussion_posts($discussion->id, "created ASC", $twftracked); twf_print_posts_nested($course, $cm, $twf, $discussion, $post, false, false, $twftracked, $posts); } } else { echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($twf->name), 2); echo $OUTPUT->confirm(get_string("deletesure", "twf", $replycount), "post.php?delete={$delete}&confirm={$delete}", $CFG->wwwroot . '/mod/twf/discuss.php?d=' . $post->discussion . '#p' . $post->id); twf_print_post($post, $discussion, $twf, $cm, $course, false, false, false); } } echo $OUTPUT->footer(); die; } else { if (!empty($prune)) { // Pruning if (!($post = twf_get_post_full($prune))) { print_error('invalidpostid', 'twf');
/** * @todo Document this function * @global object * @global object * @return void */ function twf_print_posts_nested($course, &$cm, $twf, $discussion, $parent, $reply, $twftracked, $posts) { global $USER, $CFG; $link = false; if (!empty($posts[$parent->id]->children)) { $posts = $posts[$parent->id]->children; foreach ($posts as $post) { echo '<div class="indent">'; if (!isloggedin()) { $ownpost = false; } else { $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); twf_print_posts_nested($course, $cm, $twf, $discussion, $post, $reply, $twftracked, $posts); echo "</div>\n"; } } }