[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Course overview block 19 * 20 * @package block_course_overview 21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 require_once($CFG->dirroot.'/blocks/course_overview/locallib.php'); 25 26 /** 27 * Course overview block 28 * 29 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 31 */ 32 class block_course_overview extends block_base { 33 /** 34 * If this is passed as mynumber then showallcourses, irrespective of limit by user. 35 */ 36 const SHOW_ALL_COURSES = -2; 37 38 /** 39 * Block initialization 40 */ 41 public function init() { 42 $this->title = get_string('pluginname', 'block_course_overview'); 43 } 44 45 /** 46 * Return contents of course_overview block 47 * 48 * @return stdClass contents of block 49 */ 50 public function get_content() { 51 global $USER, $CFG, $DB; 52 require_once($CFG->dirroot.'/user/profile/lib.php'); 53 54 if($this->content !== NULL) { 55 return $this->content; 56 } 57 58 $config = get_config('block_course_overview'); 59 60 $this->content = new stdClass(); 61 $this->content->text = ''; 62 $this->content->footer = ''; 63 64 $content = array(); 65 66 $updatemynumber = optional_param('mynumber', -1, PARAM_INT); 67 if ($updatemynumber >= 0) { 68 block_course_overview_update_mynumber($updatemynumber); 69 } 70 71 profile_load_custom_fields($USER); 72 73 $showallcourses = ($updatemynumber === self::SHOW_ALL_COURSES); 74 list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses($showallcourses); 75 $overviews = block_course_overview_get_overviews($sitecourses); 76 77 $renderer = $this->page->get_renderer('block_course_overview'); 78 if (!empty($config->showwelcomearea)) { 79 require_once($CFG->dirroot.'/message/lib.php'); 80 $msgcount = message_count_unread_messages(); 81 $this->content->text = $renderer->welcome_area($msgcount); 82 } 83 84 // Number of sites to display. 85 if ($this->page->user_is_editing() && empty($config->forcedefaultmaxcourses)) { 86 $this->content->text .= $renderer->editing_bar_head($totalcourses); 87 } 88 89 if (empty($sortedcourses)) { 90 $this->content->text .= get_string('nocourses','my'); 91 } else { 92 // For each course, build category cache. 93 $this->content->text .= $renderer->course_overview($sortedcourses, $overviews); 94 $this->content->text .= $renderer->hidden_courses($totalcourses - count($sortedcourses)); 95 } 96 97 return $this->content; 98 } 99 100 /** 101 * Allow the block to have a configuration page 102 * 103 * @return boolean 104 */ 105 public function has_config() { 106 return true; 107 } 108 109 /** 110 * Locations where block can be displayed 111 * 112 * @return array 113 */ 114 public function applicable_formats() { 115 return array('my' => true); 116 } 117 118 /** 119 * Sets block header to be hidden or visible 120 * 121 * @return bool if true then header will be visible. 122 */ 123 public function hide_header() { 124 // Hide header if welcome area is show. 125 $config = get_config('block_course_overview'); 126 return !empty($config->showwelcomearea); 127 } 128 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |