[ Index ]

PHP Cross Reference of Unnamed Project

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


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1