Fix course image redirection see BT#12234

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent f0a480b235
commit 869ed502dc
  1. 12
      .htaccess
  2. 2
      main/course_info/infocours.php
  3. 8
      main/inc/ajax/course.ajax.php
  4. 11
      main/inc/lib/course.lib.php

@ -27,15 +27,17 @@ RewriteRule ^courses/([^/]+)/scorm/(.*)$ main/document/download_scorm.php?doc_ur
RewriteRule ^courses/([^/]+)/document/certificates/(.*)$ app/courses/$1/document/certificates/$2 [QSA,L] RewriteRule ^courses/([^/]+)/document/certificates/(.*)$ app/courses/$1/document/certificates/$2 [QSA,L]
RewriteRule ^courses/([^/]+)/document/(.*)$ main/document/download.php?doc_url=/$2&cDir=$1 [QSA,L] RewriteRule ^courses/([^/]+)/document/(.*)$ main/document/download.php?doc_url=/$2&cDir=$1 [QSA,L]
# Course upload files
RewriteRule ^courses/([^/]+)/upload/([^/]+)/(.*)$ main/document/download_uploaded_files.php?code=$1&type=$2&file=$3 [QSA,L]
# Rewrite everything in the work folder # Rewrite everything in the work folder
RewriteRule ^courses/([^/]+)/work/(.*)$ main/work/download.php?file=work/$2&cDir=$1 [QSA,L] RewriteRule ^courses/([^/]+)/work/(.*)$ main/work/download.php?file=work/$2&cDir=$1 [QSA,L]
# Course upload files RewriteRule ^courses/([^/]+)/course-pic85x85.png$ main/inc/ajax/course.ajax.php?a=get_course_image&code=$1&image=course_image_source [QSA,L]
RewriteRule ^courses/([^/]+)/upload/([^/]+)/(.*)$ main/document/download_uploaded_files.php?code=$1&type=$2&file=$3 [QSA,L] RewriteRule ^courses/([^/]+)/course-pic.png$ main/inc/ajax/course.ajax.php?a=get_course_image&code=$1&image=course_image_large_source [QSA,L]
RewriteRule ^courses/([^/]+)/(.*)$ app/courses/$1/$2 [QSA,L]
RewriteRule ^courses/([^/]+)/course-pic85x85.png$ app/courses/$1/course-pic85x85.png [QSA,L] # Redirect all courses/ to app/courses/
RewriteRule ^courses/([^/]+)/course-pic.png$ app/courses/$1/course-pic.png [QSA,L] RewriteRule ^courses/([^/]+)/(.*)$ app/courses/$1/$2 [QSA,L]
# About session # About session
RewriteRule ^session/(\d{1,})/about/?$ main/session/about.php?session_id=$1 [L] RewriteRule ^session/(\d{1,})/about/?$ main/session/about.php?session_id=$1 [L]

@ -701,7 +701,7 @@ if ($form->validate() && is_settings_editable()) {
$picture = $_FILES['picture']; $picture = $_FILES['picture'];
if (!empty($picture['name'])) { if (!empty($picture['name'])) {
$picture_uri = CourseManager::update_course_picture( $picture_uri = CourseManager::update_course_picture(
$course_code, $_course,
$picture['name'], $picture['name'],
$picture['tmp_name'], $picture['tmp_name'],
$updateValues['picture_crop_result'] $updateValues['picture_crop_result']

@ -25,7 +25,13 @@ switch ($action) {
false false
); );
echo $rating; echo $rating;
break;
case 'get_course_image':
$courseInfo = api_get_course_info($_REQUEST['code']);
$image = isset($_REQUEST['image']) && in_array($_REQUEST['image'], ['course_image_large_source', 'course_image_source']) ? $_REQUEST['image'] : '';
if ($courseInfo && $image) {
DocumentManager::file_send_for_download($courseInfo[$image]);
}
break; break;
case 'get_user_courses': case 'get_user_courses':
if (api_is_platform_admin()) { if (api_is_platform_admin()) {

@ -3326,17 +3326,20 @@ class CourseManager
/** /**
* Update course picture * Update course picture
* @param string Course code * @param array $courseInfo
* @param string File name * @param string File name
* @param string The full system name of the image from which course picture will be created. * @param string The full system name of the image from which course picture will be created.
* @param string $cropParameters Optional string that contents "x,y,width,height" of a cropped image format * @param string $cropParameters Optional string that contents "x,y,width,height" of a cropped image format
* @return bool Returns the resulting. In case of internal error or negative validation returns FALSE. * @return bool Returns the resulting. In case of internal error or negative validation returns FALSE.
*/ */
public static function update_course_picture($course_code, $filename, $source_file = null, $cropParameters = null) public static function update_course_picture($courseInfo, $filename, $source_file = null, $cropParameters = null)
{ {
$course_info = api_get_course_info($course_code); if (empty($courseInfo)) {
return false;
}
// course path // course path
$store_path = api_get_path(SYS_COURSE_PATH) . $course_info['path']; $store_path = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'];
// image name for courses // image name for courses
$course_image = $store_path . '/course-pic.png'; $course_image = $store_path . '/course-pic.png';
$course_medium_image = $store_path . '/course-pic85x85.png'; $course_medium_image = $store_path . '/course-pic85x85.png';

Loading…
Cancel
Save