if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $modcontext) && !empty($discussion->id) && !forum_user_has_posted($forum->id, $discussion->id, $USER->id)) { echo $OUTPUT->notification(get_string('qandanotify', 'forum')); } forum_check_throttling($forum, $cm); if (!empty($parent)) { if (!($discussion = $DB->get_record('forum_discussions', array('id' => $parent->discussion)))) { print_error('notpartofdiscussion', 'forum'); } // #marginalia begin $moodlemia = moodle_marginalia::get_instance(); $miaprofile = $moodlemia->get_profile($PAGE->url->out(false)); if ($miaprofile) { $miaprofile->emit_body(); $miaprofile->emit_margin_controls(); } // #marginalia end forum_print_post($parent, $discussion, $forum, $cm, $course, false, false, false); if (empty($post->edit)) { if ($forum->type != 'qanda' || forum_user_can_see_discussion($forum, $discussion, $modcontext)) { $forumtracked = forum_tp_is_tracked($forum); $posts = forum_get_all_discussion_posts($discussion->id, "created ASC", $forumtracked); forum_print_posts_threaded($course, $cm, $forum, $discussion, $parent, 0, false, $forumtracked, $posts); } } } else { if (!empty($forum->intro)) { echo $OUTPUT->box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro'); } } $mform_post->display(); echo $OUTPUT->footer();
/** * @todo Document this function * @global object * @global object * @return void */ function forum_print_posts_nested($course, &$cm, $forum, $discussion, $parent, $reply, $forumtracked, $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); forum_print_post($post, $discussion, $forum, $cm, $course, $ownpost, $reply, $link, '', '', $postread, true, $forumtracked); forum_print_posts_nested($course, $cm, $forum, $discussion, $post, $reply, $forumtracked, $posts); echo "</div>\n"; } } }
} $cms[$forum->id] = $cm; unset($cm); // do not use cm directly, it would break caching } $fullsubject = "<a href=\"view.php?f={$forum->id}\">" . format_string($forum->name, true) . "</a>"; if ($forum->type != 'single') { $fullsubject .= " -> <a href=\"discuss.php?d={$discussion->id}\">" . format_string($discussion->name, true) . "</a>"; if ($post->parent != 0) { $fullsubject .= " -> <a href=\"discuss.php?d={$post->discussion}&parent={$post->id}\">" . format_string($post->subject, true) . "</a>"; } } if ($course->id == SITEID && has_capability('moodle/site:config', $syscontext)) { $postcoursename = get_field('course', 'shortname', 'id', $forum->course); $fullsubject = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $forum->course . '">' . $postcoursename . '</a> -> ' . $fullsubject; } $post->subject = $fullsubject; $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>"; forum_print_post($post, $discussion, $forum, $cms[$forum->id], $course, false, false, false, $ratings, $fulllink); echo "<br />"; } print_paging_bar($totalcount, $page, $perpage, "user.php?id={$user->id}&course={$course->id}&mode={$mode}&perpage={$perpage}&"); } else { if ($mode == 'posts') { print_heading(get_string('noposts', 'forum')); } else { print_heading(get_string('nodiscussionsstartedby', 'forum')); } } echo '</div>'; print_footer($course);
} else { print_header("{$course->shortname}: {$strdiscussionname} " . format_string($toppost->subject), $course->fullname, "{$navmiddle} {$navtail}", $mform_post->focus($forcefocus), "", true, "", navmenu($course, $cm)); } // checkup if (!empty($parent) && !forum_user_can_see_post($forum, $discussion, $post)) { error("You cannot reply to this post"); } if (empty($parent) && empty($edit) && !forum_user_can_post_discussion($forum)) { error("You cannot start a new discussion in this forum"); } if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $modcontext) && !empty($discussion->id) && !forum_user_has_posted($forum->id, $discussion->id, $USER->id)) { notify(get_string('qandanotify', 'forum')); } forum_check_throttling($forum); if (!empty($parent)) { forum_print_post($parent, $course->id, $ownpost = false, $reply = false, $link = false); if (empty($post->edit)) { if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) { $user_read_array = forum_tp_get_discussion_read_records($USER->id, $discussion->id); } else { $user_read_array = array(); } if ($forum->type != 'qanda' || forum_user_can_see_discussion($forum, $discussion, $modcontext)) { forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum, $modcontext); } } $heading = get_string("yourreply", "forum"); } else { $forum->intro = trim($forum->intro); if (!empty($forum->intro)) { print_box(format_text($forum->intro), 'generalbox', 'intro');
$post->message = highlight($strippedsearch, format_text($post->message, $post->messageformat, $options, $course->id), 0, '<fgw9sdpq4>', '</fgw9sdpq4>'); foreach ($searchterms as $searchterm) { if (preg_match("/{$searchterm}/i", $post->message) && !preg_match('/<fgw9sdpq4>' . $searchterm . '<\\/fgw9sdpq4>/i', $post->message)) { $missing_terms .= " {$searchterm}"; } } $post->message = str_replace('<fgw9sdpq4>', '<span class="highlight">', $post->message); $post->message = str_replace('</fgw9sdpq4>', '</span>', $post->message); if ($missing_terms) { $strmissingsearchterms = get_string('missingsearchterms', 'forum'); $post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $post->message; } // Prepare a link to the post in context, to be displayed after the forum post. $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>"; // Now pring the post. forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, $fulllink, '', -99, false); } echo $OUTPUT->paging_bar($totalcount, $page, $perpage, $url); echo $OUTPUT->footer(); /** * @todo Document this function */ function forum_print_big_search_form($course) { global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT; echo $OUTPUT->box(get_string('searchforumintro', 'forum'), 'searchbox boxaligncenter', 'intro'); echo $OUTPUT->box_start('generalbox boxaligncenter'); echo html_writer::script('', $CFG->wwwroot . '/mod/forum/forum.js'); echo '<form id="searchform" action="search.php" method="get">'; echo '<table cellpadding="10" class="searchbox" id="form">'; echo '<tr>';
if ($post->parent != 0) { $postname = format_string($post->subject, true, array('context' => $cm->context)); if (!$isspecificcourse && !$hasparentaccess) { $fullsubjects[] .= html_writer::link(new moodle_url('/mod/forum/discuss.php', array('d' => $post->discussion, 'parent' => $post->id)), $postname); } else { $fullsubjects[] .= html_writer::tag('span', $postname); } } } $post->subject = join(' -> ', $fullsubjects); // This is really important, if the strings are formatted again all the links // we've added will be lost. $post->subjectnoformat = true; $discussionurl->set_anchor('p' . $post->id); $fulllink = html_writer::link($discussionurl, get_string("postincontext", "forum")); $postoutput[] = forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, $fulllink, '', null, true, null, true); } $userfullname = fullname($user); if ($discussionsonly) { $inpageheading = get_string('discussionsstartedby', 'mod_forum', $userfullname); } else { $inpageheading = get_string('postsmadebyuser', 'mod_forum', $userfullname); } if ($isspecificcourse) { $a = new stdClass(); $a->fullname = $userfullname; $a->coursename = format_string($course->shortname, true, array('context' => $coursecontext)); $pageheading = $a->coursename; if ($discussionsonly) { $pagetitle = get_string('discussionsstartedbyuserincourse', 'mod_forum', $a); } else {
/** * */ function forum_print_posts_nested($parent, $courseid, $ratings, $reply, &$user_read_array, $forumid = 0, $modcontext = NULL) { global $USER, $CFG; $link = false; $ratingsmenuused = false; if ($posts = forum_get_child_posts($parent, $forumid)) { foreach ($posts as $post) { echo '<div class="indent">'; if (empty($USER->id)) { $ownpost = false; } else { $ownpost = $USER->id == $post->userid; } $post->subject = format_string($post->subject); $post->modcontext = $modcontext; if (forum_print_post($post, $courseid, $ownpost, $reply, $link, $ratings, '', '', isset($user_read_array[$post->id]) || forum_tp_is_post_old($post))) { $ratingsmenuused = true; } if (forum_print_posts_nested($post->id, $courseid, $ratings, $reply, $user_read_array, $forumid, $modcontext)) { $ratingsmenuused = true; } echo "</div>\n"; } } return $ratingsmenuused; }
$options = new object(); $options->trusted = $post->messagetrust; $message = highlight($strippedsearch, format_text($post->message, $post->messageformat, $options, $course->id), 0, '<fgw9sdpq4>', '</fgw9sdpq4>'); foreach ($searchterms as $searchterm) { if (preg_match("/{$searchterm}/i", $message) && !preg_match('/<fgw9sdpq4>' . $searchterm . '<\\/fgw9sdpq4>/i', $message)) { $missing_terms .= " {$searchterm}"; } } if ($missing_terms) { $strmissingsearchterms = get_string('missingsearchterms', 'forum'); $post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $post->message; } // Prepare a link to the post in context, to be displayed after the forum post. $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>"; // Now pring the post. forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, false, $fulllink, $strippedsearch, -99, false); } print_paging_bar($totalcount, $page, $perpage, "search.php?search=" . urlencode($search) . "&id={$course->id}&perpage={$perpage}&"); print_footer($course); /** * @todo Document this function */ function forum_print_big_search_form($course) { global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto; print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro'); print_simple_box_start("center"); echo "<script type=\"text/javascript\">\n"; echo "var timefromitems = ['fromday','frommonth','fromyear','fromhour', 'fromminute'];\n"; echo "var timetoitems = ['today','tomonth','toyear','tohour','tominute'];\n"; echo "</script>\n";
/** * Prints the discussion view screen for a forum. * * @global object * @global object * @param object $course The current course object. * @param object $forum Forum to be printed. * @param int $maxdiscussions . * @param string $displayformat The display format to use (optional). * @param string $sort Sort arguments for database query (optional). * @param int $groupmode Group mode of the forum (optional). * @param void $unused (originally current group) * @param int $page Page mode, page to display (optional). * @param int $perpage The maximum number of discussions per page(optional) * @param boolean $subscriptionstatus Whether the user is currently subscribed to the discussion in some fashion. * */ function oc_forum_print_latest_discussions($course, $forum, $maxdiscussions = -1, $displayformat = 'plain', $sort = '', $currentgroup = -1, $groupmode = -1, $page = -1, $perpage = 100, $cm = null) { global $CFG, $USER, $OUTPUT; if (!$cm) { if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course))) { print_error('invalidcoursemodule'); } } $context = context_module::instance($cm->id); if (empty($sort)) { $sort = "d.timemodified DESC"; } $olddiscussionlink = false; // Sort out some defaults if ($perpage <= 0) { $perpage = 0; $page = -1; } if ($maxdiscussions == 0) { // all discussions - backwards compatibility $page = -1; $perpage = 0; if ($displayformat == 'plain') { $displayformat = 'header'; // Abbreviate display by default } } else { if ($maxdiscussions > 0) { $page = -1; $perpage = $maxdiscussions; } } $fullpost = false; if ($displayformat == 'plain') { $fullpost = true; } // Decide if current user is allowed to see ALL the current discussions or not // First check the group stuff if ($currentgroup == -1 or $groupmode == -1) { $groupmode = groups_get_activity_groupmode($cm, $course); $currentgroup = groups_get_activity_group($cm); } $groups = array(); //cache // If the user can post discussions, then this is a good place to put the // button for it. We do not show the button if we are showing site news // and the current user is a guest. $canstart = forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context); if (!$canstart and $forum->type !== 'news') { if (isguestuser() or !isloggedin()) { $canstart = true; } if (!is_enrolled($context) and !is_viewing($context)) { // allow guests and not-logged-in to see the button - they are prompted to log in after clicking the link // normal users with temporary guest access see this button too, they are asked to enrol instead // do not show the button to users with suspended enrolments here $canstart = enrol_selfenrol_available($course->id); } } if ($canstart) { echo '<div class="singlebutton forumaddnew">'; echo "<form id=\"newdiscussionform\" method=\"get\" action=\"{$CFG->wwwroot}/blocks/oc_mooc_nav/forum_post.php\">"; echo '<div>'; echo "<input type=\"hidden\" name=\"forum\" value=\"{$forum->id}\" />"; switch ($forum->type) { case 'news': case 'blog': $buttonadd = get_string('addanewtopic', 'forum'); break; case 'qanda': $buttonadd = get_string('addanewquestion', 'forum'); break; default: $buttonadd = get_string('addanewdiscussion', 'forum'); break; } echo '<input type="submit" value="' . $buttonadd . '" />'; echo '</div>'; echo '</form>'; echo "</div>\n"; } else { if (isguestuser() or !isloggedin() or $forum->type == 'news' or $forum->type == 'qanda' and !has_capability('mod/forum:addquestion', $context) or $forum->type != 'qanda' and !has_capability('mod/forum:startdiscussion', $context)) { // no button and no info } else { if ($groupmode and !has_capability('moodle/site:accessallgroups', $context)) { // inform users why they can not post new discussion if (!$currentgroup) { echo $OUTPUT->notification(get_string('cannotadddiscussionall', 'forum')); } else { if (!groups_is_member($currentgroup)) { echo $OUTPUT->notification(get_string('cannotadddiscussion', 'forum')); } } } } } // Get all the recent discussions we're allowed to see $getuserlastmodified = $displayformat == 'header'; if (!($discussions = forum_get_discussions($cm, $sort, $fullpost, null, $maxdiscussions, $getuserlastmodified, $page, $perpage))) { echo '<div class="forumnodiscuss">'; if ($forum->type == 'news') { echo '(' . get_string('nonews', 'forum') . ')'; } else { if ($forum->type == 'qanda') { echo '(' . get_string('noquestions', 'forum') . ')'; } else { echo '(' . get_string('nodiscussions', 'forum') . ')'; } } echo "</div>\n"; return; } // If we want paging if ($page != -1) { ///Get the number of discussions found $numdiscussions = forum_get_discussions_count($cm); ///Show the paging bar echo $OUTPUT->paging_bar($numdiscussions, $page, $perpage, "view.php?f={$forum->id}"); if ($numdiscussions > 1000) { // saves some memory on sites with very large forums $replies = forum_count_discussion_replies($forum->id, $sort, $maxdiscussions, $page, $perpage); } else { $replies = forum_count_discussion_replies($forum->id); } } else { $replies = forum_count_discussion_replies($forum->id); if ($maxdiscussions > 0 and $maxdiscussions <= count($discussions)) { $olddiscussionlink = true; } } $canviewparticipants = has_capability('moodle/course:viewparticipants', $context); $strdatestring = get_string('strftimerecentfull'); // Check if the forum is tracked. if ($cantrack = forum_tp_can_track_forums($forum)) { $forumtracked = forum_tp_is_tracked($forum); } else { $forumtracked = false; } if ($forumtracked) { $unreads = forum_get_discussions_unread($cm); } else { $unreads = array(); } if ($displayformat == 'header') { echo '<table cellspacing="0" class="forumheaderlist">'; echo '<thead>'; echo '<tr>'; echo '<th class="header topic" scope="col">' . get_string('discussion', 'forum') . '</th>'; echo '<th class="header author" colspan="2" scope="col">' . get_string('startedby', 'forum') . '</th>'; if ($groupmode > 0) { echo '<th class="header group" scope="col">' . get_string('group') . '</th>'; } if (has_capability('mod/forum:viewdiscussion', $context)) { echo '<th class="header replies" scope="col">' . get_string('replies', 'forum') . '</th>'; // If the forum can be tracked, display the unread column. if ($cantrack) { echo '<th class="header replies" scope="col">' . get_string('unread', 'forum'); if ($forumtracked) { echo '<a title="' . get_string('markallread', 'forum') . '" href="' . $CFG->wwwroot . '/mod/forum/markposts.php?f=' . $forum->id . '&mark=read&returnpage=view.php">' . '<img src="' . $OUTPUT->pix_url('t/markasread') . '" class="iconsmall" alt="' . get_string('markallread', 'forum') . '" /></a>'; } echo '</th>'; } } echo '<th class="header lastpost" scope="col">' . get_string('lastpost', 'forum') . '</th>'; if (!is_guest($context, $USER) && isloggedin() && has_capability('mod/forum:viewdiscussion', $context)) { if (\mod_forum\subscriptions::is_subscribable($forum)) { echo '<th class="header discussionsubscription" scope="col">'; echo forum_get_discussion_subscription_icon_preloaders(); echo '</th>'; } } echo '</tr>'; echo '</thead>'; echo '<tbody>'; } foreach ($discussions as $discussion) { if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $context) && !forum_user_has_posted($forum->id, $discussion->discussion, $USER->id)) { $canviewparticipants = false; } if (!empty($replies[$discussion->discussion])) { $discussion->replies = $replies[$discussion->discussion]->replies; $discussion->lastpostid = $replies[$discussion->discussion]->lastpostid; } else { $discussion->replies = 0; } // SPECIAL CASE: The front page can display a news item post to non-logged in users. // All posts are read in this case. if (!$forumtracked) { $discussion->unread = '-'; } else { if (empty($USER)) { $discussion->unread = 0; } else { if (empty($unreads[$discussion->discussion])) { $discussion->unread = 0; } else { $discussion->unread = $unreads[$discussion->discussion]; } } } if (isloggedin()) { $ownpost = $discussion->userid == $USER->id; } else { $ownpost = false; } // Use discussion name instead of subject of first post $discussion->subject = $discussion->name; switch ($displayformat) { case 'header': if ($groupmode > 0) { if (isset($groups[$discussion->groupid])) { $group = $groups[$discussion->groupid]; } else { $group = $groups[$discussion->groupid] = groups_get_group($discussion->groupid); } } else { $group = -1; } forum_print_discussion_header($discussion, $forum, $group, $strdatestring, $cantrack, $forumtracked, $canviewparticipants, $context); break; default: $link = false; if ($discussion->replies) { $link = true; } else { $modcontext = context_module::instance($cm->id); $link = forum_user_can_see_discussion($forum, $discussion, $modcontext, $USER); } $discussion->forum = $forum->id; forum_print_post($discussion, $discussion, $forum, $cm, $course, $ownpost, 0, $link, false, '', null, true, $forumtracked); break; } } if ($displayformat == "header") { echo '</tbody>'; echo '</table>'; } if ($olddiscussionlink) { if ($forum->type == 'news') { $strolder = get_string('oldertopics', 'forum'); } else { $strolder = get_string('olderdiscussions', 'forum'); } echo '<div class="forumolddiscuss">'; echo '<a href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '&showall=1">'; echo $strolder . '</a> ...</div>'; } if ($page != -1) { ///Show the paging bar echo $OUTPUT->paging_bar($numdiscussions, $page, $perpage, "view.php?f={$forum->id}"); } }
$post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $message; $ttpresent = false; } else { $post->message = $message; } $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>"; //search terms already highlighted - fiedorow - 9/2/2005 $SESSION->forum_search = true; // reconstruct the TRUSTTEXT properly after processing if ($ttpresent) { $post->message = trusttext_mark($post->message); } else { $post->message = trusttext_strip($post->message); //make 100% sure TRUSTTEXT marker was not created during processing } forum_print_post($post, $course->id, false, false, false, false, $fulllink); unset($SESSION->forum_search); echo "<br />"; } print_paging_bar($totalcount, $page, $perpage, "search.php?search=" . urlencode(stripslashes($search)) . "&id={$course->id}&perpage={$perpage}&"); print_footer($course); /** * @todo Document this function */ function forum_print_big_search_form($course) { global $CFG, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto; print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro'); print_simple_box_start("center"); echo "<script type=\"text/javascript\">\n"; echo "var timefromitems = ['fromday','frommonth','fromyear','fromhour', 'fromminute'];\n";
$options = new object(); $options->trusttext = true; $message = highlight($strippedsearch, format_text($post->message, $post->format, $options, $course->id), 0, '<fgw9sdpq4>', '</fgw9sdpq4>'); foreach ($searchterms as $searchterm) { if (preg_match("/{$searchterm}/i", $message) && !preg_match('/<fgw9sdpq4>' . $searchterm . '<\\/fgw9sdpq4>/i', $message)) { $missing_terms .= " {$searchterm}"; } } if ($missing_terms) { $strmissingsearchterms = get_string('missingsearchterms', 'forum'); $post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $post->message; } // Prepare a link to the post in context, to be displayed after the forum post. $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>"; // Now pring the post. forum_print_post($post, $course->id, false, false, false, false, $fulllink, $strippedsearch, -99, false); } print_paging_bar($totalcount, $page, $perpage, "search.php?search=" . urlencode(stripslashes($search)) . "&id={$course->id}&perpage={$perpage}&"); print_footer($course); /** * @todo Document this function */ function forum_print_big_search_form($course) { global $CFG, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto; print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro'); print_simple_box_start("center"); echo "<script type=\"text/javascript\">\n"; echo "var timefromitems = ['fromday','frommonth','fromyear','fromhour', 'fromminute'];\n"; echo "var timetoitems = ['today','tomonth','toyear','tohour','tominute'];\n"; echo "</script>\n";
function forum_print_posts_nested($course, &$cm, $forum, $discussion, $parent, $reply, $forumtracked, $posts, $parentid = 0, $count = 1, $flag = 0) { global $USER, $CFG, $DB; $link = false; $modcontext = context_module::instance($cm->id); if (!empty($posts[$parent->id]->children)) { $posts = $posts[$parent->id]->children; foreach ($posts as $post) { if ((show_discussion($parentid, $forum) and $post->userid != $USER->id and !$flag) && !has_capability('mod/forum:editanypost', $modcontext)) { continue; } else { $flag = 1; } echo '<div class="indent">'; if (!isloggedin()) { $ownpost = false; } else { $ownpost = $USER->id == $post->userid; } $post->subject = format_string($post->subject); $postread = !empty($post->postread); if ($forum->type == 'collaborate' and $post->parent == $parentid) { $regionid = 'forum-questionview' . $count; print_collapsible_region_start('', $regionid, get_string('questionview', 'forum')); forum_print_post($post, $discussion, $forum, $cm, $course, $ownpost, $reply, false, '', '', $postread, true, $forumtracked, false, $parentid); } else { forum_print_post($post, $discussion, $forum, $cm, $course, $ownpost, $reply, false, '', '', $postread, true, $forumtracked, false, $parentid); } if ($forum->type == 'collaborate') { $n = $DB->count_records('forum_posts', array('parent' => $post->id)); if ($n == 0) { print_collapsible_region_end(); } } forum_print_posts_nested($course, $cm, $forum, $discussion, $post, $reply, $forumtracked, $posts, $parentid, $count + 1, $flag); $flag = 0; echo "</div>\n"; $count = $count + 1; } } }
} $fullsubjects = array(); if ($course->id == SITEID && has_capability('moodle/site:config', $syscontext)) { $postcoursename = $DB->get_field('course', 'shortname', array('id' => $forum->course)); $courseurl = new moodle_url('/course/view.php', array('id' => $forum->course)); $fullsubjects[] = html_writer::link($courseurl, $postcoursename); } $fullsubjects[] = html_writer::link($forumurl, format_string($forum->name, true)); if ($forum->type != 'single') { $fullsubjects[] .= html_writer::link($discussionurl, format_string($discussion->name, true)); if ($post->parent != 0) { $parenturl = new moodle_url('/mod/forum/discuss.php', array('d' => $post->discussion, 'parent' => $post->id)); $fullsubjects[] .= html_writer::link($parenturl, format_string($post->subject, true)); } } $post->subject = join(' -> ', $fullsubjects); $discussionurl->set_anchor('p' . $post->id); $fulllink = html_writer::link($discussionurl, get_string("postincontext", "forum")); forum_print_post($post, $discussion, $forum, $forum->cm, $course, false, false, false, $fulllink); echo "<br />"; } echo $OUTPUT->paging_bar($totalcount, $page, $perpage, $baseurl); } else { if ($mode == 'posts') { echo $OUTPUT->heading(get_string('noposts', 'forum')); } else { echo $OUTPUT->heading(get_string('nodiscussionsstartedby', 'forum')); } } echo '</div>'; echo $OUTPUT->footer();