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

1.10.x
Angel Fernando Quiroz Campos 9 years ago
commit bcd829be2c
  1. 14
      main/auth/sso/sso_server_test.php
  2. 2
      main/coursecopy/classes/CourseSelectForm.class.php
  3. 2
      main/coursecopy/copy_course.php
  4. 141
      main/cron/import_csv.php
  5. 1
      main/document/document.php
  6. 5
      main/document/download.php
  7. 77
      main/exercice/exercise.php
  8. 1
      main/gradebook/gradebook_display_certificate.php
  9. 24
      main/gradebook/lib/GradebookUtils.php
  10. 17
      main/gradebook/lib/be/category.class.php
  11. 5
      main/gradebook/lib/fe/gradebooktable.class.php
  12. 5
      main/inc/lib/api.lib.php
  13. 23
      main/inc/lib/certificate.lib.php
  14. 16
      main/inc/lib/document.lib.php
  15. 1
      main/inc/lib/export.lib.inc.php
  16. 44
      main/inc/lib/sessionmanager.lib.php
  17. 51
      main/inc/lib/usermanager.lib.php
  18. 3
      main/inc/local.inc.php
  19. 80
      main/newscorm/lp_upload.php
  20. 8
      main/session/session_edit.php

@ -5,12 +5,18 @@
This is the "server" of my institution/university authentification "code"
1. Active all the SSO option in your Chamilo installation: main/admin/settings.php?category=Security
2. Make sure this script is located in the index page of the server you fill in the "Domain of the Single Sign On server" Chamilo setting
2. Copy the main/auth/sso/sso.class.php file to something else representing your remote system, like
sso.Remote.class.php and modify the class name in soo.Remote.class.php to "ssoRemote"
3. Insert the following setting manually in your database (change the selected_value from 'Remote'
to the name of your system (used in the filename and classname above).
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext)
VALUES ('sso_authentication_subclass',NULL,'textfield','Security','Remote','SSOAuthSubClassTitle','SSOAuthSubClassComment',NULL,NULL);
4. Make sure this script is located in the index page of the server you fill in the "Domain of the Single Sign On server" Chamilo setting
For example this script must be located in example.com/index.php if you set the "Domain of the Single Sign On server" = example.com
3. Create a user in chamilo and in your external system with login = "joe" and password = "doe"
4. Remember this is just a sample! Check the chamilo drupal extension for more information:
5. Create a user in chamilo and in your external system with login = "joe" and password = "doe"
6. Remember this is just a sample! Check the chamilo drupal extension for more information:
http://drupal.org/node/817682
5. When activating the settings in step 1, the principal Chamilo file main/inc/local.inc.php will load the class main/auth/sso.class.php library
7. When activating the settings in step 1, the principal Chamilo file main/inc/local.inc.php will load the class main/auth/sso.[class.php library
* that will redirect to this field with some parameters.
*
*/

@ -141,7 +141,7 @@ class CourseSelectForm
$course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
echo '<h3>';
echo get_lang('DestinationCourse').' : '.$course_infos['title'] . $sessionTitle;
echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
echo '</h3>';
}
echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';

@ -104,7 +104,7 @@ if (Security::check_token('post') && (
$options = array();
while ($obj = Database::fetch_object($res)) {
$courseInfo = api_get_course_info_by_id($obj->c_id);
$options[$courseInfo['code']] = $obj->title;
$options[$courseInfo['code']] = $obj->title.' ('.$obj->code.')';
}
$form = new FormValidator('copy_course', 'post', 'copy_course.php?'.api_get_cidreq());

@ -113,6 +113,14 @@ class ImportCsv
$isStatic = strpos($method, 'Static');
if ($method == 'importSessionsextidStatic') {
$method = 'importSessionsExtIdStatic';
}
if ($method == 'importUnsubsessionsextidStatic') {
$method = 'importUnsubsessionsExtidStatic';
}
if (method_exists($this, $method)) {
if (($method == 'importUnsubscribeStatic' ||
$method == 'importSubscribeStatic') ||
@ -155,6 +163,7 @@ class ImportCsv
'subscribe-static',
'unsubscribe-static'
);
foreach ($sections as $section) {
$this->logger->addInfo("-- Import $section --");
@ -180,6 +189,8 @@ class ImportCsv
'teachers-static',
'courses-static',
'sessions-static',
'sessionsextid-static',
'unsubsessionsextid-static',
'calendar-static',
);
@ -192,6 +203,7 @@ class ImportCsv
$files = $fileToProcessStatic[$section];
foreach ($files as $fileInfo) {
$method = $fileInfo['method'];
$file = $fileInfo['file'];
echo 'Static file: '.$file.PHP_EOL;
$this->logger->addInfo("Reading static file: $file");
@ -1063,6 +1075,134 @@ class ImportCsv
}
}
/**
* @param string $file
*/
private function importUnsubSessionsExtIdStatic($file)
{
$data = Import::csv_reader($file);
if (!empty($data)) {
$this->logger->addInfo(count($data) . " records found.");
foreach ($data as $row) {
$chamiloUserName = $row['UserName'];
$chamiloCourseCode = $row['CourseCode'];
$externalSessionId = $row['ExtSessionID'];
$dateStop = $row['DateStop'];
$chamiloSessionId = null;
if (!empty($externalSessionId)) {
$chamiloSessionId = SessionManager::get_session_id_from_original_id(
$externalSessionId,
$this->extraFieldIdNameList['session']
);
}
$sessionInfo = api_get_session_info($chamiloSessionId);
if (empty($sessionInfo)) {
$this->logger->addError('Session does not exists: '.$chamiloSessionId);
continue;
}
$courseInfo = api_get_course_info($chamiloCourseCode);
if (empty($courseInfo)) {
$this->logger->addError('Course does not exists: '.$courseInfo);
continue;
}
$userId = Usermanager::get_user_id_from_username($chamiloUserName);
if (empty($userId)) {
$this->logger->addError('User does not exists: '.$chamiloUserName);
continue;
}
SessionManager::removeUsersFromCourseSession(
array($userId),
$chamiloSessionId,
$courseInfo
);
$this->logger->addError(
"User '$chamiloUserName' was remove from Session: #$chamiloSessionId - Course: " . $courseInfo['code']
);
}
}
}
/**
*
* @param string $file
*/
private function importSessionsExtIdStatic($file)
{
$data = Import::csv_reader($file);
if (!empty($data)) {
$this->logger->addInfo(count($data) . " records found.");
foreach ($data as $row) {
$chamiloUserName = $row['UserName'];
$chamiloCourseCode = $row['CourseCode'];
$externalSessionId = $row['ExtSessionID'];
$type = $row['Type'];
$chamiloSessionId = null;
if (!empty($externalSessionId)) {
$chamiloSessionId = SessionManager::get_session_id_from_original_id(
$externalSessionId,
$this->extraFieldIdNameList['session']
);
}
$sessionInfo = api_get_session_info($chamiloSessionId);
if (empty($sessionInfo)) {
$this->logger->addError('Session does not exists: '.$chamiloSessionId);
continue;
}
$courseInfo = api_get_course_info($chamiloCourseCode);
if (empty($courseInfo)) {
$this->logger->addError('Course does not exists: '.$courseInfo);
continue;
}
$userId = Usermanager::get_user_id_from_username($chamiloUserName);
if (empty($userId)) {
$this->logger->addError('User does not exists: '.$chamiloUserName);
continue;
}
$status = null;
switch ($type) {
case 'student':
SessionManager::subscribe_users_to_session_course(
array($userId),
$chamiloSessionId,
$courseInfo['code'],
null,
false
);
break;
case 'teacher':
SessionManager::set_coach_to_course_session(
$userId,
$chamiloSessionId,
$courseInfo['code']
);
break;
}
$this->logger->addError(
"User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: " . $courseInfo['code']
);
}
}
}
/**
* Updates the session synchronize with the csv file.
* @param string $file
@ -1468,6 +1608,7 @@ class ImportCsv
$courseInfo['code'],
$chamiloSessionId
);
$this->logger->addError(
"User '$chamiloUserName' was removed from session: #$chamiloSessionId, Course: ".$courseInfo['code']
);

@ -621,6 +621,7 @@ if (isset($_GET['curdirpath']) &&
$content_html = DocumentManager::replace_user_info_into_html(
api_get_user_id(),
api_get_course_id(),
api_get_session_id(),
true
);

@ -72,7 +72,10 @@ if (isset($path_info['extension']) && $path_info['extension'] == 'swf') {
$fixed_url = str_replace('-', '_', $doc_url);
$doc_id = DocumentManager::get_document_id(api_get_course_info(), $doc_url);
if (!$doc_id) {
$fix_file_name = true;
$doc_id = DocumentManager::get_document_id(api_get_course_info(), $doc_url, '0');
if (!$doc_id) {
$fix_file_name = true;
}
}
}

@ -38,6 +38,7 @@ $courseInfo = api_get_course_info();
$courseId = $courseInfo['real_id'];
$userInfo = api_get_user_info();
$userId = $userInfo['id'];
$sessionId = api_get_session_id();
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
$userId,
$courseInfo
@ -182,7 +183,7 @@ if ($is_allowedToEdit) {
// we got variable $courseId $courseInfo session api_get_session_id()
$exerciseList = ExerciseLib::get_all_exercises_for_course_id(
$courseInfo,
api_get_session_id(),
$sessionId,
$courseId,
false
);
@ -231,17 +232,33 @@ if ($is_allowedToEdit) {
break;
case 'enable':
// enables an exercise
$objExerciseTmp->enable();
$objExerciseTmp->save();
api_item_property_update($courseInfo, TOOL_QUIZ, $objExerciseTmp->id, 'visible', $userId);
if (empty($sessionId)) {
$objExerciseTmp->enable();
$objExerciseTmp->save();
}
api_item_property_update(
$courseInfo,
TOOL_QUIZ,
$objExerciseTmp->id,
'visible',
$userId
);
// "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
Display :: display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable':
// disables an exercise
$objExerciseTmp->disable();
$objExerciseTmp->save();
api_item_property_update($courseInfo, TOOL_QUIZ, $objExerciseTmp->id, 'invisible', $userId);
if (empty($sessionId)) {
$objExerciseTmp->disable();
$objExerciseTmp->save();
}
api_item_property_update(
$courseInfo,
TOOL_QUIZ,
$objExerciseTmp->id,
'invisible',
$userId
);
Display :: display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable_results':
@ -586,7 +603,24 @@ if (!empty($exercise_list)) {
);
}
$visibility = api_get_item_visibility($courseInfo, TOOL_QUIZ, $my_exercise_id);
$visibility = api_get_item_visibility(
$courseInfo,
TOOL_QUIZ,
$my_exercise_id,
0
);
if (!empty($sessionId)) {
if ($visibility == 0) {
continue;
}
$visibility = api_get_item_visibility(
$courseInfo,
TOOL_QUIZ,
$my_exercise_id,
$sessionId
);
}
if ($row['active'] == 0 || $visibility == 0) {
$title = Display::tag('font', $cut_title, array('style' => 'color:grey'));
@ -685,6 +719,26 @@ if (!empty($exercise_list)) {
} else {
// not session
$actions = Display::return_icon('edit_na.png', get_lang('ExerciseEditionNotAvailableInSession'));
// Check if this exercise was added in a LP
if ($exercise_obj->exercise_was_added_in_lp == true) {
$actions .= Display::return_icon('invisible.png', get_lang('AddedToLPCannotBeAccessed'), '', ICON_SIZE_SMALL);
} else {
if ($row['active'] == 0 || $visibility == 0) {
$actions .= Display::url(
Display::return_icon('invisible.png', get_lang('Activate'), '', ICON_SIZE_SMALL),
'exercise.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']
);
} else {
// else if not active
$actions .= Display::url(
Display::return_icon('visible.png', get_lang('Deactivate'), '', ICON_SIZE_SMALL),
'exercise.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']
);
}
}
$actions .='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercise.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
@ -743,7 +797,12 @@ if (!empty($exercise_list)) {
$item .= Display::tag('td', $number_of_questions);
} else {
// Student only.
$visibility = api_get_item_visibility($courseInfo, TOOL_QUIZ, $my_exercise_id);
$visibility = api_get_item_visibility(
$courseInfo,
TOOL_QUIZ,
$my_exercise_id,
$sessionId
);
if ($visibility == 0) {
continue;

@ -61,7 +61,6 @@ switch ($action) {
if ($user_info['status'] == INVITEE) {
continue;
}
Category::register_user_certificate($cat_id, $user_info['user_id']);
}
}

@ -611,8 +611,10 @@ class GradebookUtils
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql = 'SELECT * FROM ' . $table_certificate . '
WHERE cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '"';
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
return $row;
}
@ -674,16 +676,18 @@ class GradebookUtils
}
/**
* @param $user_id
* @param $course_code
* @param int $user_id
* @param string $course_code
* @param int $sessionId
* @param bool $is_preview
* @param bool $hide_print_button
*
* @return array
*/
public static function get_user_certificate_content($user_id, $course_code, $is_preview = false, $hide_print_button = false)
public static function get_user_certificate_content($user_id, $course_code, $sessionId, $is_preview = false, $hide_print_button = false)
{
// Generate document HTML
$content_html = DocumentManager::replace_user_info_into_html($user_id, $course_code, $is_preview);
$content_html = DocumentManager::replace_user_info_into_html($user_id, $course_code, $sessionId, $is_preview);
$new_content_html = null;
$variables = null;
$contentHead = null;
@ -1201,7 +1205,7 @@ class GradebookUtils
*
* Get the achieved certificates for a user in courses
* @param int $userId The user id
* @param type $includeNonPublicCertificates Whether include the non-plublic certificates
* @param bool $includeNonPublicCertificates Whether include the non-plublic certificates
* @return array
*/
public static function getUserCertificatesInCourses($userId, $includeNonPublicCertificates = true)
@ -1250,7 +1254,7 @@ class GradebookUtils
/**
* Get the achieved certificates for a user in course sessions
* @param int $userId The user id
* @param type $includeNonPublicCertificates Whether include the non-plublic certificates
* @param bool $includeNonPublicCertificates Whether include the non-plublic certificates
* @return array
*/
public static function getUserCertificatesInSessions($userId, $includeNonPublicCertificates = true)
@ -1258,13 +1262,12 @@ class GradebookUtils
$userId = intval($userId);
$sessionList = [];
$sessions = SessionManager::get_sessions_by_user($userId);
$sessions = SessionManager::get_sessions_by_user($userId, true, true);
foreach ($sessions as $session) {
if (empty($session['courses'])) {
continue;
}
$sessionCourses = SessionManager::get_course_list_by_session_id($session['session_id']);
foreach ($sessionCourses as $course) {
@ -1291,7 +1294,10 @@ class GradebookUtils
$courseGradebookId = $courseGradebookCategory[0]->get_id();
$certificateInfo = GradebookUtils::get_certificate_by_user_id($courseGradebookId, $userId);
$certificateInfo = GradebookUtils::get_certificate_by_user_id(
$courseGradebookId,
$userId
);
if (empty($certificateInfo)) {
continue;

@ -1900,6 +1900,7 @@ class Category implements GradebookItem
public static function register_user_certificate($category_id, $user_id)
{
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
// Generating the total score for a course
$cats_course = Category::load(
@ -1941,7 +1942,7 @@ class Category implements GradebookItem
// A student always sees only the teacher's repartition
$scoretotal_display = $scoredisplay->display_score($scoretotal, SCORE_DIV_PERCENT);
if (!self::userFinishedCourse($user_id, $cats_course[0])) {
if (!self::userFinishedCourse($user_id, $cats_course[0], 0, $courseCode, $sessionId)) {
return false;
}
@ -2150,8 +2151,7 @@ class Category implements GradebookItem
$categoryId = 0,
$courseCode = null,
$sessionId = 0
)
{
) {
if (is_null($category) && empty($categoryId)) {
return false;
}
@ -2177,7 +2177,12 @@ class Category implements GradebookItem
$category = $cats_course[0];
}
$currentScore = self::getCurrentScore($userId, $category->get_id(), $courseCode, $sessionId);
$currentScore = self::getCurrentScore(
$userId,
$category->get_id(),
$courseCode,
$sessionId
);
$minCertificateScore = $category->get_certificate_min_score();
@ -2190,6 +2195,8 @@ class Category implements GradebookItem
* @param int $categoryId The gradebook category
* @param int $courseCode The course code
* @param int $sessionId Optional. The session id
* @param bool $recalculate
*
* @return float The score
*/
public static function getCurrentScore($userId, $categoryId, $courseCode, $sessionId = 0, $recalculate = false)
@ -2208,7 +2215,7 @@ class Category implements GradebookItem
'order' => 'registered_at DESC',
'limit' => '1'
],
'fisrt'
'first'
);
if (empty($resultData)) {

@ -716,7 +716,8 @@ class GradebookTable extends SortableTable
$content_html = DocumentManager::replace_user_info_into_html(
api_get_user_id(),
$course_code
$course_code,
api_get_session_id()
);
if (!empty($content_html)) {
@ -962,7 +963,7 @@ class GradebookTable extends SortableTable
case 'E' :
$cat = new Category();
$course_id = CourseManager::get_course_by_category($categoryId);
$show_message = $cat->show_message_resource_delete($course_id);
$show_message = $cat->show_message_resource_delete($course_id);
// course/platform admin can go to the view_results page
if (api_is_allowed_to_edit() && $show_message===false) {

@ -1162,7 +1162,6 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
if (api_is_platform_admin($allow_session_admins)) {
return true;
}
if (isset($course_info) && isset($course_info['visibility'])) {
switch ($course_info['visibility']) {
default:
@ -1902,7 +1901,7 @@ function api_format_course_array($course_data)
if (array_key_exists('add_teachers_to_sessions_courses', $course_data)) {
$_course['add_teachers_to_sessions_courses'] = $course_data['add_teachers_to_sessions_courses'];
}
if (file_exists(api_get_path(SYS_COURSE_PATH).$course_data['directory'].'/course-pic85x85.png')) {
$url_image = api_get_path(WEB_COURSE_PATH).$course_data['directory'].'/course-pic85x85.png';
} else {
@ -8058,7 +8057,7 @@ function api_unique_multidim_array($array, $key){
$temp_array = array();
$i = 0;
$key_array = array();
foreach($array as $val){
if(!in_array($val[$key],$key_array)){
$key_array[$i] = $val[$key];

@ -200,6 +200,7 @@ class Certificate extends Model
$new_content_html = GradebookUtils::get_user_certificate_content(
$this->user_id,
$my_category[0]->get_course_code(),
$my_category[0]->get_session_id(),
false,
$params['hide_print_button']
);
@ -328,7 +329,7 @@ class Certificate extends Model
$final_content = array();
if (!empty($content)) {
foreach($content as $key => $value) {
foreach ($content as $key => $value) {
$my_header = str_replace(array('((', '))') , '', $headers[$key]);
$final_content[$my_header] = $value;
}
@ -353,13 +354,15 @@ class Certificate extends Model
*/
$break_space = " \n\r ";
$text = $final_content['gradebook_institution'].' - '.$final_content['gradebook_sitename'].' - '.get_lang('Certification').$break_space.
get_lang('Student'). ': '.$final_content['user_firstname'].' '.$final_content['user_lastname'].$break_space.
get_lang('Teacher'). ': '.$final_content['teacher_firstname'].' '.$final_content['teacher_lastname'].$break_space.
get_lang('Date'). ': '.$final_content['date_certificate'].$break_space.
get_lang('Score'). ': '.$final_content['gradebook_grade'].$break_space.
'URL'. ': '.$final_content['certificate_link'];
$text =
$final_content['gradebook_institution'].' - '.
$final_content['gradebook_sitename'].' - '.
get_lang('Certification').$break_space.
get_lang('Student'). ': '.$final_content['user_firstname'].' '.$final_content['user_lastname'].$break_space.
get_lang('Teacher'). ': '.$final_content['teacher_firstname'].' '.$final_content['teacher_lastname'].$break_space.
get_lang('Date'). ': '.$final_content['date_certificate'].$break_space.
get_lang('Score'). ': '.$final_content['gradebook_grade'].$break_space.
'URL'. ': '.$final_content['certificate_link'];
return $text;
}
@ -383,7 +386,9 @@ class Certificate extends Model
} else {
// Check the course-level setting to make sure the certificate
// can be printed publicly
if (isset($this->certificate_data) && isset($this->certificate_data['cat_id'])) {
if (isset($this->certificate_data) &&
isset($this->certificate_data['cat_id'])
) {
$gradebook = new Gradebook();
$gradebook_info = $gradebook->get($this->certificate_data['cat_id']);
if (!empty($gradebook_info['course_code'])) {

@ -1777,6 +1777,7 @@ class DocumentManager
}
$sql = 'SELECT document_id FROM ' . $tbl_category . '
WHERE course_code="' . Database::escape_string($course_id) . '" ' . $sql_session;
$rs = Database::query($sql);
$num = Database::num_rows($rs);
if ($num == 0) {
@ -1791,16 +1792,22 @@ class DocumentManager
* allow replace user info in file html
* @param int $user_id
* @param string $course_code
* @param int $sessionId
* @param bool $is_preview
* @return string The html content of the certificate
*/
public static function replace_user_info_into_html($user_id, $course_code, $is_preview = false)
public static function replace_user_info_into_html($user_id, $course_code, $sessionId, $is_preview = false)
{
$user_id = intval($user_id);
$course_info = api_get_course_info($course_code);
$tbl_document = Database::get_course_table(TABLE_DOCUMENT);
$course_id = $course_info['real_id'];
$document_id = self::get_default_certificate_id($course_code);
$document_id = self::get_default_certificate_id(
$course_code,
$sessionId
);
$my_content_html = null;
if ($document_id) {
$sql = "SELECT path FROM $tbl_document
@ -1815,6 +1822,7 @@ class DocumentManager
$my_content_html = file_get_contents($filepath);
}
$all_user_info = self::get_all_info_to_certificate($user_id, $course_code, $is_preview);
$info_to_be_replaced_in_content_html = $all_user_info[0];
$info_to_replace_in_content_html = $all_user_info[1];
$new_content = str_replace(
@ -1891,7 +1899,8 @@ class DocumentManager
$url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $info_grade_certificate['id'];
//replace content
$info_to_replace_in_content_html = array($first_name,
$info_to_replace_in_content_html = array(
$first_name,
$last_name,
$organization_name,
$portal_name,
@ -1934,6 +1943,7 @@ class DocumentManager
$info_list[] = $info_to_be_replaced_in_content_html;
$info_list[] = $info_to_replace_in_content_html;
return $info_list;
}

@ -264,6 +264,7 @@ class Export
foreach ($data as &$printable_data_row) {
$column = 0;
foreach ($printable_data_row as &$printable_data_cell) {
$table->setCellContents($row, $column, $printable_data_cell);
//$table->updateCellAttributes($row, $column, $atributes);
$column++;

@ -1340,7 +1340,7 @@ class SessionManager
* @param int $duration
* @param array $extraFields
* @param int $sessionAdminId
* @param boolean $sendSubscritionNotification Optional.
* @param boolean $sendSubscriptionNotification Optional.
* Whether send a mail notification to users being subscribed
* @return mixed
*/
@ -1361,7 +1361,7 @@ class SessionManager
$duration = null,
$extraFields = array(),
$sessionAdminId = 0,
$sendSubscritionNotification = false
$sendSubscriptionNotification = false
) {
$name = trim(stripslashes($name));
$coachId = intval($coachId);
@ -1370,20 +1370,25 @@ class SessionManager
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
if (empty($name)) {
$msg = get_lang('SessionNameIsRequired');
return $msg;
Display::return_message(get_lang('SessionNameIsRequired'), 'warning');
return false;
} elseif (empty($coachId)) {
$msg = get_lang('CoachIsRequired');
return $msg;
Display::return_message(get_lang('CoachIsRequired'), 'warning');
return false;
} elseif (!empty($startDate) && !api_is_valid_date($startDate, 'Y-m-d H:i')) {
$msg = get_lang('InvalidStartDate');
return $msg;
Display::return_message(get_lang('InvalidStartDate'), 'warning');
return false;
} elseif (!empty($endDate) && !api_is_valid_date($endDate, 'Y-m-d H:i')) {
$msg = get_lang('InvalidEndDate');
return $msg;
Display::return_message(get_lang('InvalidEndDate'), 'warning');
return false;
} elseif (!empty($startDate) && !empty($endDate) && $startDate >= $endDate) {
$msg = get_lang('StartDateShouldBeBeforeEndDate');
return $msg;
Display::return_message(get_lang('StartDateShouldBeBeforeEndDate'), 'warning');
return false;
} else {
$sql = "SELECT id FROM $tbl_session WHERE name='" . Database::escape_string($name) . "'";
$rs = Database::query($sql);
@ -1395,8 +1400,9 @@ class SessionManager
}
if ($exists) {
$msg = get_lang('SessionNameAlreadyExists');
return $msg;
Display::return_message(get_lang('SessionNameAlreadyExists'), 'warning');
return false;
} else {
$values = [
'name' => $name,
@ -1405,7 +1411,7 @@ class SessionManager
'description'=> $description,
'show_description' => intval($showDescription),
'visibility' => $visibility,
'send_subscription_notification' => $sendSubscritionNotification
'send_subscription_notification' => $sendSubscriptionNotification
];
if (!empty($sessionAdminId)) {
@ -3953,16 +3959,18 @@ class SessionManager
/**
* @param int $user_id
* @param bool $ignore_visibility_for_admins
* @param bool $ignoreTimeLimit
*
* @return array
*/
public static function get_sessions_by_user($user_id, $ignore_visibility_for_admins = false)
public static function get_sessions_by_user($user_id, $ignore_visibility_for_admins = false, $ignoreTimeLimit = false)
{
$sessionCategories = UserManager::get_sessions_by_category(
$user_id,
false,
$ignore_visibility_for_admins
$ignore_visibility_for_admins,
$ignoreTimeLimit
);
$sessionArray = array();
if (!empty($sessionCategories)) {
foreach ($sessionCategories as $category) {

@ -1622,9 +1622,9 @@ class UserManager
//Crop the image to adjust 1:1 ratio
$image = new Image($source_file);
$image->crop($cropParameters);
// Storing the new photos in 4 versions with various sizes.
$small = new Image($source_file);
$small->resize(22);
$small->send_image($path.'small_'.$filename);
@ -1637,9 +1637,9 @@ class UserManager
$big = new Image($source_file); // This is the original picture.
$big->send_image($path.'big_'.$filename);
$result = $small && $medium && $normal && $big;
return $result ? $filename : false;
}
@ -2294,13 +2294,16 @@ class UserManager
* @param integer $user_id
* @param boolean whether to fill the first element or not (to give space for courses out of categories)
* @param boolean optional true if limit time from session is over, false otherwise
* @param boolean $ignoreTimeLimit ignore time start/end
* @return array list of statuses [session_category][session_id]
*
* @todo ensure multiple access urls are managed correctly
*/
public static function get_sessions_by_category(
$user_id,
$is_time_over = true,
$ignore_visibility_for_admins = false
$ignore_visibility_for_admins = false,
$ignoreTimeLimit = false
) {
// Database Table Definitions
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
@ -2343,27 +2346,29 @@ class UserManager
while ($row = Database::fetch_array($result, 'ASSOC')) {
// User portal filters:
if ($is_time_over) {
// History
if (empty($row['access_end_date']) || $row['access_end_date'] == '0000-00-00 00:00:00') {
continue;
}
if (isset($row['access_end_date'])) {
if ($row['access_end_date'] > $now) {
if ($ignoreTimeLimit == false) {
if ($is_time_over) {
// History
if (empty($row['access_end_date']) || $row['access_end_date'] == '0000-00-00 00:00:00') {
continue;
}
}
} else {
// Current user portal
if (api_is_allowed_to_create_course()) {
// Teachers can access the session depending in the access_coach date
} else {
if (isset($row['access_end_date']) && $row['access_end_date'] != '0000-00-00 00:00:00') {
if ($row['access_end_date'] <= $now) {
if (isset($row['access_end_date'])) {
if ($row['access_end_date'] > $now) {
continue;
}
}
} else {
// Current user portal
if (api_is_allowed_to_create_course()) {
// Teachers can access the session depending in the access_coach date
} else {
if (isset($row['access_end_date']) && $row['access_end_date'] != '0000-00-00 00:00:00') {
if ($row['access_end_date'] <= $now) {
continue;
}
}
}
}
}
@ -2422,7 +2427,9 @@ class UserManager
case SESSION_AVAILABLE:
break;
case SESSION_INVISIBLE:
continue(2);
if ($ignore_visibility_for_admins == false) {
continue(2);
}
}
$categories[$row['session_category_id']]['sessions'][$row['id']] = array(

@ -1248,7 +1248,8 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) {
$courseCode = $_course['code'];
$isUserSubscribedInCourse = CourseManager::is_user_subscribed_in_course(
$user_id,
$courseCode
$courseCode,
$session_id
);
if (isset($user_id) && $isUserSubscribedInCourse === true && !api_is_anonymous($user_id)) {
$is_allowed_in_course = true;

@ -66,6 +66,86 @@ if (isset($_POST) && $is_error) {
}
if (!empty($manifest)) {
$oScorm->parse_manifest($manifest);
$fixTemplate = api_get_configuration_value('learnpath_fix_xerte_template');
$proxyPath = api_get_configuration_value('learnpath_proxy_url');
if ($fixTemplate && !empty($proxyPath)) {
// Check organisations:
if (isset($oScorm->manifest['organizations'])) {
foreach ($oScorm->manifest['organizations'] as $data) {
if (strpos(strtolower($data), 'xerte') !== false) {
// Check if template.xml exists:
$templatePath = str_replace('imsmanifest.xml', 'template.xml', $manifest);
if (file_exists($templatePath) && is_file($templatePath)) {
$templateContent = file_get_contents($templatePath);
$find = array(
'href="www.',
'href="https://',
'href="http://',
'url="www.',
'pdfs/download.php?'
);
$replace = array(
'href="http://www.',
'target = "_blank" href="'.$proxyPath.'?type=link&src=https://',
'target = "_blank" href="'.$proxyPath.'?type=link&src=http://',
'url="http://www.',
'pdfs/download.php&'
);
$templateContent = str_replace($find, $replace, $templateContent);
file_put_contents($templatePath, $templateContent);
}
// Fix link generation:
$linkPath = str_replace('imsmanifest.xml', 'models_html5/links.html', $manifest);
if (file_exists($linkPath) && is_file($linkPath)) {
$linkContent = file_get_contents($linkPath);
$find = array(
':this.getAttribute("url")'
);
$replace = array(
':"'.$proxyPath.'?type=link&src=" + this.getAttribute("url")'
);
$linkContent = str_replace($find, $replace, $linkContent);
file_put_contents($linkPath, $linkContent);
}
// Fix iframe generation
$framePath = str_replace('imsmanifest.xml', 'models_html5/embedDiv.html', $manifest);
if (file_exists($framePath) && is_file($framePath)) {
$content = file_get_contents($framePath);
$find = array(
'$iFrameHolder.html(iFrameTag);'
);
$replace = array(
'iFrameTag = \'<a target ="_blank" href="'.$proxyPath.'?type=link&src=\'+ pageSrc + \'">Open website. <img src="'.api_get_path(WEB_CODE_PATH).'img/link-external.png"></a>\'; $iFrameHolder.html(iFrameTag); '
);
$content = str_replace($find, $replace, $content);
file_put_contents($framePath, $content);
}
// Fix new window generation
$newWindowPath = str_replace('imsmanifest.xml', 'models_html5/newWindow.html', $manifest);
if (file_exists($newWindowPath) && is_file($newWindowPath)) {
$content = file_get_contents($newWindowPath);
$find = array(
'var src = x_currentPageXML'
);
$replace = array(
'var src = "'.$proxyPath.'?type=link&src=" + x_currentPageXML'
);
$content = str_replace($find, $replace, $content);
file_put_contents($newWindowPath, $content);
}
}
}
}
}
$oScorm->import_manifest(api_get_course_id(), $_REQUEST['use_max_score']);
} else {
// Show error message stored in $oScrom->error_msg.

@ -126,9 +126,12 @@ if ($form->validate()) {
$id_session_category = $params['session_category'];
$id_visibility = $params['session_visibility'];
$duration = isset($params['duration']) ? $params['duration'] : null;
if ($params['access'] == 1) {
$duration = null;
}
$description = $params['description'];
$showDescription = isset($params['show_description']) ? 1: 0;
$sendSubscritionNotification = isset($params['send_subscription_notification']);
$sendSubscriptionNotification = isset($params['send_subscription_notification']);
$extraFields = array();
foreach ($params as $key => $value) {
@ -154,7 +157,7 @@ if ($form->validate()) {
$duration,
$extraFields,
null,
$sendSubscritionNotification
$sendSubscriptionNotification
);
if ($return == strval(intval($return))) {
@ -165,7 +168,6 @@ if ($form->validate()) {
// display the header
Display::display_header($tool_name);
$form->display();
?>

Loading…
Cancel
Save