mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
Merge branch 'w36_MDL-28701_m22_tempcachedir' of git://github.com/skodak/moodle
This commit is contained in:
commit
f8adfe6cc0
@ -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
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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 ]
|
||||
|
@ -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 //////////////////////////////////////////////////
|
||||
|
@ -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');
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)) {
|
||||
|
@ -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));
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -86,12 +86,12 @@ 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));
|
||||
|
||||
$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();
|
||||
|
@ -223,9 +223,9 @@ function blog_rss_file_name($type, $id, $tagid=0) {
|
||||
global $CFG;
|
||||
|
||||
if ($tagid) {
|
||||
return "$CFG->dataroot/cache/rss/blog/$type/$id/$tagid.xml";
|
||||
return "$CFG->cachedir/rss/blog/$type/$id/$tagid.xml";
|
||||
} else {
|
||||
return "$CFG->dataroot/cache/rss/blog/$type/$id.xml";
|
||||
return "$CFG->cachedir/rss/blog/$type/$id.xml";
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,8 +236,8 @@ function blog_rss_save_file($type, $id, $tagid=0, $contents='') {
|
||||
$status = true;
|
||||
|
||||
//blog creates some additional dirs within the rss cache so make sure they all exist
|
||||
make_upload_directory('cache/rss/blog');
|
||||
make_upload_directory('cache/rss/blog/'.$type);
|
||||
make_cache_directory('rss/blog');
|
||||
make_cache_directory('rss/blog/'.$type);
|
||||
|
||||
$filename = blog_rss_file_name($type, $id, $tagid);
|
||||
$expandfilename = false; //we're supplying a full file path
|
||||
|
@ -347,10 +347,16 @@ $CFG->admin = 'admin';
|
||||
//
|
||||
// $CFG->themedir = '/location/of/extra/themes';
|
||||
//
|
||||
// It is possible to specify different cache and temp directories, use local fast filesystem.
|
||||
// The directories must not be accessible via web.
|
||||
//
|
||||
// $CFG->tempdir = '/var/www/moodle/temp';
|
||||
// $CFG->cachedir = '/var/www/moodle/cache';
|
||||
//
|
||||
// If $CFG->langstringcache is enabled (which should always be in production
|
||||
// environment), Moodle keeps aggregated strings in its own internal format
|
||||
// optimised for performance. By default, this on-disk cache is created in
|
||||
// $CFG->dataroot/cache/lang. In cluster environment, you may wish to specify
|
||||
// $CFG->cachedir/lang. In cluster environment, you may wish to specify
|
||||
// an alternative location of this cache so that each web server in the cluster
|
||||
// uses its own local cache and does not need to access the shared dataroot.
|
||||
// Make sure that the web server process has write permission to this location
|
||||
|
@ -54,8 +54,8 @@ echo $OUTPUT->heading($struploadcsv);
|
||||
if (!$form->get_data()) {
|
||||
$form->display();
|
||||
} else {
|
||||
$filename = $CFG->dataroot . '/temp/enrolauthorize/importedfile_'.time().'.csv';
|
||||
make_upload_directory('temp/enrolauthorize');
|
||||
$filename = $CFG->tempdir . '/enrolauthorize/importedfile_'.time().'.csv';
|
||||
make_temp_directory('enrolauthorize');
|
||||
// Fix mac/dos newlines
|
||||
$text = $form->get_file_content('csvfile');
|
||||
$text = preg_replace('!\r\n?!', "\n", $text);
|
||||
|
@ -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', true).'_'.time().'.tmp';
|
||||
|
@ -19,8 +19,8 @@
|
||||
global $CFG;
|
||||
|
||||
// construct directory structure
|
||||
$this->temp_dir = $CFG->dataroot . "/temp/latex";
|
||||
make_upload_directory('temp/latex');
|
||||
$this->temp_dir = $CFG->tempdir . "/latex";
|
||||
make_temp_directory('latex');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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'));
|
||||
|
@ -60,8 +60,8 @@ 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';
|
||||
make_upload_directory('temp/outcomeimport');
|
||||
$imported_file = $CFG->tempdir . '/outcomeimport/importedfile_'.time().'.csv';
|
||||
make_temp_directory('outcomeimport');
|
||||
|
||||
// copying imported file
|
||||
if (!$upload_form->save_file('userfile', $imported_file, true)) {
|
||||
|
@ -40,8 +40,8 @@ class grade_export_xml extends grade_export {
|
||||
/// Calculate file name
|
||||
$downloadfilename = clean_filename("{$this->course->shortname} $strgrades.xml");
|
||||
|
||||
make_upload_directory('temp/gradeexport');
|
||||
$tempfilename = $CFG->dataroot .'/temp/gradeexport/'. md5(sesskey().microtime().$downloadfilename);
|
||||
make_temp_directory('gradeexport');
|
||||
$tempfilename = $CFG->tempdir .'/gradeexport/'. md5(sesskey().microtime().$downloadfilename);
|
||||
if (!$handle = fopen($tempfilename, 'w+b')) {
|
||||
print_error('cannotcreatetempdir');
|
||||
}
|
||||
|
@ -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);
|
||||
@ -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');
|
||||
@ -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');
|
||||
|
@ -281,13 +281,13 @@ 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;
|
||||
}
|
||||
/// 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')) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
@ -124,7 +124,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2008030602) {
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
@unlink($CFG->cachedir.'/languages');
|
||||
|
||||
if (file_exists("$CFG->dataroot/lang")) {
|
||||
// rename old lang directory so that the new and old langs do not mix
|
||||
|
@ -64,8 +64,8 @@ class MoodleExcelWorkbook {
|
||||
$this->latin_output = true;
|
||||
}
|
||||
/// 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');
|
||||
make_temp_directory('excel');
|
||||
$this->pear_excel_workbook->setTempDir($CFG->tempdir.'/excel');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
@ -2935,9 +2935,9 @@ class curl_cache {
|
||||
function __construct($module = 'repository'){
|
||||
global $CFG;
|
||||
if (!empty($module)) {
|
||||
$this->dir = $CFG->dataroot.'/cache/'.$module.'/';
|
||||
$this->dir = $CFG->cachedir.'/'.$module.'/';
|
||||
} else {
|
||||
$this->dir = $CFG->dataroot.'/cache/misc/';
|
||||
$this->dir = $CFG->cachedir.'/misc/';
|
||||
}
|
||||
if (!file_exists($this->dir)) {
|
||||
mkdir($this->dir, $CFG->directorypermissions, true);
|
||||
|
@ -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
|
||||
|
@ -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_')) {
|
||||
|
@ -67,7 +67,7 @@ minify($jsfiles);
|
||||
function minify($files) {
|
||||
global $CFG;
|
||||
|
||||
$cachedir = $CFG->dataroot.'/cache/js';
|
||||
$cachedir = $CFG->cachedir.'/js';
|
||||
// make sure the cache dir exist
|
||||
if (!file_exists($cachedir)) {
|
||||
@mkdir($cachedir, $CFG->directorypermissions, true);
|
||||
|
@ -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.'';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1370,14 +1370,14 @@ function purge_all_caches() {
|
||||
get_string_manager()->reset_caches();
|
||||
|
||||
// purge all other caches: rss, simplepie, etc.
|
||||
remove_dir($CFG->dataroot.'/cache', true);
|
||||
remove_dir($CFG->cachedir.'', true);
|
||||
|
||||
// make sure cache dir is writable, throws exception if not
|
||||
make_upload_directory('cache');
|
||||
make_cache_directory('');
|
||||
|
||||
// hack: this script may get called after the purifier was initialised,
|
||||
// but we do not want to verify repeatedly this exists in each call
|
||||
make_upload_directory('cache/htmlpurifier');
|
||||
make_cache_directory('htmlpurifier');
|
||||
|
||||
clearstatcache();
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -5685,7 +5685,7 @@ function get_string_manager($forcereload=false) {
|
||||
if (empty($CFG->early_install_lang)) {
|
||||
|
||||
if (empty($CFG->langcacheroot)) {
|
||||
$langcacheroot = $CFG->dataroot . '/cache/lang';
|
||||
$langcacheroot = $CFG->cachedir . '/lang';
|
||||
} else {
|
||||
$langcacheroot = $CFG->langcacheroot;
|
||||
}
|
||||
@ -5697,7 +5697,7 @@ function get_string_manager($forcereload=false) {
|
||||
}
|
||||
|
||||
if (empty($CFG->langmenucachefile)) {
|
||||
$langmenucache = $CFG->dataroot . '/cache/languages';
|
||||
$langmenucache = $CFG->cachedir . '/languages';
|
||||
} else {
|
||||
$langmenucache = $CFG->langmenucachefile;
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -44,7 +44,7 @@ function theme_reset_all_caches() {
|
||||
require_once("$CFG->libdir/filelib.php");
|
||||
|
||||
set_config('themerev', empty($CFG->themerev) ? 1 : $CFG->themerev+1);
|
||||
fulldelete("$CFG->dataroot/cache/theme");
|
||||
fulldelete("$CFG->cachedir/theme");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -613,7 +613,7 @@ class theme_config {
|
||||
if (!defined('THEME_DESIGNER_CACHE_LIFETIME')) {
|
||||
define('THEME_DESIGNER_CACHE_LIFETIME', 4); // this can be also set in config.php
|
||||
}
|
||||
$candidatesheet = "$CFG->dataroot/cache/theme/$this->name/designer.ser";
|
||||
$candidatesheet = "$CFG->cachedir/theme/$this->name/designer.ser";
|
||||
if (!file_exists($candidatesheet)) {
|
||||
$css = $this->css_content();
|
||||
check_dir_exists(dirname($candidatesheet));
|
||||
|
@ -1213,6 +1213,6 @@ function js_reset_all_caches() {
|
||||
require_once("$CFG->libdir/filelib.php");
|
||||
|
||||
set_config('jsrev', empty($CFG->jsrev) ? 1 : $CFG->jsrev+1);
|
||||
fulldelete("$CFG->dataroot/cache/js");
|
||||
fulldelete("$CFG->cachedir/js");
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ define('K_PATH_URL', $CFG->wwwroot . '/lib/tcpdf/');
|
||||
define('K_PATH_FONTS', K_PATH_MAIN . 'fonts/');
|
||||
|
||||
/** cache directory for temporary files (full path) */
|
||||
define('K_PATH_CACHE', $CFG->dataroot . '/cache/');
|
||||
define('K_PATH_CACHE', $CFG->cachedir . '/');
|
||||
|
||||
/** images directory */
|
||||
define('K_PATH_IMAGES', $CFG->dirroot . '/');
|
||||
|
@ -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);
|
||||
|
@ -92,7 +92,7 @@ function rss_print_link($contextid, $userid, $componentname, $id, $tooltiptext='
|
||||
function rss_delete_file($componentname, $instance) {
|
||||
global $CFG;
|
||||
|
||||
$dirpath = "$CFG->dataroot/cache/rss/$componentname";
|
||||
$dirpath = "$CFG->cachedir/rss/$componentname";
|
||||
if (is_dir($dirpath)) {
|
||||
$dh = opendir($dirpath);
|
||||
while (false !== ($filename = readdir($dh))) {
|
||||
@ -145,7 +145,7 @@ function rss_save_file($componentname, $filename, $contents, $expandfilename=tru
|
||||
|
||||
$status = true;
|
||||
|
||||
if (! $basedir = make_upload_directory ('cache/rss/'. $componentname)) {
|
||||
if (! $basedir = make_cache_directory ('rss/'. $componentname)) {
|
||||
//Cannot be created, so error
|
||||
$status = false;
|
||||
}
|
||||
@ -170,7 +170,7 @@ function rss_save_file($componentname, $filename, $contents, $expandfilename=tru
|
||||
|
||||
function rss_get_file_full_name($componentname, $filename) {
|
||||
global $CFG;
|
||||
return "$CFG->dataroot/cache/rss/$componentname/$filename.xml";
|
||||
return "$CFG->cachedir/rss/$componentname/$filename.xml";
|
||||
}
|
||||
|
||||
function rss_get_file_name($instance, $sql) {
|
||||
|
@ -36,6 +36,8 @@
|
||||
* - $CFG->dataroot - Path to moodle data files directory on server's filesystem.
|
||||
* - $CFG->dirroot - Path to moodle's library folder on server's filesystem.
|
||||
* - $CFG->libdir - Path to moodle's library folder on server's filesystem.
|
||||
* - $CFG->tempdir - Path to moodle's temp file directory on server's filesystem.
|
||||
* - $CFG->cachedir - Path to moodle's cache directory on server's filesystem.
|
||||
*
|
||||
* @global object $CFG
|
||||
* @name $CFG
|
||||
@ -96,6 +98,16 @@ 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
|
||||
if (!isset($CFG->tempdir)) {
|
||||
$CFG->tempdir = "$CFG->dataroot/temp";
|
||||
}
|
||||
|
||||
// Allow overriding of cachedir but be backwards compatible
|
||||
if (!isset($CFG->cachedir)) {
|
||||
$CFG->cachedir = "$CFG->dataroot/cache";
|
||||
}
|
||||
|
||||
// The current directory in PHP version 4.3.0 and above isn't necessarily the
|
||||
// directory of the script when run from the command line. The require_once()
|
||||
// would fail, so we'll have to chdir()
|
||||
|
@ -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;
|
||||
@ -1105,25 +1105,16 @@ function check_dir_exists($dir, $create = true, $recursive = true) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory in dataroot and make sure it is writable.
|
||||
* Create a directory and make sure it is writable.
|
||||
*
|
||||
* @param string $directory a string of directory names under $CFG->dataroot eg temp/something
|
||||
* @private
|
||||
* @param string $dir the full path of the directory to be created
|
||||
* @param bool $exceptiononerror throw exception if error encountered
|
||||
* @return string|false Returns full path to directory if successful, false if not; may throw exception
|
||||
*/
|
||||
function make_upload_directory($directory, $exceptiononerror = true) {
|
||||
function make_writable_directory($dir, $exceptiononerror = true) {
|
||||
global $CFG;
|
||||
|
||||
// Make sure a .htaccess file is here, JUST IN CASE the files area is in the open and .htaccess is supported
|
||||
if (!file_exists("$CFG->dataroot/.htaccess")) {
|
||||
if ($handle = fopen("$CFG->dataroot/.htaccess", 'w')) { // For safety
|
||||
@fwrite($handle, "deny from all\r\nAllowOverride None\r\nNote: this file is broken intentionally, we do not want anybody to undo it in subdirectory!\r\n");
|
||||
@fclose($handle);
|
||||
}
|
||||
}
|
||||
|
||||
$dir = "$CFG->dataroot/$directory";
|
||||
|
||||
if (file_exists($dir) and !is_dir($dir)) {
|
||||
if ($exceptiononerror) {
|
||||
throw new coding_exception($dir.' directory can not be created, file with the same name already exists.');
|
||||
@ -1155,6 +1146,73 @@ function make_upload_directory($directory, $exceptiononerror = true) {
|
||||
return $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect a directory from web access.
|
||||
* Could be extended in the future to support other mechanisms (e.g. other webservers).
|
||||
*
|
||||
* @private
|
||||
* @param string $dir the full path of the directory to be protected
|
||||
*/
|
||||
function protect_directory($dir) {
|
||||
// Make sure a .htaccess file is here, JUST IN CASE the files area is in the open and .htaccess is supported
|
||||
if (!file_exists("$dir/.htaccess")) {
|
||||
if ($handle = fopen("$dir/.htaccess", 'w')) { // For safety
|
||||
@fwrite($handle, "deny from all\r\nAllowOverride None\r\nNote: this file is broken intentionally, we do not want anybody to undo it in subdirectory!\r\n");
|
||||
@fclose($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory under dataroot and make sure it is writable.
|
||||
* Do not use for temporary and cache files - see make_temp_directory() and make_cache_directory().
|
||||
*
|
||||
* @param string $directory the full path of the directory to be created under $CFG->dataroot
|
||||
* @param bool $exceptiononerror throw exception if error encountered
|
||||
* @return string|false Returns full path to directory if successful, false if not; may throw exception
|
||||
*/
|
||||
function make_upload_directory($directory, $exceptiononerror = true) {
|
||||
global $CFG;
|
||||
|
||||
if (strpos($directory, 'temp/') === 0 or $directory === 'temp') {
|
||||
debugging('Use make_temp_directory() for creation of temporary directory and $CFG->tempdir to get the location.');
|
||||
|
||||
} else if (strpos($directory, 'cache/') === 0 or $directory === 'cache') {
|
||||
debugging('Use make_cache_directory() for creation of chache directory and $CFG->cachedir to get the location.');
|
||||
}
|
||||
|
||||
protect_directory($CFG->dataroot);
|
||||
return make_writable_directory("$CFG->dataroot/$directory", $exceptiononerror);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory under tempdir and make sure it is writable.
|
||||
* Temporary files should be used during the current request only!
|
||||
*
|
||||
* @param string $directory the full path of the directory to be created under $CFG->tempdir
|
||||
* @param bool $exceptiononerror throw exception if error encountered
|
||||
* @return string|false Returns full path to directory if successful, false if not; may throw exception
|
||||
*/
|
||||
function make_temp_directory($directory, $exceptiononerror = true) {
|
||||
global $CFG;
|
||||
protect_directory($CFG->tempdir);
|
||||
return make_writable_directory("$CFG->tempdir/$directory", $exceptiononerror);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory under cachedir and make sure it is writable.
|
||||
*
|
||||
* @param string $directory the full path of the directory to be created under $CFG->cachedir
|
||||
* @param bool $exceptiononerror throw exception if error encountered
|
||||
* @return string|false Returns full path to directory if successful, false if not; may throw exception
|
||||
*/
|
||||
function make_cache_directory($directory, $exceptiononerror = true) {
|
||||
global $CFG;
|
||||
protect_directory($CFG->cachedir);
|
||||
return make_writable_directory("$CFG->cachedir/$directory", $exceptiononerror);
|
||||
}
|
||||
|
||||
|
||||
function init_memcached() {
|
||||
global $CFG, $MCACHE;
|
||||
|
||||
|
@ -88,7 +88,7 @@ class moodle_simplepie extends SimplePie
|
||||
private static function get_cache_directory() {
|
||||
global $CFG;
|
||||
|
||||
return $CFG->dataroot.'/cache/simplepie/';
|
||||
return $CFG->cachedir.'/simplepie/';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
@ -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();
|
||||
|
@ -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');
|
||||
|
@ -1187,7 +1187,7 @@ function reset_text_filters_cache() {
|
||||
global $CFG, $DB;
|
||||
|
||||
$DB->delete_records('cache_text');
|
||||
$purifdir = $CFG->dataroot.'/cache/htmlpurifier';
|
||||
$purifdir = $CFG->cachedir.'/htmlpurifier';
|
||||
remove_dir($purifdir, true);
|
||||
}
|
||||
|
||||
@ -1514,7 +1514,7 @@ function purify_html($text, $options = array()) {
|
||||
if (empty($purifiers[$type])) {
|
||||
|
||||
// make sure the serializer dir exists, it should be fine if it disappears later during cache reset
|
||||
$cachedir = $CFG->dataroot.'/cache/htmlpurifier';
|
||||
$cachedir = $CFG->cachedir.'/htmlpurifier';
|
||||
check_dir_exists($cachedir);
|
||||
|
||||
require_once $CFG->libdir.'/htmlpurifier/HTMLPurifier.safe-includes.php';
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
@ -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":
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -68,8 +68,8 @@ 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');
|
||||
$importfile = "{$CFG->tempdir}/questionimport/{$realfilename}";
|
||||
make_temp_directory('questionimport');
|
||||
if (!$result = $mform->save_file('questionfile', $importfile, true)) {
|
||||
throw new moodle_exception('uploadproblem');
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
@ -328,8 +328,8 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
return $errors;
|
||||
}
|
||||
$file = reset($files);
|
||||
$filename = $CFG->dataroot.'/temp/scormimport/scrom_'.time();
|
||||
make_upload_directory('temp/scormimport');
|
||||
$filename = $CFG->tempdir.'/scormimport/scrom_'.time();
|
||||
make_temp_directory('scormimport');
|
||||
$file->copy_content_to($filename);
|
||||
|
||||
$packer = get_file_packer('application/zip');
|
||||
|
@ -59,3 +59,4 @@ required changes in code:
|
||||
* fix missing parameter types in optional_param() and required_param()
|
||||
* use new optional_param_array(), required_param_array() or clean_param_array() when dealing with array parameters
|
||||
* textlib->asort() replaced by specialized collatorlib::asort()
|
||||
* use new make_temp_directory() and make_cache_directory()
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -83,8 +83,8 @@ if ($form = $import_form->get_data()) {
|
||||
// or one from the filesarea.
|
||||
$realfilename = $import_form->get_new_filename('newfile');
|
||||
|
||||
$importfile = "{$CFG->dataroot}/temp/questionimport/{$realfilename}";
|
||||
make_upload_directory('temp/questionimport');
|
||||
$importfile = "{$CFG->tempdir}/questionimport/{$realfilename}";
|
||||
make_temp_directory('questionimport');
|
||||
if (!$result = $import_form->save_file('newfile', $importfile, true)) {
|
||||
throw new moodle_exception('uploadproblem');
|
||||
}
|
||||
|
@ -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', true).'_'.time().'.tmp';
|
||||
|
@ -45,7 +45,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
|
||||
image_not_found();
|
||||
}
|
||||
|
||||
$candidatelocation = "$CFG->dataroot/cache/theme/$themename/pix/$component";
|
||||
$candidatelocation = "$CFG->cachedir/theme/$themename/pix/$component";
|
||||
|
||||
if ($rev > -1) {
|
||||
if (file_exists("$candidatelocation/$image.error")) {
|
||||
|
@ -46,7 +46,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
|
||||
die('Theme was not found, sorry.');
|
||||
}
|
||||
|
||||
$candidate = "$CFG->dataroot/cache/theme/$themename/javascript_$type.js";
|
||||
$candidate = "$CFG->cachedir/theme/$themename/javascript_$type.js";
|
||||
|
||||
if ($rev > -1 and file_exists($candidate)) {
|
||||
if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||
|
@ -50,7 +50,7 @@ if ($type === 'ie') {
|
||||
send_ie_css($themename, $rev);
|
||||
}
|
||||
|
||||
$candidatesheet = "$CFG->dataroot/cache/theme/$themename/css/$type.css";
|
||||
$candidatesheet = "$CFG->cachedir/theme/$themename/css/$type.css";
|
||||
|
||||
if (file_exists($candidatesheet)) {
|
||||
if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||
@ -97,11 +97,11 @@ if ($type === 'editor') {
|
||||
$cssfiles[] = $val;
|
||||
}
|
||||
}
|
||||
$cssfile = "$CFG->dataroot/cache/theme/$themename/css/$key.css";
|
||||
$cssfile = "$CFG->cachedir/theme/$themename/css/$key.css";
|
||||
store_css($theme, $cssfile, $cssfiles);
|
||||
$allfiles = array_merge($allfiles, $cssfiles);
|
||||
}
|
||||
$cssfile = "$CFG->dataroot/cache/theme/$themename/css/all.css";
|
||||
$cssfile = "$CFG->cachedir/theme/$themename/css/all.css";
|
||||
store_css($theme, $cssfile, $allfiles);
|
||||
}
|
||||
send_cached_css($candidatesheet, $rev);
|
||||
|
@ -46,7 +46,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
|
||||
|
||||
// no gzip compression when debugging
|
||||
|
||||
$candidatesheet = "$CFG->dataroot/cache/theme/$themename/designer.ser";
|
||||
$candidatesheet = "$CFG->cachedir/theme/$themename/designer.ser";
|
||||
|
||||
if (!file_exists($candidatesheet)) {
|
||||
css_not_found();
|
||||
|
Loading…
x
Reference in New Issue
Block a user