From 09e5917144e33e5e5e37efce9c7ec76eb9289dcb Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 29 Jan 2015 09:37:52 +0100 Subject: [PATCH] Hides "protected" folders see #7491 --- main/inc/lib/document.lib.php | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 7d9ea11195..4e41d88e80 100755 --- a/main/inc/lib/document.lib.php +++ b/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 }); } } - } "; } @@ -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' + ); } /**