Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-32867 filemanager and repository

1. Allowing "." as filename, so filemanager can rename folder
2. Fixed import_external_file method
3. Disallow recent repository to list file references
  • Loading branch information...
commit fc4e8034fcebfb787c522dac49fba9f38a683b4b 1 parent 55e8680
@dcai dcai authored marinaglancy committed
View
13 lib/filestorage/file_storage.php
@@ -1777,19 +1777,16 @@ public function get_references_count_by_storedfile($storedfile) {
* Convert file alias to local file
*
* @param stored_file $storedfile a stored_file instances
- * @return stored_file|bool stored_file or return false when fail
+ * @return stored_file stored_file
*/
public function import_external_file($storedfile) {
global $CFG;
require_once($CFG->dirroot.'/repository/lib.php');
// sync external file
- if (repository::sync_external_file($storedfile)) {
- // Remove file references
- $storedfile->delete_reference();
- return $storedfile;
- } else {
- return false;
- }
+ repository::sync_external_file($storedfile);
+ // Remove file references
+ $storedfile->delete_reference();
+ return $storedfile;
}
/**
View
5 lib/filestorage/stored_file.php
@@ -126,7 +126,10 @@ protected function update($dataobject) {
}
if ($field == 'filename') {
- $value = clean_param($value, PARAM_FILE);
+ // folder has filename == '.', so we pass this
+ if ($value != '.') {
+ $value = clean_param($value, PARAM_FILE);
+ }
if ($value === '') {
throw new file_exception('storedfileproblem', 'Invalid file name');
}
View
7 repository/recent/lib.php
@@ -64,8 +64,12 @@ public function print_login() {
private function get_recent_files($limitfrom = 0, $limit = DEFAULT_RECENT_FILES_NUM) {
// XXX: get current itemid
global $USER, $DB, $itemid;
+ // This SQL will ignore draft files if not owned by current user.
+ // Ignore all file references.
$sql = 'SELECT files1.*
FROM {files} files1
+ LEFT JOIN {files_reference} r
+ ON files1.referencefileid = r.id
JOIN (
SELECT contenthash, filename, MAX(id) AS id
FROM {files}
@@ -74,7 +78,8 @@ private function get_recent_files($limitfrom = 0, $limit = DEFAULT_RECENT_FILES_
AND ((filearea = :filearea1 AND itemid = :itemid) OR filearea != :filearea2)
GROUP BY contenthash, filename
) files2 ON files1.id = files2.id
- ORDER BY files1.timemodified DESC';
+ WHERE r.repositoryid is NULL
+ ORDER BY files1.timemodified DESC';
$params = array(
'userid' => $USER->id,
'filename' => '.',
Please sign in to comment.
Something went wrong with that request. Please try again.