mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 05:25:08 +02:00
MDL-10995 eliminated some get course record calls - reused $COURSE instead
This commit is contained in:
parent
47ba005d0d
commit
b571c6b37b
@ -8,7 +8,7 @@ class block_admin extends block_list {
|
||||
|
||||
function get_content() {
|
||||
|
||||
global $CFG, $USER, $SITE;
|
||||
global $CFG, $USER, $SITE, $COURSE;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
@ -27,13 +27,13 @@ class block_admin extends block_list {
|
||||
|
||||
if (!empty($this->instance->pageid)) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $this->instance->pageid);
|
||||
}
|
||||
|
||||
if (empty($context)) {
|
||||
if ($COURSE->id == $this->instance->pageid) {
|
||||
$course = $COURSE;
|
||||
} else {
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
}
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
}
|
||||
|
||||
if (!$course = get_record('course', 'id', $this->instance->pageid)) {
|
||||
$course = $SITE;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class block_section_links extends block_base {
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $COURSE;
|
||||
|
||||
$highlight = 0;
|
||||
|
||||
@ -42,7 +42,11 @@ class block_section_links extends block_base {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
if ($this->instance->pageid == $COURSE->id) {
|
||||
$course = $COURSE;
|
||||
} else {
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if ($course->format == 'weeks' or $course->format == 'weekscss') {
|
||||
|
@ -1154,8 +1154,13 @@ function calendar_get_module_cached(&$coursecache, $modulename, $instance) {
|
||||
}
|
||||
|
||||
function calendar_get_course_cached(&$coursecache, $courseid) {
|
||||
if(!isset($coursecache[$courseid])) {
|
||||
$coursecache[$courseid] = get_record('course', 'id', $courseid);
|
||||
global $COURSE;
|
||||
if (!isset($coursecache[$courseid])) {
|
||||
if ($courseid == $COURSE->id) {
|
||||
$coursecache[$courseid] = $COURSE;
|
||||
} else {
|
||||
$coursecache[$courseid] = get_record('course', 'id', $courseid);
|
||||
}
|
||||
}
|
||||
return $coursecache[$courseid];
|
||||
}
|
||||
|
@ -328,13 +328,19 @@ class page_course extends page_base {
|
||||
// in init_quick() and instead deferred here. Of course this function had better recognize
|
||||
// $this->full_init_done to prevent wasteful multiple-time data retrieval.
|
||||
function init_full() {
|
||||
global $COURSE;
|
||||
if($this->full_init_done) {
|
||||
return;
|
||||
}
|
||||
if (empty($this->id)) {
|
||||
$this->id = 0; // avoid db errors
|
||||
}
|
||||
$this->courserecord = get_record('course', 'id', $this->id);
|
||||
if ($this->id == $COURSE->id) {
|
||||
$this->courserecord = $COURSE;
|
||||
} else {
|
||||
$this->courserecord = get_record('course', 'id', $this->id);
|
||||
}
|
||||
|
||||
if(empty($this->courserecord) && !defined('ADMIN_STICKYBLOCKS')) {
|
||||
error('Cannot fully initialize page: invalid course id '. $this->id);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user