Merge branch 'MDL-30731-master' of git://github.com/FMCorz/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 20 Nov 2012 07:31:27 +0000 (15:31 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 20 Nov 2012 07:31:27 +0000 (15:31 +0800)
1  2 
calendar/lib.php

diff --combined calendar/lib.php
@@@ -2112,24 -2112,22 +2112,22 @@@ class calendar_event 
              if ($usingeditor) {
                  switch ($this->properties->eventtype) {
                      case 'user':
-                         $this->editorcontext = $this->properties->context;
                          $this->properties->courseid = 0;
+                         $this->properties->course = 0;
                          $this->properties->groupid = 0;
                          $this->properties->userid = $USER->id;
                          break;
                      case 'site':
-                         $this->editorcontext = $this->properties->context;
                          $this->properties->courseid = SITEID;
+                         $this->properties->course = SITEID;
                          $this->properties->groupid = 0;
                          $this->properties->userid = $USER->id;
                          break;
                      case 'course':
-                         $this->editorcontext = $this->properties->context;
                          $this->properties->groupid = 0;
                          $this->properties->userid = $USER->id;
                          break;
                      case 'group':
-                         $this->editorcontext = $this->properties->context;
                          $this->properties->userid = $USER->id;
                          break;
                      default:
                          break;
                  }
  
+                 // If we are actually using the editor, we recalculate the context because some default values
+                 // were set when calculate_context() was called from the constructor.
+                 if ($usingeditor) {
+                     $this->properties->context = $this->calculate_context($this->properties);
+                     $this->editorcontext = $this->properties->context;
+                 }
                  $editor = $this->properties->description;
                  $this->properties->format = $this->properties->description['format'];
                  $this->properties->description = $this->properties->description['text'];
                                                  $this->editoroptions,
                                                  $editor['text'],
                                                  $this->editoroptions['forcehttps']);
                  $DB->set_field('event', 'description', $this->properties->description, array('id'=>$this->properties->id));
              }
  
@@@ -2695,7 -2699,7 +2699,7 @@@ function calendar_get_eventtype_choices
          $choices[0] = get_string('userevents', 'calendar');
      }
      if ($allowed->site) {
 -        $choices[SITEID] = get_string('globalevents', 'calendar');
 +        $choices[SITEID] = get_string('siteevents', 'calendar');
      }
      if (!empty($allowed->courses)) {
          $choices[$courseid] = get_string('courseevents', 'calendar');