|
22 | 22 | * Configuration file for the File Manager Connector for PHP. |
23 | 23 | */ |
24 | 24 |
|
25 | | -// Modifications by Ivan Tcholakov, JUN-2009. |
| 25 | +// Modifications by Ivan Tcholakov, JUN-2009. |
26 | 26 |
|
27 | 27 | // Some language variables are needed. |
28 | 28 | $language_file = array('create_course'); |
29 | 29 |
|
30 | 30 | // Loading the global initialization file, Chamilo LMS. |
31 | 31 | require_once '../../../../../../global.inc.php'; |
32 | 32 |
|
| 33 | +// Disabling access for anonymous users. |
| 34 | +api_block_anonymous_users(); |
| 35 | + |
33 | 36 | // Initialization of the repositories. |
34 | 37 | require_once api_get_path(LIBRARY_PATH).'fckeditor/repository.php' ; |
35 | 38 |
|
36 | | -global $Config ; |
| 39 | +global $Config; |
37 | 40 |
|
38 | 41 | // SECURITY: You must explicitly enable this "connector". (Set it to "true"). |
39 | 42 | // WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only |
40 | 43 | // authenticated users can access this file or use some kind of session checking. |
41 | 44 | $Config['Enabled'] = true ; |
42 | 45 |
|
43 | | - |
44 | 46 | // Path to user files relative to the document root. |
45 | | -//$Config['UserFilesPath'] |
| 47 | +$Config['UserFilesPath'] = null; |
| 48 | + |
| 49 | +$userId = api_get_user_id(); |
| 50 | + |
| 51 | + |
46 | 52 | if (api_is_in_course()) { |
47 | | - if (!api_is_in_group()) { |
48 | | - // 1. We are inside a course and not in a group. |
49 | | - if (api_is_allowed_to_edit()) { |
50 | | - $Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/'; |
51 | | - } else { |
52 | | - // 1.2. Student |
53 | | - $current_session_id = api_get_session_id(); |
54 | | - if($current_session_id==0) |
55 | | - { |
56 | | - $Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/'; |
57 | | - } |
58 | | - else |
59 | | - { |
60 | | - $Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/'; |
61 | | - } |
62 | | - } |
63 | | - } else { |
64 | | - // 2. Inside a course and inside a group. |
65 | | - global $group_properties; |
66 | | - $Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/'; |
67 | | - } |
| 53 | + $coursePath = api_get_path(REL_COURSE_PATH).api_get_course_path(); |
| 54 | + if (!api_is_in_group()) { |
| 55 | + // 1. We are inside a course and not in a group. |
| 56 | + if (api_is_allowed_to_edit()) { |
| 57 | + $Config['UserFilesPath'] = $coursePath.'/document/'; |
| 58 | + } else { |
| 59 | + // 1.2. Student |
| 60 | + $current_session_id = api_get_session_id(); |
| 61 | + if ($current_session_id == 0) { |
| 62 | + $Config['UserFilesPath'] = $coursePath.'/document/shared_folder/sf_user_'.$userId.'/'; |
| 63 | + } else { |
| 64 | + $Config['UserFilesPath'] = $coursePath.'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.$userId.'/'; |
| 65 | + } |
| 66 | + } |
| 67 | + } else { |
| 68 | + $groupId = api_get_group_id(); |
| 69 | + $groupInfo = GroupManager::get_group_properties($groupId); |
| 70 | + if (!empty($groupInfo)) { |
| 71 | + // 2. Inside a course and inside a group. |
| 72 | + $Config['UserFilesPath'] = $coursePath.'/document'.$groupInfo['directory'].'/'; |
| 73 | + } |
| 74 | + } |
68 | 75 | } else { |
69 | | - if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') { |
70 | | - // 3. Platform administration activities. |
71 | | - $Config['UserFilesPath'] = api_get_path(REL_PATH).'home/default_platform_document/'; |
72 | | - } else { |
73 | | - // 4. The user is outside courses. |
74 | | - $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'rel'); |
75 | | - $Config['UserFilesPath'] = $my_path['dir'].'my_files/'; |
76 | | - } |
| 76 | + if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') { |
| 77 | + // 3. Platform administration activities. |
| 78 | + $Config['UserFilesPath'] = api_get_path(REL_PATH).'home/default_platform_document/'; |
| 79 | + } else { |
| 80 | + // 4. The user is outside courses. |
| 81 | + $my_path = UserManager::get_user_picture_path_by_id($userId, 'rel'); |
| 82 | + $Config['UserFilesPath'] = $my_path['dir'].'my_files/'; |
| 83 | + } |
77 | 84 | } |
78 | 85 |
|
| 86 | +if (empty($Config['UserFilesPath'])) { |
| 87 | + api_not_allowed(true); |
| 88 | +} |
79 | 89 |
|
80 | 90 | // Fill the following value it you prefer to specify the absolute path for the |
81 | 91 | // user files directory. Useful if you are using a virtual directory, symbolic |
82 | 92 | // link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'. |
83 | 93 | // Attention: The above 'UserFilesPath' must point to the same directory. |
84 | | -$Config['UserFilesAbsolutePath'] = rtrim(api_get_path(SYS_SERVER_ROOT_PATH), '/') . $Config['UserFilesPath'] ; |
| 94 | +$Config['UserFilesAbsolutePath'] = rtrim(api_get_path(SYS_SERVER_ROOT_PATH), '/').$Config['UserFilesPath']; |
85 | 95 |
|
86 | 96 | // Due to security issues with Apache modules, it is recommended to leave the |
87 | 97 | // following setting enabled. |
88 | | -$Config['ForceSingleExtension'] = true ; |
| 98 | +$Config['ForceSingleExtension'] = true; |
89 | 99 |
|
90 | 100 | // Perform additional checks for image files. |
91 | 101 | // If set to true, validate image size (using getimagesize). |
92 | 102 | $Config['SecureImageUploads'] = true; |
93 | 103 |
|
94 | 104 | // What the user can do with this connector. |
95 | | -$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder') ; |
| 105 | +$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder'); |
96 | 106 |
|
97 | 107 | // Allowed Resource Types. |
98 | 108 | $Config['ConfigAllowedTypes'] = array('File', 'Audio', 'Images', 'Flash', 'Media', 'MP3', 'Video', 'Video/flv') ; |
|
160 | 170 | $Config['QuickUploadAbsolutePath']['Image'] = $Config['UserFilesAbsolutePath'] ; |
161 | 171 | into: |
162 | 172 | $Config['QuickUploadPath']['Image'] = $Config['FileTypesPath']['Image'] ; |
163 | | - $Config['QuickUploadAbsolutePath']['Image'] = $Config['FileTypesAbsolutePath']['Image'] ; |
164 | | -
|
| 173 | + $Config['QuickUploadAbsolutePath']['Image'] = $Config['FileTypesAbsolutePath']['Image']; |
165 | 174 | */ |
166 | 175 |
|
167 | 176 | // Files |
|
220 | 229 | $Config['FileTypesAbsolutePath']['Video/flv'] = $Config['UserFilesAbsolutePath'] . 'video/flv/' ; |
221 | 230 | $Config['QuickUploadPath']['Video/flv'] = $Config['UserFilesPath'] . 'video/flv/' ; |
222 | 231 | $Config['QuickUploadAbsolutePath']['Video/flv'] = $Config['UserFilesAbsolutePath'] . 'video/flv/' ; |
223 | | - |
224 | | -?> |
|
0 commit comments