From af9b14446dc27fd2c0a99fb78daf809e7506a633 Mon Sep 17 00:00:00 2001 From: Tom Lanyon Date: Sat, 10 Sep 2011 10:43:49 +0200 Subject: [PATCH] MDL-28701 Change uses of make_upload_directory(temp) to make_temp_directory(). --- admin/langimport.php | 4 ++-- blocks/community/locallib.php | 2 +- enrol/authorize/uploadcsv.php | 2 +- files/externallib.php | 2 +- filter/tex/latex.php | 2 +- grade/edit/outcome/import.php | 2 +- grade/export/xml/grade_export_xml.php | 2 +- grade/import/csv/index.php | 2 +- lib/componentlib.class.php | 2 +- lib/csvlib.class.php | 2 +- lib/excellib.class.php | 2 +- lib/formslib.php | 2 +- lib/odslib.class.php | 8 ++++---- lib/textlib.class.php | 2 +- mod/data/lib.php | 4 ++-- mod/lesson/import.php | 2 +- mod/scorm/lib.php | 2 +- mod/scorm/mod_form.php | 2 +- question/format/qti_two/format.php | 4 ++-- question/import.php | 2 +- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/admin/langimport.php b/admin/langimport.php index 713f608ad0b..476dbaf0808 100644 --- a/admin/langimport.php +++ b/admin/langimport.php @@ -58,7 +58,7 @@ $notice_error = array(); if (($mode == INSTALLATION_OF_SELECTED_LANG) and confirm_sesskey() and !empty($pack)) { set_time_limit(0); - make_upload_directory('temp'); + make_temp_directory(''); make_upload_directory('lang'); $installer = new lang_installer($pack); @@ -149,7 +149,7 @@ if ($mode == UPDATE_ALL_LANG) { } } - make_upload_directory('temp'); + make_temp_directory(''); make_upload_directory('lang'); // clean-up currently installed versions of the packs diff --git a/blocks/community/locallib.php b/blocks/community/locallib.php index e54ed2c78bf..f76088fc34c 100644 --- a/blocks/community/locallib.php +++ b/blocks/community/locallib.php @@ -86,7 +86,7 @@ class block_community_manager { $params['courseid'] = $course->id; $params['filetype'] = HUB_BACKUP_FILE_TYPE; - make_upload_directory('temp/backup'); + make_temp_directory('backup'); $filename = md5(time() . '-' . $course->id . '-'. $USER->id . '-'. random_string(20)); diff --git a/enrol/authorize/uploadcsv.php b/enrol/authorize/uploadcsv.php index 769382472bf..697d3549e4d 100644 --- a/enrol/authorize/uploadcsv.php +++ b/enrol/authorize/uploadcsv.php @@ -55,7 +55,7 @@ if (!$form->get_data()) { $form->display(); } else { $filename = $CFG->tempdir . '/enrolauthorize/importedfile_'.time().'.csv'; - make_upload_directory('temp/enrolauthorize'); + make_temp_directory('enrolauthorize'); // Fix mac/dos newlines $text = $form->get_file_content('csvfile'); $text = preg_replace('!\r\n?!', "\n", $text); diff --git a/files/externallib.php b/files/externallib.php index eba388b1076..a6e3235a790 100644 --- a/files/externallib.php +++ b/files/externallib.php @@ -207,7 +207,7 @@ class moodle_file_external extends external_api { throw new moodle_exception('nofile'); } // saving file - $dir = make_upload_directory('temp/wsupload'); + $dir = make_temp_directory('wsupload'); if (empty($fileinfo['filename'])) { $filename = uniqid('wsupload').'_'.time().'.tmp'; diff --git a/filter/tex/latex.php b/filter/tex/latex.php index b3bd4b93d22..2f84bc220cc 100644 --- a/filter/tex/latex.php +++ b/filter/tex/latex.php @@ -20,7 +20,7 @@ // construct directory structure $this->temp_dir = $CFG->tempdir . "/latex"; - make_upload_directory('temp/latex'); + make_temp_directory('latex'); } /** diff --git a/grade/edit/outcome/import.php b/grade/edit/outcome/import.php index f189f73500e..6e6286746ca 100644 --- a/grade/edit/outcome/import.php +++ b/grade/edit/outcome/import.php @@ -61,7 +61,7 @@ if (!$upload_form->get_data()) { print_grade_page_head($courseid, 'outcome', 'import', get_string('importoutcomes', 'grades')); $imported_file = $CFG->tempdir . '/outcomeimport/importedfile_'.time().'.csv'; -make_upload_directory('temp/outcomeimport'); +make_temp_directory('outcomeimport'); // copying imported file if (!$upload_form->save_file('userfile', $imported_file, true)) { diff --git a/grade/export/xml/grade_export_xml.php b/grade/export/xml/grade_export_xml.php index 48fdf408a34..38cb353574a 100644 --- a/grade/export/xml/grade_export_xml.php +++ b/grade/export/xml/grade_export_xml.php @@ -40,7 +40,7 @@ class grade_export_xml extends grade_export { /// Calculate file name $downloadfilename = clean_filename("{$this->course->shortname} $strgrades.xml"); - make_upload_directory('temp/gradeexport'); + make_temp_directory('gradeexport'); $tempfilename = $CFG->tempdir .'/gradeexport/'. md5(sesskey().microtime().$downloadfilename); if (!$handle = fopen($tempfilename, 'w+b')) { print_error('cannotcreatetempdir'); diff --git a/grade/import/csv/index.php b/grade/import/csv/index.php index caca05eea54..886bf4303d0 100644 --- a/grade/import/csv/index.php +++ b/grade/import/csv/index.php @@ -111,7 +111,7 @@ if ($formdata = $mform->get_data()) { // use current (non-conflicting) time stamp $importcode = get_new_importcode(); - $filename = make_upload_directory('temp/gradeimport/cvs/'.$USER->id); + $filename = make_temp_directory('gradeimport/cvs/'.$USER->id); $filename = $filename.'/'.$importcode; $text = $mform->get_file_content('userfile'); diff --git a/lib/componentlib.class.php b/lib/componentlib.class.php index 11abf63f35f..0bb7c713c87 100644 --- a/lib/componentlib.class.php +++ b/lib/componentlib.class.php @@ -281,7 +281,7 @@ class component_installer { return COMPONENT_UPTODATE; } /// Create temp directory if necesary - if (!make_upload_directory('temp', false)) { + if (!make_temp_directory('', false)) { $this->errorstring='cannotcreatetempdir'; return COMPONENT_ERROR; } diff --git a/lib/csvlib.class.php b/lib/csvlib.class.php index 8d2d3ea212d..2eb9df30bf6 100644 --- a/lib/csvlib.class.php +++ b/lib/csvlib.class.php @@ -310,7 +310,7 @@ class csv_import_reader { function get_new_iid($type) { global $USER; - $filename = make_upload_directory('temp/csvimport/'.$type.'/'.$USER->id); + $filename = make_temp_directory('csvimport/'.$type.'/'.$USER->id); // use current (non-conflicting) time stamp $iiid = time(); diff --git a/lib/excellib.class.php b/lib/excellib.class.php index 53c2150c73d..8b1262daa35 100644 --- a/lib/excellib.class.php +++ b/lib/excellib.class.php @@ -64,7 +64,7 @@ class MoodleExcelWorkbook { $this->latin_output = true; } /// Choose our temporary directory - see MDL-7176, found by paulo.matos - make_upload_directory('temp/excel'); + make_temp_directory('excel'); $this->pear_excel_workbook->setTempDir($CFG->tempdir.'/excel'); } diff --git a/lib/formslib.php b/lib/formslib.php index aadc8a04b1c..d579b8773d0 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -652,7 +652,7 @@ abstract class moodleform { if (!$this->get_new_filename($elname)) { return false; } - if (!$dir = make_upload_directory('temp/forms')) { + if (!$dir = make_temp_directory('forms')) { return false; } if (!$tempfile = tempnam($dir, 'tempup_')) { diff --git a/lib/odslib.class.php b/lib/odslib.class.php index db2837f2f92..be1a5d9d6e2 100644 --- a/lib/odslib.class.php +++ b/lib/odslib.class.php @@ -74,10 +74,10 @@ class MoodleODSWorkbook { global $CFG; require_once($CFG->libdir.'/filelib.php'); - $dir = 'temp/ods/'.time(); - make_upload_directory($dir); - make_upload_directory($dir.'/META-INF'); - $dir = "$CFG->dataroot/$dir"; + $dir = 'ods/'.time(); + make_temp_directory($dir); + make_temp_directory($dir.'/META-INF'); + $dir = "$CFG->tempdir/$dir"; $files = array(); $handle = fopen("$dir/mimetype", 'w'); diff --git a/lib/textlib.class.php b/lib/textlib.class.php index 37dfa10f437..1f67f99f5ba 100644 --- a/lib/textlib.class.php +++ b/lib/textlib.class.php @@ -83,7 +83,7 @@ class textlib { // And this directory must exist to allow Typo to cache conversion // tables when using internal functions - make_upload_directory('temp/typo3temp/cs'); + make_temp_directory('typo3temp/cs'); // Make sure typo is using our dir permissions $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = decoct($CFG->directorypermissions); diff --git a/mod/data/lib.php b/mod/data/lib.php index 47a5c5be26e..2bee85bf059 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -3142,8 +3142,8 @@ function data_presets_export($course, $cm, $data, $tostorage=false) { global $CFG, $DB; $presetname = clean_filename($data->name) . '-preset-' . gmdate("Ymd_Hi"); - $exportsubdir = "temp/mod_data/presetexport/$presetname"; - make_upload_directory($exportsubdir); + $exportsubdir = "mod_data/presetexport/$presetname"; + make_temp_directory($exportsubdir); $exportdir = "$CFG->dataroot/$exportsubdir"; // Assemble "preset.xml": diff --git a/mod/lesson/import.php b/mod/lesson/import.php index 0b00e20a2d1..71af931060f 100644 --- a/mod/lesson/import.php +++ b/mod/lesson/import.php @@ -69,7 +69,7 @@ if ($data = $mform->get_data()) { $realfilename = $mform->get_new_filename('questionfile'); //TODO: Leave all imported questions in Questionimport for now. $importfile = "{$CFG->dataroot}/temp/questionimport/{$realfilename}"; - make_upload_directory('temp/questionimport'); + make_temp_directory('questionimport'); if (!$result = $mform->save_file('questionfile', $importfile, true)) { throw new moodle_exception('uploadproblem'); } diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index a6e4e26739a..16fcb32f95f 100644 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -994,7 +994,7 @@ function scorm_debug_log_write($type, $text, $scoid) { if (!$debugenablelog || empty($text)) { return; } - if (make_upload_directory('temp/scormlogs/')) { + if (make_temp_directory('scormlogs/')) { $logfile = scorm_debug_log_filename($type, $scoid); @file_put_contents($logfile, date('Y/m/d H:i:s O')." DEBUG $text\r\n", FILE_APPEND); } diff --git a/mod/scorm/mod_form.php b/mod/scorm/mod_form.php index 11118f76462..98dda8b3880 100644 --- a/mod/scorm/mod_form.php +++ b/mod/scorm/mod_form.php @@ -329,7 +329,7 @@ class mod_scorm_mod_form extends moodleform_mod { } $file = reset($files); $filename = $CFG->tempdir.'/scormimport/scrom_'.time(); - make_upload_directory('temp/scormimport'); + make_temp_directory('scormimport'); $file->copy_content_to($filename); $packer = get_file_packer('application/zip'); diff --git a/question/format/qti_two/format.php b/question/format/qti_two/format.php index 88cdcbb5565..d0688bd4950 100644 --- a/question/format/qti_two/format.php +++ b/question/format/qti_two/format.php @@ -263,9 +263,9 @@ function handle_questions_media(&$questions, $path, $courseid) { global $CFG, $OUTPUT, $USER; $courseid = $this->course->id; - $path = 'temp/qformat_qti_two/' . $USER->id . '/' . $this->filename; + $path = 'qformat_qti_two/' . $USER->id . '/' . $this->filename; // create a directory for the exports (if not already existing) - if (!make_upload_directory($path)) { + if (!make_temp_directory($path)) { throw new moodle_exception('cannotcreatepath', 'question', '', $path); } $path = $CFG->dataroot . '/' . $path; diff --git a/question/import.php b/question/import.php index 0001e1ae208..3750e752021 100644 --- a/question/import.php +++ b/question/import.php @@ -84,7 +84,7 @@ if ($form = $import_form->get_data()) { $realfilename = $import_form->get_new_filename('newfile'); $importfile = "{$CFG->dataroot}/temp/questionimport/{$realfilename}"; - make_upload_directory('temp/questionimport'); + make_temp_directory('questionimport'); if (!$result = $import_form->save_file('newfile', $importfile, true)) { throw new moodle_exception('uploadproblem'); }