Course catalog: add course_catalog_display_in_home conf setting - refs BT#19827

Display the course catalog in home page
pull/4232/head
Angel Fernando Quiroz Campos 4 years ago
parent e725f32a5a
commit 6e0c84cff3
  1. 14
      index.php
  2. 36
      main/inc/lib/CoursesAndSessionsCatalog.class.php
  3. 3
      main/install/configuration.dist.php
  4. 6
      main/template/default/catalog/session_catalog.tpl

@ -149,6 +149,20 @@ if (!isset($_REQUEST['include'])) {
}
}
$announcements_block = $controller->return_announcements();
if (api_get_configuration_value('course_catalog_display_in_home')
&& ('true' === api_get_setting('course_catalog_published') || !api_is_anonymous())
) {
$userCanViewPage = CoursesAndSessionsCatalog::userCanView();
if (CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) {
$announcements_block .= $userCanViewPage ? CoursesAndSessionsCatalog::sessionList(true) : '';
} else {
$announcements_block .= $userCanViewPage
? CoursesAndSessionsCatalog::displayCoursesList('display_courses', '', '', true)
: '';
}
}
}
if (api_get_configuration_value('show_hot_sessions') === true) {
$hotSessions = SessionManager::getHotSessions();

@ -1136,8 +1136,9 @@ class CoursesAndSessionsCatalog
return Display::url(
Display::returnFontAwesomeIcon('check').' '.$title,
api_get_self().'?action='.$action.'&sec_token='.$stok.
'&course_code='.$course['code'].'&search_term='.$search_term.'&category_code='.$categoryCode,
api_get_path(WEB_CODE_PATH).'auth/courses.php'
.'?action='.$action.'&sec_token='.$stok
.'&course_code='.$course['code'].'&search_term='.$search_term.'&category_code='.$categoryCode,
['class' => 'btn btn-success btn-sm', 'title' => $title, 'aria-label' => $title]
);
}
@ -1160,7 +1161,8 @@ class CoursesAndSessionsCatalog
$categoryCode = Security::remove_XSS($categoryCode);
$sessionId = (int) $sessionId;
$url = api_get_self().'?action=unsubscribe&sec_token='.$stok.'&sid='.$sessionId.'&course_code='.$course['code'].
$url = api_get_path(WEB_CODE_PATH).'auth/courses.php'
.'?action=unsubscribe&sec_token='.$stok.'&sid='.$sessionId.'&course_code='.$course['code'].
'&search_term='.$search_term.'&category_code='.$categoryCode;
return Display::url(
@ -1326,7 +1328,7 @@ class CoursesAndSessionsCatalog
/**
* Return Session catalog rendered view.
*/
public static function sessionList()
public static function sessionList(bool $returnHtml = false): ?string
{
$date = $_POST['date'] ?? '';
$limit = self::getLimitArray();
@ -1363,8 +1365,14 @@ class CoursesAndSessionsCatalog
$tpl->get_template('catalog/session_catalog.tpl')
);
if ($returnHtml) {
return $templateContent;
}
$tpl->assign('content', $templateContent);
$tpl->display_one_col_template();
return null;
}
/**
@ -1442,7 +1450,7 @@ class CoursesAndSessionsCatalog
$headers = [];
if (self::showCourses()) {
$headers[] = [
'url' => api_get_self(),
'url' => api_get_path(WEB_CODE_PATH).'auth/courses.php',
'content' => get_lang('CourseManagement'),
];
}
@ -1830,7 +1838,7 @@ class CoursesAndSessionsCatalog
$categoryCode = !empty($categoryCode) ? Security::remove_XSS($categoryCode) : 'ALL';
// Start URL with params
$pageUrl = api_get_self().
$pageUrl = api_get_path(WEB_CODE_PATH).'auth/courses.php'.
'?action='.$action.
'&search_term='.$searchTerm.
'&keyword='.$keyword.
@ -1880,7 +1888,7 @@ class CoursesAndSessionsCatalog
}
if ('course_home' !== $redirectAfterSubscription) {
return api_get_self();
return api_get_path(WEB_CODE_PATH).'auth/courses.php';
}
if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) {
@ -1897,8 +1905,12 @@ class CoursesAndSessionsCatalog
/**
* @throws Exception
*/
public static function displayCoursesList(string $action, string $searchTerm, string $categoryCode)
{
public static function displayCoursesList(
string $action = '',
string $searchTerm = '',
string $categoryCode = '',
bool $returnHtml = false
): ?string {
$settings = api_get_configuration_value('course_catalog_settings');
$courseCatalogSettings = [
@ -2226,8 +2238,14 @@ class CoursesAndSessionsCatalog
$template->get_template('catalog/course_catalog.tpl')
);
if ($returnHtml) {
return $templateContent;
}
$template->assign('content', $templateContent);
$template->display_one_col_template();
return null;
}
public static function userCanView(): bool

@ -1649,6 +1649,9 @@ $_configuration['course_catalog_settings'] = [
];
*/
// Display the course catalog in home page
//$_configuration['course_catalog_display_in_home'] = false;
// Page "My Courses" shows specific course extra fields (CourseManager::getExtraFieldsToBePresented)
/*$_configuration['my_course_course_extrafields_to_be_presented'] = [
'fields' => ['mots_cles', 'duree_en_min', 'format'],

@ -11,7 +11,7 @@
<div class="row">
{% if catalog_settings.sessions.by_title %}
<div class="col-md-4">
<form method="post" action="{{ _p.web_self }}?action=search_session_title">
<form method="post" action="{{ _p.web_main }}auth/courses.php?action=search_session_title">
<label>{{ "Name"|get_lang }}</label>
<div class="input-group">
<input type="text" name="keyword" title="{{ 'Name'|get_lang }}" class="form-control"
@ -28,7 +28,7 @@
{% if catalog_settings.sessions.by_date %}
<div class="col-md-4">
<form method="post" action="{{ _p.web_self }}?action=display_sessions">
<form method="post" action="{{ _p.web_main }}auth/courses.php?action=display_sessions">
<div class="form-group">
<label>{{ "ByDate"|get_lang }}</label>
<div class="input-group">
@ -47,7 +47,7 @@
{% if catalog_settings.sessions.by_tag %}
<div class="col-md-4">
<form method="post" action="{{ _p.web_self }}?action=search_tag">
<form method="post" action="{{ _p.web_main }}auth/courses.php?action=search_tag">
<label>{{ "ByTag"|get_lang }}</label>
<div class="input-group">
<input type="text" name="search_tag" title="{{ 'ByTag'|get_lang }}" class="form-control"

Loading…
Cancel
Save