コード例 #1
0
ファイル: lib.php プロジェクト: Jtgadbois/Pedadida
/**
 * @todo Document this function
 *
 * @global object
 * @global object
 * @uses CONTEXT_MODULE
 * @return void
 */
function forum_print_posts_threaded($course, &$cm, $forum, $discussion, $parent, $depth, $reply, $forumtracked, $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);

                forum_print_post($post, $discussion, $forum, $cm, $course, $ownpost, $reply, $link,
                                     '', '', $postread, true, $forumtracked);
            } else {
                if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) {
                    echo "</div>\n";
                    continue;
                }
                $by = new stdClass();
                $by->name = fullname($post, $canviewfullnames);
                $by->date = userdate($post->modified);

                if ($forumtracked) {
                    if (!empty($post->postread)) {
                        $style = '<span class="forumthread read">';
                    } else {
                        $style = '<span class="forumthread unread">';
                    }
                } else {
                    $style = '<span class="forumthread">';
                }
                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", "forum", $by);
                echo "</span>";
            }

            forum_print_posts_threaded($course, $cm, $forum, $discussion, $post, $depth-1, $reply, $forumtracked, $posts);
            echo "</div>\n";
        }
    }
}
コード例 #2
0
ファイル: post.php プロジェクト: veritech/pare-project
    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');
    }
    if ($forum->type == 'qanda') {
        $heading = get_string('yournewquestion', 'forum');
    } else {
        $heading = get_string('yournewtopic', 'forum');
    }
}
if ($USER->id != $post->userid) {
コード例 #3
0
ファイル: post.php プロジェクト: njorth/marginalia
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();
コード例 #4
0
/**
 * TODO document
 */
function forum_print_posts_threaded($parent, $courseid, $depth, $ratings, $reply, &$user_read_array, $forumid = 0, $modcontext = NULL)
{
    global $USER, $CFG;
    $link = false;
    $ratingsmenuused = false;
    $istracking = forum_tp_can_track_forums($forumid) && forum_tp_is_tracked($forumid);
    if ($posts = forum_get_child_posts($parent, $forumid)) {
        $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);
                $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;
                }
            } else {
                if (!forum_user_can_see_post($post->forum, $post->discussion, $post)) {
                    continue;
                }
                $by = new object();
                $by->name = fullname($post, $canviewfullnames);
                $by->date = userdate($post->modified);
                if ($istracking) {
                    if (isset($user_read_array[$post->id]) || forum_tp_is_post_old($post)) {
                        $style = '<span class="forumthread read">';
                    } else {
                        $style = '<span class="forumthread unread">';
                    }
                } else {
                    $style = '<span class="forumthread">';
                }
                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", "forum", $by);
                echo "</span>";
            }
            if (forum_print_posts_threaded($post->id, $courseid, $depth - 1, $ratings, $reply, $user_read_array, $forumid, $modcontext)) {
                $ratingsmenuused = true;
            }
            echo "</div>\n";
        }
    }
    return $ratingsmenuused;
}