Merge branch 'wip-MDL-33399-m23' of git://github.com/samhemelryk/moodle
This commit is contained in:
@@ -505,7 +505,7 @@ class file_info_stored extends file_info {
|
||||
if ($this->is_directory()) {
|
||||
$filepath = $this->lf->get_filepath();
|
||||
$fs = get_file_storage();
|
||||
$storedfiles = $fs->get_area_files($this->context->id, $this->get_component(), $this->lf->get_filearea(), $this->lf->get_itemid(), "");
|
||||
$storedfiles = $fs->get_area_files($this->context->id, $this->get_component(), $this->lf->get_filearea(), $this->lf->get_itemid());
|
||||
foreach ($storedfiles as $file) {
|
||||
if (strpos($file->get_filepath(), $filepath) === 0) {
|
||||
$file->delete();
|
||||
|
||||
@@ -366,7 +366,7 @@ class file_storage {
|
||||
* Returns all files belonging to given repository
|
||||
*
|
||||
* @param int $repositoryid
|
||||
* @param string $sort
|
||||
* @param string $sort A fragment of SQL to use for sorting
|
||||
*/
|
||||
public function get_external_files($repositoryid, $sort = 'sortorder, itemid, filepath, filename') {
|
||||
global $DB;
|
||||
@@ -374,8 +374,10 @@ class file_storage {
|
||||
FROM {files} f
|
||||
LEFT JOIN {files_reference} r
|
||||
ON f.referencefileid = r.id
|
||||
WHERE r.repositoryid = ?
|
||||
ORDER BY $sort";
|
||||
WHERE r.repositoryid = ?";
|
||||
if (!empty($sort)) {
|
||||
$sql .= " ORDER BY {$sort}";
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$filerecords = $DB->get_records_sql($sql, array($repositoryid));
|
||||
@@ -392,11 +394,11 @@ class file_storage {
|
||||
* @param string $component component
|
||||
* @param string $filearea file area
|
||||
* @param int $itemid item ID or all files if not specified
|
||||
* @param string $sort sort fields
|
||||
* @param string $sort A fragment of SQL to use for sorting
|
||||
* @param bool $includedirs whether or not include directories
|
||||
* @return array of stored_files indexed by pathanmehash
|
||||
*/
|
||||
public function get_area_files($contextid, $component, $filearea, $itemid = false, $sort="sortorder, itemid, filepath, filename", $includedirs = true) {
|
||||
public function get_area_files($contextid, $component, $filearea, $itemid = false, $sort = "sortorder, itemid, filepath, filename", $includedirs = true) {
|
||||
global $DB;
|
||||
|
||||
$conditions = array('contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea);
|
||||
@@ -414,8 +416,10 @@ class file_storage {
|
||||
WHERE f.contextid = :contextid
|
||||
AND f.component = :component
|
||||
AND f.filearea = :filearea
|
||||
$itemidsql
|
||||
ORDER BY $sort";
|
||||
$itemidsql";
|
||||
if (!empty($sort)) {
|
||||
$sql .= " ORDER BY {$sort}";
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$filerecords = $DB->get_records_sql($sql, $conditions);
|
||||
@@ -489,7 +493,7 @@ class file_storage {
|
||||
* @param int $filepath directory path
|
||||
* @param bool $recursive include all subdirectories
|
||||
* @param bool $includedirs include files and directories
|
||||
* @param string $sort sort fields
|
||||
* @param string $sort A fragment of SQL to use for sorting
|
||||
* @return array of stored_files indexed by pathanmehash
|
||||
*/
|
||||
public function get_directory_files($contextid, $component, $filearea, $itemid, $filepath, $recursive = false, $includedirs = true, $sort = "filepath, filename") {
|
||||
@@ -499,6 +503,8 @@ class file_storage {
|
||||
return array();
|
||||
}
|
||||
|
||||
$orderby = (!empty($sort)) ? " ORDER BY {$sort}" : '';
|
||||
|
||||
if ($recursive) {
|
||||
|
||||
$dirs = $includedirs ? "" : "AND filename <> '.'";
|
||||
@@ -512,7 +518,7 @@ class file_storage {
|
||||
AND ".$DB->sql_substr("f.filepath", 1, $length)." = :filepath
|
||||
AND f.id <> :dirid
|
||||
$dirs
|
||||
ORDER BY $sort";
|
||||
$orderby";
|
||||
$params = array('contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>$itemid, 'filepath'=>$filepath, 'dirid'=>$directory->get_id());
|
||||
|
||||
$files = array();
|
||||
@@ -542,7 +548,7 @@ class file_storage {
|
||||
AND f.itemid = :itemid AND f.filename = '.'
|
||||
AND ".$DB->sql_substr("f.filepath", 1, $length)." = :filepath
|
||||
AND f.id <> :dirid
|
||||
ORDER BY $sort";
|
||||
$orderby";
|
||||
$reqlevel = substr_count($filepath, '/') + 1;
|
||||
$filerecords = $DB->get_records_sql($sql, $params);
|
||||
foreach ($filerecords as $filerecord) {
|
||||
@@ -559,7 +565,7 @@ class file_storage {
|
||||
ON f.referencefileid = r.id
|
||||
WHERE f.contextid = :contextid AND f.component = :component AND f.filearea = :filearea AND f.itemid = :itemid
|
||||
AND f.filepath = :filepath AND f.filename <> '.'
|
||||
ORDER BY $sort";
|
||||
$orderby";
|
||||
|
||||
$filerecords = $DB->get_records_sql($sql, $params);
|
||||
foreach ($filerecords as $filerecord) {
|
||||
|
||||
@@ -809,7 +809,7 @@ class portfolio_exporter {
|
||||
*/
|
||||
public function get_tempfiles($skipfile='portfolio-export.zip') {
|
||||
$fs = get_file_storage();
|
||||
$files = $fs->get_area_files(SYSCONTEXTID, 'portfolio', 'exporter', $this->id, '', false);
|
||||
$files = $fs->get_area_files(SYSCONTEXTID, 'portfolio', 'exporter', $this->id, 'sortorder, itemid, filepath, filename', false);
|
||||
if (empty($files)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ function scorm_parse_aicc($scorm) {
|
||||
|
||||
$fs = get_file_storage();
|
||||
|
||||
$files = $fs->get_area_files($context->id, 'mod_scorm', 'content', 0, '', false);
|
||||
$files = $fs->get_area_files($context->id, 'mod_scorm', 'content', 0, 'sortorder, itemid, filepath, filename', false);
|
||||
|
||||
$version = 'AICC';
|
||||
$ids = array();
|
||||
|
||||
Reference in New Issue
Block a user