original_string: public function load_data() {
          global $DB;
  
          $context = context_module::instance($this->cmid);
  
          if (empty($this->fileid)) {
              if (empty($this->sid) || empty($this->area)) {
                  throw new portfolio_caller_exception('invalidfileandsubmissionid', 'mod_assign');
              }
  
              $submission = $DB->get_record('assign_submission', array('id' => $this->sid));
          } else {
              $submissionid = $DB->get_field('files', 'itemid', array('id' => $this->fileid, 'contextid' => $context->id));
              if ($submissionid) {
                  $submission = $DB->get_record('assign_submission', array('id' => $submissionid));
              }
          }
  
          if (empty($submission)) {
              throw new portfolio_caller_exception('filenotfound');
          } else if ($submission->userid == 0) {
              // This must be a group submission.
              if (!groups_is_member($submission->groupid, $this->user->id)) {
                  throw new portfolio_caller_exception('filenotfound');
              }
          } else if ($this->user->id != $submission->userid) {
              throw new portfolio_caller_exception('filenotfound');
          }
  
          // Export either an area of files or a single file (see function for more detail).
          // The first arg is an id or null. If it is an id, the rest of the args are ignored.
          // If it is null, the rest of the args are used to load a list of files from get_areafiles.
          $this->set_file_and_format_data($this->fileid,
                                          $context->id,
                                          $this->component,
                                          $this->area,
                                          $this->sid,
                                          'timemodified',
                                          false);
  
      }
code: public function load_data() {
          global $DB;
  
          $context = context_module::instance($this->cmid);
  
          if (empty($this->fileid)) {
              if (empty($this->sid) || empty($this->area)) {
                  throw new portfolio_caller_exception('invalidfileandsubmissionid', 'mod_assign');
              }
  
              $submission = $DB->get_record('assign_submission', array('id' => $this->sid));
          } else {
              $submissionid = $DB->get_field('files', 'itemid', array('id' => $this->fileid, 'contextid' => $context->id));
              if ($submissionid) {
                  $submission = $DB->get_record('assign_submission', array('id' => $submissionid));
              }
          }
  
          if (empty($submission)) {
              throw new portfolio_caller_exception('filenotfound');
          } else if ($submission->userid == 0) {
              // This must be a group submission.
              if (!groups_is_member($submission->groupid, $this->user->id)) {
                  throw new portfolio_caller_exception('filenotfound');
              }
          } else if ($this->user->id != $submission->userid) {
              throw new portfolio_caller_exception('filenotfound');
          }
  
          // Export either an area of files or a single file (see function for more detail).
          // The first arg is an id or null. If it is an id, the rest of the args are ignored.
          // If it is null, the rest of the args are used to load a list of files from get_areafiles.
          $this->set_file_and_format_data($this->fileid,
                                          $context->id,
                                          $this->component,
                                          $this->area,
                                          $this->sid,
                                          'timemodified',
                                          false);
  
      }
code_tokens: public function load_data ( ) { global $ DB ; $ context = context_module :: instance ( $ this -> cmid ) ; if ( empty ( $ this -> fileid ) ) { if ( empty ( $ this -> sid ) || empty ( $ this -> area ) ) { throw new portfolio_caller_exception ( 'invalidfileandsubmissionid' , 'mod_assign' ) ; } $ submission = $ DB -> get_record ( 'assign_submission' , array ( 'id' => $ this -> sid ) ) ; } else { $ submissionid = $ DB -> get_field ( 'files' , 'itemid' , array ( 'id' => $ this -> fileid , 'contextid' => $ context -> id ) ) ; if ( $ submissionid ) { $ submission = $ DB -> get_record ( 'assign_submission' , array ( 'id' => $ submissionid ) ) ; } } if ( empty ( $ submission ) ) { throw new portfolio_caller_exception ( 'filenotfound' ) ; } else if ( $ submission -> userid == 0 ) { // This must be a group submission. if ( ! groups_is_member ( $ submission -> groupid , $ this -> user -> id ) ) { throw new portfolio_caller_exception ( 'filenotfound' ) ; } } else if ( $ this -> user -> id != $ submission -> userid ) { throw new portfolio_caller_exception ( 'filenotfound' ) ; } // Export either an area of files or a single file (see function for more detail). // The first arg is an id or null. If it is an id, the rest of the args are ignored. // If it is null, the rest of the args are used to load a list of files from get_areafiles. $ this -> set_file_and_format_data ( $ this -> fileid , $ context -> id , $ this -> component , $ this -> area , $ this -> sid , 'timemodified' , false ) ; }
docstring: Load data needed for the portfolio export.
  
  If the assignment type implements portfolio_load_data(), the processing is delegated
  to it. Otherwise, the caller must provide either fileid (to export single file) or
  submissionid and filearea (to export all data attached to the given submission file area)
  via callback arguments.
  
  @throws     portfolio_caller_exception
docstring_tokens: Load data needed for the portfolio export .