[ 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 * Handles displaying the calendar upcoming events block. 19 * 20 * @package block_calendar_upcoming 21 * @copyright 2004 Eloy Lafuente (stronk7) {@link http://stronk7.com} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 class block_calendar_upcoming extends block_base { 25 26 /** 27 * Initialise the block. 28 */ 29 public function init() { 30 $this->title = get_string('pluginname', 'block_calendar_upcoming'); 31 } 32 33 /** 34 * Return the content of this block. 35 * 36 * @return stdClass the content 37 */ 38 public function get_content() { 39 global $CFG; 40 41 require_once($CFG->dirroot.'/calendar/lib.php'); 42 43 if ($this->content !== null) { 44 return $this->content; 45 } 46 $this->content = new stdClass; 47 $this->content->text = ''; 48 49 $filtercourse = array(); 50 if (empty($this->instance)) { // Overrides: use no course at all. 51 $courseshown = false; 52 $this->content->footer = ''; 53 54 } else { 55 $courseshown = $this->page->course->id; 56 $this->content->footer = '<div class="gotocal"><a href="'.$CFG->wwwroot. 57 '/calendar/view.php?view=upcoming&course='.$courseshown.'">'. 58 get_string('gotocalendar', 'calendar').'</a>...</div>'; 59 $context = context_course::instance($courseshown); 60 if (has_any_capability(array('moodle/calendar:manageentries', 'moodle/calendar:manageownentries'), $context)) { 61 $this->content->footer .= '<div class="newevent"><a href="'.$CFG->wwwroot. 62 '/calendar/event.php?action=new&course='.$courseshown.'">'. 63 get_string('newevent', 'calendar').'</a>...</div>'; 64 } 65 if ($courseshown == SITEID) { 66 // Being displayed at site level. This will cause the filter to fall back to auto-detecting 67 // the list of courses it will be grabbing events from. 68 $filtercourse = calendar_get_default_courses(); 69 } else { 70 // Forcibly filter events to include only those from the particular course we are in. 71 $filtercourse = array($courseshown => $this->page->course); 72 } 73 } 74 75 list($courses, $group, $user) = calendar_set_filters($filtercourse); 76 77 $defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD; 78 if (isset($CFG->calendar_lookahead)) { 79 $defaultlookahead = intval($CFG->calendar_lookahead); 80 } 81 $lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead); 82 83 $defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS; 84 if (isset($CFG->calendar_maxevents)) { 85 $defaultmaxevents = intval($CFG->calendar_maxevents); 86 } 87 $maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents); 88 $events = calendar_get_upcoming($courses, $group, $user, $lookahead, $maxevents); 89 90 if (!empty($this->instance)) { 91 $link = 'view.php?view=day&course='.$courseshown.'&'; 92 $showcourselink = ($this->page->course->id == SITEID); 93 $this->content->text = calendar_get_block_upcoming($events, $link, $showcourselink); 94 } 95 96 if (empty($this->content->text)) { 97 $this->content->text = '<div class="post">'. get_string('noupcomingevents', 'calendar').'</div>'; 98 } 99 100 return $this->content; 101 } 102 } 103 104
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 |