Browse Source

Hides "protected" folders see #7491

Julio Montoya 10 years ago
parent
commit
09e5917144
1 changed files with 25 additions and 6 deletions
  1. 25 6
      main/inc/lib/document.lib.php

+ 25 - 6
main/inc/lib/document.lib.php

@@ -3223,7 +3223,7 @@ class DocumentManager
                 if (CourseManager::is_user_subscribed_in_course($user_id, $course_info['code'])) {
                     $user_in_course = true;
                 }
-                //Check if course is open then we can consider that the student is regitered to the course
+                // Check if course is open then we can consider that the student is registered to the course
                 if (isset($course_info) && in_array($course_info['visibility'], array(2, 3))) {
                     $user_in_course = true;
                 }
@@ -3261,6 +3261,13 @@ class DocumentManager
 
         $folderCondition = " AND docs.path LIKE '/%' ";
 
+        if (!api_is_allowed_to_edit()) {
+            $protectedFolders = self::getProtectedFolderFromStudent();
+            foreach ($protectedFolders as $folder) {
+                $folderCondition .= " AND docs.path NOT LIKE '$folder' ";
+            }
+        }
+
         if ($folderId !== false) {
             $parentData = self::get_document_data_by_id($folderId, $course_info['code']);
             if (!empty($parentData)) {
@@ -3443,7 +3450,6 @@ class DocumentManager
                         });
                     }
     		    }
-
             }
     		</script>";
         }
@@ -3702,10 +3708,10 @@ class DocumentManager
                             $overwrite_url
                         );
                     }
-
                 }
             }
         }
+
         return $return;
     }
 
@@ -4178,9 +4184,9 @@ class DocumentManager
     /**
      * @return array
      */
-    static function get_system_folders()
+    public static function get_system_folders()
     {
-        $system_folders = array(
+        return array(
             '/certificates',
             '/HotPotatoes_files',
             '/chat_files',
@@ -4191,7 +4197,20 @@ class DocumentManager
             '/shared_folder',
             '/learning_path'
         );
-        return $system_folders;
+    }
+
+    /**
+     * @return array
+     */
+    public static function getProtectedFolderFromStudent()
+    {
+        return array(
+            '/certificates',
+            '/HotPotatoes_files',
+            '/chat_files',
+            '/shared_folder',
+            '/learning_path'
+        );
     }
 
     /**