public function test_oublog_time_limits()
 {
     $this->resetAfterTest();
     $course = $this->get_new_course();
     $stud1 = $this->get_new_user('student', $course->id);
     // Future posts + comments start blog.
     $oublog = $this->get_new_oublog($course->id, array('postfrom' => 2524611600, 'commentfrom' => 2524611600));
     // Past posts + comments start blog.
     $oublog1 = $this->get_new_oublog($course->id, array('postfrom' => 1262307600, 'commentfrom' => 1262307600));
     // Future posts + comments end blog.
     $oublog2 = $this->get_new_oublog($course->id, array('postuntil' => 2524611600, 'commentuntil' => 2524611600));
     // Past posts + comments end blog.
     $oublog3 = $this->get_new_oublog($course->id, array('postuntil' => 1262307600, 'commentuntil' => 1262307600));
     $this->setAdminUser();
     $this->assertTrue(oublog_can_post_now($oublog, context_module::instance($oublog->cm->id)));
     $this->assertTrue(oublog_can_post_now($oublog1, context_module::instance($oublog1->cm->id)));
     $this->assertTrue(oublog_can_post_now($oublog2, context_module::instance($oublog2->cm->id)));
     $this->assertTrue(oublog_can_post_now($oublog3, context_module::instance($oublog3->cm->id)));
     $post = (object) array('allowcomments' => true, 'visibility' => OUBLOG_VISIBILITY_COURSEUSER);
     $this->assertTrue(oublog_can_comment($oublog->cm, $oublog, $post));
     $this->assertTrue(oublog_can_comment($oublog1->cm, $oublog1, $post));
     $this->assertTrue(oublog_can_comment($oublog2->cm, $oublog2, $post));
     $this->assertTrue(oublog_can_comment($oublog3->cm, $oublog3, $post));
     $this->setUser($stud1);
     $this->assertFalse(oublog_can_post_now($oublog, context_module::instance($oublog->cm->id)));
     $this->assertTrue(oublog_can_post_now($oublog1, context_module::instance($oublog1->cm->id)));
     $this->assertTrue(oublog_can_post_now($oublog2, context_module::instance($oublog2->cm->id)));
     $this->assertFalse(oublog_can_post_now($oublog3, context_module::instance($oublog3->cm->id)));
     $post = (object) array('allowcomments' => true, 'visibility' => OUBLOG_VISIBILITY_COURSEUSER);
     $this->assertFalse(oublog_can_comment($oublog->cm, $oublog, $post));
     $this->assertTrue(oublog_can_comment($oublog1->cm, $oublog1, $post));
     $this->assertTrue(oublog_can_comment($oublog2->cm, $oublog2, $post));
     $this->assertFalse(oublog_can_comment($oublog3->cm, $oublog3, $post));
 }
Example #2
0
    if (oublog_can_comment($cm, $oublog, $maxpost, true)) {
        $ccapable = has_capability('mod/oublog:ignorecommentperiod', $oublog->global ? context_system::instance() : $context);
        if ($oublog->commentfrom != 0 && $oublog->commentfrom > time()) {
            echo $oublogoutput->render_time_limit_msg('beforestartcomment', $oublog->commentfrom, $capable, 'comment');
        }
        if ($oublog->commentuntil != 0) {
            if ($oublog->commentuntil > time()) {
                echo $oublogoutput->render_time_limit_msg('beforeendcomment', $oublog->commentuntil, $capable, 'comment');
            } else {
                echo $oublogoutput->render_time_limit_msg('afterendcomment', $oublog->commentuntil, $capable, 'comment');
            }
        }
    }
}
echo '<div id="oublogbuttons">';
if ($showpostbutton && oublog_can_post_now($oublog, $context)) {
    echo '<div id="addpostbutton">';
    echo $OUTPUT->single_button(new moodle_url('/mod/oublog/editpost.php', array('blog' => $cm->instance)), $straddpost, 'get');
    echo '</div>';
    if ($oublog->allowimport && ($oublog->global || $oublog->individual != OUBLOG_NO_INDIVIDUAL_BLOGS)) {
        echo '<div class="oublog_importpostbutton">';
        echo $OUTPUT->single_button(new moodle_url('/mod/oublog/import.php', array('id' => $cm->id)), get_string('import', 'oublog'), 'get');
        echo '</div>';
    }
}
// View participation button.
$canview = oublog_can_view_participation($course, $oublog, $cm, $currentgroup);
if ($canview) {
    if ($canview == OUBLOG_USER_PARTICIPATION) {
        $strparticipation = get_string('participationbyuser', 'oublog');
        $participationurl = new moodle_url('participation.php', array('id' => $cm->id, 'group' => $currentgroup));