$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';
$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!';
$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;
}
$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);
}
}
$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);
}
}
}
$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)) {
}
$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;
$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);
}
}
$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);
}
$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);
}
$a->itemid = $itemid;
$a->filepath = $filepath;
$a->filename = $filename;
- parent::__construct('localfilenotcreated', $a, $debuginfo);
+ parent::__construct('storedfilenotcreated', $a, $debuginfo);
}
}
<?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) {
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;
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();
}
// 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',
// 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, '.');
$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);
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');
}
$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');
}
}
$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');
}
}
// 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();
// 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();
*/
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)) {
} 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) {
} else {
if (!check_dir_exists($hashpath, true, true)) {
- throw new file_exception('localfilecannotcreatefiledirs'); // permission trouble
+ throw new file_exception('storedfilecannotcreatefiledirs'); // permission trouble
}
$newfile = true;
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!!
}
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);
}
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());
}
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);
}