mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?PHP //$Id$
|
|
|
|
class CourseBlock_news_items extends MoodleBlock {
|
|
function CourseBlock_news_items ($course) {
|
|
$this->title = get_string('latestnews');
|
|
$this->content_type = BLOCK_TYPE_TEXT;
|
|
$this->course = $course;
|
|
$this->version = 2004052600;
|
|
}
|
|
|
|
function get_content() {
|
|
global $CFG;
|
|
|
|
if ($this->content !== NULL) {
|
|
return $this->content;
|
|
}
|
|
|
|
if (empty($this->course)) {
|
|
$this->content = '';
|
|
return $this->content;
|
|
}
|
|
|
|
require_once($CFG->dirroot.'/course/lib.php');
|
|
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
|
|
|
$this->content = New object;
|
|
$this->content->text = '';
|
|
$this->content->footer = '';
|
|
|
|
if ($this->course->newsitems) {
|
|
$news = forum_get_course_forum($this->course->id, 'news');
|
|
// Slightly hacky way to do it but...
|
|
ob_start();
|
|
forum_print_latest_discussions($news->id, $this->course->newsitems, "minimal", "", get_current_group($this->course->id));
|
|
$this->content->text = ob_get_contents();
|
|
ob_end_clean();
|
|
}
|
|
return $this->content;
|
|
}
|
|
}
|
|
|
|
?>
|