$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', 'quora'); $post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $post->message; } // Prepare a link to the post in context, to be displayed after the quora post. $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "quora") . "</a>"; // Now pring the post. quora_print_post($post, $discussion, $quora, $cm, $course, false, false, false, $fulllink, '', -99, false); } echo $OUTPUT->paging_bar($totalcount, $page, $perpage, $url); echo $OUTPUT->footer(); /** * Print a full-sized search form for the specified course. * * @param stdClass $course The Course that will be searched. * @return void The function prints the form. */ function quora_print_big_search_form($course) { global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT; echo $OUTPUT->box(get_string('searchquoraintro', 'quora'), 'searchbox boxaligncenter', 'intro'); echo $OUTPUT->box_start('generalbox boxaligncenter'); echo html_writer::script('', $CFG->wwwroot . '/mod/quora/quora.js');
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/quora/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", "quora")); $postoutput[] = quora_print_post($post, $discussion, $quora, $cm, $course, false, false, false, $fulllink, '', null, true, null, true); } $userfullname = fullname($user); if ($discussionsonly) { $inpageheading = get_string('discussionsstartedby', 'mod_quora', $userfullname); } else { $inpageheading = get_string('postsmadebyuser', 'mod_quora', $userfullname); } if ($isspecificcourse) { $a = new stdClass(); $a->fullname = $userfullname; $a->coursename = format_string($course->fullname, true, array('context' => $coursecontext)); $pageheading = $a->coursename; if ($discussionsonly) { $pagetitle = get_string('discussionsstartedbyuserincourse', 'mod_quora', $a); } else {
/** * @todo Document this function * @global object * @global object * @return void */ function quora_print_posts_nested($course, &$cm, $quora, $discussion, $parent, $is_assessed, $reply, $quoratracked, $posts) { global $USER, $CFG, $DB; $link = false; if (!empty($posts[$parent->id]->children)) { $posts = $posts[$parent->id]->children; //NighCool make the replys of the firstpost sorted by the number of assessments if ($parent->id == $discussion->firstpost) { $assess = array(); foreach ($posts as $post) { $assess[$post->id] = count($DB->get_records('quora_post_assessments', array('post' => $post->id))); } arsort($assess); $keys = array_keys($assess); $new_posts = array(); foreach ($keys as $key) { $new_posts[$key] =& $posts[$key]; } $posts = $new_posts; } 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); quora_print_post($post, $discussion, $quora, $cm, $course, $is_assessed, $ownpost, $reply, $link, '', '', $postread, true, $quoratracked); quora_print_posts_nested($course, $cm, $quora, $discussion, $post, $is_assessed, $reply, $quoratracked, $posts); echo "</div>\n"; } } }
if (empty($parent) && empty($edit) && !quora_user_can_post_discussion($quora, $groupid, -1, $cm, $modcontext)) { print_error('cannotcreatediscussion', 'quora'); } if ($quora->type == 'qanda' && !has_capability('mod/quora:viewqandawithoutposting', $modcontext) && !empty($discussion->id) && !quora_user_has_posted($quora->id, $discussion->id, $USER->id)) { echo $OUTPUT->notification(get_string('qandanotify', 'quora')); } // 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. quora_check_blocking_threshold($thresholdwarning); } if (!empty($parent)) { if (!($discussion = $DB->get_record('quora_discussions', array('id' => $parent->discussion)))) { print_error('notpartofdiscussion', 'quora'); } quora_print_post($parent, $discussion, $quora, $cm, $course, false, false, false); if (empty($post->edit)) { if ($quora->type != 'qanda' || quora_user_can_see_discussion($quora, $discussion, $modcontext)) { $quoratracked = quora_tp_is_tracked($quora); $posts = quora_get_all_discussion_posts($discussion->id, "created ASC", $quoratracked); quora_print_posts_threaded($course, $cm, $quora, $discussion, $parent, 0, false, $quoratracked, $posts); } } } else { if (!empty($quora->intro)) { echo $OUTPUT->box(format_module_intro('quora', $quora, $cm->id), 'generalbox', 'intro'); if (!empty($CFG->enableplagiarism)) { require_once $CFG->libdir . '/plagiarismlib.php'; echo plagiarism_print_disclosure($cm->id); } }