Adding 23:59:59 as end_date limit see BT#7740

1.9.x
Julio Montoya 11 years ago
parent 9563bd4723
commit d7d278bfda
  1. 7
      main/inc/lib/main_api.lib.php
  2. 33
      main/inc/lib/userportal.lib.php

@ -1949,7 +1949,6 @@ function api_get_session_visibility($session_id, $course_code = null, $ignore_vi
}
$now = time();
if (!empty($session_id)) {
$session_id = intval($session_id);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
@ -1986,7 +1985,9 @@ function api_get_session_visibility($session_id, $course_code = null, $ignore_vi
// If the end date was set.
if (!empty($row['date_end']) && $row['date_end'] != '0000-00-00') {
// End date finish at midnight.
$row['date_end'] = $row['date_end'].' 23:59:59';
// Only if date_start said that it was ok
if ($visibility == SESSION_AVAILABLE) {
if ($now < api_strtotime($row['date_end'], 'UTC')) {
@ -2011,7 +2012,7 @@ function api_get_session_visibility($session_id, $course_code = null, $ignore_vi
$row['date_end'] != '0000-00-00' &&
$row['nb_days_access_after_end'] != '0'
) {
$end_date_for_coach = new DateTime($row['date_end']);
$end_date_for_coach = new DateTime($row['date_end'].' 23:59:59');
$number_of_days = "P".intval($row['nb_days_access_after_end']).'D';
$end_date_for_coach->add(new DateInterval($number_of_days));
@ -2028,7 +2029,7 @@ function api_get_session_visibility($session_id, $course_code = null, $ignore_vi
$row['date_start'] != '0000-00-00' &&
$row['nb_days_access_before_beginning'] != '0'
) {
$start_date_for_coach = new DateTime($row['date_start']);
$start_date_for_coach = new DateTime($row['date_start'].' 00:00:00');
$number_of_days = "P".intval($row['nb_days_access_before_beginning']).'D';
$start_date_for_coach->sub(new DateInterval($number_of_days));
if ($start_date_for_coach->getTimestamp() < $now) {

@ -997,9 +997,10 @@ class IndexManager
// Courses inside the current session.
$date_session_start = $session['date_start'];
$date_session_end = $session['date_end'];
$days_access_before_beginning = $session['nb_days_access_before_beginning'];
$days_access_after_end = $session['nb_days_access_after_end'];
$date_session_end = $session['date_end'];
$session_now = time();
$count_courses_session = 0;
@ -1012,16 +1013,20 @@ class IndexManager
if ($date_session_start != '0000-00-00') {
if ($is_coach_course && !isset($_GET['history'])) {
$allowed_time = api_strtotime($date_session_start) - ($days_access_before_beginning*86400);
if ($session_now > $date_session_end) {
$dif_time_after = $session_now - api_strtotime($date_session_end);
$allowed_time = api_strtotime($date_session_start.' 00:00:00') - ($days_access_before_beginning * 86400);
if ($date_session_end != '0000-00-00') {
$endSessionToTms = api_strtotime($date_session_end.' 23:59:59');
if ($session_now > $endSessionToTms) {
$dif_time_after = $session_now - $endSessionToTms;
$dif_time_after = round($dif_time_after/86400);
}
}
} else {
$allowed_time = api_strtotime($date_session_start);
$allowed_time = api_strtotime($date_session_start.' 00:00:00');
}
}
if ($session_now > $allowed_time && $days_access_after_end >= $dif_time_after-1) {
if ($session_now > $allowed_time && $days_access_after_end > $dif_time_after - 1) {
// Read only and accessible.
if (api_get_setting('hide_courses_in_sessions') == 'false') {
@ -1094,9 +1099,10 @@ class IndexManager
continue;
}
$date_session_start = $session['date_start'];
$date_session_end = $session['date_end'];
$days_access_before_beginning = $session['nb_days_access_before_beginning'];
$days_access_after_end = $session['nb_days_access_after_end'];
$date_session_end = $session['date_end'];
$session_now = time();
$html_courses_session = '';
$count = 0;
@ -1109,19 +1115,20 @@ class IndexManager
if ($is_coach_course) {
// 24 hours = 86400
if ($date_session_start != '0000-00-00') {
$allowed_time = api_strtotime($date_session_start) - ($days_access_before_beginning*86400);
$allowed_time = api_strtotime($date_session_start.' 00:00:00') - ($days_access_before_beginning*86400);
}
if ($date_session_end != '0000-00-00') {
if ($session_now > $date_session_end) {
$dif_time_after = $session_now - api_strtotime($date_session_end);
$dif_time_after = round($dif_time_after/86400);
$endSessionToTms = api_strtotime($date_session_end.' 23:59:59');
if ($session_now > $endSessionToTms) {
$dif_time_after = $session_now - $endSessionToTms;
$dif_time_after = round($dif_time_after / 86400);
}
}
} else {
$allowed_time = api_strtotime($date_session_start);
$allowed_time = api_strtotime($date_session_start.' 00:00:00');
}
if ($session_now > $allowed_time && $days_access_after_end >= $dif_time_after - 1) {
if ($session_now > $allowed_time && $days_access_after_end > $dif_time_after - 1) {
if (api_get_setting('hide_courses_in_sessions') == 'false') {
$c = CourseManager :: get_logged_user_course_html($course, $session_id, 'session_course_item');
$html_courses_session .= $c[1];

Loading…
Cancel
Save