Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/3141/head
Angel Fernando Quiroz Campos 6 years ago
commit f55d478457
  1. 29
      main/inc/lib/fileUpload.lib.php
  2. 47
      main/inc/lib/tracking.lib.php
  3. 5
      main/install/configuration.dist.php
  4. 4
      main/lp/scorm.class.php

@ -1221,6 +1221,27 @@ function clean_up_files_in_zip($p_event, &$p_header)
return 1; 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. * Allow .htaccess file.
* *
@ -1260,13 +1281,14 @@ function cleanZipFilesAllowHtaccess($p_event, &$p_header)
* by eliminating dangerous file names and cleaning them. * by eliminating dangerous file names and cleaning them.
* *
* @param string $path * @param string $path
* @param bool $replaceName
* *
* @return string * @return string
* *
* @see disable_dangerous_file() * @see disable_dangerous_file()
* @see api_replace_dangerous_char() * @see api_replace_dangerous_char()
*/ */
function clean_up_path($path) function clean_up_path($path, $replaceName = true)
{ {
// Split the path in folders and files // Split the path in folders and files
$path_array = explode('/', $path); $path_array = explode('/', $path);
@ -1274,7 +1296,10 @@ function clean_up_path($path)
foreach ($path_array as $key => &$val) { foreach ($path_array as $key => &$val) {
// We don't want to lose the dots in ././folder/file (cfr. zipfile) // We don't want to lose the dots in ././folder/file (cfr. zipfile)
if ($val != '.') { 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) // Join the "cleaned" path (modified in-place as passed by reference)

@ -6867,14 +6867,12 @@ class Tracking
*/ */
public static function isAllowToTrack($sessionId) public static function isAllowToTrack($sessionId)
{ {
$allow = return
api_is_platform_admin(true, true) || api_is_platform_admin(true, true) ||
SessionManager::user_is_general_coach(api_get_user_id(), $sessionId) || SessionManager::user_is_general_coach(api_get_user_id(), $sessionId) ||
api_is_allowed_to_create_course() || api_is_allowed_to_create_course() ||
api_is_course_tutor() || api_is_course_tutor() ||
api_is_course_admin(); api_is_course_admin();
return $allow;
} }
public static function getCourseLpProgress($userId, $sessionId) public static function getCourseLpProgress($userId, $sessionId)
@ -6885,7 +6883,7 @@ class Tracking
$result = []; $result = [];
if ($courseList) { if ($courseList) {
$counter = 0; //$counter = 1;
foreach ($courseList as $course) { foreach ($courseList as $course) {
$courseId = $course['course_id']; $courseId = $course['course_id'];
$courseInfo = api_get_course_info_by_id($courseId); $courseInfo = api_get_course_info_by_id($courseId);
@ -6893,8 +6891,19 @@ class Tracking
continue; continue;
} }
$courseCode = $courseInfo['code']; $courseCode = $courseInfo['code'];
$categoriesTempList = learnpath::getCategories($courseId);
$time = self::get_time_spent_in_lp($userId, $courseCode, [], $sessionId);
$score = self::getAverageStudentScore($userId, $courseCode, [], $sessionId);
$progress = self::get_avg_student_progress($userId, $courseCode, [], $sessionId);
$result[] = [
'module' => $courseInfo['name'],
'progress' => $progress,
'qualification' => $score,
'activeTime' => $time,
];
/*
$categoriesTempList = learnpath::getCategories($courseId);
$categoryNone = new CLpCategory(); $categoryNone = new CLpCategory();
$categoryNone->setId(0); $categoryNone->setId(0);
$categoryNone->setName(get_lang('WithOutCategory')); $categoryNone->setName(get_lang('WithOutCategory'));
@ -6902,7 +6911,6 @@ class Tracking
$categories = array_merge([$categoryNone], $categoriesTempList); $categories = array_merge([$categoryNone], $categoriesTempList);
/** @var CLpCategory $category */
foreach ($categories as $category) { foreach ($categories as $category) {
$learnPathList = new LearnpathList( $learnPathList = new LearnpathList(
$userId, $userId,
@ -6966,33 +6974,8 @@ class Tracking
$time = self::get_time_spent_in_lp($userId, $courseCode, [], $sessionId); $time = self::get_time_spent_in_lp($userId, $courseCode, [], $sessionId);
$score = self::getAverageStudentScore($userId, $courseCode, [], $sessionId); $score = self::getAverageStudentScore($userId, $courseCode, [], $sessionId);
/*$listData[] = [
'id' => $lpId,
'title' => Security::remove_XSS($lpDetails['lp_name']),
'progress' => $progress,
'url' => api_get_path(WEB_CODE_PATH).'webservices/api/v2.php?'.http_build_query(
[
'hash' => $this->encodeParams(
[
'action' => 'course_learnpath',
'lp_id' => $lpId,
'course' => $this->course->getId(),
'session' => $sessionId,
]
),
]
),
];*/
$counter++;
$result['course'.$counter] = [
'module' => $lpDetails['lp_name'],
'progress' => $progress,
'qualification' => $score,
'activeTime' => $time,
];
}
} }
}*/
} }
} }

@ -1390,7 +1390,7 @@ ALTER TABLE notification_event ADD COLUMN event_id INT NULL;
//$_configuration['scorm_api_username_as_student_id'] = false; //$_configuration['scorm_api_username_as_student_id'] = false;
// In Scorm comunication use a specific extra field instead of the user_id // 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 // Show online user only to Administrators
//$_configuration['whoisonline_only_for_admin'] = false; //$_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 // id of the admin to attach user session
//$_configuration['session_automatic_creation_user_id'] = 1; //$_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 // KEEP THIS AT THE END
// -------- Custom DB changes // -------- Custom DB changes
// Add user activation by confirmation email // Add user activation by confirmation email

@ -752,6 +752,10 @@ class scorm extends learnpath
$callBack = 'cleanZipFilesAllowHtaccess'; $callBack = 'cleanZipFilesAllowHtaccess';
} }
if (api_get_configuration_value('skip_scorm_package_clean_up')) {
$callBack = 'cleanZipFilesNoRename';
}
$zipFile->extract( $zipFile->extract(
PCLZIP_CB_PRE_EXTRACT, PCLZIP_CB_PRE_EXTRACT,
$callBack $callBack

Loading…
Cancel
Save