Admin: Add configuration setting 'skip_scorm_package_clean_up' BT#16922

Skip rename the scorm files (except .htaccess and php files)
pull/3141/head
Julio Montoya 6 years ago
parent 977fbdcdde
commit c674baa7c2
  1. 37
      main/inc/lib/fileUpload.lib.php
  2. 5
      main/install/configuration.dist.php
  3. 10
      main/lp/scorm.class.php

@ -1221,6 +1221,27 @@ function clean_up_files_in_zip($p_event, &$p_header)
return 1;
}
function cleanZipFilesNoRename($p_event, &$p_header)
{
$originalStoredFileName = $p_header['stored_filename'];
$baseName = basename($originalStoredFileName);
// Skip files
$skipFiles = [
'__MACOSX',
'.Thumbs.db',
'Thumbs.db',
];
if (in_array($baseName, $skipFiles)) {
return 0;
}
$modifiedStoredFileName = clean_up_path($originalStoredFileName, false);
$p_header['filename'] = str_replace($originalStoredFileName, $modifiedStoredFileName, $p_header['filename']);
return 1;
}
/**
* Allow .htaccess file.
*
@ -1260,13 +1281,14 @@ function cleanZipFilesAllowHtaccess($p_event, &$p_header)
* by eliminating dangerous file names and cleaning them.
*
* @param string $path
* @param bool $replaceName
*
* @return string
*
* @see disable_dangerous_file()
* @see api_replace_dangerous_char()
*/
function clean_up_path($path)
function clean_up_path($path, $replaceName = true)
{
// Split the path in folders and files
$path_array = explode('/', $path);
@ -1274,7 +1296,10 @@ function clean_up_path($path)
foreach ($path_array as $key => &$val) {
// We don't want to lose the dots in ././folder/file (cfr. zipfile)
if ($val != '.') {
$val = disable_dangerous_file(api_replace_dangerous_char($val));
if ($replaceName) {
$val = api_replace_dangerous_char($val);
}
$val = disable_dangerous_file($val);
}
}
// Join the "cleaned" path (modified in-place as passed by reference)
@ -1510,11 +1535,11 @@ function item_property_update_on_folder($_course, $path, $user_id)
if ($folder_id) {
$sql = "UPDATE $table SET
lastedit_date = '$time',
lastedit_type = 'DocumentInFolderUpdated',
lastedit_type = 'DocumentInFolderUpdated',
lastedit_user_id='$user_id'
WHERE
c_id = $course_id AND
tool='".TOOL_DOCUMENT."' AND
WHERE
c_id = $course_id AND
tool='".TOOL_DOCUMENT."' AND
ref = '$folder_id'";
Database::query($sql);
}

@ -1390,7 +1390,7 @@ ALTER TABLE notification_event ADD COLUMN event_id INT NULL;
//$_configuration['scorm_api_username_as_student_id'] = false;
// In Scorm comunication use a specific extra field instead of the user_id
//$_configuration['scorm_api_extrafield_to_use_as_student_id'] = "";
//$_configuration['scorm_api_extrafield_to_use_as_student_id'] = '';
// Show online user only to Administrators
//$_configuration['whoisonline_only_for_admin'] = false;
@ -1419,6 +1419,9 @@ ALTER TABLE notification_event ADD COLUMN event_id INT NULL;
// id of the admin to attach user session
//$_configuration['session_automatic_creation_user_id'] = 1;
// Skip scorm package file names clean up
//$_configuration['skip_scorm_package_clean_up'] = false;
// KEEP THIS AT THE END
// -------- Custom DB changes
// Add user activation by confirmation email

@ -752,6 +752,10 @@ class scorm extends learnpath
$callBack = 'cleanZipFilesAllowHtaccess';
}
if (api_get_configuration_value('skip_scorm_package_clean_up')) {
$callBack = 'cleanZipFilesNoRename';
}
$zipFile->extract(
PCLZIP_CB_PRE_EXTRACT,
$callBack
@ -809,7 +813,7 @@ class scorm extends learnpath
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET theme = '$theme'
$sql = "UPDATE $tbl_lp SET theme = '$theme'
WHERE iid = $lp";
$res = Database::query($sql);
@ -834,7 +838,7 @@ class scorm extends learnpath
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image'
$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image'
WHERE iid = $lp";
$res = Database::query($sql);
@ -859,7 +863,7 @@ class scorm extends learnpath
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET author = '$author'
$sql = "UPDATE $tbl_lp SET author = '$author'
WHERE iid = ".$lp;
$res = Database::query($sql);

Loading…
Cancel
Save