moodle/blocks/news_items/block_news_items.php
stronk7 0f3fe4b6ad First Official realease of the "Blocks System".
Integrated with Moodle:
    - Install automatically.
    - Update course->blockinfo for each course at installation time.
    - Modified course creation to insert into blockinfo field.
    - Modified restore to insert into blockinfo field.
    - Admin options (hide, show, delete, config) from admin page.
    - Lang strings inserted (en only).
    - Database support to mysql and postgresql (not tested!!).
Moodle, backup and block versions updated to 2004041800.
Tested with mysql: Install fresh and upgrade from previous.
section_activities block renamed to social_activities and created
its own lang file to support name "Social Activities". This can
be changed at any time.

TODO:
=====
Support it really in backup/restore.
????

Enjoy!! Ciao :-)
2004-04-18 23:20:53 +00:00

39 lines
1.1 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 = 2004041200;
}
function get_content() {
global $CFG;
if($this->content !== NULL) {
return $this->content;
}
require_once($CFG->dirroot.'/course/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();
echo '<font size="-2">';
forum_print_latest_discussions($news->id, $this->course->newsitems, "minimal", "", get_current_group($this->course->id));
echo '</font>';
$this->content->text = ob_get_contents();
ob_end_clean();
}
return $this->content;
}
}
?>