$course = $site; //just in case we need the old global $course hack if (array_key_exists($site->id, $courses)) { unset($courses[$site->id]); } foreach ($courses as $c) { if (isset($USER->lastcourseaccess[$c->id])) { $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id]; } else { $courses[$c->id]->lastaccess = 0; } } if (empty($courses)) { print_simple_box(get_string('nocourses', 'my'), 'center'); } else { print_overview($courses); } // if more than 20 courses if (count($courses) > 20) { echo '<br />...'; } print_container_end(); echo '</td>'; break; case 'right': $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210); if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) { echo '<td style="vertical-align: top; width: ' . $blocks_preferred_width . 'px;" id="right-column">'; print_container_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); print_container_end();
/** * block contents * * @return object */ public function get_content() { global $USER, $CFG; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; $content = array(); // limits the number of courses showing up $courses_limit = 21; // FIXME: this should be a block setting, rather than a global setting if (isset($CFG->mycoursesperpage)) { $courses_limit = $CFG->mycoursesperpage; } $morecourses = false; if ($courses_limit > 0) { $courses_limit = $courses_limit + 1; } $courses = enrol_get_my_courses('id, shortname', 'visible DESC,sortorder ASC', $courses_limit); $site = get_site(); $course = $site; //just in case we need the old global $course hack if (is_enabled_auth('mnet')) { $remote_courses = get_my_remotecourses(); } if (empty($remote_courses)) { $remote_courses = array(); } if ($courses_limit > 0 && count($courses) + count($remote_courses) >= $courses_limit) { // get rid of any remote courses that are above the limit $remote_courses = array_slice($remote_courses, 0, $courses_limit - count($courses), true); if (count($courses) >= $courses_limit) { //remove the 'marker' course that we retrieve just to see if we have more than $courses_limit array_pop($courses); } $morecourses = true; } if (array_key_exists($site->id, $courses)) { unset($courses[$site->id]); } foreach ($courses as $c) { if (isset($USER->lastcourseaccess[$c->id])) { $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id]; } else { $courses[$c->id]->lastaccess = 0; } } if (empty($courses) && empty($remote_courses)) { $content[] = get_string('nocourses', 'my'); } else { ob_start(); require_once $CFG->dirroot . "/course/lib.php"; print_overview($courses, $remote_courses); $content[] = ob_get_contents(); ob_end_clean(); } // if more than 20 courses if ($morecourses) { $content[] = '<br />...'; } $this->content->text = implode($content); return $this->content; }