Permalink
Browse files

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

  • Loading branch information...
1 parent 3e93987 commit 7aa06e6ded5f7294af03cca4cbd055e2ad606d0a @tomlanyon tomlanyon committed with skodak Aug 10, 2011
Showing with 111 additions and 111 deletions.
  1. +7 −7 admin/timezoneimport.php
  2. +1 −1 admin/uploadpicture.php
  3. +1 −1 auth/mnet/auth.php
  4. +2 −2 backup/controller/restore_controller.class.php
  5. +2 −2 backup/converter/convertlib.php
  6. +1 −1 backup/converter/moodle1/lib.php
  7. +10 −10 backup/converter/moodle1/simpletest/testlib.php
  8. +1 −1 backup/import.php
  9. +9 −9 backup/lib.php
  10. +1 −1 backup/restorefile.php
  11. +2 −2 backup/util/factories/backup_factory.class.php
  12. +1 −1 backup/util/helper/backup_file_manager.class.php
  13. +1 −1 backup/util/helper/backup_general_helper.class.php
  14. +5 −5 backup/util/helper/backup_helper.class.php
  15. +1 −1 backup/util/helper/convert_helper.class.php
  16. +5 −5 backup/util/loggers/simpletest/testlogger.php
  17. +1 −1 backup/util/plan/backup_plan.class.php
  18. +1 −1 backup/util/plan/restore_plan.class.php
  19. +2 −2 backup/util/plan/simpletest/teststep.php
  20. +3 −3 backup/util/ui/restore_ui_stage.class.php
  21. +7 −7 backup/util/xml/output/simpletest/testoutput.php
  22. +1 −1 blocks/community/communitycourse.php
  23. +2 −2 blocks/community/locallib.php
  24. +1 −1 enrol/authorize/uploadcsv.php
  25. +1 −1 filter/tex/latex.php
  26. +2 −2 filter/tex/lib.php
  27. +1 −1 grade/edit/outcome/import.php
  28. +1 −1 grade/export/xml/grade_export_xml.php
  29. +2 −2 grade/import/csv/index.php
  30. +1 −1 lib/componentlib.class.php
  31. +5 −5 lib/csvlib.class.php
  32. +1 −1 lib/excellib.class.php
  33. +1 −1 lib/filelib.php
  34. +4 −4 lib/filestorage/zip_packer.php
  35. +1 −1 lib/minify/config.php
  36. +1 −1 lib/moodlelib.php
  37. +1 −1 lib/profilerlib.php
  38. +2 −2 lib/setup.php
  39. +1 −1 lib/setuplib.php
  40. +1 −1 lib/simpletest/broken_testfiltermanager.php
  41. +1 −1 lib/textlib.class.php
  42. +1 −1 lib/upgradelib.php
  43. +1 −1 mod/assignment/lib.php
  44. +1 −1 mod/data/lib.php
  45. +1 −1 mod/data/preset.php
  46. +1 −1 mod/feedback/analysis_to_excel.php
  47. +1 −1 mod/scorm/lib.php
  48. +1 −1 mod/scorm/mod_form.php
  49. +5 −5 question/format/blackboard_six/format.php
  50. +4 −4 repository/lib.php
View
@@ -22,8 +22,8 @@
if (!$ok or !confirm_sesskey()) {
$message = '<br /><br />';
- $message .= $CFG->dataroot.'/temp/olson.txt<br />';
- $message .= $CFG->dataroot.'/temp/timezone.txt<br />';
+ $message .= $CFG->tempdir.'/olson.txt<br />';
+ $message .= $CFG->tempdir.'/timezone.txt<br />';
$message .= '<a href="http://download.moodle.org/timezone/">http://download.moodle.org/timezone/</a><br />';
$message .= '<a href="'.$CFG->wwwroot.'/lib/timezone.txt">'.$CFG->dirroot.'/lib/timezone.txt</a><br />';
$message .= '<br />';
@@ -43,7 +43,7 @@
/// First, look for an Olson file locally
- $source = $CFG->dataroot.'/temp/olson.txt';
+ $source = $CFG->tempdir.'/olson.txt';
if (!$importdone and is_readable($source)) {
if ($timezones = olson_to_timezones($source)) {
update_timezone_records($timezones);
@@ -53,7 +53,7 @@
/// Next, look for a CSV file locally
- $source = $CFG->dataroot.'/temp/timezone.txt';
+ $source = $CFG->tempdir.'/timezone.txt';
if (!$importdone and is_readable($source)) {
if ($timezones = get_records_csv($source, 'timezone')) {
update_timezone_records($timezones);
@@ -64,14 +64,14 @@
/// Otherwise, let's try moodle.org's copy
$source = 'http://download.moodle.org/timezone/';
if (!$importdone && ($content=download_file_content($source))) {
- if ($file = fopen($CFG->dataroot.'/temp/timezone.txt', 'w')) { // Make local copy
+ if ($file = fopen($CFG->tempdir.'/timezone.txt', 'w')) { // Make local copy
fwrite($file, $content);
fclose($file);
- if ($timezones = get_records_csv($CFG->dataroot.'/temp/timezone.txt', 'timezone')) { // Parse it
+ if ($timezones = get_records_csv($CFG->tempdir.'/timezone.txt', 'timezone')) { // Parse it
update_timezone_records($timezones);
$importdone = $source;
}
- unlink($CFG->dataroot.'/temp/timezone.txt');
+ unlink($CFG->tempdir.'/timezone.txt');
}
}
View
@@ -72,7 +72,7 @@
// Create a unique temporary directory, to process the zip file
// contents.
- $zipdir = my_mktempdir($CFG->dataroot.'/temp/', 'usrpic');
+ $zipdir = my_mktempdir($CFG->tempdir.'/', 'usrpic');
$dstfile = $zipdir.'/images.zip';
if (!$mform->save_file('userpicturesfile', $dstfile, true)) {
View
@@ -311,7 +311,7 @@ function confirm_mnet_session($token, $remotepeer) {
$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 @@ public function convert() {
public function get_workdir_path() {
global $CFG;
- return "$CFG->dataroot/temp/backup/$this->workdir";
+ return "$CFG->tempdir/backup/$this->workdir";
}
/**
@@ -156,7 +156,7 @@ public function get_workdir_path() {
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 @@ public function log($message, $level, $a = null, $depth = null, $display = false
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 @@ public function setUp() {
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 @@ public function test_question_bank_conversion() {
copy(
"$CFG->dirroot/backup/converter/moodle1/simpletest/files/questions.xml",
- "$CFG->dataroot/temp/backup/$this->tempdir/moodle.xml"
+ "$CFG->tempdir/backup/$this->tempdir/moodle.xml"
);
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
$converter->convert();
View
@@ -96,7 +96,7 @@
// Check whether the backup directory still exists. If missing, something
// went really wrong in backup, throw error. Note that backup::MODE_IMPORT
// backups don't store resulting files ever
- $tempdestination = $CFG->dataroot . '/temp/backup/' . $backupid;
+ $tempdestination = $CFG->tempdir . '/backup/' . $backupid;
if (!file_exists($tempdestination) || !is_dir($tempdestination)) {
print_error('unknownbackupexporterror'); // shouldn't happen ever
}
View
@@ -54,9 +54,9 @@ function backup_delete_old_dirs($delete_from) {
$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 backup_delete_old_dirs($delete_from) {
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 delete_dir_contents ($dir,$excludeddir="") {
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 @@ function clean_temp_data ($preferences) {
&& $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 @@ function backup_putid($backup_unique_code, $table, $old_id, $new_id, $info="") {
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 @@ function backup_getid ($backup_unique_code, $table, $old_id) {
//If info field = "infile", get file contents
if (!empty($status->info) && $status->info == "infile") {
- $filename = $CFG->dataroot."/temp/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
+ $filename = $CFG->tempdir."/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
//Read data from file
$status2 = backup_file2data($filename,$info);
if ($status2) {
View
@@ -64,7 +64,7 @@
$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 @@ public static function get_logger_chain($interactive, $execution, $backupid) {
// 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 @@ public static function get_backup_information($tempdir) {
$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 @@
*/
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 @@ static public function check_and_create_backup_dir($backupid) {
*/
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 @@ static public function clear_backup_dir($backupid) {
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 @@ static public function delete_old_backup_dirs($deletefrom) {
$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 @@ public static function available_converters() {
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 @@ function test_database_logger() {
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 @@ function test_file_logger() {
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 @@ function test_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';
@@ -313,7 +313,7 @@ function test_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');
@@ -324,7 +324,7 @@ function test_file_logger() {
}
// 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 @@ public function __construct($controller) {
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 @@ public function __construct($controller) {
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;
Oops, something went wrong.

0 comments on commit 7aa06e6

Please sign in to comment.