original_string: public function get_file_info($browser, $filearea, $itemid, $filepath, $filename) {
          global $CFG, $DB, $USER;
          $urlbase = $CFG->wwwroot.'/pluginfile.php';
          $writeaccess = false;
          // Permission check on the itemid.
          $assignment = $this->assignment;
  
          if ($this->get_subtype() == 'assignsubmission') {
              if ($itemid) {
                  $record = $DB->get_record('assign_submission', array('id' => $itemid), 'userid,groupid', IGNORE_MISSING);
                  if (!$record) {
                      return null;
                  }
                  if (!empty($record->userid)) {
                      if (!$assignment->can_view_submission($record->userid)) {
                          return null;
                      }
  
                      // We only report write access for teachers.
                      $writeaccess = $assignment->can_grade() && $assignment->can_edit_submission($record->userid);
                  } else {
                      // Must be a team submission with a group.
                      if (!$assignment->can_view_group_submission($record->groupid)) {
                          return null;
                      }
                      // We only report write access for teachers.
                      $writeaccess = $assignment->can_grade() && $assignment->can_edit_group_submission($record->groupid);
                  }
              }
          } else {
              // Not supported for feedback plugins.
              return null;
          }
  
          $fs = get_file_storage();
          $filepath = is_null($filepath) ? '/' : $filepath;
          $filename = is_null($filename) ? '.' : $filename;
          if (!($storedfile = $fs->get_file($assignment->get_context()->id,
                                            $this->get_subtype() . '_' . $this->get_type(),
                                            $filearea,
                                            $itemid,
                                            $filepath,
                                            $filename))) {
              return null;
          }
  
          return new file_info_stored($browser,
                                      $assignment->get_context(),
                                      $storedfile,
                                      $urlbase,
                                      $filearea,
                                      $itemid,
                                      true,
                                      $writeaccess,
                                      false);
      }
code: public function get_file_info($browser, $filearea, $itemid, $filepath, $filename) {
          global $CFG, $DB, $USER;
          $urlbase = $CFG->wwwroot.'/pluginfile.php';
          $writeaccess = false;
          // Permission check on the itemid.
          $assignment = $this->assignment;
  
          if ($this->get_subtype() == 'assignsubmission') {
              if ($itemid) {
                  $record = $DB->get_record('assign_submission', array('id' => $itemid), 'userid,groupid', IGNORE_MISSING);
                  if (!$record) {
                      return null;
                  }
                  if (!empty($record->userid)) {
                      if (!$assignment->can_view_submission($record->userid)) {
                          return null;
                      }
  
                      // We only report write access for teachers.
                      $writeaccess = $assignment->can_grade() && $assignment->can_edit_submission($record->userid);
                  } else {
                      // Must be a team submission with a group.
                      if (!$assignment->can_view_group_submission($record->groupid)) {
                          return null;
                      }
                      // We only report write access for teachers.
                      $writeaccess = $assignment->can_grade() && $assignment->can_edit_group_submission($record->groupid);
                  }
              }
          } else {
              // Not supported for feedback plugins.
              return null;
          }
  
          $fs = get_file_storage();
          $filepath = is_null($filepath) ? '/' : $filepath;
          $filename = is_null($filename) ? '.' : $filename;
          if (!($storedfile = $fs->get_file($assignment->get_context()->id,
                                            $this->get_subtype() . '_' . $this->get_type(),
                                            $filearea,
                                            $itemid,
                                            $filepath,
                                            $filename))) {
              return null;
          }
  
          return new file_info_stored($browser,
                                      $assignment->get_context(),
                                      $storedfile,
                                      $urlbase,
                                      $filearea,
                                      $itemid,
                                      true,
                                      $writeaccess,
                                      false);
      }
code_tokens: public function get_file_info ( $ browser , $ filearea , $ itemid , $ filepath , $ filename ) { global $ CFG , $ DB , $ USER ; $ urlbase = $ CFG -> wwwroot . '/pluginfile.php' ; $ writeaccess = false ; // Permission check on the itemid. $ assignment = $ this -> assignment ; if ( $ this -> get_subtype ( ) == 'assignsubmission' ) { if ( $ itemid ) { $ record = $ DB -> get_record ( 'assign_submission' , array ( 'id' => $ itemid ) , 'userid,groupid' , IGNORE_MISSING ) ; if ( ! $ record ) { return null ; } if ( ! empty ( $ record -> userid ) ) { if ( ! $ assignment -> can_view_submission ( $ record -> userid ) ) { return null ; } // We only report write access for teachers. $ writeaccess = $ assignment -> can_grade ( ) && $ assignment -> can_edit_submission ( $ record -> userid ) ; } else { // Must be a team submission with a group. if ( ! $ assignment -> can_view_group_submission ( $ record -> groupid ) ) { return null ; } // We only report write access for teachers. $ writeaccess = $ assignment -> can_grade ( ) && $ assignment -> can_edit_group_submission ( $ record -> groupid ) ; } } } else { // Not supported for feedback plugins. return null ; } $ fs = get_file_storage ( ) ; $ filepath = is_null ( $ filepath ) ? '/' : $ filepath ; $ filename = is_null ( $ filename ) ? '.' : $ filename ; if ( ! ( $ storedfile = $ fs -> get_file ( $ assignment -> get_context ( ) -> id , $ this -> get_subtype ( ) . '_' . $ this -> get_type ( ) , $ filearea , $ itemid , $ filepath , $ filename ) ) ) { return null ; } return new file_info_stored ( $ browser , $ assignment -> get_context ( ) , $ storedfile , $ urlbase , $ filearea , $ itemid , true , $ writeaccess , false ) ; }
docstring: Default implementation of file_get_info for plugins.
  This is used by the filebrowser to browse a plugins file areas.
  
  This implementation should work for most plugins but can be overridden if required.
  @param file_browser $browser
  @param string $filearea
  @param int $itemid
  @param string $filepath
  @param string $filename
  @return file_info_stored
docstring_tokens: Default implementation of file_get_info for plugins . This is used by the filebrowser to browse a plugins file areas .