Commit 9b4b78fd authored by defacer's avatar defacer
Browse files

Da monster-commit of blocks version 2!

Code based on the work of Daryl Hawes for the blog module. Thanks, Daryl!

Please test the hell out of it as it's sure to have issues that need to be
ironed out.
parent 2defdcd7
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
require_variable($_REQUEST['block']); require_variable($_REQUEST['block']);
$blockid = intval($_REQUEST['block']); $blockid = intval($_REQUEST['block']);
if(($blockrecord = get_record('blocks', 'id', $blockid)) === false) { if(($blockrecord = blocks_get_record($blockid)) === false) {
error('This block does not exist'); error('This block does not exist');
} }
$block = block_instance($blockrecord->name, NULL); $block = block_instance($blockrecord->name);
if($block === false) { if($block === false) {
error('Problem in instantiating block object'); error('Problem in instantiating block object');
} }
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
require_once('../config.php'); require_once('../config.php');
require_once($CFG->libdir.'/blocklib.php'); require_once($CFG->libdir.'/blocklib.php');
optional_variable($_GET['hide']);
optional_variable($_GET['show']);
optional_variable($_GET['delete']);
optional_variable($_GET['confirm'], 0); optional_variable($_GET['confirm'], 0);
$delete = $_GET['delete']; // Dependency remover $hide = optional_param('hide', 0, PARAM_INT);
$show = optional_param('show', 0, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
$multiple = optional_param('multiple', 0, PARAM_INT);
require_login(); require_login();
...@@ -32,8 +32,9 @@ ...@@ -32,8 +32,9 @@
$strhide = get_string('hide'); $strhide = get_string('hide');
$strshow = get_string('show'); $strshow = get_string('show');
$strsettings = get_string('settings'); $strsettings = get_string('settings');
$strcourses = get_string('courses'); $strcourses = get_string('blockinstances', 'admin');
$strname = get_string('name'); $strname = get_string('name');
$strmultiple = get_string('blockmultiple', 'admin');
print_header("$site->shortname: $strmanageblocks", "$site->fullname", print_header("$site->shortname: $strmanageblocks", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> ". "<a href=\"index.php\">$stradministration</a> -> ".
...@@ -44,27 +45,35 @@ ...@@ -44,27 +45,35 @@
/// If data submitted, then process and store. /// If data submitted, then process and store.
if (!empty($_GET['hide']) and confirm_sesskey()) { if (!empty($hide) && confirm_sesskey()) {
if (!$block = get_record('blocks', 'id', $_GET['hide'])) { if (!$block = get_record('block', 'id', $hide)) {
error("Block doesn't exist!"); error("Block doesn't exist!");
} }
set_field('blocks', 'visible', '0', 'id', $block->id); // Hide block set_field('block', 'visible', '0', 'id', $block->id); // Hide block
} }
if (!empty($_GET['show']) and confirm_sesskey() ) { if (!empty($show) && confirm_sesskey() ) {
if (!$block = get_record('blocks', 'id', $_GET['show'])) { if (!$block = get_record('block', 'id', $show)) {
error("Block doesn't exist!"); error("Block doesn't exist!");
} }
set_field('blocks', 'visible', '1', 'id', $block->id); // Show block set_field('block', 'visible', '1', 'id', $block->id); // Show block
} }
if (!empty($delete) and confirm_sesskey()) { if (!empty($multiple) && confirm_sesskey()) {
if (!$block = blocks_get_record($multiple)) {
error("Block doesn't exist!");
}
$block->multiple = !$block->multiple;
update_record('block', $block);
}
if (!$block = get_record('blocks', 'id', $delete)) { if (!empty($delete) && confirm_sesskey()) {
if (!$block = blocks_get_record($delete)) {
error("Block doesn't exist!"); error("Block doesn't exist!");
} }
$blockobject = block_instance($block->name, $site); $blockobject = block_instance($block->name);
$strblockname = $blockobject->get_title(); $strblockname = $blockobject->get_title();
if (!$_GET['confirm']) { if (!$_GET['confirm']) {
...@@ -76,11 +85,16 @@ ...@@ -76,11 +85,16 @@
} else { } else {
// Delete block // Delete block
if (!delete_records('blocks', 'id', $block->id)) { if (!delete_records('block', 'id', $block->id)) {
notify("Error occurred while deleting the $strblockname record from blocks table"); notify("Error occurred while deleting the $strblockname record from blocks table");
} }
blocks_update_every_block_by_id($block->id, 'delete'); // Delete blocks in all courses by id $instances = get_records('block_instance', 'blockid', $block->id);
if(!empty($instances)) {
foreach($instances as $instance) {
blocks_delete_instance($instance);
}
}
// Then the tables themselves // Then the tables themselves
...@@ -105,12 +119,12 @@ ...@@ -105,12 +119,12 @@
/// Get and sort the existing blocks /// Get and sort the existing blocks
if (false === ($blocks = get_records('blocks'))) { if (false === ($blocks = get_records('block'))) {
error('No blocks found!'); // Should never happen error('No blocks found!'); // Should never happen
} }
foreach ($blocks as $block) { foreach ($blocks as $block) {
if(($blockobject = block_instance($block->name, NULL)) === false) { if(($blockobject = block_instance($block->name)) === false) {
// Failed to load // Failed to load
continue; continue;
} }
...@@ -136,11 +150,11 @@ ...@@ -136,11 +150,11 @@
//$modpixpath = '../theme/'.$CFG->theme.'/pix/mod'; //$modpixpath = '../theme/'.$CFG->theme.'/pix/mod';
} }
$table->head = array ($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strdelete, $strsettings); $table->head = array ($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strmultiple, $strdelete, $strsettings);
$table->align = array ('LEFT', 'RIGHT', 'LEFT', 'CENTER', 'CENTER', 'CENTER'); $table->align = array ('LEFT', 'RIGHT', 'LEFT', 'CENTER', 'CENTER', 'CENTER', 'CENTER');
$table->wrap = array ("NOWRAP", "", "", "", "",""); $table->wrap = array ('NOWRAP', '', '', '', '', '', '');
$table->size = array ("100%", "10", "10", "10", "10","12"); $table->size = array ('100%', '10', '10', '10', '10','12');
$table->width = "100"; $table->width = '100';
foreach ($blockbyname as $blockname => $blockid) { foreach ($blockbyname as $blockname => $blockid) {
...@@ -155,7 +169,7 @@ ...@@ -155,7 +169,7 @@
$settings = '<a href="block.php?block='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strsettings.'</a>'; $settings = '<a href="block.php?block='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strsettings.'</a>';
} }
$count = blocks_get_courses_using_block_by_id($blockid); $count = count_records('block_instance', 'blockid', $blockid);
$class = ''; // Nothing fancy, by default $class = ''; // Nothing fancy, by default
if ($blocks[$blockid]->visible) { if ($blocks[$blockid]->visible) {
...@@ -166,8 +180,27 @@ ...@@ -166,8 +180,27 @@
'<img src="'.$pixpath.'/i/show.gif" style="height: 16px; width: 16px;" alt=\"\" /></a>'; '<img src="'.$pixpath.'/i/show.gif" style="height: 16px; width: 16px;" alt=\"\" /></a>';
$class = ' class="dimmed_text"'; // Leading space required! $class = ' class="dimmed_text"'; // Leading space required!
} }
if ($blockobject->instance_allow_multiple()) {
if($blocks[$blockid]->multiple) {
$multiple = '<nobr>'.get_string('yes').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</nobr>';
}
else {
$multiple = '<nobr>'.get_string('no').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</nobr>';
}
}
else {
$multiple = '';
}
$table->data[] = array ('<p'.$class.'>'.$blockobject->get_title().'</p>', $count, $blockobject->get_version(), $visible, $delete, $settings); $table->data[] = array(
'<p'.$class.'>'.$blockobject->get_title().'</p>',
$count,
$blockobject->get_version(),
$visible,
$multiple,
$delete,
$settings
);
} }
echo '<p>'; echo '<p>';
print_table($table); print_table($table);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
if (!empty($USER->id)) { // Additional identity check if (!empty($USER->id)) { // Additional identity check
if (!confirm_sesskey()) { if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error')); //error(get_string('confirmsesskeybad', 'error'));
} }
} }
...@@ -38,9 +38,14 @@ ...@@ -38,9 +38,14 @@
// [pj] We are about to create the site, so let's add some blocks... // [pj] We are about to create the site, so let's add some blocks...
// calendar_month is included as a Moodle feature advertisement ;-) // calendar_month is included as a Moodle feature advertisement ;-)
require_once($CFG->dirroot.'/lib/blocklib.php'); require_once($CFG->dirroot.'/lib/blocklib.php');
$form->blockinfo = blocks_get_default_blocks(NULL, blocks_get_config_default('site'));
if ($newid = insert_record("course", $form)) { if ($newid = insert_record("course", $form)) {
// Site created, add blocks for it
$page = new stdClass;
$page->type = MOODLE_PAGE_COURSE;
$page->id = $newid;
blocks_repopulate_page($page); // Return value not checked because you can always edit later
$cat->name = get_string("miscellaneous"); $cat->name = get_string("miscellaneous");
if (insert_record("course_categories", $cat)) { if (insert_record("course_categories", $cat)) {
redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1); redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
......
<?PHP //$Id$ <?PHP //$Id$
class CourseBlock_activity_modules extends MoodleBlock { class CourseBlock_activity_modules extends MoodleBlock {
function CourseBlock_activity_modules($course) { function init() {
$this->title = get_string('activities'); $this->title = get_string('activities');
$this->content_type = BLOCK_TYPE_LIST; $this->content_type = BLOCK_TYPE_LIST;
$this->course = $course;
$this->version = 2004041000; $this->version = 2004041000;
} }
...@@ -18,7 +17,7 @@ class CourseBlock_activity_modules extends MoodleBlock { ...@@ -18,7 +17,7 @@ class CourseBlock_activity_modules extends MoodleBlock {
return $this->content; return $this->content;
} }
$this->content = New object; $this->content = new stdClass;
$this->content->items = array(); $this->content->items = array();
$this->content->icons = array(); $this->content->icons = array();
$this->content->footer = ''; $this->content->footer = '';
...@@ -26,7 +25,7 @@ class CourseBlock_activity_modules extends MoodleBlock { ...@@ -26,7 +25,7 @@ class CourseBlock_activity_modules extends MoodleBlock {
if ($modnamesused) { if ($modnamesused) {
foreach ($modnamesused as $modname => $modfullname) { foreach ($modnamesused as $modname => $modfullname) {
if ($modname != 'label') { if ($modname != 'label') {
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$this->course->id.'">'.$modnamesplural[$modname].'</a>'; $this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$this->instance->pageid.'">'.$modnamesplural[$modname].'</a>';
$this->content->icons[] = '<img src="'.$CFG->modpixpath.'/'.$modname.'/icon.gif" height="16" width="16" alt="" />'; $this->content->icons[] = '<img src="'.$CFG->modpixpath.'/'.$modname.'/icon.gif" height="16" width="16" alt="" />';
} }
} }
......
<?php //$Id$ <?php //$Id$
class CourseBlock_admin extends MoodleBlock { class CourseBlock_admin extends MoodleBlock {
function CourseBlock_admin($course) { function init() {
$this->title = get_string('administration'); $this->title = get_string('administration');
$this->content_type = BLOCK_TYPE_LIST; $this->content_type = BLOCK_TYPE_LIST;
$this->course = $course;
$this->version = 2004081200; $this->version = 2004081200;
} }
...@@ -14,14 +13,14 @@ class CourseBlock_admin extends MoodleBlock { ...@@ -14,14 +13,14 @@ class CourseBlock_admin extends MoodleBlock {
return $this->content; return $this->content;
} }
$this->content = New object; $this->content = new stdClass;
$this->content->items = array(); $this->content->items = array();
$this->content->icons = array(); $this->content->icons = array();
$this->content->footer = ''; $this->content->footer = '';
if (empty($this->course)) { if (empty($this->instance)) {
$this->content = ''; $this->content = '';
} else if ($this->course->id == SITEID) { } else if ($this->instance->pageid == SITEID) {
$this->load_content_for_site(); $this->load_content_for_site();
} else { } else {
$this->load_content_for_course(); $this->load_content_for_course();
...@@ -77,81 +76,83 @@ class CourseBlock_admin extends MoodleBlock { ...@@ -77,81 +76,83 @@ class CourseBlock_admin extends MoodleBlock {
return $this->content; return $this->content;
} }
if (isteacher($this->course->id)) { $course = get_record('course', 'id', $this->instance->pageid);
$isteacheredit = isteacheredit($this->course->id); if (isteacher($this->instance->pageid)) {
$isteacheredit = isteacheredit($this->instance->pageid);
if ($isteacheredit) { if ($isteacheredit) {
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" />';
if (isediting($this->course->id)) { if (isediting($this->instance->pageid)) {
$this->content->items[]='<a href="view.php?id='.$this->course->id.'&amp;edit=off">'.get_string('turneditingoff').'</a>'; $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=off">'.get_string('turneditingoff').'</a>';
} else { } else {
$this->content->items[]='<a href="view.php?id='.$this->course->id.'&amp;edit=on">'.get_string('turneditingon').'</a>'; $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=on">'.get_string('turneditingon').'</a>';
} }
$this->content->items[]='<a href="edit.php?id='.$this->course->id.'">'.get_string('settings').'...</a>'; $this->content->items[]='<a href="edit.php?id='.$this->instance->pageid.'">'.get_string('settings').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" height="16" width="16" alt="" />';
if (iscreator() or !empty($CFG->teacherassignteachers)) { if (iscreator() || !empty($CFG->teacherassignteachers)) {
if (!$this->course->teachers) { if (!$course->teachers) {
$this->course->teachers = get_string('defaultcourseteachers'); $course->teachers = get_string('defaultcourseteachers');
} }
$this->content->items[]='<a href="teacher.php?id='.$this->course->id.'">'.$this->course->teachers.'...</a>'; $this->content->items[]='<a href="teacher.php?id='.$this->instance->pageid.'">'.$course->teachers.'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
} }
if (!$this->course->students) { if (!$course->students) {
$this->course->students = get_string('defaultcoursestudents'); $course->students = get_string('defaultcoursestudents');
} }
$this->content->items[]='<a href="student.php?id='.$this->course->id.'">'.$this->course->students.'...</a>'; $this->content->items[]='<a href="student.php?id='.$this->instance->pageid.'">'.$course->students.'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
$this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->course->id.'">'.get_string('backup').'...</a>'; $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->instance->pageid.'">'.get_string('backup').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="" />';
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->course->id.'&amp;wdir=/backupdata">'.get_string('restore').'...</a>'; $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'&amp;wdir=/backupdata">'.get_string('restore').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
$this->content->items[]='<a href="scales.php?id='.$this->course->id.'">'.get_string('scales').'...</a>'; $this->content->items[]='<a href="scales.php?id='.$this->instance->pageid.'">'.get_string('scales').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" height="16" width="16" alt="" />';
} }
$this->content->items[]='<a href="grades.php?id='.$this->course->id.'">'.get_string('grades').'...</a>'; $this->content->items[]='<a href="grades.php?id='.$this->instance->pageid.'">'.get_string('grades').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />';
$this->content->items[]='<a href="log.php?id='.$this->course->id.'">'.get_string('logs').'...</a>'; $this->content->items[]='<a href="log.php?id='.$this->instance->pageid.'">'.get_string('logs').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />';
if ($isteacheredit) { if ($isteacheredit) {
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->course->id.'">'.get_string('files').'...</a>'; $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'">'.get_string('files').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="" />';
} }
$this->content->items[]='<a href="'.$CFG->wwwroot.'/doc/view.php?id='.$this->course->id.'&amp;file=teacher.html">'.get_string('help').'...</a>'; $this->content->items[]='<a href="'.$CFG->wwwroot.'/doc/view.php?id='.$this->instance->pageid.'&amp;file=teacher.html">'.get_string('help').'...</a>';
$this->content->icons[]='<img src="'.$CFG->modpixpath.'/resource/icon.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->modpixpath.'/resource/icon.gif" height="16" width="16" alt="" />';
if ($teacherforum = forum_get_course_forum($this->course->id, 'teacher')) { if ($teacherforum = forum_get_course_forum($this->instance->pageid, 'teacher')) {
$this->content->items[]='<a href="'.$CFG->wwwroot.'/mod/forum/view.php?f='.$teacherforum->id.'">'.get_string('nameteacher', 'forum').'</a>'; $this->content->items[]='<a href="'.$CFG->wwwroot.'/mod/forum/view.php?f='.$teacherforum->id.'">'.get_string('nameteacher', 'forum').'</a>';
$this->content->icons[]='<img src="'.$CFG->modpixpath.'/forum/icon.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->modpixpath.'/forum/icon.gif" height="16" width="16" alt="" />';
} }
} else if (!isguest()) { // Students menu } else if (!isguest()) { // Students menu
if ($this->course->showgrades) { if ($course->showgrades) {
$this->content->items[]='<a href="grade.php?id='.$this->course->id.'">'.get_string('grades').'...</a>'; $this->content->items[]='<a href="grade.php?id='.$this->instance->pageid.'">'.get_string('grades').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />';
} }
if ($this->course->showreports) { if ($course->showreports) {
$this->content->items[]='<a href="user.php?id='.$this->course->id.'&amp;user='.$USER->id.'">'.get_string('activityreport').'...</a>'; $this->content->items[]='<a href="user.php?id='.$this->instance->pageid.'&amp;user='.$USER->id.'">'.get_string('activityreport').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/report.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/report.gif" height="16" width="16" alt="" />';
} }
if (is_internal_auth()) { if (is_internal_auth()) {
$this->content->items[]='<a href="'.$CFG->wwwroot.'/login/change_password.php?id='.$this->course->id.'">'.get_string('changepassword').'...</a>'; $this->content->items[]='<a href="'.$CFG->wwwroot.'/login/change_password.php?id='.$this->instance->pageid.'">'.get_string('changepassword').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
} else if ($CFG->changepassword) { } else if ($CFG->changepassword) {
$this->content->items[]='<a href="'.$CFG->changepassword.'">'.get_string('changepassword').'...</a>'; $this->content->items[]='<a href="'.$CFG->changepassword.'">'.get_string('changepassword').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
} }
if ($CFG->allowunenroll) { if ($CFG->allowunenroll) {
$this->content->items[]='<a href="unenrol.php?id='.$this->course->id.'">'.get_string('unenrolme', '', $this->course->shortname).'...</a>'; $this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />'; $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
} }
} }
......
<?PHP //$Id$ <?PHP //$Id$
class CourseBlock_calendar_month extends MoodleBlock { class CourseBlock_calendar_month extends MoodleBlock {
function CourseBlock_calendar_month($course) { function init() {
$this->title = get_string('calendar', 'calendar'); $this->title = get_string('calendar', 'calendar');
$this->content_type = BLOCK_TYPE_TEXT; $this->content_type = BLOCK_TYPE_TEXT;
$this->course = $course;
$this->version = 2004081200; $this->version = 2004081200;
} }
...@@ -19,20 +18,20 @@ class CourseBlock_calendar_month extends MoodleBlock { ...@@ -19,20 +18,20 @@ class CourseBlock_calendar_month extends MoodleBlock {
return $this->content; return $this->content;
} }
$this->content = New object; $this->content = new stdClass;
$this->content->text = ''; $this->content->text = '';
$this->content->footer = ''; $this->content->footer = '';
if (empty($this->course)) { // Overrides: use no course at all if (empty($this->instance)) { // Overrides: use no course at all
$courseshown = false; $courseshown = false;
$filtercourse = array(); $filtercourse = array();
} else { } else {
$courseshown = $this->course->id; $courseshown = $this->instance->pageid;
if($this->course->id == SITEID) { if($courseshown == SITEID) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting // Being displayed at site level. This will cause the filter to fall back to auto-detecting
// the list of courses it will be grabbing events from. // the list of courses it will be grabbing events from.
$filtercourse = NULL; $filtercourse = NULL;
......
<?PHP //$Id$ <?PHP //$Id$
class CourseBlock_calendar_upcoming extends MoodleBlock { class CourseBlock_calendar_upcoming extends MoodleBlock {
function CourseBlock_calendar_upcoming ($course) { function init() {
$this->title = get_string('upcomingevents', 'calendar'); $this->title = get_string('upcomingevents', 'calendar');
$this->content_type = BLOCK_TYPE_TEXT; $this->content_type = BLOCK_TYPE_TEXT;
$this->course = $course;
$this->version = 2004052600; $this->version = 2004052600;
} }