|
|
|
@ -142,22 +142,102 @@ $stok = Security::get_token(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; |
|
|
|
|
$user_id = api_get_user_id(); |
|
|
|
|
|
|
|
|
|
if (!empty($browse_courses_in_category)) { |
|
|
|
|
|
|
|
|
|
foreach ($browse_courses_in_category as $course) { |
|
|
|
|
|
|
|
|
|
// if course is closed, don't show it. |
|
|
|
|
if ($course['visibility'] == COURSE_VISIBILITY_CLOSED || $course['visibility'] == COURSE_VISIBILITY_HIDDEN) { |
|
|
|
|
$course_hidden = ($course['visibility'] == COURSE_VISIBILITY_HIDDEN); |
|
|
|
|
|
|
|
|
|
if ($course_hidden) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// course isn't closed |
|
|
|
|
$title = cut($course['title'], 70); |
|
|
|
|
$tutor_name = $course['tutor']; |
|
|
|
|
|
|
|
|
|
$creation_date = substr($course['creation_date'],0,10); |
|
|
|
|
$user_registerd_in_course = CourseManager::is_user_subscribed_in_course($user_id, $course['code']); |
|
|
|
|
$user_registerd_in_course_as_teacher = CourseManager::is_course_teacher($user_id, $course['code']); |
|
|
|
|
$user_registerd_in_course_as_student = ($user_registerd_in_course && !$user_registerd_in_course_as_teacher); |
|
|
|
|
$course_public = ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD); |
|
|
|
|
$course_open = ($course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM); |
|
|
|
|
$course_private = ($course['visibility'] == COURSE_VISIBILITY_REGISTERED); |
|
|
|
|
$course_closed = ($course['visibility'] == COURSE_VISIBILITY_CLOSED); |
|
|
|
|
$course_subscribe_allowed = ($course['subscribe'] == 1); |
|
|
|
|
$course_unsubscribe_allowed = ($course['unsubscribe'] == 1); |
|
|
|
|
$count_connections = $course['count_connections']; |
|
|
|
|
$creation_date = substr($course['creation_date'],0,10); |
|
|
|
|
|
|
|
|
|
// display the course bloc |
|
|
|
|
echo '<div class="well_border"><div class="row">'; |
|
|
|
|
|
|
|
|
|
// display thumbnail |
|
|
|
|
display_thumbnail($course, $icon_title); |
|
|
|
|
|
|
|
|
|
// display course title and button bloc |
|
|
|
|
echo '<div class="span4">'; |
|
|
|
|
display_title($course); |
|
|
|
|
// display button line |
|
|
|
|
echo '<div class="btn-toolbar">'; |
|
|
|
|
// if user registered as student |
|
|
|
|
if ($user_registerd_in_course_as_student) { |
|
|
|
|
if (!$course_closed) { |
|
|
|
|
display_description_button($course, $icon_title); |
|
|
|
|
display_goto_button($course); |
|
|
|
|
if ($course_unsubscribe_allowed) { |
|
|
|
|
display_unregister_button($course, $stok, $search_term, $code); |
|
|
|
|
} |
|
|
|
|
display_already_registered_label('student'); |
|
|
|
|
} |
|
|
|
|
} elseif ($user_registerd_in_course_as_teacher) { |
|
|
|
|
// if user registered as teacher |
|
|
|
|
display_description_button($course, $icon_title); |
|
|
|
|
display_goto_button($course); |
|
|
|
|
if ($course_unsubscribe_allowed) { |
|
|
|
|
display_unregister_button($course, $stok, $search_term, $code); |
|
|
|
|
} |
|
|
|
|
display_already_registered_label('teacher'); |
|
|
|
|
} else { |
|
|
|
|
// if user not registered in the course |
|
|
|
|
if (!$course_closed) { |
|
|
|
|
display_description_button($course, $icon_title); |
|
|
|
|
if (!$course_private) { |
|
|
|
|
display_goto_button($course); |
|
|
|
|
if ($course_subscribe_allowed) { |
|
|
|
|
display_register_button($course, $stok, $code, $search_term); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
echo '</div>'; // btn-toolbar |
|
|
|
|
echo '</div>'; // span4 |
|
|
|
|
|
|
|
|
|
// display counter |
|
|
|
|
echo '<div class="span2">'; |
|
|
|
|
echo '<div class="course-block-popularity"><span>'.get_lang('ConnectionsLastMonth').'</span><div class="course-block-popularity-score">'.$count_connections.'</div></div>'; |
|
|
|
|
echo '</div>'; |
|
|
|
|
|
|
|
|
|
// end of course bloc |
|
|
|
|
echo '</div></div>'; // well_border row |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (!isset($_REQUEST['subscribe_user_with_password']) && !isset($_REQUEST['subscribe_course'])) { |
|
|
|
|
Display::display_warning_message(get_lang('ThereAreNoCoursesInThisCategory')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
?> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Display the course catalog image of a course |
|
|
|
|
* @param $course |
|
|
|
|
* @param $icon_title |
|
|
|
|
*/ |
|
|
|
|
function display_thumbnail($course, $icon_title) |
|
|
|
|
{ |
|
|
|
|
$title = cut($course['title'], 70); |
|
|
|
|
$course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; // course path |
|
|
|
|
|
|
|
|
|
if (file_exists($course_path.'/course-pic85x85.png')) { |
|
|
|
@ -166,9 +246,7 @@ $stok = Security::get_token(); |
|
|
|
|
$course_medium_image = api_get_path(WEB_IMG_PATH).'without_picture.png'; // without picture |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$rating = Display::return_rating_system('star_'.$course['real_id'], $ajax_url.'&course_id='.$course['real_id'], $course['point_info']); |
|
|
|
|
|
|
|
|
|
echo '<div class="well_border"><div class="row">'; |
|
|
|
|
// course image |
|
|
|
|
echo '<div class="span2">'; |
|
|
|
|
echo '<div class="thumbnail">'; |
|
|
|
|
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { |
|
|
|
@ -178,57 +256,83 @@ $stok = Security::get_token(); |
|
|
|
|
} else { |
|
|
|
|
echo '<img src="'.$course_medium_image.'" alt="'.$title.'"/>'; |
|
|
|
|
} |
|
|
|
|
echo '</div>';//thumb |
|
|
|
|
echo '</div>'; |
|
|
|
|
echo '</div>'; // thumbail |
|
|
|
|
echo '</div>'; // span2 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo '<div class="span4">'; |
|
|
|
|
/** |
|
|
|
|
* Display the title of a course in course catalog |
|
|
|
|
* @param $course |
|
|
|
|
*/ |
|
|
|
|
function display_title($course) |
|
|
|
|
{ |
|
|
|
|
$title = cut($course['title'], 70); |
|
|
|
|
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; |
|
|
|
|
$teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code']); |
|
|
|
|
$teachers = '<h5>'.$teachers.'</h5>'; |
|
|
|
|
echo '<div class="categories-course-description"><h3>'.cut($title, 60).'</h3>'.$teachers.$rating.'</div>'; |
|
|
|
|
$rating = Display::return_rating_system('star_'.$course['real_id'], $ajax_url.'&course_id='.$course['real_id'], $course['point_info']); |
|
|
|
|
|
|
|
|
|
echo '<p>'; |
|
|
|
|
// we display the icon to subscribe or the text already subscribed |
|
|
|
|
echo '<div class="btn-toolbar">'; |
|
|
|
|
$teachers = '<h5>'.$teachers.'</h5>'; |
|
|
|
|
echo '<div class="categories-course-description">'; |
|
|
|
|
echo '<h3>'.cut($title, 60).'</h3>'; |
|
|
|
|
echo $teachers; |
|
|
|
|
echo $rating; |
|
|
|
|
echo '</div>'; // categories-course-description |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Display the description button of a course in the course catalog |
|
|
|
|
* @param $course |
|
|
|
|
* @param $icon_title |
|
|
|
|
*/ |
|
|
|
|
function display_description_button($course, $icon_title) |
|
|
|
|
{ |
|
|
|
|
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { |
|
|
|
|
echo '<a class="ajax btn" href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'].'" title="'.$icon_title.'" class="thickbox">'.get_lang('Description').'</a>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Get access type for course button ("enter" or/and "register") |
|
|
|
|
$access_type = CourseManager::get_access_link_by_user(api_get_user_id(), $course); |
|
|
|
|
/** |
|
|
|
|
* Display the goto course button of a course in the course catalog |
|
|
|
|
* @param $course |
|
|
|
|
*/ |
|
|
|
|
function display_goto_button($course) |
|
|
|
|
{ |
|
|
|
|
echo ' <a class="btn btn-primary" href="'.api_get_course_url($course['code']).'">'.get_lang('GoToCourse').'</a>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Go To Course button (only if admin, if course public or if student already subscribed) |
|
|
|
|
if ($access_type && in_array('enter', $access_type)) { |
|
|
|
|
echo ' <a class="btn btn-primary" href="'. api_get_course_url($course['code']).'">'.get_lang('GoToCourse').'</a>'; |
|
|
|
|
/** |
|
|
|
|
* Display the already registerd text in a course in the course catalog |
|
|
|
|
* @param $in_status |
|
|
|
|
*/ |
|
|
|
|
function display_already_registered_label($in_status) |
|
|
|
|
{ |
|
|
|
|
$icon = Display::return_icon('teachers.gif', get_lang('Teacher')); |
|
|
|
|
if ($in_status == 'student') { |
|
|
|
|
$icon = Display::return_icon('students.gif', get_lang('Student')); |
|
|
|
|
} |
|
|
|
|
echo Display::label($icon.' '.get_lang("AlreadyRegisteredToCourse"), "info"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Register button |
|
|
|
|
if ($access_type && in_array('register', $access_type)) { |
|
|
|
|
echo ' <a class="btn btn-primary" href="'. api_get_self().'?action=subscribe_course&sec_token='.$stok.'&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code.'">'.get_lang('Subscribe').'</a>'; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Display the register button of a course in the course catalog |
|
|
|
|
* @param $course |
|
|
|
|
* @param $stok |
|
|
|
|
* @param $code |
|
|
|
|
* @param $search_term |
|
|
|
|
*/ |
|
|
|
|
function display_register_button($course, $stok, $code, $search_term) |
|
|
|
|
{ |
|
|
|
|
echo ' <a class="btn btn-primary" href="'.api_get_self().'?action=subscribe_course&sec_token='.$stok.'&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code.'">'.get_lang('Subscribe').'</a>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// If user is already subscribed to the course |
|
|
|
|
if (!api_is_anonymous() && in_array($course['code'], $user_coursecodes)) { |
|
|
|
|
if ($course['unsubscribe'] == UNSUBSCRIBE_ALLOWED) { |
|
|
|
|
/** |
|
|
|
|
* Display the unregister button of a course in the course catalog |
|
|
|
|
* @param $course |
|
|
|
|
* @param $stok |
|
|
|
|
* @param $search_term |
|
|
|
|
* @param $code |
|
|
|
|
*/ |
|
|
|
|
function display_unregister_button($course, $stok, $search_term, $code) |
|
|
|
|
{ |
|
|
|
|
echo ' <a class="btn btn-primary" href="'. api_get_self().'?action=unsubscribe&sec_token='.$stok.'&unsubscribe='.$course['code'].'&search_term='.$search_term.'&category_code='.$code.'">'.get_lang('Unsubscribe').'</a>'; |
|
|
|
|
} |
|
|
|
|
echo '<br />'; |
|
|
|
|
echo '<br />'; |
|
|
|
|
echo Display::label(get_lang("AlreadyRegisteredToCourse"), "info"); |
|
|
|
|
} |
|
|
|
|
echo '</div>'; |
|
|
|
|
echo '</p>'; |
|
|
|
|
echo '</div>'; |
|
|
|
|
echo '<div class="span2">'; |
|
|
|
|
echo '<div class="course-block-popularity"><span>'.get_lang('ConnectionsLastMonth').'</span><div class="course-block-popularity-score">'.$count_connections.'</div></div>'; |
|
|
|
|
echo '</div>'; |
|
|
|
|
echo '</div></div>'; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (!isset($_REQUEST['subscribe_user_with_password']) && !isset($_REQUEST['subscribe_course'])) { |
|
|
|
|
echo Display::display_warning_message(get_lang('ThereAreNoCoursesInThisCategory')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
?> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|