Should fix button "go to course" see #5140

skala
Julio Montoya 13 years ago
parent 092b2b2b75
commit c29c4f801f
  1. 29
      main/inc/lib/course.lib.php
  2. 5
      main/inc/lib/main_api.lib.php
  3. 2
      main/inc/lib/template.lib.php
  4. 8
      main/template/default/auth/courses_categories.php
  5. 18
      main/template/default/layout/hot_courses.tpl

@ -3647,6 +3647,14 @@ class CourseManager {
*/
function return_hot_courses($days = 30, $limit = 5) {
$limit = intval($limit);
//Getting my courses
$my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id());
$my_course_code_list = array();
foreach ($my_course_list as $course) {
$my_course_code_list[$course['real_id']] = $course['real_id'];
}
$table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
//@todo all dates in the tracking_course_access, last_access are in the DB time (NOW) not UTC
@ -3670,12 +3678,27 @@ class CourseManager {
$courses = array();
if (Database::num_rows($result)) {
$courses = Database::store_result($result, 'ASSOC');
$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']);
$my_course['extra_info'] = $course_info;
$my_course['extra_info'] = $course_info;
$my_course['extra_info']['go_to_course_button'] = '';
//World
if ($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'));
}
//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']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($my_course['course_code']);
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$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.'&course_id='.$course_info['real_id'], $point_info);
}

@ -5941,3 +5941,8 @@ function api_get_locked_settings() {
'chamilo_database_version'
);
}
function api_user_is_login($user_id = null) {
$user_id = empty($user_id) ? api_get_user_id() : intval($user_id);
return $user_id && !api_is_anonymous();
}

@ -274,7 +274,7 @@ class Template {
$user_info = array();
$user_info['logged'] = 0;
$this->user_is_logged_in = false;
if (api_get_user_id() && !api_is_anonymous()) {
if (api_user_is_login()) {
$user_info = api_get_user_info();
$user_info['logged'] = 1;

@ -114,6 +114,7 @@ $stok = Security::get_token();
}
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
if (!empty($browse_courses_in_category)) {
@ -166,10 +167,13 @@ $stok = Security::get_token();
}
// Go To Course button
if (!api_is_anonymous()
&& ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)) {
if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD ||
($course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && api_user_is_login()) ||
in_array($course['code'], $user_coursecodes)
) {
echo ' <a class="btn btn-primary" href="'. api_get_course_url($course['code']).'">'.get_lang('GoToCourse').'</a>';
}
// Subscribe button
if (!api_is_anonymous()
&& ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)

@ -42,22 +42,12 @@ $(document).ready( function() {
<div class="categories-course-description">
<h3>{{ hot_course.extra_info.name }}</h3>
<h5>{{ hot_course.extra_info.teachers }}</h5>
{{ hot_course.extra_info.rating_html }}
</div>
<p>
{# World #}
{% if hot_course.extra_info.visibility == 3 or (hot_course.extra_info.visibility == 2 and _u.logged == 1 ) %}
<a class="btn btn-primary" title="" href="{{_p.web_course}}{{hot_course.extra_info.path}}/index.php">
{{ "GoToCourse"|get_lang }}
</a>
{% endif %}
{# Description #}
{% if hot_course.extra_info.visibility == 3 %}
<a class="ajax btn" title="" href="{{ _p.web_ajax}}course_home.ajax.php?a=show_course_information&code={{hot_course.course_code}}">
{{"Description"|get_lang}}
</a>
{% endif %}
<p>
{{ hot_course.extra_info.go_to_course_button }}
{{ hot_course.extra_info.description_button }}
</p>
</div>
</div>

Loading…
Cancel
Save