Example #1
0
/**
 * @todo Document this function
 *
 * @global object
 * @global object
 * @uses CONTEXT_MODULE
 * @return void
 */
function quora_print_posts_threaded($course, &$cm, $quora, $discussion, $parent, $is_assessed, $depth, $reply, $quoratracked, $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);
                quora_print_post($post, $discussion, $quora, $cm, $course, $is_assessed, $ownpost, $reply, $link, '', '', $postread, true, $quoratracked);
            } else {
                if (!quora_user_can_see_post($quora, $discussion, $post, NULL, $cm)) {
                    echo "</div>\n";
                    continue;
                }
                $by = new stdClass();
                $by->name = fullname($post, $canviewfullnames);
                $by->date = userdate($post->modified);
                if ($quoratracked) {
                    if (!empty($post->postread)) {
                        $style = '<span class="quorathread read">';
                    } else {
                        $style = '<span class="quorathread unread">';
                    }
                } else {
                    $style = '<span class="quorathread">';
                }
                echo $style . "<a name=\"{$post->id}\"></a>" . "<a href=\"discuss.php?d={$post->discussion}&amp;parent={$post->id}\">" . format_string($post->subject, true) . "</a> ";
                print_string("bynameondate", "quora", $by);
                echo "</span>";
            }
            quora_print_posts_threaded($course, $cm, $quora, $discussion, $post, $is_assessed, $depth - 1, $reply, $quoratracked, $posts);
            echo "</div>\n";
        }
    }
}
Example #2
0
}
// 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);
        }
    }
}
if (!empty($formheading)) {
    echo $OUTPUT->heading($formheading, 2, array('class' => 'accesshide'));
}
$mform_post->display();