Fixing bad validation see #5140

skala
Julio Montoya 13 years ago
parent 1b2cdc193f
commit d6fee94338
  1. 23
      main/inc/lib/course.lib.php
  2. 43
      main/template/default/layout/hot_courses.tpl

@ -3665,7 +3665,8 @@ class CourseManager {
}
}
$table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
//@todo all dates in the tracking_course_access, last_access are in the DB time (NOW) not UTC
/*
@ -3678,8 +3679,11 @@ class CourseManager {
//$table_course_access table uses the now() and interval ...
$sql = "SELECT COUNT(course_access_id) course_count, course_code FROM $table_course_access
WHERE login_course_date <= now() AND login_course_date > DATE_SUB(now(), INTERVAL $days DAY)
$sql = "SELECT COUNT(course_access_id) course_count, a.course_code, visibility FROM $table_course c INNER JOIN $table_course_access a
ON (c.code = a.course_code)
WHERE login_course_date <= now() AND
login_course_date > DATE_SUB(now(), INTERVAL $days DAY) AND
visibility <> '".COURSE_VISIBILITY_CLOSED."'
GROUP BY course_code
ORDER BY course_count DESC
LIMIT $limit";
@ -3691,12 +3695,7 @@ class CourseManager {
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
foreach ($courses as &$my_course) {
$course_info = api_get_course_info($my_course['course_code']);
if ($course_info['visibility'] == COURSE_VISIBILITY_CLOSED) {
continue;
}
$course_info = api_get_course_info($my_course['course_code']);
$my_course['extra_info'] = $course_info;
$my_course['extra_info']['go_to_course_button'] = '';
@ -3705,16 +3704,16 @@ class CourseManager {
$course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD ||
($course_info['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && api_user_is_login()) || in_array($course_info['real_id'], $my_course_code_list))
) {
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$my_course['extra_info']['path'].'/index.php', array('class' => 'btn btn-primary'));
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', array('class' => 'btn btn-primary'));
}
//Description
$my_course['extra_info']['description_button'] = '';
if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'], $my_course_code_list) ) {
$my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$my_course['course_code'], array('class' => 'ajax btn'));
$my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], array('class' => 'ajax btn'));
}
$my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($my_course['course_code']);
$my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']);
$point_info = self::get_course_ranking($course_info['real_id'], 0);
$my_course['extra_info']['rating_html'] = Display::return_rating_system('star_'.$course_info['real_id'], $ajax_url.'&amp;course_id='.$course_info['real_id'], $point_info);
}

@ -27,33 +27,36 @@ $(document).ready( function() {
<div class="span9">
{{"HottestCourses"|display_page_header}}
</div>
{% for hot_course in hot_courses %}
<div class="span9">
<div class="well_border">
<div class="row">
<div class="span2">
<div class="thumbnail">
<img src="{{ hot_course.extra_info.course_image }}" />
{# html_image file=$hot_course.extra_info.course_image #}
{% for hot_course in hot_courses %}
{% if hot_course.extra_info.title %}
<div class="span9">
<div class="well_border">
<div class="row">
<div class="span2">
<div class="thumbnail">
<img src="{{ hot_course.extra_info.course_image }}" />
{# html_image file=$hot_course.extra_info.course_image #}
</div>
</div>
</div>
<div class="span6">
<div class="categories-course-description">
<h3>{{ hot_course.extra_info.name }}</h3>
<h5>{{ hot_course.extra_info.teachers }}</h5>
<div class="span6">
<div class="categories-course-description">
<h3>{{ hot_course.extra_info.title}}</h3>
<h5>{{ hot_course.extra_info.teachers }}</h5>
{{ hot_course.extra_info.rating_html }}
{{ hot_course.extra_info.rating_html }}
</div>
<p>
{{ hot_course.extra_info.go_to_course_button }}
{{ hot_course.extra_info.description_button }}
</p>
</div>
<p>
{{ hot_course.extra_info.go_to_course_button }}
{{ hot_course.extra_info.description_button }}
</p>
</div>
</div>
</div>
</div>
{% endfor %}
{% endif %}
{% endfor %}
</div>
</section>
{% endif %}

Loading…
Cancel
Save