From: moodler Date: Mon, 29 May 2006 08:17:57 +0000 (+0000) Subject: Merged $course -> $COURSE fixes from 1.6 stable X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1a2ea6f488db3c420b5f6da3cbd6406f9542e0a1;p=moodle.git Merged $course -> $COURSE fixes from 1.6 stable --- diff --git a/blocks/calendar_month/block_calendar_month.php b/blocks/calendar_month/block_calendar_month.php index 9c796b9098..424e1fbf1c 100644 --- a/blocks/calendar_month/block_calendar_month.php +++ b/blocks/calendar_month/block_calendar_month.php @@ -11,7 +11,7 @@ class block_calendar_month extends block_base { } function get_content() { - global $USER, $CFG, $SESSION; + global $USER, $CFG, $SESSION, $COURSE; $cal_m = optional_param( 'cal_m', 0, PARAM_INT ); $cal_y = optional_param( 'cal_y', 0, PARAM_INT ); @@ -28,12 +28,7 @@ class block_calendar_month extends block_base { // [pj] To me it looks like this if would never be needed, but Penny added it // when committing the /my/ stuff. Reminder to discuss and learn what it's about. // It definitely needs SOME comment here! - if (!empty($this->instance->pageid)) { - $courseshown = $this->instance->pageid; - } - else { - $courseshown = SITEID; - } + $courseshown = $COURSE->id; if($courseshown == SITEID) { // Being displayed at site level. This will cause the filter to fall back to auto-detecting @@ -58,13 +53,12 @@ class block_calendar_month extends block_base { $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y); // No filters for now - } elseif (!empty($courseshown)) { + } else { // For any other course $this->content->text .= calendar_overlib_html(); $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y)); $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y); - $course = get_record('course', 'id', $this->instance->pageid); - $this->content->text .= '
'.calendar_filter_controls('course', '', $course).'
'; + $this->content->text .= '
'.calendar_filter_controls('course', '', $COURSE).'
'; } diff --git a/blocks/calendar_upcoming/block_calendar_upcoming.php b/blocks/calendar_upcoming/block_calendar_upcoming.php index 8be39db96f..b69b932329 100644 --- a/blocks/calendar_upcoming/block_calendar_upcoming.php +++ b/blocks/calendar_upcoming/block_calendar_upcoming.php @@ -7,7 +7,7 @@ class block_calendar_upcoming extends block_base { } function get_content() { - global $USER, $CFG, $SESSION; + global $USER, $CFG, $SESSION, $COURSE; $cal_m = optional_param( 'cal_m', 0, PARAM_INT ); $cal_y = optional_param( 'cal_y', 0, PARAM_INT ); @@ -27,12 +27,7 @@ class block_calendar_upcoming extends block_base { $this->content->footer = ''; } else { - if (!empty($this->instance->pageid)) { - $courseshown = $this->instance->pageid; - } - else { - $courseshown = SITEID; - } + $courseshown = $COURSE->id; $this->content->footer = '
'. get_string('gotocalendar', 'calendar').'...'; diff --git a/blocks/course_summary/block_course_summary.php b/blocks/course_summary/block_course_summary.php index d86982243d..ebe8b1d96c 100644 --- a/blocks/course_summary/block_course_summary.php +++ b/blocks/course_summary/block_course_summary.php @@ -7,13 +7,14 @@ class block_course_summary extends block_base { } function specialization() { - if($this->instance->pagetype == PAGE_COURSE_VIEW && $this->instance->pageid != SITEID) { + global $COURSE; + if($this->instance->pagetype == PAGE_COURSE_VIEW && $COURSE->id != SITEID) { $this->title = get_string('coursesummary', 'block_course_summary'); } } function get_content() { - global $CFG, $THEME; + global $CFG, $COURSE; if($this->content !== NULL) { return $this->content; @@ -23,19 +24,14 @@ class block_course_summary extends block_base { return ''; } - if (empty($this->instance->pageid)) { - $this->instance->pageid = SITEID; - } - $course = get_record('course', 'id', $this->instance->pageid); - $this->content = New stdClass; $options->noclean = true; // Don't clean Javascripts etc - $this->content->text = format_text($course->summary, FORMAT_HTML, $options); - if(isediting($this->instance->pageid)) { - if($this->instance->pageid == SITEID) { + $this->content->text = format_text($COURSE->summary, FORMAT_HTML, $options); + if(isediting($COURSE->id)) { + if($COURSE->id == SITEID) { $editpage = $CFG->wwwroot.'/'.$CFG->admin.'/site.php'; } else { - $editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->instance->pageid; + $editpage = $CFG->wwwroot.'/course/edit.php?id='.$COURSE->id; } $this->content->text .= "
pixpath/t/edit.gif\" alt=\"\" />
"; } diff --git a/blocks/glossary_random/block_glossary_random.php b/blocks/glossary_random/block_glossary_random.php index c7b7a244c2..eb2dbb55a1 100644 --- a/blocks/glossary_random/block_glossary_random.php +++ b/blocks/glossary_random/block_glossary_random.php @@ -13,8 +13,8 @@ class block_glossary_random extends block_base { } function specialization() { - global $CFG; - $this->course = get_record('course', 'id', $this->instance->pageid); + global $CFG, $COURSE; + $this->course = $COURSE; // load userdefined title and make sure it's never empty if (empty($this->config->title)) { diff --git a/blocks/news_items/block_news_items.php b/blocks/news_items/block_news_items.php index a928809aa4..ac8cdb0e5e 100644 --- a/blocks/news_items/block_news_items.php +++ b/blocks/news_items/block_news_items.php @@ -7,7 +7,7 @@ class block_news_items extends block_base { } function get_content() { - global $CFG, $USER; + global $CFG, $USER, $COURSE; if ($this->content !== NULL) { return $this->content; @@ -22,44 +22,39 @@ class block_news_items extends block_base { } - if ($this->instance->pageid == 0) { - $this->instance->pageid = SITEID; - } - $course = get_record('course', 'id', $this->instance->pageid); - - if ($course->newsitems) { // Create a nice listing of recent postings + if ($COURSE->newsitems) { // Create a nice listing of recent postings require_once($CFG->dirroot.'/mod/forum/lib.php'); // We'll need this $text = ''; - if (!$forum = forum_get_course_forum($course->id, 'news')) { + if (!$forum = forum_get_course_forum($COURSE->id, 'news')) { return $this->content; } /// First work out whether we can post to this group and if so, include a link - if (isteacheredit($course->id)) { /// Teachers can always post + if (isteacheredit($COURSE->id)) { /// Teachers can always post $visiblegroups = -1; $text .= ''; } else { /// Check the group situation - $currentgroup = get_current_group($course->id); + $currentgroup = get_current_group($COURSE->id); if (forum_user_can_post_discussion($forum, $currentgroup)) { $text .= ''; } - if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { + if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $COURSE->id)) { $this->content->text = $text; return $this->content; } - $groupmode = groupmode($course, $cm); + $groupmode = groupmode($COURSE, $cm); /// Decides if current user is allowed to see ALL the current discussions or not @@ -73,7 +68,7 @@ class block_news_items extends block_base { /// Get all the recent discussions we're allowed to see if (! $discussions = forum_get_discussions($forum->id, 'p.modified DESC', 0, false, - $visiblegroups, $course->newsitems) ) { + $visiblegroups, $COURSE->newsitems) ) { $text .= '('.get_string('nonews', 'forum').')'; $this->content->text = $text; return $this->content; @@ -119,7 +114,7 @@ class block_news_items extends block_base { } else { $userid = $USER->id; } - $this->content->footer .= '
'.rss_get_link($course->id, $userid, 'forum', $forum->id, $tooltiptext); + $this->content->footer .= '
'.rss_get_link($COURSE->id, $userid, 'forum', $forum->id, $tooltiptext); } } diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php index be9b96263e..7eb84ffda0 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -9,7 +9,7 @@ class block_online_users extends block_base { function has_config() {return true;} function get_content() { - global $USER, $CFG; + global $USER, $CFG, $COURSE; if ($this->content !== NULL) { return $this->content; @@ -23,8 +23,6 @@ class block_online_users extends block_base { return $this->content; } - $course = get_record('course', 'id', $this->instance->pageid); - $timetoshowusers = 300; //Seconds default if (isset($CFG->block_online_users_timetosee)) { $timetoshowusers = $CFG->block_online_users_timetosee * 60; @@ -32,10 +30,10 @@ class block_online_users extends block_base { $timefrom = time()-$timetoshowusers; //Calculate if we are in separate groups - $isseparategroups = ($course->groupmode == SEPARATEGROUPS && $course->groupmodeforce && !isteacheredit($this->instance->pageid)); + $isseparategroups = ($COURSE->groupmode == SEPARATEGROUPS && $COURSE->groupmodeforce && !isteacheredit($COURSE->id)); //Get the user current group - $currentgroup = $isseparategroups ? get_current_group($this->instance->pageid) : NULL; + $currentgroup = $isseparategroups ? get_current_group($COURSE->id) : NULL; $groupmembers = ""; $groupselect = ""; @@ -46,11 +44,11 @@ class block_online_users extends block_base { $groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'"; } - if ($this->instance->pageid == SITEID) { // Site-level + if ($COURSE->id == SITEID) { // Site-level $courseselect = ''; $timeselect = "AND (s.timeaccess > $timefrom OR u.lastaccess > $timefrom)"; } else { - $courseselect = "AND s.course = '".$this->instance->pageid."'"; + $courseselect = "AND s.course = '".$COURSE->id."'"; $timeselect = "AND s.timeaccess > $timefrom"; } @@ -69,7 +67,7 @@ class block_online_users extends block_base { } } - if ($this->instance->pageid == SITEID && $CFG->allusersaresitestudents) { + if ($COURSE->id == SITEID && $CFG->allusersaresitestudents) { if ($siteusers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess FROM {$CFG->prefix}user u WHERE u.lastaccess > $timefrom AND u.username <> 'guest' @@ -88,7 +86,7 @@ class block_online_users extends block_base { $groupmembers WHERE u.id = s.userid $courseselect $groupselect $timeselect "; - if (!isteacher($course->id)) { + if (!isteacher($COURSE->id)) { // Hide hidden teachers from students. $findteacherssql .= 'AND s.authority > 0 '; } @@ -116,8 +114,8 @@ class block_online_users extends block_base { foreach ($users as $user) { $this->content->text .= '
  • '; $timeago = format_time(time() - max($user->timeaccess, $user->lastaccess)); //bruno to calculate correctly on frontpage - $this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 16, true).' '; - $this->content->text .= ''.$user->fullname.''; + $this->content->text .= print_user_picture($user->id, $COURSE->id, $user->picture, 16, true).' '; + $this->content->text .= ''.$user->fullname.''; if (!empty($USER->id) and ($USER->id != $user->id) and !empty($CFG->messaging) and !isguest()) { // Only when logged in $this->content->text .= "\n".' ' .''. get_string('messageselectadd') .''; diff --git a/blocks/recent_activity/block_recent_activity.php b/blocks/recent_activity/block_recent_activity.php index 7a075bcb48..06516b359c 100644 --- a/blocks/recent_activity/block_recent_activity.php +++ b/blocks/recent_activity/block_recent_activity.php @@ -7,6 +7,7 @@ class block_recent_activity extends block_base { } function get_content() { + global $COURSE; if ($this->content !== NULL) { return $this->content; @@ -21,11 +22,9 @@ class block_recent_activity extends block_base { $this->content->text = ''; $this->content->footer = ''; - $course = get_record('course', 'id', $this->instance->pageid); - // Slightly hacky way to do it but... ob_start(); - print_recent_activity($course); + print_recent_activity($COURSE); $this->content->text = ob_get_contents(); ob_end_clean(); diff --git a/blocks/rss_client/block_rss_client.php b/blocks/rss_client/block_rss_client.php index 5b23469a9d..555eaa6f4f 100644 --- a/blocks/rss_client/block_rss_client.php +++ b/blocks/rss_client/block_rss_client.php @@ -42,7 +42,7 @@ } function get_content() { - global $CFG, $editing; + global $CFG, $editing, $COURSE; require_once($CFG->libdir .'/rsslib.php'); @@ -89,7 +89,7 @@ $isteacher = false; $this->courseid = SITEID; if ($this->instance->pagetype == PAGE_COURSE_VIEW) { - $this->courseid = $this->instance->pageid; + $this->courseid = $COURSE->id; $isteacher = isteacher($this->courseid); }