* 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;
}
/**
}
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');
}
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}
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' => '.',