Skip to content

Commit

Permalink
MDL-28701 Change uses of make_upload_directory(temp) to make_temp_dir…
Browse files Browse the repository at this point in the history
…ectory().
  • Loading branch information
tomlanyon authored and skodak committed Sep 10, 2011
1 parent e695890 commit af9b144
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions admin/langimport.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

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);
Expand Down Expand Up @@ -149,7 +149,7 @@
}
}

make_upload_directory('temp');
make_temp_directory('');
make_upload_directory('lang');

// clean-up currently installed versions of the packs
Expand Down
2 changes: 1 addition & 1 deletion blocks/community/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function block_community_download_course_backup($course) {
$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));

Expand Down
2 changes: 1 addition & 1 deletion enrol/authorize/uploadcsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
$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);
Expand Down
2 changes: 1 addition & 1 deletion files/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static function upload($contextid, $component, $filearea, $itemid, $filep
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';
Expand Down
2 changes: 1 addition & 1 deletion filter/tex/latex.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function latex() {

// construct directory structure
$this->temp_dir = $CFG->tempdir . "/latex";
make_upload_directory('temp/latex');
make_temp_directory('latex');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion grade/edit/outcome/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
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)) {
Expand Down
2 changes: 1 addition & 1 deletion grade/export/xml/grade_export_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function print_grades($feedback = false) {
/// 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');
Expand Down
2 changes: 1 addition & 1 deletion grade/import/csv/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

// 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');
Expand Down
2 changes: 1 addition & 1 deletion lib/componentlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function install() {
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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/csvlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function get_encoded_delimiter($delimiter_name) {
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();
Expand Down
2 changes: 1 addition & 1 deletion lib/excellib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function MoodleExcelWorkbook($filename) {
$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');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/formslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ function save_temp_file($elname) {
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_')) {
Expand Down
8 changes: 4 additions & 4 deletions lib/odslib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ function close() {
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');
Expand Down
2 changes: 1 addition & 1 deletion lib/textlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected static function typo3() {

// 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);
Expand Down
4 changes: 2 additions & 2 deletions mod/data/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
$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');
}
Expand Down
2 changes: 1 addition & 1 deletion mod/scorm/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion mod/scorm/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ function validation($data, $files) {
}
$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');
Expand Down
4 changes: 2 additions & 2 deletions question/format/qti_two/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ public function exportprocess() {
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;
Expand Down
2 changes: 1 addition & 1 deletion question/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
$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');
}
Expand Down

0 comments on commit af9b144

Please sign in to comment.