Exemplo n.º 1
0
    $comment->userid = $USER->id;
    $comment->postid = $postid;
    // Special behaviour for moderated users
    if ($moderated) {
        // Check IP address
        if (oublog_too_many_comments_from_ip()) {
            print_error('error_toomanycomments', 'oublog');
        }
        // Set the confirmed cookie if they haven't got it yet
        if (!$confirmed) {
            setcookie(OUBLOG_CONFIRMED_COOKIE, $comment->confirm, time() + 365 * 24 * 3600);
            // Expire in 1 year
        }
        if (!oublog_add_comment_moderated($oublog, $oubloginstance, $post, $comment)) {
            print_error('couldnotaddcomment', 'oublog');
        }
        $approvaltime = oublog_get_typical_approval_time($post->userid);
        oublog_build_navigation($oublog, $oubloginstance, isset($oubloguser) ? $oubloguser : null);
        oublog_get_post_extranav($post);
        $PAGE->navbar->add(get_string('moderated_submitted', 'oublog'));
        echo $OUTPUT->header();
        notice(get_string('moderated_addedcomment', 'oublog') . ($approvaltime ? ' ' . get_string('moderated_typicaltime', 'oublog', $approvaltime) : ''), 'viewpost.php?post=' . $postid, $course);
        // does not continue
    }
    $comment->userid = $USER->id;
    if (!oublog_add_comment($course, $cm, $oublog, $comment)) {
        print_error('couldnotaddcomment', 'oublog');
    }
    add_to_log($course->id, "oublog", "add comment", $viewurl, $oublog->id, $cm->id);
    redirect($viewurl);
}
Exemplo n.º 2
0
    if (!($oubloguser = $DB->get_record('user', array('id' => $oubloginstance->userid)))) {
        print_error('invaliduserid');
    }
    $PAGE->navbar->add(fullname($oubloguser), new moodle_url("/user/view.php", array('id' => $oubloguser->id)));
    $PAGE->navbar->add($blogname, new moodle_url("/mod/oublog/view.php", array('user' => $oubloginstance->userid)));
    $url = new moodle_url("{$CFG->wwwroot}/course/mod.php", array('update' => $cm->id, 'return' => true, 'sesskey' => sesskey()));
} else {
    $blogtype = 'course';
    $returnurl = 'view.php?id=' . $cm->id;
    $blogname = $oublog->name;
    $url = new moodle_url("{$CFG->wwwroot}/course/mod.php", array('update' => $cm->id, 'return' => true, 'sesskey' => sesskey()));
}
$CFG->additionalhtmlhead .= oublog_get_meta_tags($oublog, $oubloginstance, $currentgroup, $cm);
$PAGE->set_title(format_string($oublog->name));
$PAGE->set_heading(format_string($course->fullname));
oublog_get_post_extranav($post, false);
echo $OUTPUT->header();
// Print the main part of the page.
echo '<div class="oublog-topofpage"></div>';
// Print blog posts.
echo '<div id="middle-column" >';
echo '<div class="oublog-post-commented">';
echo $oublogoutput->render_post($cm, $oublog, $post, $returnurl, $blogtype, $canmanageposts, $canaudit, false, false);
if (!empty($post->comments)) {
    // Code extracted to new renderer function.
    echo $oublogoutput->render_comments($post, $oublog, $canaudit, $canmanagecomments, false, $cm);
}
echo '</div>';
// If it is your own post, then see if there are any moderated comments -
// for security reasons, you must also be allowed to comment on the post in
// order to moderate it (because 'approving' a comment is basically equivalent