original_string: function save_file($elname, $pathname, $override=false) {
          global $USER;
  
          if (!$this->is_submitted() or !$this->is_validated()) {
              return false;
          }
          if (file_exists($pathname)) {
              if ($override) {
                  if (!@unlink($pathname)) {
                      return false;
                  }
              } else {
                  return false;
              }
          }
  
          $element = $this->_form->getElement($elname);
  
          if ($element instanceof MoodleQuickForm_filepicker || $element instanceof MoodleQuickForm_filemanager) {
              $values = $this->_form->exportValues($elname);
              if (empty($values[$elname])) {
                  return false;
              }
              $draftid = $values[$elname];
              $fs = get_file_storage();
              $context = context_user::instance($USER->id);
              if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
                  return false;
              }
              $file = reset($files);
  
              return $file->copy_content_to($pathname);
  
          } else if (isset($_FILES[$elname])) {
              return copy($_FILES[$elname]['tmp_name'], $pathname);
          }
  
          return false;
      }
code: function save_file($elname, $pathname, $override=false) {
          global $USER;
  
          if (!$this->is_submitted() or !$this->is_validated()) {
              return false;
          }
          if (file_exists($pathname)) {
              if ($override) {
                  if (!@unlink($pathname)) {
                      return false;
                  }
              } else {
                  return false;
              }
          }
  
          $element = $this->_form->getElement($elname);
  
          if ($element instanceof MoodleQuickForm_filepicker || $element instanceof MoodleQuickForm_filemanager) {
              $values = $this->_form->exportValues($elname);
              if (empty($values[$elname])) {
                  return false;
              }
              $draftid = $values[$elname];
              $fs = get_file_storage();
              $context = context_user::instance($USER->id);
              if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
                  return false;
              }
              $file = reset($files);
  
              return $file->copy_content_to($pathname);
  
          } else if (isset($_FILES[$elname])) {
              return copy($_FILES[$elname]['tmp_name'], $pathname);
          }
  
          return false;
      }
code_tokens: function save_file ( $ elname , $ pathname , $ override = false ) { global $ USER ; if ( ! $ this -> is_submitted ( ) or ! $ this -> is_validated ( ) ) { return false ; } if ( file_exists ( $ pathname ) ) { if ( $ override ) { if ( ! @ unlink ( $ pathname ) ) { return false ; } } else { return false ; } } $ element = $ this -> _form -> getElement ( $ elname ) ; if ( $ element instanceof MoodleQuickForm_filepicker || $ element instanceof MoodleQuickForm_filemanager ) { $ values = $ this -> _form -> exportValues ( $ elname ) ; if ( empty ( $ values [ $ elname ] ) ) { return false ; } $ draftid = $ values [ $ elname ] ; $ fs = get_file_storage ( ) ; $ context = context_user :: instance ( $ USER -> id ) ; if ( ! $ files = $ fs -> get_area_files ( $ context -> id , 'user' , 'draft' , $ draftid , 'id DESC' , false ) ) { return false ; } $ file = reset ( $ files ) ; return $ file -> copy_content_to ( $ pathname ) ; } else if ( isset ( $ _FILES [ $ elname ] ) ) { return copy ( $ _FILES [ $ elname ] [ 'tmp_name' ] , $ pathname ) ; } return false ; }
docstring: Save file to standard filesystem
  
  @param string $elname name of element
  @param string $pathname full path name of file
  @param bool $override override file if exists
  @return bool success
docstring_tokens: Save file to standard filesystem