Fixed typo in get_course_id_from_original_id()

Added param to get_logged_user_course_html()
Removed the link inside the sessions history when the session is expired and "unacessible" (BT#1615)
skala
ywarnier 14 years ago
parent 95a13dae03
commit 34775c1d6a
  1. 35
      main/inc/lib/course.lib.php
  2. 8
      user_portal.php

@ -2805,7 +2805,7 @@ class CourseManager {
$table_field = Database::get_main_table(TABLE_MAIN_COURSE_FIELD); $table_field = Database::get_main_table(TABLE_MAIN_COURSE_FIELD);
$sql_course = "SELECT id FROM $table_field cf INNER JOIN $t_cfv cfv ON cfv.field_id=cf.id WHERE field_variable='$original_course_id_name' AND field_value='$original_course_id_value'"; $sql_course = "SELECT id FROM $table_field cf INNER JOIN $t_cfv cfv ON cfv.field_id=cf.id WHERE field_variable='$original_course_id_name' AND field_value='$original_course_id_value'";
$res = Database::query($sql_course); $res = Database::query($sql_course);
$row = Database::fetch_object($res_course); $row = Database::fetch_object($res);
if($row != false) { if($row != false) {
return $row->id; return $row->id;
} else { } else {
@ -2822,6 +2822,12 @@ class CourseManager {
* $my_course['c'] - visual course code * $my_course['c'] - visual course code
* $my_course['k'] - system course code * $my_course['k'] - system course code
* $my_course['db'] - course database * $my_course['db'] - course database
*
* @param array Course details
* @param integer Session ID
* @param string CSS class to apply to course entry
* @param boolean Whether the session is supposedly accessible now (not in the case it has passed and is in invisible/unaccessible mode)
* @return string The HTML to be printed for the course entry
* *
* @version 1.0.3 * @version 1.0.3
* @todo refactor into different functions for database calls | logic | display * @todo refactor into different functions for database calls | logic | display
@ -2829,7 +2835,7 @@ class CourseManager {
* @todo move code for what's new icons to a separate function to clear things up * @todo move code for what's new icons to a separate function to clear things up
* @todo add a parameter user_id so that it is possible to show the courselist of other users (=generalisation). This will prevent having to write a new function for this. * @todo add a parameter user_id so that it is possible to show the courselist of other users (=generalisation). This will prevent having to write a new function for this.
*/ */
function get_logged_user_course_html($course, $session_id = 0, $class = 'courses') { function get_logged_user_course_html($course, $session_id = 0, $class = 'courses', $session_accessible = true) {
global $nosession, $nbDigestEntries, $digest, $thisCourseSysCode, $orderKey; global $nosession, $nbDigestEntries, $digest, $thisCourseSysCode, $orderKey;
$charset = api_get_system_encoding(); $charset = api_get_system_encoding();
@ -2923,21 +2929,24 @@ class CourseManager {
$result.="\n\t"; $result.="\n\t";
$result .= '<li class="'.$class.'"><div class="coursestatusicons">'.$s_htlm_status_icon.'</div>'; $result .= '<li class="'.$class.'"><div class="coursestatusicons">'.$s_htlm_status_icon.'</div>';
// Show a hyperlink to the course, unless the course is closed and user is not course admin. // Show a hyperlink to the course, unless the course is closed and user is not course admin.
if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) { if ($session_accessible) {
if (api_get_setting('use_session_mode') == 'true' && !$nosession) { if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
if (empty($my_course['id_session'])) { if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
$my_course['id_session'] = 0; if (empty($my_course['id_session'])) {
} $my_course['id_session'] = 0;
if ($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start == '0000-00-00') { }
$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>'; if ($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start == '0000-00-00') {
$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
}
} else {
$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
} }
} else { } else {
$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>'; $result .= $course_display_title.' '.get_lang('CourseClosed');
} }
} else { } else {
$result .= $course_display_title.' '.get_lang('CourseClosed'); $result .= $course_display_title;
} }
// Show the course_code and teacher if chosen to display this. // Show the course_code and teacher if chosen to display this.
if (api_get_setting('display_coursecode_in_courselist') == 'true' || api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_coursecode_in_courselist') == 'true' || api_get_setting('display_teacher_in_courselist') == 'true') {
$result .= '<br />'; $result .= '<br />';

@ -343,7 +343,7 @@ if (is_array($courses_tree)) {
$allowed_time = strtotime($date_session_start); $allowed_time = strtotime($date_session_start);
} }
if ($session_now > $allowed_time) { if ($session_now > $allowed_time) {
$c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item'); $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',($session['details']['visibility']==3?false:true));
$html_courses_session .= $c[1]; $html_courses_session .= $c[1];
$count_courses_session++; $count_courses_session++;
} }
@ -360,7 +360,11 @@ if (is_array($courses_tree)) {
$s = Display :: get_session_title_box($session['details']['id']); $s = Display :: get_session_title_box($session['details']['id']);
$extra_info = (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates']; $extra_info = (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates'];
$session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?session_id='.$session['details']['id'])); if ($session['details']['visibility'] == 3) {
$session_link = $s['title'];
} else {
$session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?session_id='.$session['details']['id']));
}
echo Display::tag('span',$session_link. ' </span> <span style="padding-left: 10px; font-size: 90%; font-weight: normal;">'.$extra_info); echo Display::tag('span',$session_link. ' </span> <span style="padding-left: 10px; font-size: 90%; font-weight: normal;">'.$extra_info);
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
echo '<div style="float:right;"><a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session['details']['id'].'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('align' => 'absmiddle')).'</a></div>'; echo '<div style="float:right;"><a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session['details']['id'].'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('align' => 'absmiddle')).'</a></div>';

Loading…
Cancel
Save