deleted array items[] html BT#11017

ofaj
Alex Aragon 9 years ago
parent 492e4192be
commit e3c1c68908
  1. 332
      main/inc/lib/course.lib.php
  2. 1
      main/inc/lib/userportal.lib.php

@ -3339,81 +3339,6 @@ class CourseManager
return $html;
}
/**
* Builds the course block in user_portal.php
* @todo use Twig
* @param array $params
* @param bool|false $is_sub_content
* @return string
*/
public static function course_item_html($params, $is_sub_content = false)
{
$html = '';
$class = "panel panel-default";
if ($is_sub_content) {
$class = "course_item";
}
$html .= '<div class="' . $class . '">';
$html .= '<div class="panel-body">';
$html .= '<div class="course-items">';
$html .= ' <div class="row">';
$html .= '<div class="col-md-2">';
if (!empty($params['link'])) {
$html .= '<a class="thumbnail" href="' . $params['link'] . '">';
$html .= $params['icon'];
$html .= '</a>';
} else {
$html .= '<div class="thumbnail">';
$html .= $params['icon'];
$html .= '</div>';
}
$html .= '</div>';
$notifications = isset($params['notifications']) ? $params['notifications'] : '';
$param_class = isset($params['class']) ? $params['class'] : '';
$params['right_actions'] = isset($params['right_actions']) ? $params['right_actions'] : '';
$html .= '<div class="col-md-10 ' . $param_class . '">';
$html .= '<div class="pull-right">' . $params['right_actions'] . '</div>';
$html .= '<h4 class="course-items-title">' . $params['title'] . $notifications . '</h4> ';
if (isset($params['show_description'], $params['description']) && $params['show_description'] == 1) {
$html .= '<p class="description-session">' . $params['description'] . '</p>';
}
if (!empty($params['subtitle'])) {
$html .= '<div class="subtitle-session">' . $params['subtitle'] . '</div>';
}
if (!empty($params['teachers'])) {
$html .= '<h5 class="course-items-session">' .
Display::return_icon('teacher.png', get_lang('Teacher'), array(), ICON_SIZE_TINY) .
$params['teachers'] . '</h5>';
}
if (!empty($params['coaches'])) {
$html .= '<h5 class="course-items-session">' .
Display::return_icon('teacher.png', get_lang('Coach'), array(), ICON_SIZE_TINY) .
$params['coaches'] . '</h5>';
}
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
/**
* @param string $main_content
* @param string $sub_content
* @param string $sub_sub_content
* @return string
*/
public static function course_item_parent($main_content, $sub_content, $sub_sub_content = null)
{
return '<div class="panel panel-default">' . $main_content . $sub_content . $sub_sub_content . '</div>';
}
/**
* Display special courses (and only these) as several HTML divs of class userportal-course-item
*
@ -3516,76 +3441,7 @@ class CourseManager
}
return $listCourse;
}
/**
* Display courses (without special courses) as several HTML divs
* of course categories, as class userportal-catalog-item.
* @uses displayCoursesInCategory() to display the courses themselves
* @param int user id
* @param bool Whether to show the document quick-loader or not
* @return string
*/
public static function display_courses($user_id, $load_dirs = false)
{
$user_id = intval($user_id);
if (empty($user_id)) {
$user_id = api_get_user_id();
}
// Step 1: We get all the categories of the user
$table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT id, title FROM $table
WHERE user_id = '" . $user_id . "'
ORDER BY sort ASC";
$result = Database::query($sql);
$html = null;
$courseCount = 0;
$items = [];
while ($row = Database::fetch_array($result)) {
// We simply display the title of the category.
$params = array(
'icon' => Display::return_icon(
'folder_yellow.png',
api_htmlentities($row['title']), array(), ICON_SIZE_LARGE
),
'title' => $row['title'],
'class' => 'table_user_course_category'
);
$courseInCategory = self:: displayCoursesInCategory(
$row['id'],
$load_dirs
);
$item = self::course_item_parent(
self::course_item_html($params, true),
$courseInCategory['html']
);
$html .= $item;
$items[] = $item;
$courseCount += $courseInCategory['course_count'];
}
// Step 2: We display the course without a user category.
$courseInCategory = self::displayCoursesInCategory(0, $load_dirs);
$html .= $courseInCategory['html'];
if (!empty($courseInCategory['items'])) {
$items = array_merge($items, $courseInCategory['items']);
}
$courseCount += $courseInCategory['course_count'];
return [
'html' => $html,
'items' => $items,
'course_count' => $courseCount
];
}
/**
* Display courses (without special courses) as several HTML divs
* of course categories, as class userportal-catalog-item.
@ -3906,191 +3762,7 @@ class CourseManager
return $listCourse;
}
/**
* Display courses inside a category (without special courses) as HTML dics of
* class userportal-course-item.
* @param int User category id
* @param bool Whether to show the document quick-loader or not
* @return string
*/
public static function displayCoursesInCategory($user_category_id, $load_dirs = false)
{
$user_id = api_get_user_id();
// Table definitions
$TABLECOURS = Database:: get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database:: get_main_table(TABLE_MAIN_COURSE_USER);
$TABLE_ACCESS_URL_REL_COURSE = Database:: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$current_url_id = api_get_current_access_url_id();
// Get course list auto-register
$special_course_list = self::get_special_course_list();
$without_special_courses = '';
if (!empty($special_course_list)) {
$without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")';
}
//AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH."
$sql = "SELECT
course.id,
course.title,
course.code,
course.subscribe subscr,
course.unsubscribe unsubscr,
course_rel_user.status status,
course_rel_user.sort sort,
course_rel_user.user_course_cat user_course_cat
FROM $TABLECOURS course,
$TABLECOURSUSER course_rel_user,
$TABLE_ACCESS_URL_REL_COURSE url
WHERE
course.id = course_rel_user.c_id AND
url.c_id = course.id AND
course_rel_user.user_id = '" . $user_id . "' AND
course_rel_user.user_course_cat = '" . $user_category_id . "'
$without_special_courses ";
// If multiple URL access mode is enabled, only fetch courses
// corresponding to the current URL.
if (api_get_multiple_access_url() && $current_url_id != -1) {
$sql .= " AND url.c_id = course.id AND access_url_id='" . $current_url_id . "'";
}
// Use user's classification for courses (if any).
$sql .= " ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC";
$result = Database::query($sql);
$html = '';
$items = [];
$course_list = array();
$showCustomIcon = api_get_setting('course_images_in_courses_list');
$courseCount = 0;
// Browse through all courses.
while ($course = Database::fetch_array($result)) {
$course_info = api_get_course_info($course['code']);
if (isset($course_info['visibility']) &&
$course_info['visibility'] == COURSE_VISIBILITY_HIDDEN
) {
continue;
}
$course_info['id_session'] = null;
$course_info['status'] = $course['status'];
//In order to avoid doubles
if (in_array($course_info['real_id'], $course_list)) {
continue;
} else {
$course_list[] = $course_info['real_id'];
}
$courseCount++;
// For each course, get if there is any notification icon to show
// (something that would have changed since the user's last visit).
$show_notification = Display::show_notification($course_info);
$status_icon = Display::return_icon(
'blackboard.png',
api_htmlentities($course_info['title']),
array(),
ICON_SIZE_LARGE
);
$iconName = basename($course_info['course_image']);
if ($showCustomIcon === 'true' && $iconName != 'course.png') {
$status_icon = Display::img(
$course_info['course_image'],
api_htmlentities($course_info['title']),
array()
);
}
$params = array();
$params['right_actions'] = '';
if (api_is_platform_admin()) {
if ($load_dirs) {
$params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png',
get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
$params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png',
get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
$params['right_actions'] .= Display::div('', array(
'id' => 'document_result_' . $course_info['real_id'] . '_0',
'class' => 'document_preview_container'
));
} else {
$params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png',
get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
}
if ($course_info['status'] == COURSEMANAGER) {
//echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;'));
}
} else {
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
if ($load_dirs) {
$params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png',
get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
$params['right_actions'] .= Display::div('', array(
'id' => 'document_result_' . $course_info['real_id'] . '_0',
'class' => 'document_preview_container'
));
} else {
if ($course_info['status'] == COURSEMANAGER) {
$params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png',
get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
}
}
}
}
$course_title_url = '';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
$course_title_url = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?id_session=0';
$course_title = Display::url($course_info['title'], $course_title_url);
} else {
$course_title = $course_info['title'] . " " . Display::tag('span', get_lang('CourseClosed'),
array('class' => 'item_closed'));
}
// Start displaying the course block itself
if (api_get_setting('display_coursecode_in_courselist') == 'true') {
$course_title .= ' (' . $course_info['visual_code'] . ') ';
}
if (api_get_setting('display_teacher_in_courselist') == 'true') {
$teachers = CourseManager::get_teacher_list_from_course_code_to_string(
$course['code'],
self::USER_SEPARATOR,
true
);
}
$params['link'] = $course_title_url;
$params['icon'] = $status_icon;
$params['title'] = $course_title;
$params['teachers'] = $teachers;
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
$params['notifications'] = $show_notification;
}
$isSubContent = true;
if (empty($user_category_id)) {
$isSubContent = false;
}
$item = self::course_item_html($params, $isSubContent);
$html .= $item;
$items[] = $item;
}
return [
'html' => $html,
'items' => $items,
'course_count' => $courseCount
];
}
/**
* Retrieves the user defined course categories
* @param string $userId

@ -1043,7 +1043,6 @@ class IndexManager
$sessionCount = 0;
$courseCount = 0;
$items = [];
// If we're not in the history view...
if (!isset($_GET['history'])) {
// Display special courses.

Loading…
Cancel
Save