Merge branch 'MDL-34607-master' of git://github.com/FMCorz/moodle

Conflicts:
	lib/db/upgrade.php
	version.php
This commit is contained in:
Sam Hemelryk
2012-09-25 09:51:28 +12:00
3 changed files with 32 additions and 3 deletions
+10
View File
@@ -1220,5 +1220,15 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012091700.00);
}
if ($oldversion < 2012092100.01) {
// Some folders still have a sortorder set, which is used for main files but is not
// supported by the folder resource. We reset the value here.
$sql = 'UPDATE {files} SET sortorder = ? WHERE component = ? AND filearea = ? AND sortorder <> ?';
$DB->execute($sql, array(0, 'mod_folder', 'content', 0));
// Main savepoint reached.
upgrade_main_savepoint(true, 2012092100.01);
}
return true;
}
+21 -2
View File
@@ -398,7 +398,7 @@ class file_storage {
* @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 = "itemid, filepath, filename", $includedirs = true) {
global $DB;
$conditions = array('contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea);
@@ -443,7 +443,7 @@ class file_storage {
*/
public function get_area_tree($contextid, $component, $filearea, $itemid) {
$result = array('dirname'=>'', 'dirfile'=>null, 'subdirs'=>array(), 'files'=>array());
$files = $this->get_area_files($contextid, $component, $filearea, $itemid, "sortorder, itemid, filepath, filename", true);
$files = $this->get_area_files($contextid, $component, $filearea, $itemid, '', true);
// first create directory structure
foreach ($files as $hash=>$dir) {
if (!$dir->is_directory()) {
@@ -480,9 +480,28 @@ class file_storage {
$pointer['files'][$file->get_filename()] = $file;
unset($pointer);
}
$result = $this->sort_area_tree($result);
return $result;
}
/**
* Sorts the result of {@link file_storage::get_area_tree()}.
*
* @param array $tree Array of results provided by {@link file_storage::get_area_tree()}
* @return array of sorted results
*/
protected function sort_area_tree($tree) {
foreach ($tree as $key => &$value) {
if ($key == 'subdirs') {
$value = $this->sort_area_tree($value);
collatorlib::ksort($value, collatorlib::SORT_NATURAL);
} else if ($key == 'files') {
collatorlib::ksort($value, collatorlib::SORT_NATURAL);
}
}
return $tree;
}
/**
* Returns all files and optionally directories
*
+1 -1
View File
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2012092100.00; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012092100.01; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes