public function test_oublog_get_last_modified() { global $USER, $DB; $this->resetAfterTest(true); $this->setAdminUser(); $course = $this->get_new_course(); $oublog = $this->get_new_oublog($course->id); $cm = get_coursemodule_from_id('oublog', $oublog->cmid); $post = $this->get_post_stub($oublog->id); $postid = oublog_add_post($post, $cm, $oublog, $course); $timeposted = $DB->get_field('oublog_posts', 'timeposted', array('id' => $postid)); $lastmodified = oublog_get_last_modified($cm, $course, $USER->id); $this->assertTrue(is_numeric($lastmodified)); $this->assertEquals($timeposted, $lastmodified); // TODO: More comprehensive checking with separate group/individual blogs. }
/** * Return blogs on course that have last modified date for current user * * @param stdClass $course * @return array */ function oublog_get_ourecent_activity($course) { global $CFG; require_once $CFG->dirroot . '/mod/oublog/locallib.php'; $modinfo = get_fast_modinfo($course); $return = array(); foreach ($modinfo->get_instances_of('oublog') as $blog) { if ($blog->uservisible) { $lastpostdate = oublog_get_last_modified($blog, $blog->get_course()); if (!empty($lastpostdate)) { $data = new stdClass(); $data->cm = $blog; $data->text = get_string('lastmodified', 'oublog', userdate($lastpostdate, get_string('strftimerecent', 'oublog'))); $data->date = $lastpostdate; $return[$data->cm->id] = $data; } } } return $return; }