]> git.mjollnir.org Git - moodle.git/commitdiff
Ignore all files and directories beginning with "."
authormoodler <moodler>
Tue, 28 Jan 2003 03:34:26 +0000 (03:34 +0000)
committermoodler <moodler>
Tue, 28 Jan 2003 03:34:26 +0000 (03:34 +0000)
lib/moodlelib.php

index 441daf1aea1dd15d33aac79400cb37db1e41f056..592c6fcb853593bfeae7bdb0b78cba64a03bd4fb 100644 (file)
@@ -424,6 +424,9 @@ function isguest($userid=0) {
     global $USER;
 
     if (!$userid) {
+        if (empty($USER->username)) {
+            return false;
+        }
         return ($USER->username == "guest");
     }
 
@@ -832,16 +835,18 @@ function get_directory_list($rootdir, $excludefile="", $descend=true) {
     }
 
     while ($file = readdir($dir)) {
-        if ($file != "." and $file != ".." and $file != "CVS" and $file != $excludefile) {
-            $fullfile = $rootdir."/".$file;
-            if ($descend and filetype($fullfile) == "dir") {
-                $subdirs = get_directory_list($fullfile, $excludefile, $descend);
-                foreach ($subdirs as $subdir) {
-                    $dirs[] = $file."/".$subdir;
-                }
-            } else {
-                $dirs[] = $file;
+        $firstchar = substr($file, 0, 1);
+        if ($firstchar == "." or $file == "CVS" or $file == $excludefile) {
+            continue;
+        }
+        $fullfile = $rootdir."/".$file;
+        if ($descend and filetype($fullfile) == "dir") {
+            $subdirs = get_directory_list($fullfile, $excludefile, $descend);
+            foreach ($subdirs as $subdir) {
+                $dirs[] = $file."/".$subdir;
             }
+        } else {
+            $dirs[] = $file;
         }
     }
     closedir($dir);
@@ -1111,7 +1116,8 @@ function get_list_of_plugins($plugin="mod") {
 
     $basedir = opendir("$CFG->dirroot/$plugin");
     while ($dir = readdir($basedir)) {
-        if ($dir == "." || $dir == ".." || $dir == "CVS") {
+        $firstchar = substr($dir, 0, 1);
+        if ($firstchar == "." or $dir == "CVS") {
             continue;
         }
         if (filetype("$CFG->dirroot/$plugin/$dir") != "dir") {