2004-04-18 23:20:53 +00:00
|
|
|
<?PHP //$Id$
|
|
|
|
|
|
|
|
class CourseBlock_news_items extends MoodleBlock {
|
2004-10-19 21:04:28 +00:00
|
|
|
function init() {
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->title = get_string('latestnews');
|
|
|
|
$this->content_type = BLOCK_TYPE_TEXT;
|
2004-05-28 10:53:54 +00:00
|
|
|
$this->version = 2004052600;
|
|
|
|
}
|
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
function get_content() {
|
|
|
|
global $CFG;
|
|
|
|
|
2004-08-11 09:00:53 +00:00
|
|
|
if ($this->content !== NULL) {
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content = new stdClass;
|
|
|
|
$this->content->text = '';
|
|
|
|
$this->content->footer = '';
|
|
|
|
|
|
|
|
if (empty($this->instance)) {
|
2004-04-18 23:20:53 +00:00
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once($CFG->dirroot.'/course/lib.php');
|
2004-05-28 10:53:54 +00:00
|
|
|
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$course = get_record('course', 'id', $this->instance->pageid);
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if ($course->newsitems) {
|
|
|
|
$news = forum_get_course_forum($this->instance->pageid, 'news');
|
2004-04-18 23:20:53 +00:00
|
|
|
// Slightly hacky way to do it but...
|
|
|
|
ob_start();
|
2004-10-19 21:04:28 +00:00
|
|
|
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "", get_current_group($this->instance->pageid));
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->text = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|