Example #1
0
    $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', 'twf');
        $post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $post->message;
    }
    // Prepare a link to the post in context, to be displayed after the twf post.
    $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "twf") . "</a>";
    // Now pring the post.
    twf_print_post($post, $discussion, $twf, $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 twf_print_big_search_form($course)
{
    global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT;
    echo $OUTPUT->box(get_string('searchtwfintro', 'twf'), 'searchbox boxaligncenter', 'intro');
    echo $OUTPUT->box_start('generalbox boxaligncenter');
    echo html_writer::script('', $CFG->wwwroot . '/mod/twf/twf.js');
Example #2
0
if (empty($parent) && empty($edit) && !twf_user_can_post_discussion($twf, $groupid, -1, $cm, $modcontext)) {
    print_error('cannotcreatediscussion', 'twf');
}
if ($twf->type == 'qanda' && !has_capability('mod/twf:viewqandawithoutposting', $modcontext) && !empty($discussion->id) && !twf_user_has_posted($twf->id, $discussion->id, $USER->id)) {
    echo $OUTPUT->notification(get_string('qandanotify', 'twf'));
}
// 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);
        }
    }
Example #3
0
        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/twf/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", "twf"));
    $postoutput[] = twf_print_post($post, $discussion, $twf, $cm, $course, false, false, false, $fulllink, '', null, true, null, true);
}
$userfullname = fullname($user);
if ($discussionsonly) {
    $inpageheading = get_string('discussionsstartedby', 'mod_twf', $userfullname);
} else {
    $inpageheading = get_string('postsmadebyuser', 'mod_twf', $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_twf', $a);
    } else {
Example #4
0
/**
 * @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";
        }
    }
}