MDL-28701 Change all uses of $CFG->dataroot/temp to $CFG->tempdir

This commit is contained in:
Tom Lanyon 2011-08-11 03:03:58 +09:30 committed by Petr Skoda
parent 3e93987142
commit 7aa06e6ded
50 changed files with 111 additions and 111 deletions

View File

@ -22,8 +22,8 @@
if (!$ok or !confirm_sesskey()) {
$message = '<br /><br />';
$message .= $CFG->dataroot.'/temp/olson.txt<br />';
$message .= $CFG->dataroot.'/temp/timezone.txt<br />';
$message .= $CFG->tempdir.'/olson.txt<br />';
$message .= $CFG->tempdir.'/timezone.txt<br />';
$message .= '<a href="http://download.moodle.org/timezone/">http://download.moodle.org/timezone/</a><br />';
$message .= '<a href="'.$CFG->wwwroot.'/lib/timezone.txt">'.$CFG->dirroot.'/lib/timezone.txt</a><br />';
$message .= '<br />';
@ -43,7 +43,7 @@
/// First, look for an Olson file locally
$source = $CFG->dataroot.'/temp/olson.txt';
$source = $CFG->tempdir.'/olson.txt';
if (!$importdone and is_readable($source)) {
if ($timezones = olson_to_timezones($source)) {
update_timezone_records($timezones);
@ -53,7 +53,7 @@
/// Next, look for a CSV file locally
$source = $CFG->dataroot.'/temp/timezone.txt';
$source = $CFG->tempdir.'/timezone.txt';
if (!$importdone and is_readable($source)) {
if ($timezones = get_records_csv($source, 'timezone')) {
update_timezone_records($timezones);
@ -64,14 +64,14 @@
/// Otherwise, let's try moodle.org's copy
$source = 'http://download.moodle.org/timezone/';
if (!$importdone && ($content=download_file_content($source))) {
if ($file = fopen($CFG->dataroot.'/temp/timezone.txt', 'w')) { // Make local copy
if ($file = fopen($CFG->tempdir.'/timezone.txt', 'w')) { // Make local copy
fwrite($file, $content);
fclose($file);
if ($timezones = get_records_csv($CFG->dataroot.'/temp/timezone.txt', 'timezone')) { // Parse it
if ($timezones = get_records_csv($CFG->tempdir.'/timezone.txt', 'timezone')) { // Parse it
update_timezone_records($timezones);
$importdone = $source;
}
unlink($CFG->dataroot.'/temp/timezone.txt');
unlink($CFG->tempdir.'/timezone.txt');
}
}

View File

@ -72,7 +72,7 @@ if ($formdata = $mform->get_data()) {
// Create a unique temporary directory, to process the zip file
// contents.
$zipdir = my_mktempdir($CFG->dataroot.'/temp/', 'usrpic');
$zipdir = my_mktempdir($CFG->tempdir.'/', 'usrpic');
$dstfile = $zipdir.'/images.zip';
if (!$mform->save_file('userpicturesfile', $dstfile, true)) {

View File

@ -311,7 +311,7 @@ class auth_plugin_mnet extends auth_plugin_base {
$fetchrequest->add_param($localuser->username);
if ($fetchrequest->send($remotepeer) === true) {
if (strlen($fetchrequest->response['f1']) > 0) {
$imagefilename = $CFG->dataroot . '/temp/mnet-usericon-' . $localuser->id;
$imagefilename = $CFG->tempdir . '/mnet-usericon-' . $localuser->id;
$imagecontents = base64_decode($fetchrequest->response['f1']);
file_put_contents($imagefilename, $imagecontents);
if (process_new_icon($usercontext, 'user', 'icon', 0, $imagefilename)) {

View File

@ -32,7 +32,7 @@
*/
class restore_controller extends backup implements loggable {
protected $tempdir; // Directory under dataroot/temp/backup awaiting restore
protected $tempdir; // Directory under tempdir/backup awaiting restore
protected $restoreid; // Unique identificator for this restore
protected $courseid; // courseid where restore is going to happen
@ -61,7 +61,7 @@ class restore_controller extends backup implements loggable {
/**
*
* @param string $tempdir Directory under dataroot/temp/backup awaiting restore
* @param string $tempdir Directory under tempdir/backup awaiting restore
* @param int $courseid Course id where restore is going to happen
* @param bool $interactive backup::INTERACTIVE_YES[true] or backup::INTERACTIVE_NO[false]
* @param int $mode backup::MODE_[ GENERAL | HUB | IMPORT | SAMESITE ]

View File

@ -147,7 +147,7 @@ abstract class base_converter implements loggable {
public function get_workdir_path() {
global $CFG;
return "$CFG->dataroot/temp/backup/$this->workdir";
return "$CFG->tempdir/backup/$this->workdir";
}
/**
@ -156,7 +156,7 @@ abstract class base_converter implements loggable {
public function get_tempdir_path() {
global $CFG;
return "$CFG->dataroot/temp/backup/$this->tempdir";
return "$CFG->tempdir/backup/$this->tempdir";
}
/// public static methods //////////////////////////////////////////////////

View File

@ -89,7 +89,7 @@ class moodle1_converter extends base_converter {
public static function detect_format($tempdir) {
global $CFG;
$filepath = $CFG->dataroot . '/temp/backup/' . $tempdir . '/moodle.xml';
$filepath = $CFG->tempdir . '/backup/' . $tempdir . '/moodle.xml';
if (file_exists($filepath)) {
// looks promising, lets load some information
$handle = fopen($filepath, 'r');

View File

@ -39,38 +39,38 @@ class moodle1_converter_test extends UnitTestCase {
global $CFG;
$this->tempdir = convert_helper::generate_id('simpletest');
check_dir_exists("$CFG->dataroot/temp/backup/$this->tempdir/course_files/sub1");
check_dir_exists("$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/7");
check_dir_exists("$CFG->tempdir/backup/$this->tempdir/course_files/sub1");
check_dir_exists("$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/7");
copy(
"$CFG->dirroot/backup/converter/moodle1/simpletest/files/moodle.xml",
"$CFG->dataroot/temp/backup/$this->tempdir/moodle.xml"
"$CFG->tempdir/backup/$this->tempdir/moodle.xml"
);
copy(
"$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
"$CFG->dataroot/temp/backup/$this->tempdir/course_files/file1.gif"
"$CFG->tempdir/backup/$this->tempdir/course_files/file1.gif"
);
copy(
"$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
"$CFG->dataroot/temp/backup/$this->tempdir/course_files/sub1/file2.gif"
"$CFG->tempdir/backup/$this->tempdir/course_files/sub1/file2.gif"
);
copy(
"$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
"$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/file1.gif"
"$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/file1.gif"
);
copy(
"$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
"$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/icon.gif"
"$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/icon.gif"
);
copy(
"$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
"$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/7/icon.gif"
"$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/7/icon.gif"
);
}
public function tearDown() {
global $CFG;
if (empty($CFG->keeptempdirectoriesonbackup)) {
fulldelete("$CFG->dataroot/temp/backup/$this->tempdir");
fulldelete("$CFG->tempdir/backup/$this->tempdir");
}
}
@ -440,7 +440,7 @@ as it is parsed from the backup file. <br /><br /><img border="0" width="110" vs
copy(
"$CFG->dirroot/backup/converter/moodle1/simpletest/files/questions.xml",
"$CFG->dataroot/temp/backup/$this->tempdir/moodle.xml"
"$CFG->tempdir/backup/$this->tempdir/moodle.xml"
);
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
$converter->convert();

View File

@ -96,7 +96,7 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
// Check whether the backup directory still exists. If missing, something
// went really wrong in backup, throw error. Note that backup::MODE_IMPORT
// backups don't store resulting files ever
$tempdestination = $CFG->dataroot . '/temp/backup/' . $backupid;
$tempdestination = $CFG->tempdir . '/backup/' . $backupid;
if (!file_exists($tempdestination) || !is_dir($tempdestination)) {
print_error('unknownbackupexporterror'); // shouldn't happen ever
}

View File

@ -54,9 +54,9 @@
$status = true;
//Get files and directories in the temp backup dir witout descend
$list = get_directory_list($CFG->dataroot."/temp/backup", "", false, true, true);
$list = get_directory_list($CFG->tempdir."/backup", "", false, true, true);
foreach ($list as $file) {
$file_path = $CFG->dataroot."/temp/backup/".$file;
$file_path = $CFG->tempdir."/backup/".$file;
$moddate = filemtime($file_path);
if ($status && $moddate < $delete_from) {
//If directory, recurse
@ -81,12 +81,12 @@
function check_and_create_backup_dir($backup_unique_code) {
global $CFG;
$status = check_dir_exists($CFG->dataroot."/temp",true);
$status = check_dir_exists($CFG->tempdir."",true);
if ($status) {
$status = check_dir_exists($CFG->dataroot."/temp/backup",true);
$status = check_dir_exists($CFG->tempdir."/backup",true);
}
if ($status) {
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$backup_unique_code,true);
$status = check_dir_exists($CFG->tempdir."/backup/".$backup_unique_code,true);
}
return $status;
@ -162,7 +162,7 @@
function clear_backup_dir($backup_unique_code) {
global $CFG;
$rootdir = $CFG->dataroot."/temp/backup/".$backup_unique_code;
$rootdir = $CFG->tempdir."/backup/".$backup_unique_code;
//Delete recursively
$status = delete_dir_contents($rootdir);
@ -237,7 +237,7 @@
&& $DB->delete_records('backup_files', array('backup_code'=>$preferences->backup_unique_code));
//Now, delete temp directory (if exists)
$file_path = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code;
$file_path = $CFG->tempdir."/backup/".$preferences->backup_unique_code;
if (is_dir($file_path)) {
$status = delete_dir_contents($file_path);
//There is nothing, delete the directory itself
@ -348,7 +348,7 @@
if (strlen($info_ser) > $max_db_storage) {
//Calculate filename (in current_backup_dir, $backup_unique_code_$table_$old_id.info)
$filename = $CFG->dataroot."/temp/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
$filename = $CFG->tempdir."/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
//Save data to file
$status = backup_data2file($filename,$info_ser);
//Set info_to save
@ -394,7 +394,7 @@
//If info field = "infile", get file contents
if (!empty($status->info) && $status->info == "infile") {
$filename = $CFG->dataroot."/temp/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
$filename = $CFG->tempdir."/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
//Read data from file
$status2 = backup_file2data($filename,$info);
if ($status2) {

View File

@ -64,7 +64,7 @@ require_capability('moodle/restore:restorecourse', $context);
$browser = get_file_browser();
// check if tmp dir exists
$tmpdir = $CFG->dataroot . '/temp/backup';
$tmpdir = $CFG->tempdir . '/backup';
if (!check_dir_exists($tmpdir, true, true)) {
throw new restore_controller_exception('cannot_create_backup_temp_dir');
}

View File

@ -60,9 +60,9 @@ abstract class backup_factory {
// Create file_logger, observing $CFG->backup_file_logger_level
// defaulting to $dfltloglevel
check_dir_exists($CFG->dataroot . '/temp/backup', true, true); // need to ensure that temp/backup already exists
check_dir_exists($CFG->tempdir . '/backup', true, true); // need to ensure that temp/backup already exists
$fllevel = isset($CFG->backup_file_logger_level) ? $CFG->backup_file_logger_level : $dfltloglevel;
$enabledloggers[] = new file_logger($fllevel, true, true, $CFG->dataroot . '/temp/backup/' . $backupid . '.log');
$enabledloggers[] = new file_logger($fllevel, true, true, $CFG->tempdir . '/backup/' . $backupid . '.log');
// Create database_logger, observing $CFG->backup_database_logger_level and defaulting to LOG_WARNING
// and pointing to the backup_logs table

View File

@ -43,7 +43,7 @@ class backup_file_manager {
public static function get_backup_storage_base_dir($backupid) {
global $CFG;
return $CFG->dataroot . '/temp/backup/' . $backupid . '/files';
return $CFG->tempdir . '/backup/' . $backupid . '/files';
}
/**

View File

@ -114,7 +114,7 @@ abstract class backup_general_helper extends backup_helper {
$info = new stdclass(); // Final information goes here
$moodlefile = $CFG->dataroot . '/temp/backup/' . $tempdir . '/moodle_backup.xml';
$moodlefile = $CFG->tempdir . '/backup/' . $tempdir . '/moodle_backup.xml';
if (!file_exists($moodlefile)) { // Shouldn't happen ever, but...
throw new backup_helper_exception('missing_moodle_backup_xml_file', $moodlefile);
}

View File

@ -34,7 +34,7 @@ abstract class backup_helper {
*/
static public function check_and_create_backup_dir($backupid) {
global $CFG;
if (!check_dir_exists($CFG->dataroot . '/temp/backup/' . $backupid, true, true)) {
if (!check_dir_exists($CFG->tempdir . '/backup/' . $backupid, true, true)) {
throw new backup_helper_exception('cannot_create_backup_temp_dir');
}
}
@ -44,7 +44,7 @@ abstract class backup_helper {
*/
static public function clear_backup_dir($backupid) {
global $CFG;
if (!self::delete_dir_contents($CFG->dataroot . '/temp/backup/' . $backupid)) {
if (!self::delete_dir_contents($CFG->tempdir . '/backup/' . $backupid)) {
throw new backup_helper_exception('cannot_empty_backup_temp_dir');
}
return true;
@ -56,7 +56,7 @@ abstract class backup_helper {
static public function delete_backup_dir($backupid) {
global $CFG;
self::clear_backup_dir($backupid);
return rmdir($CFG->dataroot . '/temp/backup/' . $backupid);
return rmdir($CFG->tempdir . '/backup/' . $backupid);
}
/**
@ -132,9 +132,9 @@ abstract class backup_helper {
$status = true;
// Get files and directories in the temp backup dir witout descend
$list = get_directory_list($CFG->dataroot . '/temp/backup', '', false, true, true);
$list = get_directory_list($CFG->tempdir . '/backup', '', false, true, true);
foreach ($list as $file) {
$file_path = $CFG->dataroot . '/temp/backup/' . $file;
$file_path = $CFG->tempdir . '/backup/' . $file;
$moddate = filemtime($file_path);
if ($status && $moddate < $deletefrom) {
//If directory, recurse

View File

@ -85,7 +85,7 @@ abstract class convert_helper {
public static function detect_moodle2_format($tempdir) {
global $CFG;
$dirpath = $CFG->dataroot . '/temp/backup/' . $tempdir;
$dirpath = $CFG->tempdir . '/backup/' . $tempdir;
$filepath = $dirpath . '/moodle_backup.xml';
if (!is_dir($dirpath)) {

View File

@ -230,7 +230,7 @@ class logger_test extends UnitTestCase {
function test_file_logger() {
global $CFG;
$file = $CFG->dataroot . '/temp/test/test_file_logger.txt';
$file = $CFG->tempdir . '/test/test_file_logger.txt';
// Remove the test dir and any content
@remove_dir(dirname($file));
// Recreate test dir
@ -272,7 +272,7 @@ class logger_test extends UnitTestCase {
unlink($file); // delete file
// Try one html file
$file = $CFG->dataroot . '/temp/test/test_file_logger.html';
$file = $CFG->tempdir . '/test/test_file_logger.html';
$options = array('depth' => 1);
$lo = new file_logger(backup::LOG_ERROR, true, true, $file);
$this->assertTrue($lo instanceof file_logger);
@ -289,7 +289,7 @@ class logger_test extends UnitTestCase {
unlink($file); // delete file
// Instantiate, write something, force deletion, try to write again
$file = $CFG->dataroot . '/temp/test/test_file_logger.html';
$file = $CFG->tempdir . '/test/test_file_logger.html';
$lo = new mock_file_logger(backup::LOG_ERROR, true, true, $file);
$this->assertTrue(file_exists($file));
$message = 'testing file_logger';
@ -313,7 +313,7 @@ class logger_test extends UnitTestCase {
}
// Instantiate in (near) impossible path
$file = $CFG->dataroot . '/temp/test_azby/test_file_logger.txt';
$file = $CFG->tempdir . '/test_azby/test_file_logger.txt';
try {
$lo = new file_logger(backup::LOG_WARNING, true, true, $file);
$this->assertTrue(false, 'base_logger_exception expected');
@ -324,7 +324,7 @@ class logger_test extends UnitTestCase {
}
// Instatiate one file logger with level = backup::LOG_NONE
$file = $CFG->dataroot . '/temp/test/test_file_logger.txt';
$file = $CFG->tempdir . '/test/test_file_logger.txt';
$lo = new file_logger(backup::LOG_NONE, true, true, $file);
$this->assertTrue($lo instanceof file_logger);
$this->assertFalse(file_exists($file));

View File

@ -43,7 +43,7 @@ class backup_plan extends base_plan implements loggable {
throw new backup_plan_exception('wrong_backup_controller_specified');
}
$this->controller = $controller;
$this->basepath = $CFG->dataroot . '/temp/backup/' . $controller->get_backupid();
$this->basepath = $CFG->tempdir . '/backup/' . $controller->get_backupid();
parent::__construct('backup_plan');
}

View File

@ -50,7 +50,7 @@ class restore_plan extends base_plan implements loggable {
throw new restore_plan_exception('wrong_restore_controller_specified');
}
$this->controller = $controller;
$this->basepath = $CFG->dataroot . '/temp/backup/' . $controller->get_tempdir();
$this->basepath = $CFG->tempdir . '/backup/' . $controller->get_tempdir();
$this->preloaded = false;
$this->decoder = new restore_decode_processor($this->get_restoreid(), $this->get_info()->original_wwwroot, $CFG->wwwroot);
$this->missingmodules = false;

View File

@ -195,7 +195,7 @@ class backup_step_test extends UnitTestCase {
function test_backup_structure_step() {
global $CFG;
$file = $CFG->dataroot . '/temp/test/test_backup_structure_step.txt';
$file = $CFG->tempdir . '/test/test_backup_structure_step.txt';
// Remove the test dir and any content
@remove_dir(dirname($file));
// Recreate test dir
@ -295,7 +295,7 @@ class mock_backup_task_basepath extends backup_task {
public function get_taskbasepath() {
global $CFG;
return $CFG->dataroot . '/temp/test';
return $CFG->tempdir . '/test';
}
}

View File

@ -153,7 +153,7 @@ class restore_ui_stage_confirm extends restore_ui_independent_stage {
}
public function process() {
global $CFG;
if (!file_exists("$CFG->dataroot/temp/backup/".$this->filename)) {
if (!file_exists("$CFG->tempdir/backup/".$this->filename)) {
throw new restore_ui_exception('invalidrestorefile');
}
$outcome = $this->extract_file_to_dir();
@ -168,7 +168,7 @@ class restore_ui_stage_confirm extends restore_ui_independent_stage {
$this->filepath = restore_controller::get_tempdir_name($this->contextid, $USER->id);
$fb = get_file_packer();
return ($fb->extract_to_pathname("$CFG->dataroot/temp/backup/".$this->filename, "$CFG->dataroot/temp/backup/$this->filepath/"));
return ($fb->extract_to_pathname("$CFG->tempdir/backup/".$this->filename, "$CFG->tempdir/backup/$this->filepath/"));
}
/**
@ -236,7 +236,7 @@ class restore_ui_stage_destination extends restore_ui_independent_stage {
}
public function process() {
global $CFG, $DB;
if (!file_exists("$CFG->dataroot/temp/backup/".$this->filepath) || !is_dir("$CFG->dataroot/temp/backup/".$this->filepath)) {
if (!file_exists("$CFG->tempdir/backup/".$this->filepath) || !is_dir("$CFG->tempdir/backup/".$this->filepath)) {
throw new restore_ui_exception('invalidrestorepath');
}
if (optional_param('searchcourses', false, PARAM_BOOL)) {

View File

@ -219,7 +219,7 @@ class xml_output_test extends UnitTestCase {
function test_file_xml_output() {
global $CFG;
$file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt';
$file = $CFG->tempdir . '/test/test_file_xml_output.txt';
// Remove the test dir and any content
@remove_dir(dirname($file));
// Recreate test dir
@ -232,7 +232,7 @@ class xml_output_test extends UnitTestCase {
$this->assertTrue($xo instanceof xml_output);
// Try to init file in (near) impossible path
$file = $CFG->dataroot . '/temp/test_azby/test_file_xml_output.txt';
$file = $CFG->tempdir . '/test_azby/test_file_xml_output.txt';
$xo = new file_xml_output($file);
try {
$xo->start();
@ -243,7 +243,7 @@ class xml_output_test extends UnitTestCase {
}
// Try to init file already existing
$file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt';
$file = $CFG->tempdir . '/test/test_file_xml_output.txt';
file_put_contents($file, 'createdtobedeleted'); // create file manually
$xo = new file_xml_output($file);
try {
@ -256,7 +256,7 @@ class xml_output_test extends UnitTestCase {
unlink($file); // delete file
// Send some output and check
$file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt';
$file = $CFG->tempdir . '/test/test_file_xml_output.txt';
$xo = new file_xml_output($file);
$xo->start();
$xo->write('first text');
@ -266,7 +266,7 @@ class xml_output_test extends UnitTestCase {
// With buffer of 4 bytes, send 3 contents of 3 bytes each
// so we force both buffering and last write on stop
$file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt';
$file = $CFG->tempdir . '/test/test_file_xml_output.txt';
$xo = new file_xml_output($file);
$xo->set_buffersize(5);
$xo->start();
@ -278,7 +278,7 @@ class xml_output_test extends UnitTestCase {
unlink($file); // delete file
// Write some line feeds, tabs and friends
$file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt';
$file = $CFG->tempdir . '/test/test_file_xml_output.txt';
$string = "\n\r\tcrazy test\n\r\t";
$xo = new file_xml_output($file);
$xo->start();
@ -288,7 +288,7 @@ class xml_output_test extends UnitTestCase {
unlink($file); // delete file
// Write some UTF-8 chars
$file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt';
$file = $CFG->tempdir . '/test/test_file_xml_output.txt';
$string = 'áéíóú';
$xo = new file_xml_output($file);
$xo->start();

View File

@ -88,7 +88,7 @@ $cancelrestore = optional_param('cancelrestore', false, PARAM_INT);
if ($usercandownload and $cancelrestore and confirm_sesskey()) {
$filename = optional_param('filename', '', PARAM_ALPHANUMEXT);
//delete temp file
unlink($CFG->dataroot . '/temp/backup/' . $filename . ".mbz");
unlink($CFG->tempdir . '/backup/' . $filename . ".mbz");
}
/// Download

View File

@ -91,7 +91,7 @@ class block_community_manager {
$filename = md5(time() . '-' . $course->id . '-'. $USER->id . '-'. random_string(20));
$url = new moodle_url($course->huburl.'/local/hub/webservice/download.php', $params);
$path = $CFG->dataroot.'/temp/backup/'.$filename.".mbz";
$path = $CFG->tempdir.'/backup/'.$filename.".mbz";
$fp = fopen($path, 'w');
$curlurl = $course->huburl.'/local/hub/webservice/download.php?filetype='
.HUB_BACKUP_FILE_TYPE.'&courseid='.$course->id;
@ -122,7 +122,7 @@ class block_community_manager {
if (!$fs->file_exists($record->contextid, $record->component,
$record->filearea, 0, $record->filepath, $record->filename)) {
$fs->create_file_from_pathname($record,
$CFG->dataroot.'/temp/backup/'.$filename.".mbz");
$CFG->tempdir.'/backup/'.$filename.".mbz");
}
$filenames = array();

View File

@ -54,7 +54,7 @@ echo $OUTPUT->heading($struploadcsv);
if (!$form->get_data()) {
$form->display();
} else {
$filename = $CFG->dataroot . '/temp/enrolauthorize/importedfile_'.time().'.csv';
$filename = $CFG->tempdir . '/enrolauthorize/importedfile_'.time().'.csv';
make_upload_directory('temp/enrolauthorize');
// Fix mac/dos newlines
$text = $form->get_file_content('csvfile');

View File

@ -19,7 +19,7 @@
global $CFG;
// construct directory structure
$this->temp_dir = $CFG->dataroot . "/temp/latex";
$this->temp_dir = $CFG->tempdir . "/latex";
make_upload_directory('temp/latex');
}

View File

@ -104,8 +104,8 @@ function filter_tex_updatedcallback($name) {
if (file_exists("$CFG->dataroot/filter/algebra")) {
remove_dir("$CFG->dataroot/filter/algebra");
}
if (file_exists("$CFG->dataroot/temp/latex")) {
remove_dir("$CFG->dataroot/temp/latex");
if (file_exists("$CFG->tempdir/latex")) {
remove_dir("$CFG->tempdir/latex");
}
$DB->delete_records('cache_filters', array('filter'=>'tex'));

View File

@ -60,7 +60,7 @@ if (!$upload_form->get_data()) {
}
print_grade_page_head($courseid, 'outcome', 'import', get_string('importoutcomes', 'grades'));
$imported_file = $CFG->dataroot . '/temp/outcomeimport/importedfile_'.time().'.csv';
$imported_file = $CFG->tempdir . '/outcomeimport/importedfile_'.time().'.csv';
make_upload_directory('temp/outcomeimport');
// copying imported file

View File

@ -41,7 +41,7 @@ class grade_export_xml extends grade_export {
$downloadfilename = clean_filename("{$this->course->shortname} $strgrades.xml");
make_upload_directory('temp/gradeexport');
$tempfilename = $CFG->dataroot .'/temp/gradeexport/'. md5(sesskey().microtime().$downloadfilename);
$tempfilename = $CFG->tempdir .'/gradeexport/'. md5(sesskey().microtime().$downloadfilename);
if (!$handle = fopen($tempfilename, 'w+b')) {
print_error('cannotcreatetempdir');
}

View File

@ -91,7 +91,7 @@ if ($id) {
}
if ($importcode = optional_param('importcode', '', PARAM_FILE)) {
$filename = $CFG->dataroot.'/temp/gradeimport/cvs/'.$USER->id.'/'.$importcode;
$filename = $CFG->tempdir.'/gradeimport/cvs/'.$USER->id.'/'.$importcode;
$fp = fopen($filename, "r");
$headers = fgets($fp, GRADE_CSV_LINE_LENGTH);
$header = explode($csv_delimiter, $headers);
@ -164,7 +164,7 @@ if ($formdata = $mform->get_data()) {
} else if ($formdata = $mform2->get_data()) {
$importcode = clean_param($formdata->importcode, PARAM_FILE);
$filename = $CFG->dataroot.'/temp/gradeimport/cvs/'.$USER->id.'/'.$importcode;
$filename = $CFG->tempdir.'/gradeimport/cvs/'.$USER->id.'/'.$importcode;
if (!file_exists($filename)) {
print_error('cannotuploadfile');

View File

@ -287,7 +287,7 @@ class component_installer {
}
/// Download zip file and save it to temp
$source = $this->sourcebase.'/'.$this->zippath.'/'.$this->zipfilename;
$zipfile= $CFG->dataroot.'/temp/'.$this->zipfilename;
$zipfile= $CFG->tempdir.'/'.$this->zipfilename;
if($contents = download_file_content($source)) {
if ($file = fopen($zipfile, 'w')) {

View File

@ -121,7 +121,7 @@ class csv_import_reader {
$this->_columns = $columns; // cached columns
// open file for writing
$filename = $CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
$filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
$fp = fopen($filename, "w");
fwrite($fp, serialize($columns)."\n");
@ -161,7 +161,7 @@ class csv_import_reader {
global $USER, $CFG;
$filename = $CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
$filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
if (!file_exists($filename)) {
return false;
}
@ -188,7 +188,7 @@ class csv_import_reader {
if (!empty($this->_fp)) {
$this->close();
}
$filename = $CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
$filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
if (!file_exists($filename)) {
return false;
}
@ -247,9 +247,9 @@ class csv_import_reader {
global $USER, $CFG;
if ($full) {
@remove_dir($CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id);
@remove_dir($CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id);
} else {
@unlink($CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid);
@unlink($CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid);
}
}

View File

@ -65,7 +65,7 @@ class MoodleExcelWorkbook {
}
/// Choose our temporary directory - see MDL-7176, found by paulo.matos
make_upload_directory('temp/excel');
$this->pear_excel_workbook->setTempDir($CFG->dataroot.'/temp/excel');
$this->pear_excel_workbook->setTempDir($CFG->tempdir.'/excel');
}
/**

View File

@ -2176,7 +2176,7 @@ function put_records_csv($file, $records, $table = NULL) {
echo "x";
if(!($fp = @fopen($CFG->dataroot.'/temp/'.$file, 'w'))) {
if(!($fp = @fopen($CFG->tempdir.'/'.$file, 'w'))) {
print_error('put_records_csv failed to open '.$file);
}

View File

@ -57,8 +57,8 @@ class zip_packer extends file_packer {
$fs = get_file_storage();
check_dir_exists($CFG->dataroot.'/temp/zip');
$tmpfile = tempnam($CFG->dataroot.'/temp/zip', 'zipstor');
check_dir_exists($CFG->tempdir.'/zip');
$tmpfile = tempnam($CFG->tempdir.'/zip', 'zipstor');
if ($result = $this->archive_to_pathname($files, $tmpfile)) {
if ($file = $fs->get_file($contextid, $component, $filearea, $itemid, $filepath, $filename)) {
@ -282,7 +282,7 @@ class zip_packer extends file_packer {
return $archivefile->extract_to_pathname($this, $contextid, $component, $filearea, $itemid, $pathbase, $userid);
}
check_dir_exists($CFG->dataroot.'/temp/zip');
check_dir_exists($CFG->tempdir.'/zip');
$pathbase = trim($pathbase, '/');
$pathbase = ($pathbase === '') ? '/' : '/'.$pathbase.'/';
@ -360,7 +360,7 @@ class zip_packer extends file_packer {
} else {
// large file, would not fit into memory :-(
$tmpfile = tempnam($CFG->dataroot.'/temp/zip', 'unzip');
$tmpfile = tempnam($CFG->tempdir.'/zip', 'unzip');
if (!$fp = fopen($tmpfile, 'wb')) {
@unlink($tmpfile);
$processed[$name] = 'Can not write temp file'; // TODO: localise

View File

@ -40,7 +40,7 @@ $min_enableBuilder = false;
* For best performance, specify your temp directory here. Otherwise Minify
* will have to load extra code to guess. Some examples below:
*/
$min_cachePath = $CFG->dataroot.'/temp';
$min_cachePath = $CFG->tempdir.'';
/**

View File

@ -5263,7 +5263,7 @@ function get_file_storage() {
$trashdirdir = $CFG->dataroot.'/trashdir';
}
$fs = new file_storage($filedir, $trashdirdir, "$CFG->dataroot/temp/filestorage", $CFG->directorypermissions, $CFG->filepermissions);
$fs = new file_storage($filedir, $trashdirdir, "$CFG->tempdir/filestorage", $CFG->directorypermissions, $CFG->filepermissions);
return $fs;
}

View File

@ -64,7 +64,7 @@ class Profiler
{
global $CFG, $USER;
// List all files under our temporary directory
$tempdir = $CFG->dataroot . '/temp/profile/' . $USER->id;
$tempdir = $CFG->tempdir . '/profile/' . $USER->id;
if ($files = scandir($tempdir)) {
// Concatenate the files
print_r($files);

View File

@ -97,9 +97,9 @@ if (!isset($CFG->admin)) { // Just in case it isn't defined in config.php
// Set up some paths.
$CFG->libdir = $CFG->dirroot .'/lib';
// Allow overriding of tempdir but be backwards compatible with dataroot/temp
// Allow overriding of tempdir but be backwards compatible with tempdir
if (!isset($CFG->tempdir)) {
$CFG->tempdir = "$CFG->dataroot/temp";
$CFG->tempdir = "$CFG->tempdir";
}
// The current directory in PHP version 4.3.0 and above isn't necessarily the

View File

@ -860,7 +860,7 @@ function init_performance_info() {
if (function_exists('apd_set_pprof_trace')) {
// APD profiling
if ($USER->id > 0 && $CFG->perfdebug >= 15) {
$tempdir = $CFG->dataroot . '/temp/profile/' . $USER->id;
$tempdir = $CFG->tempdir . '/profile/' . $USER->id;
mkdir($tempdir);
apd_set_pprof_trace($tempdir);
$PERF->profiling = true;

View File

@ -65,7 +65,7 @@ class filter_manager_test extends UnitTestCase {
global $CFG;
$this->filtermanager = new testable_filter_manager();
$this->olddirroot = $CFG->dirroot;
$CFG->dirroot = $CFG->dataroot . '/temp';
$CFG->dirroot = $CFG->tempdir . '';
}
public function tearDown() {

View File

@ -95,7 +95,7 @@ class textlib {
// to forward slashed because Typo3 requires it.
define ('PATH_t3lib', str_replace('\\','/',$CFG->libdir.'/typo3/'));
define ('PATH_typo3', str_replace('\\','/',$CFG->libdir.'/typo3/'));
define ('PATH_site', str_replace('\\','/',$CFG->dataroot.'/temp/'));
define ('PATH_site', str_replace('\\','/',$CFG->tempdir.'/'));
define ('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
$typo3cs = new t3lib_cs();

View File

@ -1319,7 +1319,7 @@ function upgrade_language_pack($lang='') {
upgrade_started(false);
echo $OUTPUT->heading(get_string('langimport', 'admin').': '.$lang);
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
@mkdir ($CFG->tempdir.'/'); //make it in case it's a fresh install, it might not be there
@mkdir ($CFG->dataroot.'/lang/');
require_once($CFG->libdir.'/componentlib.class.php');

View File

@ -3723,7 +3723,7 @@ function assignment_extend_settings_navigation(settings_navigation $settings, na
function assignment_pack_files($filesforzipping) {
global $CFG;
//create path for new zip file.
$tempzip = tempnam($CFG->dataroot.'/temp/', 'assignment_');
$tempzip = tempnam($CFG->tempdir.'/', 'assignment_');
//zip files
$zipper = new zip_packer();
if ($zipper->archive_to_pathname($filesforzipping, $tempzip)) {

View File

@ -2463,7 +2463,7 @@ function data_preset_path($course, $userid, $shortname) {
} else if ($userid == 0) {
$path = $CFG->dirroot.'/mod/data/preset/'.$shortname;
} else if ($userid < 0) {
$path = $CFG->dataroot.'/temp/data/'.-$userid.'/'.$shortname;
$path = $CFG->tempdir.'/data/'.-$userid.'/'.$shortname;
}
return $path;

View File

@ -190,7 +190,7 @@ if (optional_param('sesskey', false, PARAM_BOOL) && confirm_sesskey()) {
} else if ($action == 'finishimport') {
$overwritesettings = optional_param('overwritesettings', false, PARAM_BOOL);
if (!$fullname) {
$presetdir = $CFG->dataroot.'/temp/forms/'.required_param('directory', PARAM_ALPHANUMEXT);
$presetdir = $CFG->tempdir.'/forms/'.required_param('directory', PARAM_ALPHANUMEXT);
if (!file_exists($presetdir) || !is_dir($presetdir)) {
print_error('cannotimport');
}

View File

@ -79,7 +79,7 @@ $mygroupid = groups_get_activity_group($cm);
// Creating a workbook
// $workbook = new EasyWorkbook("-");
$workbook = new MoodleExcelWorkbook('-');
// $workbook->setTempDir($CFG->dataroot.'/temp');
// $workbook->setTempDir($CFG->tempdir.'');
$workbook->send($filename);
// $workbook->setVersion(8);

View File

@ -976,7 +976,7 @@ function scorm_extend_navigation($navigation, $course, $module, $cm) {
function scorm_debug_log_filename($type, $scoid) {
global $CFG, $USER;
$logpath = $CFG->dataroot.'/temp/scormlogs';
$logpath = $CFG->tempdir.'/scormlogs';
$logfile = $logpath.'/'.$type.'debug_'.$USER->id.'_'.$scoid.'.log';
return $logfile;
}

View File

@ -328,7 +328,7 @@ class mod_scorm_mod_form extends moodleform_mod {
return $errors;
}
$file = reset($files);
$filename = $CFG->dataroot.'/temp/scormimport/scrom_'.time();
$filename = $CFG->tempdir.'/scormimport/scrom_'.time();
make_upload_directory('temp/scormimport');
$file->copy_content_to($filename);

View File

@ -46,12 +46,12 @@ class qformat_blackboard_six extends qformat_default {
global $CFG;
$status = $this->check_dir_exists($CFG->dataroot."/temp",true);
$status = $this->check_dir_exists($CFG->tempdir."",true);
if ($status) {
$status = $this->check_dir_exists($CFG->dataroot."/temp/bbquiz_import",true);
$status = $this->check_dir_exists($CFG->tempdir."/bbquiz_import",true);
}
if ($status) {
$status = $this->check_dir_exists($CFG->dataroot."/temp/bbquiz_import/".$unique_code,true);
$status = $this->check_dir_exists($CFG->tempdir."/bbquiz_import/".$unique_code,true);
}
return $status;
@ -61,7 +61,7 @@ class qformat_blackboard_six extends qformat_default {
global $CFG;
// for now we will just say everything happened okay note
// that a mess may be piling up in $CFG->dataroot/temp/bbquiz_import
// that a mess may be piling up in $CFG->tempdir/bbquiz_import
// TODO return true at top of the function renders all the following code useless
return true;
@ -189,7 +189,7 @@ class qformat_blackboard_six extends qformat_default {
}
$unique_code = time();
$temp_dir = $CFG->dataroot."/temp/bbquiz_import/".$unique_code;
$temp_dir = $CFG->tempdir."/bbquiz_import/".$unique_code;
$this->temp_dir = $temp_dir;
if ($this->check_and_create_import_dir($unique_code)) {
if(is_readable($filename)) {

View File

@ -1310,11 +1310,11 @@ abstract class repository {
*/
public function prepare_file($filename) {
global $CFG;
if (!file_exists($CFG->dataroot.'/temp/download')) {
mkdir($CFG->dataroot.'/temp/download/', $CFG->directorypermissions, true);
if (!file_exists($CFG->tempdir.'/download')) {
mkdir($CFG->tempdir.'/download/', $CFG->directorypermissions, true);
}
if (is_dir($CFG->dataroot.'/temp/download')) {
$dir = $CFG->dataroot.'/temp/download/';
if (is_dir($CFG->tempdir.'/download')) {
$dir = $CFG->tempdir.'/download/';
}
if (empty($filename)) {
$filename = uniqid('repo').'_'.time().'.tmp';