[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/blocks/calendar_month/ -> block_calendar_month.php (source)

   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 block.
  19   *
  20   * @package    block_calendar_month
  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_month extends block_base {
  25  
  26      /**
  27       * Initialise the block.
  28       */
  29      public function init() {
  30          $this->title = get_string('pluginname', 'block_calendar_month');
  31      }
  32  
  33      /**
  34       * Return preferred_width.
  35       *
  36       * @return int
  37       */
  38      public function preferred_width() {
  39          return 210;
  40      }
  41  
  42      /**
  43       * Return the content of this block.
  44       *
  45       * @return stdClass the content
  46       */
  47      public function get_content() {
  48          global $CFG;
  49  
  50          $calm = optional_param('cal_m', 0, PARAM_INT);
  51          $caly = optional_param('cal_y', 0, PARAM_INT);
  52          $time = optional_param('time', 0, PARAM_INT);
  53  
  54          require_once($CFG->dirroot.'/calendar/lib.php');
  55  
  56          if ($this->content !== null) {
  57              return $this->content;
  58          }
  59  
  60          // If a day, month and year were passed then convert it to a timestamp. If these were passed then we can assume
  61          // the day, month and year are passed as Gregorian, as no where in core should we be passing these values rather
  62          // than the time. This is done for BC.
  63          if (!empty($calm) && (!empty($caly))) {
  64              $time = make_timestamp($caly, $calm, 1);
  65          } else if (empty($time)) {
  66              $time = time();
  67          }
  68  
  69          $this->content = new stdClass;
  70          $this->content->text = '';
  71          $this->content->footer = '';
  72  
  73          // [pj] To me it looks like this if would never be needed, but Penny added it
  74          // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
  75          // It definitely needs SOME comment here!
  76          $courseid = $this->page->course->id;
  77          $issite = ($courseid == SITEID);
  78  
  79          if ($issite) {
  80              // Being displayed at site level. This will cause the filter to fall back to auto-detecting
  81              // the list of courses it will be grabbing events from.
  82              $filtercourse = calendar_get_default_courses();
  83          } else {
  84              // Forcibly filter events to include only those from the particular course we are in.
  85              $filtercourse = array($courseid => $this->page->course);
  86          }
  87  
  88          list($courses, $group, $user) = calendar_set_filters($filtercourse);
  89          if ($issite) {
  90              // For the front page.
  91              $this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'frontpage', $courseid, $time);
  92              // No filters for now.
  93          } else {
  94              // For any other course.
  95              $this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'course', $courseid, $time);
  96              $this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
  97              $this->content->text .= '<div class="filters calendar_filters">'.calendar_filter_controls($this->page->url).'</div>';
  98          }
  99  
 100          return $this->content;
 101      }
 102  }
 103  
 104  


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1