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 />';
/// 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);
/// 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);
/// 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');
}
}
// 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)) {
$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)) {
*/
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
/**
*
- * @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 ]
public function get_workdir_path() {
global $CFG;
- return "$CFG->dataroot/temp/backup/$this->workdir";
+ return "$CFG->tempdir/backup/$this->workdir";
}
/**
public function get_tempdir_path() {
global $CFG;
- return "$CFG->dataroot/temp/backup/$this->tempdir";
+ return "$CFG->tempdir/backup/$this->tempdir";
}
/// public static methods //////////////////////////////////////////////////
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');
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");
}
}
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();
// 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
}
$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
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;
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);
&& $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
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
//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) {
$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');
}
// 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
public static function get_backup_storage_base_dir($backupid) {
global $CFG;
- return $CFG->dataroot . '/temp/backup/' . $backupid . '/files';
+ return $CFG->tempdir . '/backup/' . $backupid . '/files';
}
/**
$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);
}
*/
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');
}
}
*/
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;
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);
}
/**
$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
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)) {
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
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);
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';
}
// 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');
}
// 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));
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');
}
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;
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
public function get_taskbasepath() {
global $CFG;
- return $CFG->dataroot . '/temp/test';
+ return $CFG->tempdir . '/test';
}
}
}
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();
$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/"));
}
/**
}
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)) {
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
$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();
}
// 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 {
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');
// 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();
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();
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();
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
$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;
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();
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');
global $CFG;
// construct directory structure
- $this->temp_dir = $CFG->dataroot . "/temp/latex";
+ $this->temp_dir = $CFG->tempdir . "/latex";
make_upload_directory('temp/latex');
}
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'));
}
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
$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');
}
}
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);
} 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');
}
/// 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')) {
$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");
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;
}
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;
}
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);
}
}
}
/// 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');
}
/**
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);
}
$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)) {
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.'/';
} 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
* 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.'';
/**
$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;
}
{
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);
// 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
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;
global $CFG;
$this->filtermanager = new testable_filter_manager();
$this->olddirroot = $CFG->dirroot;
- $CFG->dirroot = $CFG->dataroot . '/temp';
+ $CFG->dirroot = $CFG->tempdir . '';
}
public function tearDown() {
// 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();
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');
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)) {
} 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;
} 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');
}
// Creating a workbook
// $workbook = new EasyWorkbook("-");
$workbook = new MoodleExcelWorkbook('-');
-// $workbook->setTempDir($CFG->dataroot.'/temp');
+// $workbook->setTempDir($CFG->tempdir.'');
$workbook->send($filename);
// $workbook->setVersion(8);
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;
}
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);
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;
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;
}
$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)) {
*/
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';