|
|
|
@ -267,7 +267,8 @@ function handle_uploaded_document( |
|
|
|
$maxSpace, |
|
|
|
$maxSpace, |
|
|
|
$sessionId, |
|
|
|
$sessionId, |
|
|
|
$groupId, |
|
|
|
$groupId, |
|
|
|
$output |
|
|
|
$output, |
|
|
|
|
|
|
|
$onlyUploadFile |
|
|
|
); |
|
|
|
); |
|
|
|
} elseif ($unzip == 1 && !preg_match('/.zip$/', strtolower($uploadedFile['name']))) { |
|
|
|
} elseif ($unzip == 1 && !preg_match('/.zip$/', strtolower($uploadedFile['name']))) { |
|
|
|
// We can only unzip ZIP files (no gz, tar,...) |
|
|
|
// We can only unzip ZIP files (no gz, tar,...) |
|
|
|
@ -1036,14 +1037,15 @@ function unzip_uploaded_file($uploaded_file, $upload_path, $base_work_dir, $max_ |
|
|
|
* @param array $courseInfo |
|
|
|
* @param array $courseInfo |
|
|
|
* @param array $userInfo |
|
|
|
* @param array $userInfo |
|
|
|
* @param array $uploaded_file - follows the $_FILES Structure |
|
|
|
* @param array $uploaded_file - follows the $_FILES Structure |
|
|
|
* @param string $upload_path - destination of the upload. |
|
|
|
* @param string $uploadPath - destination of the upload. |
|
|
|
* This path is to append to $base_work_dir |
|
|
|
* This path is to append to $base_work_dir |
|
|
|
* @param string $base_work_dir - base working directory of the module |
|
|
|
* @param string $base_work_dir - base working directory of the module |
|
|
|
* @param int $maxFilledSpace - amount of bytes to not exceed in the base |
|
|
|
* @param int $maxFilledSpace - amount of bytes to not exceed in the base |
|
|
|
* working directory |
|
|
|
* working directory |
|
|
|
* @param int $sessionId |
|
|
|
* @param int $sessionId |
|
|
|
* @param int $groupId group.id |
|
|
|
* @param int $groupId group.id |
|
|
|
* @param boolean $output Optional. If no output not wanted on success, set to false. |
|
|
|
* @param bool $output Optional. If no output not wanted on success, set to false. |
|
|
|
|
|
|
|
* @param bool $onlyUploadFile |
|
|
|
* |
|
|
|
* |
|
|
|
* @return boolean true if it succeeds false otherwise |
|
|
|
* @return boolean true if it succeeds false otherwise |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -1056,7 +1058,8 @@ function unzip_uploaded_document( |
|
|
|
$maxFilledSpace, |
|
|
|
$maxFilledSpace, |
|
|
|
$sessionId = 0, |
|
|
|
$sessionId = 0, |
|
|
|
$groupId = 0, |
|
|
|
$groupId = 0, |
|
|
|
$output = true |
|
|
|
$output = true, |
|
|
|
|
|
|
|
$onlyUploadFile = false |
|
|
|
) { |
|
|
|
) { |
|
|
|
$zip = new PclZip($uploaded_file['tmp_name']); |
|
|
|
$zip = new PclZip($uploaded_file['tmp_name']); |
|
|
|
|
|
|
|
|
|
|
|
@ -1087,6 +1090,7 @@ function unzip_uploaded_document( |
|
|
|
PCLZIP_OPT_REPLACE_NEWER |
|
|
|
PCLZIP_OPT_REPLACE_NEWER |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($onlyUploadFile === false) { |
|
|
|
// Add all documents in the unzipped folder to the database |
|
|
|
// Add all documents in the unzipped folder to the database |
|
|
|
add_all_documents_in_folder_to_database( |
|
|
|
add_all_documents_in_folder_to_database( |
|
|
|
$courseInfo, |
|
|
|
$courseInfo, |
|
|
|
@ -1098,6 +1102,11 @@ function unzip_uploaded_document( |
|
|
|
$output, |
|
|
|
$output, |
|
|
|
array('path' => $uploadPath) |
|
|
|
array('path' => $uploadPath) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// Copy result |
|
|
|
|
|
|
|
$fs = new \Symfony\Component\Filesystem\Filesystem(); |
|
|
|
|
|
|
|
$fs->mirror($destinationDir, $base_work_dir.$uploadPath, null, ['overwrite']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (is_dir($destinationDir)) { |
|
|
|
if (is_dir($destinationDir)) { |
|
|
|
rmdirr($destinationDir); |
|
|
|
rmdirr($destinationDir); |
|
|
|
|