|
@@ -159,6 +159,8 @@ function CreateFolder( $resourceType, $currentFolder )
|
|
|
|
|
|
function FileUpload( $resourceType, $currentFolder, $sCommand )
|
|
|
{
|
|
|
+ // TODO: System's black and white lists to be taken into account.
|
|
|
+
|
|
|
if (!isset($_FILES)) {
|
|
|
global $_FILES;
|
|
|
}
|
|
@@ -264,6 +266,32 @@ function FileUpload( $resourceType, $currentFolder, $sCommand )
|
|
|
else
|
|
|
$sErrorNumber = '202' ;
|
|
|
|
|
|
+ if ($sErrorNumber == '0')
|
|
|
+ {
|
|
|
+ // While we are in a course: Registering the newly created folder in the course's database.
|
|
|
+ if (api_is_in_course())
|
|
|
+ {
|
|
|
+ global $_course, $_user;
|
|
|
+ $repository_path = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/';
|
|
|
+ $to_group_id = 0;
|
|
|
+
|
|
|
+ if (api_is_in_group())
|
|
|
+ {
|
|
|
+ global $group_properties;
|
|
|
+ $to_group_id = $group_properties['id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $file_path = substr($sFilePath, strpos($sFilePath, $repository_path) + strlen($repository_path) - 1);
|
|
|
+ $path = explode('/', $file_path);
|
|
|
+ $file_name = $path[count($path) - 1];
|
|
|
+ $path[count($path) - 1] = '';
|
|
|
+ $folder_path = '/' + implode('/', $path);
|
|
|
+ $file_size = @filesize($sFilePath);
|
|
|
+ $doc_id = add_document($_course, $file_path, 'file', $file_size, $file_name);
|
|
|
+ api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], $to_group_id);
|
|
|
+ item_property_update_on_folder($_course, $folder_path, $_user['user_id']);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
$sFileUrl = CombinePaths( GetResourceTypePath( $resourceType, $sCommand ) , $currentFolder ) ;
|
|
|
$sFileUrl = CombinePaths( $sFileUrl, $sFileName ) ;
|