MDL-14589 more local --> stored renaming
This commit is contained in:
@@ -291,10 +291,6 @@ $string['listcantmoveup'] = 'Failed to move the item up, as it is the first of i
|
||||
$string['listcantmovedown'] = 'Failed to move item down, as it is the last of it\'s peers';
|
||||
$string['listcantmoveleft'] = 'Failed to move item left, as it has no parent';
|
||||
$string['listcantmoveright'] = 'Failed to move item right, as there is no peer to make it a child of. Move it below another peer and then you can move it right.';
|
||||
$string['localfilecannotcreatefiledirs'] = 'Can not create local file pool directories, please verify permissions in dataroot.';
|
||||
$string['localfilecannotread'] = 'Can not read file, either file does not exist or there are permission problems';
|
||||
$string['localfilenotcreated'] = 'Can not create file \"$a->contextid/$a->filearea/$a->itemid/$a->filepath/$a->filename\"';
|
||||
$string['localfileproblem'] = 'Unknown exception related to local files ($a)';
|
||||
$string['loginasonecourse'] = 'You cannot enter this course.<br /> You have to terminate the \"Login as\" session before entering any other course.';
|
||||
$string['loginasnoenrol'] = 'You cannot use enrol or unenrol when in course \"Login as\" session';
|
||||
$string['logfilenotavailable'] = 'Logs not available';
|
||||
@@ -387,6 +383,10 @@ $string['sessionipnomatch'] = 'Sorry, but your IP number seems to have changed f
|
||||
$string['socksnotsupported'] = 'SOCKS5 proxy is not supported in PHP4';
|
||||
$string['spellcheckernotconf'] = 'Spellchecker not configured';
|
||||
$string['statscatchupmode'] = 'Statistics is currently in catchup mode. So far $a->daysdone day(s) have been processed and $a->dayspending are pending. Check back soon!';
|
||||
$string['storedfilecannotcreatefiledirs'] = 'Can not create local file pool directories, please verify permissions in dataroot.';
|
||||
$string['storedfilecannotread'] = 'Can not read file, either file does not exist or there are permission problems';
|
||||
$string['storedfilenotcreated'] = 'Can not create file \"$a->contextid/$a->filearea/$a->itemid/$a->filepath/$a->filename\"';
|
||||
$string['storedfileproblem'] = 'Unknown exception related to local files ($a)';
|
||||
$string['tagnotfound'] = 'The specified tag was not found in the database';
|
||||
$string['tagdisabled'] = 'Tags are disabled!';
|
||||
$string['themenotinstall'] = 'This theme is not installed!';
|
||||
|
||||
+21
-21
@@ -54,9 +54,9 @@ class file_browser {
|
||||
$filepath = is_null($filepath) ? '/' : $filepath;
|
||||
$filename = is_null($filename) ? '.' : $filename;
|
||||
|
||||
if (!$localfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if (!$storedfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if ($filepath === '/' and $filename === '.') {
|
||||
$localfile = $fs->create_directory($context->id, $filearea, 0, $filepath, $USER->id);
|
||||
$storedfile = $fs->create_directory($context->id, $filearea, 0, $filepath, $USER->id);
|
||||
} else {
|
||||
// not found
|
||||
return null;
|
||||
@@ -64,19 +64,19 @@ class file_browser {
|
||||
}
|
||||
$urlbase = $CFG->wwwroot.'/userfile.php';
|
||||
// TODO: localise
|
||||
return new file_info_stored($this, $context, $localfile, $urlbase, 'Personal files', false, true, true);
|
||||
return new file_info_stored($this, $context, $storedfile, $urlbase, 'Personal files', false, true, true);
|
||||
|
||||
} else if ($filearea == 'user_draft') {
|
||||
if (empty($itemid)) {
|
||||
return new file_info_user($this, $context);
|
||||
}
|
||||
$urlbase = $CFG->wwwroot.'/draftfile.php';
|
||||
if (!$localfile = $fs->get_file($context->id, $filearea, $itemid, $filepath, $filename)) {
|
||||
if (!$storedfile = $fs->get_file($context->id, $filearea, $itemid, $filepath, $filename)) {
|
||||
return null;
|
||||
}
|
||||
//something must create the top most directory
|
||||
// TODO: localise
|
||||
return new file_info_stored($this, $context, $localfile, $urlbase, 'Draft file area', true, true, true);
|
||||
return new file_info_stored($this, $context, $storedfile, $urlbase, 'Draft file area', true, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,16 +107,16 @@ class file_browser {
|
||||
$filename = is_null($filename) ? '.' : $filename;
|
||||
|
||||
$urlbase = $CFG->wwwroot.'/pluginfile.php';
|
||||
if (!$localfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if (!$storedfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if ($filepath === '/' and $filename === '.') {
|
||||
$localfile = $fs->create_directory($context->id, $filearea, 0, $filepath);
|
||||
$storedfile = $fs->create_directory($context->id, $filearea, 0, $filepath);
|
||||
} else {
|
||||
// not found
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// TODO: localise
|
||||
return new file_info_stored($this, $context, $localfile, $urlbase, 'Category introduction files', false, true, true);
|
||||
return new file_info_stored($this, $context, $storedfile, $urlbase, 'Category introduction files', false, true, true);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -148,16 +148,16 @@ class file_browser {
|
||||
}
|
||||
|
||||
$urlbase = $CFG->wwwroot.'/pluginfile.php';
|
||||
if (!$localfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if (!$storedfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if ($filepath === '/' and $filename === '.') {
|
||||
$localfile = $fs->create_directory($context->id, $filearea, 0, $filepath);
|
||||
$storedfile = $fs->create_directory($context->id, $filearea, 0, $filepath);
|
||||
} else {
|
||||
// not found
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// TODO: localise
|
||||
return new file_info_stored($this, $context, $localfile, $urlbase, 'Course introduction files', false, true, true);
|
||||
return new file_info_stored($this, $context, $storedfile, $urlbase, 'Course introduction files', false, true, true);
|
||||
|
||||
} else if ($filearea == 'course_backup') {
|
||||
if (!has_capability('moodle/site:backup', $context) and !has_capability('moodle/site:restore', $context)) {
|
||||
@@ -165,9 +165,9 @@ class file_browser {
|
||||
}
|
||||
|
||||
$urlbase = $CFG->wwwroot.'/pluginfile.php';
|
||||
if (!$localfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if (!$storedfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if ($filepath === '/' and $filename === '.') {
|
||||
$localfile = $fs->create_directory($context->id, $filearea, 0, $filepath);
|
||||
$storedfile = $fs->create_directory($context->id, $filearea, 0, $filepath);
|
||||
} else {
|
||||
// not found
|
||||
return null;
|
||||
@@ -177,23 +177,23 @@ class file_browser {
|
||||
$downloadable = has_capability('moodle/site:backupdownload', $context);
|
||||
$uploadable = has_capability('moodle/site:backupupload', $context);
|
||||
// TODO: localise
|
||||
return new file_info_stored($this, $context, $localfile, $urlbase, 'Backup files', false, $downloadable, $uploadable);
|
||||
return new file_info_stored($this, $context, $storedfile, $urlbase, 'Backup files', false, $downloadable, $uploadable);
|
||||
|
||||
} else if ($filearea == 'course_content') {
|
||||
if (!has_capability('moodle/course:managefiles', $context)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$localfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if (!$storedfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
|
||||
if ($filepath === '/' and $filename === '.') {
|
||||
$localfile = $fs->create_directory($context->id, $filearea, 0, $filepath);
|
||||
$storedfile = $fs->create_directory($context->id, $filearea, 0, $filepath);
|
||||
} else {
|
||||
// not found
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return new file_info_coursefile($this, $context, $localfile);
|
||||
return new file_info_coursefile($this, $context, $storedfile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,8 +211,8 @@ class file_browser {
|
||||
$result = array();
|
||||
$fs = get_file_storage();
|
||||
|
||||
$localfiles = $fs->get_directory_files($context->id, $filearea, $itemid, $filepath, false, true, "filepath, filename");
|
||||
foreach ($localfiles as $file) {
|
||||
$storedfiles = $fs->get_directory_files($context->id, $filearea, $itemid, $filepath, false, true, "filepath, filename");
|
||||
foreach ($storedfiles as $file) {
|
||||
$result[] = new file_info_stored($this, $context, $file, $urlbase, $areavisiblename, $itemidused, $readaccess, $writeaccess);
|
||||
}
|
||||
|
||||
@@ -226,8 +226,8 @@ class file_browser {
|
||||
$result = array();
|
||||
$fs = get_file_storage();
|
||||
|
||||
$localfiles = $fs->get_directory_files($context->id, 'course_content', 0, $filepath, false, true, "filepath, filename");
|
||||
foreach ($localfiles as $file) {
|
||||
$storedfiles = $fs->get_directory_files($context->id, 'course_content', 0, $filepath, false, true, "filepath, filename");
|
||||
foreach ($storedfiles as $file) {
|
||||
$result[] = new file_info_coursefile($this, $context, $file);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class stored_file_creation_exception extends file_exception {
|
||||
$a->itemid = $itemid;
|
||||
$a->filepath = $filepath;
|
||||
$a->filename = $filename;
|
||||
parent::__construct('localfilenotcreated', $a, $debuginfo);
|
||||
parent::__construct('storedfilenotcreated', $a, $debuginfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php //$Id$
|
||||
|
||||
class file_info_coursefile extends file_info_stored {
|
||||
public function __construct($browser, $context, $localfile) {
|
||||
public function __construct($browser, $context, $storedfile) {
|
||||
global $CFG;
|
||||
$urlbase = $CFG->wwwroot.'/file.php';
|
||||
parent::__construct($browser, $context, $localfile, $urlbase, 'Course files', false, true, true); // TODO: localise
|
||||
parent::__construct($browser, $context, $storedfile, $urlbase, 'Course files', false, true, true); // TODO: localise
|
||||
}
|
||||
|
||||
public function get_url($forcedownload=false, $https=false) {
|
||||
|
||||
@@ -8,10 +8,10 @@ class file_info_stored extends file_info {
|
||||
protected $readaccess;
|
||||
protected $writeaccess;
|
||||
|
||||
public function __construct($browser, $context, $localfile, $urlbase, $areavisiblename, $itemidused, $readaccess, $writeaccess) {
|
||||
public function __construct($browser, $context, $storedfile, $urlbase, $areavisiblename, $itemidused, $readaccess, $writeaccess) {
|
||||
parent::__construct($browser, $context);
|
||||
|
||||
$this->lf = $localfile;
|
||||
$this->lf = $storedfile;
|
||||
$this->urlbase = $urlbase;
|
||||
$this->areavisiblename = $areavisiblename;
|
||||
$this->itemidused = $itemidused;
|
||||
@@ -265,8 +265,8 @@ class file_info_stored extends file_info {
|
||||
if ($this->is_directory()) {
|
||||
$filepath = $this->lf->get_filepath();
|
||||
$fs = get_file_storage();
|
||||
$localfiles = $fs->get_area_files($this->context->id, $this->lf->get_filearea(), $this->lf->get_itemid(), "");
|
||||
foreach ($localfiles as $file) {
|
||||
$storedfiles = $fs->get_area_files($this->context->id, $this->lf->get_filearea(), $this->lf->get_itemid(), "");
|
||||
foreach ($storedfiles as $file) {
|
||||
if (strpos($file->get_filepath(), $filepath) === 0) {
|
||||
$file->delete();
|
||||
}
|
||||
|
||||
+25
-25
@@ -15,7 +15,7 @@ class file_storage {
|
||||
// make sure the file pool directory exists
|
||||
if (!is_dir($this->filedir)) {
|
||||
if (!check_dir_exists($this->filedir, true, true)) {
|
||||
throw new file_exception('localfilecannotcreatefiledirs'); // permission trouble
|
||||
throw new file_exception('storedfilecannotcreatefiledirs'); // permission trouble
|
||||
}
|
||||
// place warning file in file pool root
|
||||
file_put_contents($this->filedir.'/warning.txt',
|
||||
@@ -280,22 +280,22 @@ class file_storage {
|
||||
|
||||
// validate all parameters, we do not want any rubbish stored in database, right?
|
||||
if (!is_number($contextid) or $contextid < 1) {
|
||||
throw new file_exception('localfileproblem', 'Invalid contextid');
|
||||
throw new file_exception('storedfileproblem', 'Invalid contextid');
|
||||
}
|
||||
|
||||
$filearea = clean_param($filearea, PARAM_ALPHAEXT);
|
||||
if ($filearea === '') {
|
||||
throw new file_exception('localfileproblem', 'Invalid filearea');
|
||||
throw new file_exception('storedfileproblem', 'Invalid filearea');
|
||||
}
|
||||
|
||||
if (!is_number($itemid) or $itemid < 0) {
|
||||
throw new file_exception('localfileproblem', 'Invalid itemid');
|
||||
throw new file_exception('storedfileproblem', 'Invalid itemid');
|
||||
}
|
||||
|
||||
$filepath = clean_param($filepath, PARAM_PATH);
|
||||
if (strpos($filepath, '/') !== 0 or strrpos($filepath, '/') !== strlen($filepath)-1) {
|
||||
// path must start and end with '/'
|
||||
throw new file_exception('localfileproblem', 'Invalid file path');
|
||||
throw new file_exception('storedfileproblem', 'Invalid file path');
|
||||
}
|
||||
|
||||
$pathnamehash = $this->get_pathname_hash($contextid, $filearea, $itemid, $filepath, '.');
|
||||
@@ -361,7 +361,7 @@ class file_storage {
|
||||
$now = time();
|
||||
|
||||
if ($newrecord = $DB->get_record('files', array('id'=>$fid))) {
|
||||
throw new file_exception('localfileproblem', 'File does not exist');
|
||||
throw new file_exception('storedfileproblem', 'File does not exist');
|
||||
}
|
||||
|
||||
unset($newrecord->id);
|
||||
@@ -369,18 +369,18 @@ class file_storage {
|
||||
foreach ($file_record as $key=>$value) {
|
||||
// validate all parameters, we do not want any rubbish stored in database, right?
|
||||
if ($key == 'contextid' and (!is_number($value) or $value < 1)) {
|
||||
throw new file_exception('localfileproblem', 'Invalid contextid');
|
||||
throw new file_exception('storedfileproblem', 'Invalid contextid');
|
||||
}
|
||||
|
||||
if ($key == 'filearea') {
|
||||
$value = clean_param($value, PARAM_ALPHAEXT);
|
||||
if ($value === '') {
|
||||
throw new file_exception('localfileproblem', 'Invalid filearea');
|
||||
throw new file_exception('storedfileproblem', 'Invalid filearea');
|
||||
}
|
||||
}
|
||||
|
||||
if ($key == 'itemid' and (!is_number($value) or $value < 0)) {
|
||||
throw new file_exception('localfileproblem', 'Invalid itemid');
|
||||
throw new file_exception('storedfileproblem', 'Invalid itemid');
|
||||
}
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ class file_storage {
|
||||
$value = clean_param($value, PARAM_PATH);
|
||||
if (strpos($value, '/') !== 0 or strpos($value, '/') !== strlen($value)-1) {
|
||||
// path must start and end with '/'
|
||||
throw new file_exception('localfileproblem', 'Invalid file path');
|
||||
throw new file_exception('storedfileproblem', 'Invalid file path');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ class file_storage {
|
||||
$value = clean_param($value, PARAM_FILE);
|
||||
if ($value === '') {
|
||||
// path must start and end with '/'
|
||||
throw new file_exception('localfileproblem', 'Invalid file name');
|
||||
throw new file_exception('storedfileproblem', 'Invalid file name');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,28 +434,28 @@ class file_storage {
|
||||
|
||||
// validate all parameters, we do not want any rubbish stored in database, right?
|
||||
if (!is_number($file_record->contextid) or $file_record->contextid < 1) {
|
||||
throw new file_exception('localfileproblem', 'Invalid contextid');
|
||||
throw new file_exception('storedfileproblem', 'Invalid contextid');
|
||||
}
|
||||
|
||||
$file_record->filearea = clean_param($file_record->filearea, PARAM_ALPHAEXT);
|
||||
if ($file_record->filearea === '') {
|
||||
throw new file_exception('localfileproblem', 'Invalid filearea');
|
||||
throw new file_exception('storedfileproblem', 'Invalid filearea');
|
||||
}
|
||||
|
||||
if (!is_number($file_record->itemid) or $file_record->itemid < 0) {
|
||||
throw new file_exception('localfileproblem', 'Invalid itemid');
|
||||
throw new file_exception('storedfileproblem', 'Invalid itemid');
|
||||
}
|
||||
|
||||
$file_record->filepath = clean_param($file_record->filepath, PARAM_PATH);
|
||||
if (strpos($file_record->filepath, '/') !== 0 or strrpos($file_record->filepath, '/') !== strlen($file_record->filepath)-1) {
|
||||
// path must start and end with '/'
|
||||
throw new file_exception('localfileproblem', 'Invalid file path');
|
||||
throw new file_exception('storedfileproblem', 'Invalid file path');
|
||||
}
|
||||
|
||||
$file_record->filename = clean_param($file_record->filename, PARAM_FILE);
|
||||
if ($file_record->filename === '') {
|
||||
// path must start and end with '/'
|
||||
throw new file_exception('localfileproblem', 'Invalid file name');
|
||||
throw new file_exception('storedfileproblem', 'Invalid file name');
|
||||
}
|
||||
|
||||
$now = time();
|
||||
@@ -509,28 +509,28 @@ class file_storage {
|
||||
|
||||
// validate all parameters, we do not want any rubbish stored in database, right?
|
||||
if (!is_number($file_record->contextid) or $file_record->contextid < 1) {
|
||||
throw new file_exception('localfileproblem', 'Invalid contextid');
|
||||
throw new file_exception('storedfileproblem', 'Invalid contextid');
|
||||
}
|
||||
|
||||
$file_record->filearea = clean_param($file_record->filearea, PARAM_ALPHAEXT);
|
||||
if ($file_record->filearea === '') {
|
||||
throw new file_exception('localfileproblem', 'Invalid filearea');
|
||||
throw new file_exception('storedfileproblem', 'Invalid filearea');
|
||||
}
|
||||
|
||||
if (!is_number($file_record->itemid) or $file_record->itemid < 0) {
|
||||
throw new file_exception('localfileproblem', 'Invalid itemid');
|
||||
throw new file_exception('storedfileproblem', 'Invalid itemid');
|
||||
}
|
||||
|
||||
$file_record->filepath = clean_param($file_record->filepath, PARAM_PATH);
|
||||
if (strpos($file_record->filepath, '/') !== 0 or strrpos($file_record->filepath, '/') !== strlen($file_record->filepath)-1) {
|
||||
// path must start and end with '/'
|
||||
throw new file_exception('localfileproblem', 'Invalid file path');
|
||||
throw new file_exception('storedfileproblem', 'Invalid file path');
|
||||
}
|
||||
|
||||
$file_record->filename = clean_param($file_record->filename, PARAM_FILE);
|
||||
if ($file_record->filename === '') {
|
||||
// path must start and end with '/'
|
||||
throw new file_exception('localfileproblem', 'Invalid file name');
|
||||
throw new file_exception('storedfileproblem', 'Invalid file name');
|
||||
}
|
||||
|
||||
$now = time();
|
||||
@@ -579,7 +579,7 @@ class file_storage {
|
||||
*/
|
||||
public function add_file_to_pool($pathname, $contenthash=null) {
|
||||
if (!is_readable($pathname)) {
|
||||
throw new file_exception('localfilecannotread');
|
||||
throw new file_exception('storedfilecannotread');
|
||||
}
|
||||
|
||||
if (is_null($contenthash)) {
|
||||
@@ -599,12 +599,12 @@ class file_storage {
|
||||
|
||||
} else {
|
||||
if (!check_dir_exists($hashpath, true, true)) {
|
||||
throw new file_exception('localfilecannotcreatefiledirs'); // permission trouble
|
||||
throw new file_exception('storedfilecannotcreatefiledirs'); // permission trouble
|
||||
}
|
||||
$newfile = true;
|
||||
|
||||
if (!copy($pathname, $hashfile)) {
|
||||
throw new file_exception('localfilecannotread');
|
||||
throw new file_exception('storedfilecannotread');
|
||||
}
|
||||
|
||||
if (filesize($hashfile) !== $filesize) {
|
||||
@@ -638,7 +638,7 @@ class file_storage {
|
||||
|
||||
} else {
|
||||
if (!check_dir_exists($hashpath, true, true)) {
|
||||
throw new file_exception('localfilecannotcreatefiledirs'); // permission trouble
|
||||
throw new file_exception('storedfilecannotcreatefiledirs'); // permission trouble
|
||||
}
|
||||
$newfile = true;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class stored_file {
|
||||
public function get_content_file_handle() {
|
||||
$path = $this->get_content_file_location();
|
||||
if (!is_readable($path)) {
|
||||
throw new file_exception('localfilecannotread');
|
||||
throw new file_exception('storedfilecannotread');
|
||||
}
|
||||
return fopen($path, 'rb'); //binary reading only!!
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class stored_file {
|
||||
public function readfile() {
|
||||
$path = $this->get_content_file_location();
|
||||
if (!is_readable($path)) {
|
||||
throw new file_exception('localfilecannotread');
|
||||
throw new file_exception('storedfilecannotread');
|
||||
}
|
||||
readfile($path);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class stored_file {
|
||||
public function get_content() {
|
||||
$path = $this->get_content_file_location();
|
||||
if (!is_readable($path)) {
|
||||
throw new file_exception('localfilecannotread');
|
||||
throw new file_exception('storedfilecannotread');
|
||||
}
|
||||
return file_get_contents($this->get_content_file_location());
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class stored_file {
|
||||
public function copy_content_to($pathname) {
|
||||
$path = $this->get_content_file_location();
|
||||
if (!is_readable($path)) {
|
||||
throw new file_exception('localfilecannotread');
|
||||
throw new file_exception('storedfilecannotread');
|
||||
}
|
||||
return copy($path, $pathname);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user