original_string: public function properties($prepareeditor = false) {
          global $DB;
  
          // First take a copy of the properties. We don't want to actually change the
          // properties or we'd forever be converting back and forwards between an
          // editor formatted description and not.
          $properties = clone($this->properties);
          // Clean the description here.
          $properties->description = clean_text($properties->description, $properties->format);
  
          // If set to true we need to prepare the properties for use with an editor
          // and prepare the file area.
          if ($prepareeditor) {
  
              // We may or may not have a property id. If we do then we need to work
              // out the context so we can copy the existing files to the draft area.
              if (!empty($properties->id)) {
  
                  if ($properties->eventtype === 'site') {
                      // Site context.
                      $this->editorcontext = $this->get_context();
                  } else if ($properties->eventtype === 'user') {
                      // User context.
                      $this->editorcontext = $this->get_context();
                  } else if ($properties->eventtype === 'group' || $properties->eventtype === 'course') {
                      // First check the course is valid.
                      $course = $DB->get_record('course', array('id' => $properties->courseid));
                      if (!$course) {
                          print_error('invalidcourse');
                      }
                      // Course context.
                      $this->editorcontext = $this->get_context();
                      // We have a course and are within the course context so we had
                      // better use the courses max bytes value.
                      $this->editoroptions['maxbytes'] = $course->maxbytes;
                  } else if ($properties->eventtype === 'category') {
                      // First check the course is valid.
                      \core_course_category::get($properties->categoryid, MUST_EXIST, true);
                      // Course context.
                      $this->editorcontext = $this->get_context();
                  } else {
                      // If we get here we have a custom event type as used by some
                      // modules. In this case the event will have been added by
                      // code and we won't need the editor.
                      $this->editoroptions['maxbytes'] = 0;
                      $this->editoroptions['maxfiles'] = 0;
                  }
  
                  if (empty($this->editorcontext) || empty($this->editorcontext->id)) {
                      $contextid = false;
                  } else {
                      // Get the context id that is what we really want.
                      $contextid = $this->editorcontext->id;
                  }
              } else {
  
                  // If we get here then this is a new event in which case we don't need a
                  // context as there is no existing files to copy to the draft area.
                  $contextid = null;
              }
  
              // If the contextid === false we don't support files so no preparing
              // a draft area.
              if ($contextid !== false) {
                  // Just encase it has already been submitted.
                  $draftiddescription = file_get_submitted_draft_itemid('description');
                  // Prepare the draft area, this copies existing files to the draft area as well.
                  $properties->description = file_prepare_draft_area($draftiddescription, $contextid, 'calendar',
                      'event_description', $properties->id, $this->editoroptions, $properties->description);
              } else {
                  $draftiddescription = 0;
              }
  
              // Structure the description field as the editor requires.
              $properties->description = array('text' => $properties->description, 'format' => $properties->format,
                  'itemid' => $draftiddescription);
          }
  
          // Finally return the properties.
          return $properties;
      }
code: public function properties($prepareeditor = false) {
          global $DB;
  
          // First take a copy of the properties. We don't want to actually change the
          // properties or we'd forever be converting back and forwards between an
          // editor formatted description and not.
          $properties = clone($this->properties);
          // Clean the description here.
          $properties->description = clean_text($properties->description, $properties->format);
  
          // If set to true we need to prepare the properties for use with an editor
          // and prepare the file area.
          if ($prepareeditor) {
  
              // We may or may not have a property id. If we do then we need to work
              // out the context so we can copy the existing files to the draft area.
              if (!empty($properties->id)) {
  
                  if ($properties->eventtype === 'site') {
                      // Site context.
                      $this->editorcontext = $this->get_context();
                  } else if ($properties->eventtype === 'user') {
                      // User context.
                      $this->editorcontext = $this->get_context();
                  } else if ($properties->eventtype === 'group' || $properties->eventtype === 'course') {
                      // First check the course is valid.
                      $course = $DB->get_record('course', array('id' => $properties->courseid));
                      if (!$course) {
                          print_error('invalidcourse');
                      }
                      // Course context.
                      $this->editorcontext = $this->get_context();
                      // We have a course and are within the course context so we had
                      // better use the courses max bytes value.
                      $this->editoroptions['maxbytes'] = $course->maxbytes;
                  } else if ($properties->eventtype === 'category') {
                      // First check the course is valid.
                      \core_course_category::get($properties->categoryid, MUST_EXIST, true);
                      // Course context.
                      $this->editorcontext = $this->get_context();
                  } else {
                      // If we get here we have a custom event type as used by some
                      // modules. In this case the event will have been added by
                      // code and we won't need the editor.
                      $this->editoroptions['maxbytes'] = 0;
                      $this->editoroptions['maxfiles'] = 0;
                  }
  
                  if (empty($this->editorcontext) || empty($this->editorcontext->id)) {
                      $contextid = false;
                  } else {
                      // Get the context id that is what we really want.
                      $contextid = $this->editorcontext->id;
                  }
              } else {
  
                  // If we get here then this is a new event in which case we don't need a
                  // context as there is no existing files to copy to the draft area.
                  $contextid = null;
              }
  
              // If the contextid === false we don't support files so no preparing
              // a draft area.
              if ($contextid !== false) {
                  // Just encase it has already been submitted.
                  $draftiddescription = file_get_submitted_draft_itemid('description');
                  // Prepare the draft area, this copies existing files to the draft area as well.
                  $properties->description = file_prepare_draft_area($draftiddescription, $contextid, 'calendar',
                      'event_description', $properties->id, $this->editoroptions, $properties->description);
              } else {
                  $draftiddescription = 0;
              }
  
              // Structure the description field as the editor requires.
              $properties->description = array('text' => $properties->description, 'format' => $properties->format,
                  'itemid' => $draftiddescription);
          }
  
          // Finally return the properties.
          return $properties;
      }
code_tokens: public function properties ( $ prepareeditor = false ) { global $ DB ; // First take a copy of the properties. We don't want to actually change the // properties or we'd forever be converting back and forwards between an // editor formatted description and not. $ properties = clone ( $ this -> properties ) ; // Clean the description here. $ properties -> description = clean_text ( $ properties -> description , $ properties -> format ) ; // If set to true we need to prepare the properties for use with an editor // and prepare the file area. if ( $ prepareeditor ) { // We may or may not have a property id. If we do then we need to work // out the context so we can copy the existing files to the draft area. if ( ! empty ( $ properties -> id ) ) { if ( $ properties -> eventtype === 'site' ) { // Site context. $ this -> editorcontext = $ this -> get_context ( ) ; } else if ( $ properties -> eventtype === 'user' ) { // User context. $ this -> editorcontext = $ this -> get_context ( ) ; } else if ( $ properties -> eventtype === 'group' || $ properties -> eventtype === 'course' ) { // First check the course is valid. $ course = $ DB -> get_record ( 'course' , array ( 'id' => $ properties -> courseid ) ) ; if ( ! $ course ) { print_error ( 'invalidcourse' ) ; } // Course context. $ this -> editorcontext = $ this -> get_context ( ) ; // We have a course and are within the course context so we had // better use the courses max bytes value. $ this -> editoroptions [ 'maxbytes' ] = $ course -> maxbytes ; } else if ( $ properties -> eventtype === 'category' ) { // First check the course is valid. \ core_course_category :: get ( $ properties -> categoryid , MUST_EXIST , true ) ; // Course context. $ this -> editorcontext = $ this -> get_context ( ) ; } else { // If we get here we have a custom event type as used by some // modules. In this case the event will have been added by // code and we won't need the editor. $ this -> editoroptions [ 'maxbytes' ] = 0 ; $ this -> editoroptions [ 'maxfiles' ] = 0 ; } if ( empty ( $ this -> editorcontext ) || empty ( $ this -> editorcontext -> id ) ) { $ contextid = false ; } else { // Get the context id that is what we really want. $ contextid = $ this -> editorcontext -> id ; } } else { // If we get here then this is a new event in which case we don't need a // context as there is no existing files to copy to the draft area. $ contextid = null ; } // If the contextid === false we don't support files so no preparing // a draft area. if ( $ contextid !== false ) { // Just encase it has already been submitted. $ draftiddescription = file_get_submitted_draft_itemid ( 'description' ) ; // Prepare the draft area, this copies existing files to the draft area as well. $ properties -> description = file_prepare_draft_area ( $ draftiddescription , $ contextid , 'calendar' , 'event_description' , $ properties -> id , $ this -> editoroptions , $ properties -> description ) ; } else { $ draftiddescription = 0 ; } // Structure the description field as the editor requires. $ properties -> description = array ( 'text' => $ properties -> description , 'format' => $ properties -> format , 'itemid' => $ draftiddescription ) ; } // Finally return the properties. return $ properties ; }
docstring: Fetch all event properties.
  
  This function returns all of the events properties as an object and optionally
  can prepare an editor for the description field at the same time. This is
  designed to work when the properties are going to be used to set the default
  values of a moodle forms form.
  
  @param bool $prepareeditor If set to true a editor is prepared for use with
  the mforms editor element. (for description)
  @return \stdClass Object containing event properties
docstring_tokens: Fetch all event properties .