[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

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

   1  <?PHP //$Id: block_calendar_month.php,v 1.30.2.5 2008/03/03 20:39:19 skodak Exp $
   2  
   3  class block_calendar_month extends block_base {
   4      function init() {
   5          $this->title = get_string('calendar', 'calendar');
   6          $this->version = 2007101509;
   7      }
   8  
   9      function preferred_width() {
  10          return 210;
  11      }
  12  
  13      function get_content() {
  14          global $USER, $CFG, $SESSION, $COURSE;
  15          $cal_m = optional_param( 'cal_m', 0, PARAM_INT );
  16          $cal_y = optional_param( 'cal_y', 0, PARAM_INT );
  17  
  18          require_once($CFG->dirroot.'/calendar/lib.php');
  19          
  20          if ($this->content !== NULL) {
  21              return $this->content;
  22          }
  23          // Reset the session variables
  24          calendar_session_vars($COURSE);
  25          
  26          $this->content = new stdClass;
  27          $this->content->text = '';
  28          $this->content->footer = '';
  29  
  30          // [pj] To me it looks like this if would never be needed, but Penny added it 
  31          // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
  32          // It definitely needs SOME comment here!
  33          $courseshown = $COURSE->id;
  34  
  35          if ($courseshown == SITEID) {
  36              // Being displayed at site level. This will cause the filter to fall back to auto-detecting
  37              // the list of courses it will be grabbing events from.
  38              $filtercourse    = NULL;
  39              $groupeventsfrom = NULL;
  40              $SESSION->cal_courses_shown = calendar_get_default_courses(true);
  41              calendar_set_referring_course(0);
  42  
  43          } else {
  44              // Forcibly filter events to include only those from the particular course we are in.
  45              $filtercourse    = array($courseshown => $COURSE);
  46              $groupeventsfrom = array($courseshown => 1);
  47          }
  48  
  49          // We 'll need this later
  50          calendar_set_referring_course($courseshown);
  51  
  52          // MDL-9059, set to show this course when admins go into a course, then unset it.
  53          if ($COURSE->id != SITEID && !isset($SESSION->cal_courses_shown[$COURSE->id]) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
  54              $courseset = true;
  55              $SESSION->cal_courses_shown[$COURSE->id] = $COURSE;
  56          }
  57      
  58          // Be VERY careful with the format for default courses arguments!
  59          // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
  60          calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, false);
  61          if ($courseshown == SITEID) {
  62              // For the front page
  63              $this->content->text .= calendar_overlib_html();
  64              $this->content->text .= calendar_top_controls('frontpage', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
  65              $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
  66              // No filters for now
  67  
  68          } else {
  69              // For any other course
  70              $this->content->text .= calendar_overlib_html();
  71              $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
  72              $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
  73              $this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
  74              $this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $COURSE).'</div>';
  75              
  76          }
  77          
  78          // MDL-9059, unset this so that it doesn't stay in session
  79          if (!empty($courseset)) {
  80              unset($SESSION->cal_courses_shown[$COURSE->id]);
  81          }
  82  
  83          return $this->content;
  84      }
  85  }
  86  
  87  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7