]> git.mjollnir.org Git - moodle.git/commitdiff
This is required for directory resources
authormoodler <moodler>
Sun, 2 May 2004 15:31:23 +0000 (15:31 +0000)
committermoodler <moodler>
Sun, 2 May 2004 15:31:23 +0000 (15:31 +0000)
lib/moodlelib.php

index d3815b22a06f3beb0b291d2c10706c29ca21b2b5..277b5556b46938cb8593a171420885605c9f1530 100644 (file)
@@ -1520,10 +1520,11 @@ function get_max_upload_sizes($sitebytes=0, $coursebytes=0, $modulebytes=0) {
     return $filesize;
 }
 
-function get_directory_list($rootdir, $excludefile="", $descend=true) {
+function get_directory_list($rootdir, $excludefile="", $descend=true, $justdirs=false) {
 /// Returns an array with all the filenames in
 /// all subdirectories, relative to the given rootdir.
 /// If excludefile is defined, then that file/directory is ignored
+/// If justdirs is defined, then only subdirectories are listed, otherwise just files
 
     $dirs = array();
 
@@ -1540,13 +1541,16 @@ function get_directory_list($rootdir, $excludefile="", $descend=true) {
         if ($firstchar == "." or $file == "CVS" or $file == $excludefile) {
             continue;
         }
-        $fullfile = $rootdir."/".$file;
+        $fullfile = "$rootdir/$file";
         if ($descend and filetype($fullfile) == "dir") {
-            $subdirs = get_directory_list($fullfile, $excludefile, $descend);
+            if ($justdirs) {
+                $dirs[] = $file;
+            }
+            $subdirs = get_directory_list($fullfile, $excludefile, $descend, $justdirs);
             foreach ($subdirs as $subdir) {
-                $dirs[] = $file."/".$subdir;
+                $dirs[] = "$file/$subdir";
             }
-        } else {
+        } else if (!$justdirs) {
             $dirs[] = $file;
         }
     }