Internal: Update from 1.11.x

pull/3466/head
Julio Montoya 5 years ago
parent 26a1d264af
commit 1a20706f65
  1. 20
      public/main/auth/catalog_layout.php
  2. 584
      public/main/auth/courses.php
  3. 523
      public/main/auth/courses_categories.php
  4. 673
      public/main/auth/courses_controller.php
  5. 16
      public/main/auth/justification.php
  6. 17
      public/main/auth/layout.php
  7. 4
      public/main/auth/lostPassword.php
  8. 7
      public/main/auth/pausetraining.php
  9. 28
      public/main/auth/profile.php
  10. 3
      public/main/auth/sort_my_courses.php
  11. 385
      public/main/session/session_list_simple.php

@ -1,20 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Layout (principal view) used for structuring course/session catalog.
*
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
*/
if ('true' !== api_get_setting('course_catalog_published')) {
// Access rights: anonymous users can't do anything usefull here.
api_block_anonymous_users();
}
// Header
Display::display_header('');
// Display
echo $content;
// Footer
Display::display_footer();

@ -4,21 +4,15 @@
use Chamilo\CoreBundle\Entity\SequenceResource;
/**
* Template (front controller in MVC pattern) used for dispatching
* to the controllers depend on the current action.
*
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
*/
// Delete the globals['_cid'], we don't need it here.
$cidReset = true; // Flag forcing the 'current course' reset
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$ctok = Security::get_existing_token();
// Get Limit data
$limit = CoursesController::getLimitArray();
$limit = CoursesAndSessionsCatalog::getLimitArray();
// Section for the tabs.
$this_section = SECTION_CATALOG;
@ -28,42 +22,27 @@ if ('true' !== api_get_setting('course_catalog_published')) {
api_block_anonymous_users();
}
$allowExtraFields = api_get_configuration_value('allow_course_extra_field_in_catalog');
// For students
$user_can_view_page = true;
$userCanViewPage = true;
if ('false' === api_get_setting('allow_students_to_browse_courses')) {
$user_can_view_page = false;
$userCanViewPage = false;
}
//For teachers/admins
if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
$user_can_view_page = true;
}
// filter actions
$actions = [
'subscribe',
'display_courses',
'display_random_courses',
'subscribe_user_with_password',
'display_sessions',
'subscribe_to_session',
'search_tag',
'search_session_title',
'subscribe_course_validation',
'subscribe_course',
];
$action = CoursesAndSessionsCatalog::is(CATALOG_SESSIONS) ? 'display_sessions' : 'display_courses';
if (isset($_GET['action']) && in_array($_GET['action'], $actions)) {
$action = Security::remove_XSS($_GET['action']);
$userCanViewPage = true;
}
$categoryCode = isset($_GET['category_code']) && !empty($_GET['category_code']) ? $_GET['category_code'] : 'ALL';
$defaultAction = CoursesAndSessionsCatalog::is(CATALOG_SESSIONS) ? 'display_sessions' : 'display_courses';
$action = isset($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']) : $defaultAction;
$categoryCode = isset($_REQUEST['category_code']) ? Security::remove_XSS($_REQUEST['category_code']) : '';
$searchTerm = isset($_REQUEST['search_term']) ? Security::remove_XSS($_REQUEST['search_term']) : '';
$nameTools = CourseCategory::getCourseCatalogNameTools($action);
if (empty($nameTools)) {
$nameTools = get_lang('Courses catalog');
$nameTools = get_lang('CourseManagement');
} else {
if (!in_array(
$action,
@ -71,73 +50,102 @@ if (empty($nameTools)) {
)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'auth/courses.php',
'name' => get_lang('Courses catalog'),
'name' => get_lang('CourseManagement'),
];
}
$interbreadcrumb[] = ['url' => '#', 'name' => $nameTools];
}
// course description controller object
$courseController = new CoursesController();
// search courses
if (isset($_REQUEST['search_course'])) {
if (!empty($_REQUEST['sec_token']) && $ctok == $_REQUEST['sec_token']) {
$courseController->search_courses(
$searchTerm,
null,
null,
null,
$limit,
true
);
exit;
$auth = new Auth();
$userId = api_get_user_id();
$currentUrl = api_get_path(WEB_CODE_PATH).'auth/courses.php?category_code='.$categoryCode.'&search_term='.$searchTerm;
$content = '';
$toolTitle = get_lang('CourseCatalog');
$courseCatalogSettings = [
'info_url' => 'course_description_popup',
'title_url' => 'course_home',
'image_url' => 'course_about',
];
$redirectAfterSubscription = 'course_home';
$settings = api_get_configuration_value('course_catalog_settings');
// By default all extra fields are shown (visible and filterable)
$extraFieldsInSearchForm = [];
$extraFieldsInCourseBlock = [];
if (!empty($settings)) {
if (isset($settings['link_settings'])) {
$courseCatalogSettings = $settings['link_settings'];
}
if (isset($settings['redirect_after_subscription'])) {
$redirectAfterSubscription = $settings['redirect_after_subscription'];
}
}
// We are unsubscribing from a course (=Unsubscribe from course).
if (isset($_GET['unsubscribe'])) {
if (!empty($_GET['sec_token']) && $ctok == $_GET['sec_token']) {
$courseController->unsubscribe_user_from_course(
$_GET['unsubscribe'],
$searchTerm,
$categoryCode
);
if (isset($settings['extra_fields_in_search_form'])) {
$extraFieldsInSearchForm = $settings['extra_fields_in_search_form'];
}
}
// We are unsubscribing from a course (=Unsubscribe from course).
if (isset($_POST['unsubscribe'])) {
if (!empty($_POST['sec_token']) && $ctok == $_POST['sec_token']) {
$courseController->unsubscribe_user_from_course($_POST['unsubscribe']);
if (isset($settings['extra_fields_in_course_block'])) {
$extraFieldsInCourseBlock = $settings['extra_fields_in_course_block'];
}
}
switch ($action) {
case 'unsubscribe':
// We are unsubscribing from a course (=Unsubscribe from course).
if (!empty($_GET['sec_token']) && $ctok == $_GET['sec_token']) {
$result = $auth->remove_user_from_course($_GET['course_code']);
if ($result) {
Display::addFlash(
Display::return_message(get_lang('YouAreNowUnsubscribed'))
);
}
}
header('Location: '.$currentUrl);
exit;
break;
case 'subscribe_course':
if (api_is_anonymous()) {
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php?c='.$courseCodeToSubscribe);
exit;
}
$courseCodeToSubscribe = isset($_GET['subscribe_course']) ? Security::remove_XSS($_GET['subscribe_course']) : '';
$courseCodeToSubscribe = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : '';
if (Security::check_token('get')) {
$courseInfo = api_get_course_info($courseCodeToSubscribe);
CourseManager::autoSubscribeToCourse($courseCodeToSubscribe);
if ('course_home' === $redirectAfterSubscription) {
$redirectionTarget = $courseInfo['course_public_url'];
if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) {
$user = api_get_user_entity(api_get_user_id());
if ($user) {
foreach ($user->getCurrentlyAccessibleSessions() as $session) {
$redirectionTarget = $redirectionTarget.'?id_session='.$session->getId();
break;
}
}
}
header('Location: '.$redirectionTarget);
exit;
}
header('Location: '.api_get_self());
exit;
}
break;
case 'subscribe_course_validation':
$courseCodeToSubscribe = isset($_GET['subscribe_course']) ? Security::remove_XSS($_GET['subscribe_course']) : '';
$toolTitle = get_lang('Subscribe');
$courseCodeToSubscribe = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : '';
$courseInfo = api_get_course_info($courseCodeToSubscribe);
if (empty($courseInfo)) {
header('Location: '.api_get_self());
exit;
}
$message = get_lang('This course requires a password').' ';
$message = get_lang('CourseRequiresPassword').' ';
$message .= $courseInfo['title'].' ('.$courseInfo['visual_code'].') ';
$action = api_get_self().
'?action=subscribe_course_validation&sec_token='.Security::getTokenFromSession().'&subscribe_course='.$courseCodeToSubscribe;
$action = api_get_self().'?action=subscribe_course_validation&sec_token='.
Security::getTokenFromSession().'&course_code='.$courseInfo['code'];
$form = new FormValidator(
'subscribe_user_with_password',
'post',
@ -147,62 +155,441 @@ switch ($action) {
$form->addElement('hidden', 'sec_token', Security::getTokenFromSession());
$form->addElement('hidden', 'subscribe_user_with_password', $courseInfo['code']);
$form->addElement('text', 'course_registration_code');
$form->addButtonSave(get_lang('Submit registration code'));
$form->addButtonSave(get_lang('SubmitRegistrationCode'));
$content = $form->returnForm();
if ($form->validate()) {
if (sha1($_POST['course_registration_code']) === $courseInfo['registration_code']) {
CourseManager::autoSubscribeToCourse($_POST['subscribe_user_with_password']);
if ('course_home' === $redirectAfterSubscription) {
$redirectionTarget = $courseInfo['course_public_url'];
if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) {
$user = api_get_user_entity(api_get_user_id());
if ($user) {
foreach ($user->getCurrentlyAccessibleSessions() as $session) {
$redirectionTarget = $redirectionTarget.'?id_session='.$session->getId();
break;
}
}
}
header('Location: '.$redirectionTarget);
exit;
}
header('Location: '.api_get_self());
exit;
} else {
Display::addFlash(Display::return_message(get_lang('The course password is incorrect')), 'warning');
Display::addFlash(Display::return_message(get_lang('CourseRegistrationCodeIncorrect')), 'warning');
header('Location: '.$action);
exit;
}
}
$template = new Template(get_lang('Subscribe'), true, true, false, false, false);
$template->assign('content', $content);
$template->display_one_col_template();
break;
case 'subscribe':
if (!$user_can_view_page) {
if (!$userCanViewPage) {
api_not_allowed(true);
}
header('Location: '.api_get_self());
exit;
break;
case 'display_random_courses':
if (!$user_can_view_page) {
case 'display_courses':
case 'search_course':
if (!$userCanViewPage) {
api_not_allowed(true);
}
$courseController->courses_categories($action);
break;
case 'display_courses':
if (!$user_can_view_page) {
api_not_allowed(true);
$settings = CoursesAndSessionsCatalog::getCatalogSearchSettings();
$form = new FormValidator('search', 'get', '', null, null, FormValidator::LAYOUT_GRID);
$form->addHidden('action', 'search_course');
if (isset($settings['courses']) && true === $settings['courses']['by_title']) {
$form->addText('search_term', get_lang('Title'));
}
$select = $form->addSelect(
'category_code',
get_lang('CourseCategories'),
[],
['placeholder' => get_lang('SelectAnOption')]
);
$defaults = [];
$listCategories = CoursesAndSessionsCatalog::getCourseCategoriesTree();
foreach ($listCategories as $category) {
$countCourse = (int) $category['number_courses'];
if (empty($countCourse)) {
continue;
}
$categoryCodeItem = Security::remove_XSS($category['code']);
$categoryName = Security::remove_XSS($category['name']);
$level = $category['level'];
$separate = '';
if ($level > 0) {
$separate = str_repeat('--', $level);
}
$select->addOption($separate.' '.$categoryName.' ('.$countCourse.')', $categoryCodeItem);
}
$jqueryReadyContent = '';
if ($allowExtraFields) {
$extraField = new ExtraField('course');
$onlyFields = [];
$returnParams = $extraField->addElements($form, null, [], true, false, $extraFieldsInSearchForm);
$jqueryReadyContent = $returnParams['jquery_ready_content'];
}
$sortKeySelect = $form->addSelect(
'sortKeys',
get_lang('SortKeys'),
CoursesAndSessionsCatalog::courseSortOptions(),
['multiple' => true]
);
$sortKeys = isset($_REQUEST['sortKeys']) ? Security::remove_XSS($_REQUEST['sortKeys']) : '';
$defaults['sortKeys'] = $sortKeys;
$defaults['search_term'] = $searchTerm;
$defaults['category_code'] = $categoryCode;
$conditions = [];
$fields = [];
if ('display_random_courses' === $action) {
// Random value is used instead limit filter
$courses = CoursesAndSessionsCatalog::getCoursesInCategory(null, 12);
$countCoursesInCategory = count($courses);
} else {
$values = $_REQUEST;
if ($allowExtraFields) {
$extraResult = $extraField->processExtraFieldSearch($values, $form, 'course', 'AND');
$conditions = $extraResult['condition'];
$fields = $extraResult['fields'];
$defaults = $extraResult['defaults'];
$defaults['sortKeys'] = $sortKeys;
$defaults['search_term'] = $searchTerm;
$defaults['category_code'] = $categoryCode;
}
$courses = CoursesAndSessionsCatalog::searchAndSortCourses(
$categoryCode,
$searchTerm,
$limit,
true,
$conditions,
$sortKeySelect->getValue()
);
$countCoursesInCategory = CourseCategory::countCoursesInCategory(
$categoryCode,
$searchTerm,
true,
$conditions
);
}
$showCourses = CoursesAndSessionsCatalog::showCourses();
$showSessions = CoursesAndSessionsCatalog::showSessions();
$pageCurrent = isset($_GET['pageCurrent']) ? (int) $_GET['pageCurrent'] : 1;
$pageLength = isset($_GET['pageLength']) ? (int) $_GET['pageLength'] : CoursesAndSessionsCatalog::PAGE_LENGTH;
$pageTotal = (int) ceil($countCoursesInCategory / $pageLength);
$url = CoursesAndSessionsCatalog::getCatalogUrl(1, $pageLength, 'ALL', 'search_course', $fields);
$urlNoExtraFields = CoursesAndSessionsCatalog::getCatalogUrl(1, $pageLength, 'ALL', 'search_course');
$urlNoCategory = CoursesAndSessionsCatalog::getCatalogUrl(1, $pageLength, '', 'search_course', $fields);
$urlNoCategory = str_replace('&category_code=ALL', '', $urlNoCategory);
$form->setAttribute('action', $url);
// getting all the courses to which the user is subscribed to
$user_courses = CourseManager::getCoursesByUserCourseCategory($userId);
$user_coursecodes = [];
// we need only the course codes as these will be used to match against the courses of the category
if ('' != $user_courses) {
foreach ($user_courses as $key => $value) {
$user_coursecodes[] = $value['code'];
}
}
if (api_is_drh()) {
$coursesDrh = CourseManager::get_courses_followed_by_drh($userId);
foreach ($coursesDrh as $course) {
$user_coursecodes[] = $course['code'];
}
}
$catalogShowCoursesSessions = 0;
$showCoursesSessions = (int) api_get_setting('catalog_show_courses_sessions');
if ($showCoursesSessions > 0) {
$catalogShowCoursesSessions = $showCoursesSessions;
}
$catalogPagination = '';
if ($pageTotal > 1) {
$catalogPagination = CoursesAndSessionsCatalog::getCatalogPagination(
$pageCurrent,
$pageLength,
$pageTotal,
$categoryCode,
$action,
$fields,
$sortKeySelect->getValue()
);
}
$userInfo = api_get_user_info();
$extraDate = '';
if ($showSessions) {
$extraDate = "
$('#date').datepicker({
dateFormat: 'yy-mm-dd'
});";
}
$htmlHeadXtra[] = "
<script>
$(function() {
$(\".selectpicker\").selectpicker({
\"width\": \"500px\",
});
$('.star-rating li a').on('click', function(event) {
var id = $(this).parents('ul').attr('id');
$('#vote_label2_' + id).html('".get_lang('Loading')."');
$.ajax({
url: $(this).attr('data-link'),
success: function(data) {
$('#rating_wrapper_'+id).html(data);
}
});
});
var getSessionId = function (el) {
var parts = el.id.split('_');
return parseInt(parts[1], 10);
};
$extraDate
});
</script>";
$stok = Security::get_token();
$content = CoursesAndSessionsCatalog::getTabList(1);
$content .= '<div class="row">
<div class="col-md-12">
<div class="search-courses">
';
if ($showCourses) {
$htmlHeadXtra[] = '<script>
$(function () {
'.$jqueryReadyContent.'
});
</script>';
$form->addButtonSearch(get_lang('Search'));
$form->setDefaults($defaults);
$content .= $form->returnForm();
}
$content .= '</div></div></div>';
if ($showCourses) {
$showTeacher = 'true' === api_get_setting('display_teacher_in_courselist');
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$user_id = api_get_user_id();
$categoryListFromDatabase = CourseCategory::getAllCategories();
$categoryList = [];
if (!empty($categoryListFromDatabase)) {
foreach ($categoryListFromDatabase as $categoryItem) {
$categoryList[$categoryItem['code']] = $categoryItem['name'];
}
}
if ($allowExtraFields) {
$extraFieldValues = new ExtraFieldValue('course');
$em = Database::getManager();
$fieldsRepo = $em->getRepository('ChamiloCoreBundle:ExtraField');
$fieldTagsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag');
}
$courseUrl = api_get_path(WEB_COURSE_PATH);
$hideRating = api_get_configuration_value('hide_course_rating');
if (!empty($courses)) {
foreach ($courses as &$course) {
$courseId = $course['real_id'];
if (COURSE_VISIBILITY_HIDDEN == $course['visibility']) {
continue;
}
$aboutPage = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about';
$settingsUrl = [
'course_description_popup' => api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'],
'course_about' => $aboutPage,
'course_home' => $courseUrl.$course['directory'].'/index.php?id_session=0',
];
$infoUrl = $settingsUrl[$courseCatalogSettings['info_url']];
$course['title_url'] = $settingsUrl[$courseCatalogSettings['title_url']];
$course['image_url'] = $settingsUrl[$courseCatalogSettings['image_url']];
$userRegisteredInCourse = CourseManager::is_user_subscribed_in_course($user_id, $course['code']);
$userRegisteredInCourseAsTeacher = CourseManager::is_course_teacher($user_id, $course['code']);
$userRegistered = $userRegisteredInCourse && $userRegisteredInCourseAsTeacher;
$course_public = COURSE_VISIBILITY_OPEN_WORLD == $course['visibility'];
$course_open = COURSE_VISIBILITY_OPEN_PLATFORM == $course['visibility'];
$course_private = COURSE_VISIBILITY_REGISTERED == $course['visibility'];
$courseClosed = COURSE_VISIBILITY_CLOSED == $course['visibility'];
$course_subscribe_allowed = 1 == $course['subscribe'];
$course_unsubscribe_allowed = 1 == $course['unsubscribe'];
$count_connections = $course['count_connections'];
$creation_date = substr($course['creation_date'], 0, 10);
// display the course bloc
$course['category_title'] = '';
if (!empty($course['category_code'])) {
$course['category_title'] = isset($categoryList[$course['category_code']]) ? $categoryList[$course['category_code']] : '';
$course['category_code_link'] = $urlNoCategory.'&category_code='.$course['category_code'];
}
// Display thumbnail
$course['thumbnail'] = CoursesAndSessionsCatalog::returnThumbnail($course);
$course['description_button'] = CourseManager::returnDescriptionButton($course, $infoUrl);
$subscribeButton = CoursesAndSessionsCatalog::return_register_button(
$course,
$stok,
$categoryCode,
$searchTerm
);
// Start buy course validation
// display the course price and buy button if the buycourses plugin is enabled and this course is configured
$plugin = BuyCoursesPlugin::create();
$isThisCourseInSale = $plugin->buyCoursesForGridCatalogValidator(
$courseId,
BuyCoursesPlugin::PRODUCT_TYPE_COURSE
);
$separator = '';
if ($isThisCourseInSale) {
// set the Price label
$separator = $isThisCourseInSale['html'];
// set the Buy button instead register.
if ($isThisCourseInSale['verificator']) {
$subscribeButton = $plugin->returnBuyCourseButton(
$courseId,
BuyCoursesPlugin::PRODUCT_TYPE_COURSE
);
}
}
$course['rating'] = '';
if ($hideRating === false) {
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$rating = Display::return_rating_system(
'star_'.$course['real_id'],
$ajax_url.'&course_id='.$course['real_id'],
$course['point_info']
);
$course['rating'] = '<div class="ranking">'.$rating.'</div>';
}
if ($showTeacher) {
$course['teacher_info'] = CoursesAndSessionsCatalog::return_teacher($course);
}
// display button line
$course['buy_course'] = $separator;
$course['extra_data'] = '';
if ($allowExtraFields) {
$course['extra_data'] = $extraField->getDataAndFormattedValues(
$courseId,
true,
$extraFieldsInCourseBlock
);
}
// if user registered as student
if ($userRegisteredInCourse) {
$course['already_registered_formatted'] = Display::url(
Display::returnFontAwesomeIcon('external-link').'&nbsp;'.
get_lang('GoToCourse'),
$courseUrl.$course['directory'].'/index.php?id_session=0',
['class' => 'btn btn-primary']
);
if (!$courseClosed) {
if ($course_unsubscribe_allowed) {
$course['unregister_formatted'] = CoursesAndSessionsCatalog::return_unregister_button(
$course,
$stok,
$searchTerm,
$categoryCode
);
}
}
} elseif ($userRegisteredInCourseAsTeacher) {
// if user registered as teacher
if ($course_unsubscribe_allowed) {
$course['unregister_formatted'] = CoursesAndSessionsCatalog::return_unregister_button(
$course,
$stok,
$searchTerm,
$categoryCode
);
}
} else {
// if user not registered in the course
if (!$courseClosed) {
if (!$course_private) {
if ($course_subscribe_allowed) {
$course['subscribe_formatted'] = $subscribeButton;
}
}
}
}
}
} else {
if (!isset($_REQUEST['subscribe_user_with_password']) &&
!isset($_REQUEST['subscribe_course'])
) {
Display::addFlash(Display::return_message(get_lang('NoResults'), 'warning'));
}
}
}
$courseController->courses_categories(
$action,
$categoryCode,
null,
null,
null,
$limit
if (api_is_course_admin()) {
foreach ($courses as &$course) {
$course['admin_url'] = api_get_path(WEB_CODE_PATH).'/admin/course_list.php?keyword='.$course['code'];
}
}
$template = new Template($toolTitle, true, true, false, false, false);
$template->assign('content', $content);
$template->assign('courses', $courses);
$template->assign(
'total_number_of_courses',
CoursesAndSessionsCatalog::countAvailableCoursesToShowInCatalog(
api_get_current_access_url_id()
)
);
$template->assign('total_number_of_matching_courses', $countCoursesInCategory);
$template->assign('catalog_url_no_extra_fields', $urlNoExtraFields);
$template->assign('pagination', $catalogPagination);
$template->display($template->get_template('catalog/course_catalog.tpl'));
exit;
break;
case 'display_sessions':
if (!$user_can_view_page) {
if (!$userCanViewPage) {
api_not_allowed(true);
}
$courseController->sessionList($action, $nameTools, $limit);
CoursesAndSessionsCatalog::sessionList($limit);
exit;
break;
case 'subscribe_to_session':
if (!$user_can_view_page) {
if (!$userCanViewPage) {
api_not_allowed(true);
}
@ -227,20 +614,19 @@ switch ($action) {
if ('true' === $registrationAllowed) {
$entityManager = Database::getManager();
$repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
$sequences = $repository->getRequirements(
$sessionId,
SequenceResource::SESSION_TYPE
);
if (count($sequences) > 0) {
$requirementsData = SequenceResourceManager::checkRequirementsForUser(
$requirementsData = $repository->checkRequirementsForUser(
$sequences,
SequenceResource::SESSION_TYPE,
$userId
);
$continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData);
$continueWithSubscription = $repository->checkSequenceAreCompleted($requirementsData);
if (!$continueWithSubscription) {
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/courses.php');
@ -275,17 +661,23 @@ switch ($action) {
}
break;
case 'search_tag':
if (!$user_can_view_page) {
if (!$userCanViewPage) {
api_not_allowed(true);
}
$courseController->sessionsListByCoursesTag($limit);
CoursesAndSessionsCatalog::sessionsListByCoursesTag($limit);
exit;
break;
case 'search_session_title':
if (!$user_can_view_page) {
if (!$userCanViewPage) {
api_not_allowed(true);
}
$courseController->sessionsListByName($limit);
CoursesAndSessionsCatalog::sessionsListByName($limit);
exit;
break;
}
$template = new Template($toolTitle, true, true, false, false, false);
$template->assign('content', $content);
$template->display_one_col_template();

@ -1,523 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
/**
* View (MVC patter) for courses categories.
*
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
*/
if (isset($_REQUEST['action']) && 'subscribe' !== Security::remove_XSS($_REQUEST['action'])) {
$stok = Security::get_token();
} else {
$stok = Security::getTokenFromSession();
}
$action = !empty($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']) : 'display_courses';
global $actions;
$action = in_array($action, $actions) ? $action : 'display_courses';
$showCourses = CoursesAndSessionsCatalog::showCourses();
$showSessions = CoursesAndSessionsCatalog::showSessions();
$pageCurrent = isset($_GET['pageCurrent']) ? (int) $_GET['pageCurrent'] : 1;
$pageLength = isset($_GET['pageLength']) ? (int) $_GET['pageLength'] : CoursesAndSessionsCatalog::PAGE_LENGTH;
$pageTotal = (int) ceil((int) $countCoursesInCategory / $pageLength);
$cataloguePagination = $pageTotal > 1 ? CourseCategory::getCatalogPagination($pageCurrent, $pageLength, $pageTotal) : '';
$searchTerm = isset($_REQUEST['search_term']) ? Security::remove_XSS($_REQUEST['search_term']) : '';
$codeType = isset($_REQUEST['category_code']) ? Security::remove_XSS($_REQUEST['category_code']) : '';
$date = date('Y-m-d');
if ($showSessions && isset($_POST['date'])) {
$date = $_POST['date'];
}
$userInfo = api_get_user_info();
$code = isset($code) ? $code : null;
?>
<script>
$(function() {
$('.star-rating li a').on('click', function(event) {
var id = $(this).parents('ul').attr('id');
$('#vote_label2_' + id).html("<?php echo get_lang('Loading'); ?>");
$.ajax({
url: $(this).attr('data-link'),
success: function(data) {
$("#rating_wrapper_"+id).html(data);
}
});
});
var getSessionId = function (el) {
var parts = el.id.split('_');
return parseInt(parts[1], 10);
};
<?php if ($showSessions) {
?>
$('#date').datepicker({
dateFormat: 'yy-mm-dd'
});
<?php
} ?>
});
</script>
<?php
echo CoursesController::getTabList(1);
echo '<div class="row">
<div class="col-md-12">
<div class="search-courses">
<div class="row">';
if ($showCourses) {
echo '<div class="col-md-'.($showSessions ? '4' : '6').'">';
if (!isset($_GET['hidden_links']) || 1 != intval($_GET['hidden_links'])) {
?>
<form method="post"
action="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, 'ALL', 0, 'subscribe'); ?>">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="search_course" value="1"/>
<label><?php echo get_lang('Search'); ?></label>
<div class="input-group">
<input class="form-control" type="text" name="search_term"
value="<?php echo empty($_POST['search_term']) ? '' : api_htmlentities($searchTerm); ?>"/>
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<em class="fa fa-search"></em> <?php echo get_lang('Search'); ?>
</button>
</div>
</div>
</form>
<?php
}
echo '</div>';
echo '<div class="col-md-'.($showSessions ? '4' : '6').'">';
$listCategories = CoursesAndSessionsCatalog::getCourseCategoriesTree();
$categoriesSelect = getOptionSelect($listCategories, $codeType);
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$form = '<form action="'.$webAction.'" method="GET">';
$form .= '<input type="hidden" name="action" value="'.$action.'">';
$form .= '<input type="hidden" name="pageCurrent" value="'.$pageCurrent.'">';
$form .= '<input type="hidden" name="pageLength" value="'.$pageLength.'">';
$form .= '<div class="form-group">';
$form .= '<label>'.get_lang('Courses categories').'</label>';
$form .= $categoriesSelect;
$form .= '</div>';
$form .= '</form>';
echo $form;
echo '</div>';
}
echo '</div></div></div></div>';
if ($showCourses && 'display_sessions' != $action) {
if (!empty($message)) {
echo Display::return_message($message, 'confirmation', false);
}
if (!empty($error)) {
echo Display::return_message($error, 'error', false);
}
if (!empty($content)) {
echo $content;
}
if (!empty($searchTerm)) {
echo "<p><strong>".get_lang('Search results for:')." ".$searchTerm."</strong><br />";
}
$showTeacher = 'true' === api_get_setting('display_teacher_in_courselist');
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$user_id = api_get_user_id();
$categoryListFromDatabase = CourseCategory::getCategories();
$categoryList = [];
if (!empty($categoryListFromDatabase)) {
foreach ($categoryListFromDatabase as $categoryItem) {
$categoryList[$categoryItem['code']] = $categoryItem['name'];
}
}
if (!empty($browse_courses_in_category)) {
echo '<div class="grid-courses row">';
foreach ($browse_courses_in_category as $course) {
$course_hidden = COURSE_VISIBILITY_HIDDEN == $course['visibility'];
if ($course_hidden) {
continue;
}
$userRegisteredInCourse = CourseManager::is_user_subscribed_in_course($user_id, $course['code']);
$userRegisteredInCourseAsTeacher = CourseManager::is_course_teacher($user_id, $course['code']);
$userRegistered = $userRegisteredInCourse && $userRegisteredInCourseAsTeacher;
$course_public = COURSE_VISIBILITY_OPEN_WORLD == $course['visibility'];
$course_open = COURSE_VISIBILITY_OPEN_PLATFORM == $course['visibility'];
$course_private = COURSE_VISIBILITY_REGISTERED == $course['visibility'];
$course_closed = COURSE_VISIBILITY_CLOSED == $course['visibility'];
$course_subscribe_allowed = 1 == $course['subscribe'];
$course_unsubscribe_allowed = 1 == $course['unsubscribe'];
$count_connections = $course['count_connections'];
$creation_date = substr($course['creation_date'], 0, 10);
// display the course bloc
$html = '<div class="col-xs-12 col-sm-6 col-md-4"><div class="items items-courses">';
$course['category_title'] = '';
if (isset($course['category'])) {
$course['category_title'] = isset($categoryList[$course['category']]) ? $categoryList[$course['category']] : '';
}
// Display thumbnail
$html .= returnThumbnail($course, $userRegistered);
$separator = null;
$subscribeButton = return_register_button($course, $stok, $code, $searchTerm);
// Start buy course validation
// display the course price and buy button if the buycourses plugin is enabled and this course is configured
$plugin = BuyCoursesPlugin::create();
$isThisCourseInSale = $plugin->buyCoursesForGridCatalogValidator(
$course['real_id'],
BuyCoursesPlugin::PRODUCT_TYPE_COURSE
);
if ($isThisCourseInSale) {
// set the Price label
$separator = $isThisCourseInSale['html'];
// set the Buy button instead register.
if ($isThisCourseInSale['verificator']) {
$subscribeButton = $plugin->returnBuyCourseButton(
$course['real_id'],
BuyCoursesPlugin::PRODUCT_TYPE_COURSE
);
}
}
// end buy course validation
// display course title and button bloc
$html .= '<div class="description">';
$html .= return_title($course, $userRegisteredInCourse);
if ($showTeacher) {
$html .= return_teacher($course);
}
// display button line
$html .= '<div class="toolbar row">';
$html .= $separator ? '<div class="col-sm-4">'.$separator.'</div>' : '';
$html .= '<div class="col-sm-8">';
// if user registered as student
if ($userRegisteredInCourse) {
$html .= return_already_registered_label('student');
if (!$course_closed) {
if ($course_unsubscribe_allowed) {
$html .= return_unregister_button($course, $stok, $searchTerm, $code);
}
}
} elseif ($userRegisteredInCourseAsTeacher) {
// if user registered as teacher
if ($course_unsubscribe_allowed) {
$html .= return_unregister_button($course, $stok, $searchTerm, $code);
}
} else {
// if user not registered in the course
if (!$course_closed) {
if (!$course_private) {
if ($course_subscribe_allowed) {
$html .= $subscribeButton;
}
}
}
}
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
echo $html;
}
echo '</div>';
} else {
if (!isset($_REQUEST['subscribe_user_with_password']) &&
!isset($_REQUEST['subscribe_course'])
) {
echo Display::return_message(
get_lang('No course at this category level'),
'warning'
);
}
}
}
echo '<div class="col-md-12">';
echo $cataloguePagination;
echo '</div>';
function getOptionSelect($categories, $codeType)
{
$html = '';
$html .= '<select name="category_code" onchange="submit();" class="selectpicker form-control">';
foreach ($categories as $category) {
$categoryCode = Security::remove_XSS($category['code']);
$categoryName = Security::remove_XSS($category['name']);
$countCourse = (int) $category['number_courses'];
$level = $category['level'];
if (empty($countCourse)) {
continue;
}
if ($level > 0) {
$separate = str_repeat('--', $level);
} else {
$separate = '';
}
$html .= '<option '.($categoryCode == $codeType ? 'selected="selected" ' : '')
.' value="'.$categoryCode.'">'.$separate.' '.$categoryName.' ('.$countCourse.') </option>';
}
$html .= '</select>';
return $html;
}
/**
* Display the course catalog image of a course.
*
* @param array $course
* @param bool $registeredUser
*
* @return string HTML string
*/
function returnThumbnail($course)
{
$html = '';
$title = cut($course['title'], 70);
//$linkCourse = api_get_course_url($course['code']);
$linkCourse = api_get_path(WEB_PATH).'courses/'.$course['real_id'].'/about';
$courseEntity = api_get_course_entity($course['real_id']);
$courseMediumImage = Display::return_icon(
'session_default.png',
null,
null,
null,
null,
true,
true
);
$illustrationUrl = Container::getIllustrationRepository()->getIllustrationUrl(
$courseEntity,
'course_picture_medium'
);
if ($illustrationUrl) {
$courseMediumImage = $illustrationUrl;
}
$html .= '<div class="image">';
$html .= '<a href="'.$linkCourse.'" title="'.$course['title'].'">'
.'<img class="img-responsive" src="'.$courseMediumImage.'" '
.'alt="'.api_htmlentities($title).'"/></a>';
$categoryTitle = isset($course['category_title']) ? $course['category_title'] : '';
if (!empty($categoryTitle)) {
$html .= '<span class="category">'.$categoryTitle.'</span>';
$html .= '<div class="cribbon"></div>';
}
$html .= '<div class="user-actions">';
$html .= CourseManager::returnDescriptionButton($course);
$html .= '</div></div>';
return $html;
}
/**
* @param array $courseInfo
*
* @return string
*/
function return_teacher($courseInfo)
{
$teachers = CourseManager::getTeachersFromCourse($courseInfo['real_id']);
$length = count($teachers);
if (!$length) {
return '';
}
$html = '<div class="block-author">';
if ($length > 6) {
$html .= '<a
id="plist"
data-trigger="focus"
tabindex="0" role="button"
class="btn btn-default panel_popover"
data-toggle="popover"
title="'.addslashes(get_lang('Trainers')).'"
data-html="true"
>
<i class="fa fa-graduation-cap" aria-hidden="true"></i>
</a>';
$html .= '<div id="popover-content-plist" class="hide">';
foreach ($teachers as $value) {
$name = $value['firstname'].' '.$value['lastname'];
$html .= '<div class="popover-teacher">';
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" title="'.$name.'" alt="'.get_lang('Picture').'"/></a>';
$html .= '<div class="teachers-details"><h5>
<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">'
.$name.'</a></h5></div>';
$html .= '</div>';
}
$html .= '</div>';
} else {
foreach ($teachers as $value) {
$name = $value['firstname'].' '.$value['lastname'];
if ($length > 2) {
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" title="'.$name.'" alt="'.get_lang('Picture').'"/></a>';
} else {
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" title="'.$name.'" alt="'.get_lang('Picture').'"/></a>';
$html .= '<div class="teachers-details"><h5>
<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">'
.$name.'</a></h5><p>'.get_lang('Trainer').'</p></div>';
}
}
}
$html .= '</div>';
return $html;
}
/**
* Display the title of a course in course catalog.
*
* @param array $course
*
* @return string HTML string
*/
function return_title($course)
{
$html = '<div class="block-title"><h4 class="title">';
$html .= '<a title="'.$course['title'].'" href="'.$course['about_url'].'">'.$course['title'].'</a>';
$html .= '</h4></div>';
if (false === api_get_configuration_value('hide_course_rating')) {
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$rating = Display::return_rating_system(
'star_'.$course['real_id'],
$ajax_url.'&course_id='.$course['real_id'],
$course['point_info']
);
$html .= '<div class="ranking">'.$rating.'</div>';
}
return $html;
}
/**
* Display the goto course button of a course in the course catalog.
*
* @param $course
*
* @return string HTML string
*/
function return_goto_button($course)
{
$title = get_lang('Go to the course');
$html = Display::url(
Display::returnFontAwesomeIcon('share'),
api_get_course_url($course['code']),
[
'class' => 'btn btn-default btn-sm',
'title' => $title,
'aria-label' => $title,
]
);
return $html.PHP_EOL;
}
/**
* Display the already registerd text in a course in the course catalog.
*
* @param $in_status
*
* @return string HTML string
*/
function return_already_registered_label($in_status)
{
$icon = '<em class="fa fa-check"></em>';
$title = get_lang("YouAreATrainerOfThisCourse");
if ('student' == $in_status) {
$icon = '<em class="fa fa-check"></em>';
$title = get_lang("Already subscribed");
}
$html = Display::tag(
'span',
$icon.' '.$title,
[
'id' => 'register',
'class' => 'label-subscribed text-success',
'title' => $title,
'aria-label' => $title,
]
);
return $html.PHP_EOL;
}
/**
* Display the register button of a course in the course catalog.
*
* @param $course
* @param $stok
* @param $code
* @param $search_term
*
* @return string
*/
function return_register_button($course, $stok, $code, $search_term)
{
$title = get_lang('Subscribe');
$action = 'subscribe_course';
if (!empty($course['registration_code'])) {
$action = 'subscribe_course_validation';
}
$html = Display::url(
Display::returnFontAwesomeIcon('check').' '.$title,
api_get_self().'?action='.$action.'&sec_token='.$stok.
'&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code,
['class' => 'btn btn-success btn-sm', 'title' => $title, 'aria-label' => $title]
);
return $html;
}
/**
* Display the unregister button of a course in the course catalog.
*
* @param $course
* @param $stok
* @param $search_term
* @param $code
*
* @return string
*/
function return_unregister_button($course, $stok, $search_term, $code)
{
$title = get_lang('Unsubscribe');
$html = Display::url(
Display::returnFontAwesomeIcon('sign-in').' '.$title,
api_get_self().'?action=unsubscribe&sec_token='.$stok
.'&unsubscribe='.$course['code'].'&search_term='.$search_term.'&category_code='.$code,
['class' => 'btn btn-danger btn-sm', 'title' => $title, 'aria-label' => $title]
);
return $html;
}

@ -1,673 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\SequenceResource;
use Chamilo\CoreBundle\Entity\SessionRelCourse;
use Chamilo\CoreBundle\Entity\Tag;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Hook\HookResubscribe;
use Chamilo\CoreBundle\Repository\SequenceRepository;
/**
* Class CoursesController.
*
* This file contains class used like controller,
* it should be included inside a dispatcher file (e.g: index.php)
*
* @author Christian Fasanando <christian1827@gmail.com> - BeezNest
*/
class CoursesController
{
private $toolname;
private $view;
private $model;
/**
* Constructor.
*/
public function __construct()
{
$this->toolname = 'auth';
$this->view = new View($this->toolname);
$this->model = new Auth();
}
/**
* It's used for listing courses with categories,
* render to courses_categories view.
*
* @param string $action
* @param string $category_code
* @param string $message
* @param string $error
* @param string $content
* @param array $limit will be used if $random_value is not set.
* This array should contains 'start' and 'length' keys
*
* @internal param \action $string
* @internal param \Category $string code (optional)
*/
public function courses_categories(
$action,
$category_code = null,
$message = '',
$error = '',
$content = null,
$limit = []
) {
$data = [];
$listCategories = CoursesAndSessionsCatalog::getCourseCategoriesTree();
$data['countCoursesInCategory'] = CourseCategory::countCoursesInCategory($category_code);
if ('display_random_courses' === $action) {
// Random value is used instead limit filter
$data['browse_courses_in_category'] = CoursesAndSessionsCatalog::getCoursesInCategory(null, 12);
$data['countCoursesInCategory'] = count($data['browse_courses_in_category']);
} else {
if (!isset($category_code)) {
$category_code = $listCategories['ALL']['code']; // by default first category
}
$limit = isset($limit) ? $limit : self::getLimitArray();
$listCourses = CoursesAndSessionsCatalog::getCoursesInCategory($category_code, null, $limit);
$data['browse_courses_in_category'] = $listCourses;
}
$data['list_categories'] = $listCategories;
$data['code'] = Security::remove_XSS($category_code);
// getting all the courses to which the user is subscribed to
$curr_user_id = api_get_user_id();
$user_courses = $this->model->get_courses_of_user($curr_user_id);
$user_coursecodes = [];
// we need only the course codes as these will be used to match against the courses of the category
if ('' != $user_courses) {
foreach ($user_courses as $key => $value) {
$user_coursecodes[] = $value['code'];
}
}
if (api_is_drh()) {
$courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
foreach ($courses as $course) {
$user_coursecodes[] = $course['code'];
}
}
$data['user_coursecodes'] = $user_coursecodes;
$data['action'] = $action;
$data['message'] = $message;
$data['content'] = $content;
$data['error'] = $error;
$data['catalogShowCoursesSessions'] = 0;
$showCoursesSessions = (int) api_get_setting('catalog_show_courses_sessions');
if ($showCoursesSessions > 0) {
$data['catalogShowCoursesSessions'] = $showCoursesSessions;
}
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('courses_categories');
$this->view->render();
}
/**
* @param string $search_term
* @param string $message
* @param string $error
* @param string $content
* @param array $limit
* @param bool $justVisible Whether to search only in courses visibles in the catalogue
*/
public function search_courses(
$search_term,
$message = '',
$error = '',
$content = null,
$limit = [],
$justVisible = false
) {
$data = [];
$limit = !empty($limit) ? $limit : self::getLimitArray();
$browse_course_categories = CoursesAndSessionsCatalog::getCourseCategories();
$data['countCoursesInCategory'] = CourseCategory::countCoursesInCategory('ALL', $search_term);
$data['browse_courses_in_category'] = CoursesAndSessionsCatalog::search_courses(
$search_term,
$limit,
$justVisible
);
$data['browse_course_categories'] = $browse_course_categories;
$data['search_term'] = Security::remove_XSS($search_term); //filter before showing in template
// getting all the courses to which the user is subscribed to
$curr_user_id = api_get_user_id();
$user_courses = $this->model->get_courses_of_user($curr_user_id);
$user_coursecodes = [];
// we need only the course codes as these will be used to match against the courses of the category
if ('' != $user_courses) {
foreach ($user_courses as $value) {
$user_coursecodes[] = $value['code'];
}
}
$data['user_coursecodes'] = $user_coursecodes;
$data['message'] = $message;
$data['content'] = $content;
$data['error'] = $error;
$data['action'] = 'display_courses';
// render to the view
$this->view->set_data($data);
$this->view->set_layout('catalog_layout');
$this->view->set_template('courses_categories');
$this->view->render();
}
/**
* Unsubscribe user from a course
* render to listing view.
*
* @param string $course_code
* @param string $search_term
* @param string $category_code
*/
public function unsubscribe_user_from_course(
$course_code,
$search_term = null,
$category_code = null
) {
$result = $this->model->remove_user_from_course($course_code);
$message = '';
$error = '';
if ($result) {
Display::addFlash(
Display::return_message(get_lang('You have been unsubscribed from this course'))
);
}
if (!empty($search_term)) {
CoursesAndSessionsCatalog::search_courses($search_term, $message, $error);
} else {
$this->courses_categories(
'subcribe',
$category_code,
$message,
$error
);
}
}
/**
* Get a HTML button for subscribe to session.
*
* @param int $sessionId The session ID
* @param string $sessionName The session name
* @param bool $checkRequirements Optional.
* Whether the session has requirement. Default is false
* @param bool $includeText Optional. Whether show the text in button
* @param bool $btnBing
*
* @return string The button HTML
*/
public function getRegisteredInSessionButton(
$sessionId,
$sessionName,
$checkRequirements = false,
$includeText = false,
$btnBing = false
) {
$sessionId = (int) $sessionId;
if ($btnBing) {
$btnBing = 'btn-lg btn-block';
} else {
$btnBing = 'btn-sm';
}
if ($checkRequirements) {
return $this->getRequirements($sessionId, SequenceResource::SESSION_TYPE, $includeText, $btnBing);
}
$catalogSessionAutoSubscriptionAllowed = false;
if ('true' === api_get_setting('catalog_allow_session_auto_subscription')) {
$catalogSessionAutoSubscriptionAllowed = true;
}
$url = api_get_path(WEB_CODE_PATH);
if ($catalogSessionAutoSubscriptionAllowed) {
$url .= 'auth/courses.php?';
$url .= http_build_query([
'action' => 'subscribe_to_session',
'session_id' => $sessionId,
]);
$result = Display::toolbarButton(
get_lang('Subscribe'),
$url,
'pencil',
'primary',
[
'class' => $btnBing.' ajax',
'data-title' => get_lang('Are you sure to subscribe?'),
'data-size' => 'md',
'title' => get_lang('Subscribe'),
],
$includeText
);
} else {
$url .= 'inc/email_editor.php?';
$url .= http_build_query([
'action' => 'subscribe_me_to_session',
'session' => Security::remove_XSS($sessionName),
]);
$result = Display::toolbarButton(
get_lang('Request subscription'),
$url,
'pencil',
'primary',
['class' => $btnBing],
$includeText
);
}
return $result;
}
public function getRequirements($id, $type, $includeText, $btnBing)
{
$id = (int) $id;
$type = (int) $type;
$url = api_get_path(WEB_AJAX_PATH);
$url .= 'sequence.ajax.php?';
$url .= http_build_query(
[
'a' => 'get_requirements',
'id' => $id,
'type' => $type,
]
);
return Display::toolbarButton(
get_lang('CheckRequirements'),
$url,
'shield',
'info',
[
'class' => $btnBing.' ajax',
'data-title' => get_lang('CheckRequirements'),
'data-size' => 'md',
'title' => get_lang('CheckRequirements'),
],
$includeText
);
}
/**
* Generate a label if the user has been registered in session.
*
* @return string The label
*/
public function getAlreadyRegisteredInSessionLabel()
{
$icon = '<em class="fa fa-graduation-cap"></em>';
return Display::div(
$icon,
[
'class' => 'btn btn-default btn-sm registered',
'title' => get_lang("Already registered to session"),
]
);
}
/**
* Get a icon for a session.
*
* @param string $sessionName The session name
*
* @return string The icon
*/
public function getSessionIcon($sessionName)
{
return Display::return_icon(
'window_list.png',
$sessionName,
null,
ICON_SIZE_MEDIUM
);
}
/**
* Return Session catalog rendered view.
*
* @param array $limit
*/
public function sessionList($limit = [])
{
$date = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
$hiddenLinks = isset($_GET['hidden_links']) ? 1 == $_GET['hidden_links'] : false;
$limit = isset($limit) ? $limit : self::getLimitArray();
$countSessions = CoursesAndSessionsCatalog::browseSessions($date, [], false, true);
$sessions = CoursesAndSessionsCatalog::browseSessions($date, $limit);
$pageTotal = ceil($countSessions / $limit['length']);
// Do NOT show pagination if only one page or less
$pagination = $pageTotal > 1 ? CourseCategory::getCatalogPagination($limit['current'], $limit['length'], $pageTotal) : '';
$sessionsBlocks = $this->getFormattedSessionsBlock($sessions);
// Get session search catalogue URL
$courseUrl = CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
null,
0,
'subscribe'
);
$tpl = new Template();
$tpl->assign('actions', self::getTabList(2));
$tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
$tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
$tpl->assign('show_tutor', 'true' === api_get_setting('show_session_coach'));
$tpl->assign('course_url', $courseUrl);
$tpl->assign('catalog_pagination', $pagination);
$tpl->assign('hidden_links', $hiddenLinks);
$tpl->assign('search_token', Security::get_token());
$tpl->assign('search_date', $date);
$tpl->assign('web_session_courses_ajax_url', api_get_path(WEB_AJAX_PATH).'course.ajax.php');
$tpl->assign('sessions', $sessionsBlocks);
$tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
$tpl->assign('catalog_settings', self::getCatalogSearchSettings());
$layout = $tpl->get_template('auth/session_catalog.html.twig');
$content = $tpl->fetch($layout);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
}
/**
* Show the Session Catalogue with filtered session by course tags.
*
* @param array $limit Limit info
*/
public function sessionsListByName(array $limit)
{
$keyword = isset($_POST['keyword']) ? $_POST['keyword'] : null;
$hiddenLinks = isset($_GET['hidden_links']) ? 1 == (int) $_GET['hidden_links'] : false;
$courseUrl = CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
null,
0,
'subscribe'
);
$sessions = CoursesAndSessionsCatalog::getSessionsByName($keyword, $limit);
$sessionsBlocks = $this->getFormattedSessionsBlock($sessions);
$tpl = new Template();
$tpl->assign('actions', self::getTabList(2));
$tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
$tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
$tpl->assign('show_tutor', 'true' === api_get_setting('show_session_coach') ? true : false);
$tpl->assign('course_url', $courseUrl);
$tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
$tpl->assign('hidden_links', $hiddenLinks);
$tpl->assign('search_token', Security::get_token());
$tpl->assign('keyword', Security::remove_XSS($keyword));
$tpl->assign('sessions', $sessionsBlocks);
$tpl->assign('catalog_settings', self::getCatalogSearchSettings());
$layout = $tpl->get_template('auth/session_catalog.html.twig');
$content = $tpl->fetch($layout);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
}
public static function getCatalogSearchSettings()
{
$settings = api_get_configuration_value('catalog_settings');
if (empty($settings)) {
// Default everything is visible
$settings = [
'sessions' => [
'by_title' => true,
'by_date' => true,
'by_tag' => true,
'show_session_info' => true,
'show_session_date' => true,
],
];
}
return $settings;
}
/**
* @param int $active
*
* @return string
*/
public static function getTabList($active = 1)
{
$pageLength = isset($_GET['pageLength']) ? (int) $_GET['pageLength'] : CoursesAndSessionsCatalog::PAGE_LENGTH;
$url = CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions');
$headers = [];
if (CoursesAndSessionsCatalog::showCourses()) {
$headers[] = [
'url' => api_get_self(),
'content' => get_lang('CourseManagement'),
];
}
if (CoursesAndSessionsCatalog::showSessions()) {
$headers[] = [
'url' => $url,
'content' => get_lang('SessionList'),
];
}
return Display::tabsOnlyLink($headers, $active);
}
/**
* Show the Session Catalogue with filtered session by course tags.
*
* @param array $limit Limit info
*/
public function sessionsListByCoursesTag(array $limit)
{
$searchTag = isset($_POST['search_tag']) ? $_POST['search_tag'] : null;
$searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
$hiddenLinks = isset($_GET['hidden_links']) ? 1 == (int) $_GET['hidden_links'] : false;
$courseUrl = CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
null,
0,
'subscribe'
);
$sessions = CoursesAndSessionsCatalog::browseSessionsByTags($searchTag, $limit);
$sessionsBlocks = $this->getFormattedSessionsBlock($sessions);
$tpl = new Template();
$tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
$tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
$tpl->assign('show_tutor', 'true' === api_get_setting('show_session_coach') ? true : false);
$tpl->assign('course_url', $courseUrl);
$tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
$tpl->assign('hidden_links', $hiddenLinks);
$tpl->assign('search_token', Security::get_token());
$tpl->assign('search_date', Security::remove_XSS($searchDate));
$tpl->assign('search_tag', Security::remove_XSS($searchTag));
$tpl->assign('sessions', $sessionsBlocks);
$contentTemplate = $tpl->get_template('auth/session_catalog.tpl');
$tpl->display($contentTemplate);
}
/**
* @return array
*/
public static function getLimitArray()
{
$pageCurrent = isset($_REQUEST['pageCurrent']) ? (int) $_GET['pageCurrent'] : 1;
$pageLength = isset($_REQUEST['pageLength']) ? (int) $_GET['pageLength'] : CoursesAndSessionsCatalog::PAGE_LENGTH;
return [
'start' => ($pageCurrent - 1) * $pageLength,
'current' => $pageCurrent,
'length' => $pageLength,
];
}
/**
* Get the formatted data for sessions block to be displayed on Session Catalog page.
*
* @param array $sessions The session list
*
* @return array
*/
private function getFormattedSessionsBlock(array $sessions)
{
$extraFieldValue = new ExtraFieldValue('session');
$userId = api_get_user_id();
$sessionsBlocks = [];
$entityManager = Database::getManager();
$sessionRelCourseRepo = $entityManager->getRepository('ChamiloCoreBundle:SessionRelCourse');
$extraFieldRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraField');
$extraFieldRelTagRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraFieldRelTag');
$tagsField = $extraFieldRepo->findOneBy([
'extraFieldType' => Chamilo\CoreBundle\Entity\ExtraField::COURSE_FIELD_TYPE,
'variable' => 'tags',
]);
/** @var \Chamilo\CoreBundle\Entity\Session $session */
foreach ($sessions as $session) {
$sessionDates = SessionManager::parseSessionDates([
'display_start_date' => $session->getDisplayStartDate(),
'display_end_date' => $session->getDisplayEndDate(),
'access_start_date' => $session->getAccessStartDate(),
'access_end_date' => $session->getAccessEndDate(),
'coach_access_start_date' => $session->getCoachAccessStartDate(),
'coach_access_end_date' => $session->getCoachAccessEndDate(),
]);
$imageField = $extraFieldValue->get_values_by_handler_and_field_variable(
$session->getId(),
'image'
);
$sessionCourseTags = [];
if (!is_null($tagsField)) {
$sessionRelCourses = $sessionRelCourseRepo->findBy([
'session' => $session,
]);
/** @var SessionRelCourse $sessionRelCourse */
foreach ($sessionRelCourses as $sessionRelCourse) {
$courseTags = $extraFieldRelTagRepo->getTags(
$tagsField,
$sessionRelCourse->getCourse()->getId()
);
/** @var Tag $tag */
foreach ($courseTags as $tag) {
$sessionCourseTags[] = $tag->getTag();
}
}
}
if (!empty($sessionCourseTags)) {
$sessionCourseTags = array_unique($sessionCourseTags);
}
/** @var SequenceRepository $repo */
$repo = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
$sequences = $repo->getRequirementsAndDependenciesWithinSequences(
$session->getId(),
SequenceResource::SESSION_TYPE
);
$hasRequirements = false;
foreach ($sequences as $sequence) {
if (0 === count($sequence['requirements'])) {
continue;
}
$hasRequirements = true;
break;
}
$cat = $session->getCategory();
if (empty($cat)) {
$cat = null;
$catName = '';
} else {
$catName = $cat->getName();
}
$generalCoach = $session->getGeneralCoach();
$coachId = $generalCoach ? $generalCoach->getId() : 0;
$coachName = $generalCoach ? UserManager::formatUserFullName($session->getGeneralCoach()) : '';
$actions = null;
if (api_is_platform_admin()) {
$actions = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session->getId();
}
$plugin = \BuyCoursesPlugin::create();
$isThisSessionOnSale = $plugin->getBuyCoursePluginPrice($session);
$sessionsBlock = [
'id' => $session->getId(),
'name' => $session->getName(),
'image' => isset($imageField['value']) ? $imageField['value'] : null,
'nbr_courses' => $session->getNbrCourses(),
'nbr_users' => $session->getNbrUsers(),
'coach_id' => $coachId,
'coach_url' => $generalCoach
? api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$coachId
: '',
'coach_name' => $coachName,
'coach_avatar' => UserManager::getUserPicture(
$coachId,
USER_IMAGE_SIZE_SMALL
),
'is_subscribed' => SessionManager::isUserSubscribedAsStudent(
$session->getId(),
$userId
),
'icon' => $this->getSessionIcon($session->getName()),
'date' => $sessionDates['display'],
'price' => !empty($isThisSessionOnSale['html']) ? $isThisSessionOnSale['html'] : '',
'subscribe_button' => isset($isThisSessionOnSale['buy_button']) ? $isThisSessionOnSale['buy_button'] : $this->getRegisteredInSessionButton(
$session->getId(),
$session->getName(),
$hasRequirements
),
'show_description' => $session->getShowDescription(),
'description' => $session->getDescription(),
'category' => $catName,
'tags' => $sessionCourseTags,
'edit_actions' => $actions,
'duration' => SessionManager::getDayLeftInSession(
['id' => $session->getId(), 'duration' => $session->getDuration()],
$userId
),
];
$sessionsBlocks[] = array_merge($sessionsBlock, $sequences);
}
return $sessionsBlocks;
}
}

@ -157,20 +157,8 @@ if (!empty($userJustifications)) {
$userJustificationList .= $justificationContent.$table->toHtml();
}
$justificationTab = '';
$headers = [
[
'url' => api_get_path(WEB_CODE_PATH).'auth/profile.php',
'content' => get_lang('Profile'),
],
[
'url' => api_get_path(WEB_CODE_PATH).'auth/justification.php',
'content' => $plugin->get_lang('Justification'),
],
];
$justificationTab = Display::tabsOnlyLink($headers, 2);
$justification = $justificationTab.$formValidator->returnForm().$userJustificationList;
$tabs = SocialManager::getHomeProfileTabs('justification');
$justification = $tabs.$formValidator->returnForm().$userJustificationList;
$tpl = new Template(get_lang('ModifyProfile'));

@ -1,17 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Layout (principal view) used for structuring other views.
*
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
*/
// Header
Display::display_header('');
// Display
echo $content;
// Footer
Display::display_footer();

@ -116,6 +116,10 @@ if ($form->validate()) {
exit;
}
if ('true' === api_get_plugin_setting('whispeakauth', WhispeakAuthPlugin::SETTING_ENABLE)) {
WhispeakAuthPlugin::deleteEnrollment($user['uid']);
}
$passwordEncryption = api_get_configuration_value('password_encryption');
if ('none' === $passwordEncryption) {

@ -32,7 +32,7 @@ $return = $extraField->addElements(
[],
false,
false,
['pause_formation', 'start_pause_date', 'end_pause_date', 'allow_notifications'],
['pause_formation', 'start_pause_date', 'end_pause_date'],
[],
[],
false,
@ -54,11 +54,6 @@ if ($form->validate()) {
if (!isset($values['extra_pause_formation'])) {
$values['extra_pause_formation'] = 0;
}
if (!isset($values['extra_allow_notifications'])) {
$values['extra_allow_notifications'] = 0;
}
$extraField = new ExtraFieldValue('user');
$extraField->saveFieldValues($values, true, false, [], [], true);

@ -23,8 +23,6 @@ if ($allowSocialTool) {
$logInfo = [
'tool' => 'profile',
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => $this_section,
];
Event::registerLog($logInfo);
@ -100,7 +98,10 @@ $user_data = api_get_user_info(
);
$array_list_key = UserManager::get_api_keys(api_get_user_id());
$id_temp_key = UserManager::get_api_key_id(api_get_user_id(), 'dokeos');
$value_array = $array_list_key[$id_temp_key];
$value_array = [];
if (isset($array_list_key[$id_temp_key])) {
$value_array = $array_list_key[$id_temp_key];
}
$user_data['api_key_generate'] = $value_array;
if (false !== $user_data) {
@ -112,9 +113,6 @@ if (false !== $user_data) {
}
}
/*
* Initialize the form.
*/
$form = new FormValidator('profile');
if (api_is_western_name_order()) {
@ -691,23 +689,7 @@ if ($actions) {
}
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
$allowJustification = 'true' === api_get_plugin_setting('justification', 'tool_enable');
$justification = '';
if ($allowJustification) {
$plugin = Justification::create();
$headers = [
[
'url' => api_get_self(),
'content' => get_lang('Profile'),
],
[
'url' => api_get_path(WEB_CODE_PATH).'auth/justification.php',
'content' => $plugin->get_lang('Justification'),
],
];
$justification = Display::tabsOnlyLink($headers, 1);
}
$tabs = SocialManager::getHomeProfileTabs('profile');
if ($allowSocialTool) {
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true; // Flag forcing the 'current course' reset
@ -9,7 +10,7 @@ api_block_anonymous_users();
$auth = new Auth();
$user_course_categories = CourseManager::get_user_course_categories(api_get_user_id());
$courses_in_category = $auth->get_courses_in_category();
$courses_in_category = $auth->getCoursesInCategory();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$currentUrl = api_get_self();

@ -1,385 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* List sessions in an efficient and usable way.
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
SessionManager::protectSession(null, false);
// Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null;
$list_type = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'simple';
$tool_name = get_lang('SessionList');
Display::display_header($tool_name);
$courseId = isset($_GET['course_id']) ? $_GET['course_id'] : null;
$sessionFilter = new FormValidator(
'course_filter',
'get',
'',
'',
[],
FormValidator::LAYOUT_INLINE
);
$courseSelect = $sessionFilter->addElement(
'select_ajax',
'course_name',
get_lang('SearchCourse'),
null,
['url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course']
);
if (!empty($courseId)) {
$courseInfo = api_get_course_info_by_id($courseId);
$parents = CourseCategory::getParentsToString($courseInfo['categoryCode']);
$courseSelect->addOption($parents.$courseInfo['title'], $courseInfo['code'], ['selected' => 'selected']);
}
$url = api_get_self();
$actions = '
<script>
$(function() {
$("#course_name").on("change", function() {
var courseId = $(this).val();
if (!courseId) {
return;
}
window.location = "'.$url.'?course_id="+courseId;
});
});
</script>';
// jqgrid will use this URL to do the selects
if (!empty($courseId)) {
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&course_id='.$courseId;
} else {
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions';
}
if (isset($_REQUEST['keyword'])) {
//Begin with see the searchOper param
$filter = new stdClass();
$filter->groupOp = 'OR';
$rule = new stdClass();
$rule->field = 'category_name';
$rule->op = 'in';
$rule->data = Security::remove_XSS($_REQUEST['keyword']);
$filter->rules[] = $rule;
$filter->groupOp = 'OR';
$filter = json_encode($filter);
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_force_search=true&rows=20&page=1&sidx=&sord=asc&filters='.$filter.'&searchField=s.name&searchString='.Security::remove_XSS($_REQUEST['keyword']).'&searchOper=in';
}
if (isset($_REQUEST['id_category'])) {
$sessionCategory = SessionManager::get_session_category($_REQUEST['id_category']);
if (!empty($sessionCategory)) {
//Begin with see the searchOper param
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_force_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=sc.name&searchString='.Security::remove_XSS($sessionCategory['name']).'&searchOper=in';
}
}
$url .= '&list_type='.$list_type;
$result = SessionManager::getGridColumns($list_type);
$columns = $result['columns'];
$column_model = $result['column_model'];
// Autowidth
$extra_params['autowidth'] = 'true';
// height auto
$extra_params['height'] = 'auto';
if (!isset($_GET['keyword'])) {
$extra_params['postData'] = [
'filters' => [
'groupOp' => 'AND',
'rules' => $result['rules'],
],
];
}
$hideSearch = api_get_configuration_value('hide_search_form_in_session_list');
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="session_edit.php?page=resume_session.php&id=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a href="add_users_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('user_subscribe_session.png', get_lang('SubscribeUsersToSession'), '', ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a href="add_courses_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('courses_to_session.png', get_lang('SubscribeCoursesToSession'), '', ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="session_list.php?action=copy&idChecked=\'+options.rowId+\'">'.Display::return_icon('copy.png', get_lang('Copy'), '', ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="session_list.php?action=delete&idChecked=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'.
'\';
}';
$urlAjaxExtraField = api_get_path(WEB_AJAX_PATH).'extra_field.ajax.php?1=1';
$allowOrder = api_get_configuration_value('session_list_order');
$orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
?>
<script>
function setSearchSelect(columnName) {
$("#sessions").jqGrid('setColProp', columnName, {
});
}
var added_cols = [];
var original_cols = [];
function clean_cols(grid, added_cols) {
// Cleaning
for (key in added_cols) {
grid.hideCol(key);
};
grid.showCol('name');
grid.showCol('display_start_date');
grid.showCol('display_end_date');
grid.showCol('course_title');
}
function show_cols(grid, added_cols) {
grid.showCol('name').trigger('reloadGrid');
for (key in added_cols) {
grid.showCol(key);
};
}
var second_filters = [];
$(function() {
date_pick_today = function(elem) {
$(elem).datetimepicker({dateFormat: "yy-mm-dd"});
$(elem).datetimepicker('setDate', (new Date()));
}
date_pick_one_month = function(elem) {
$(elem).datetimepicker({dateFormat: "yy-mm-dd"});
next_month = Date.today().next().month();
$(elem).datetimepicker('setDate', next_month);
}
//Great hack
register_second_select = function(elem) {
second_filters[$(elem).val()] = $(elem);
}
fill_second_select = function(elem) {
$(elem).on("change", function() {
composed_id = $(this).val();
field_id = composed_id.split("#")[0];
id = composed_id.split("#")[1];
$.ajax({
url: "<?php echo $urlAjaxExtraField; ?>&a=get_second_select_options",
dataType: "json",
data: "type=session&field_id="+field_id+"&option_value_id="+id,
success: function(data) {
my_select = second_filters[field_id];
my_select.empty();
$.each(data, function(index, value) {
my_select.append($("<option/>", {
value: index,
text: value
}));
});
}
});
});
}
<?php
echo Display::grid_js(
'sessions',
$url,
$columns,
$column_model,
$extra_params,
[],
$action_links,
true
);
?>
setSearchSelect("status");
var grid = $("#sessions"),
prmSearch = {
multipleSearch : true,
overlay : false,
width: 'auto',
caption: '<?php echo addslashes(get_lang('Search')); ?>',
formclass:'data_table',
onSearch : function() {
var postdata = grid.jqGrid('getGridParam', 'postData');
if (postdata && postdata.filters) {
filters = jQuery.parseJSON(postdata.filters);
clean_cols(grid, added_cols);
added_cols = [];
$.each(filters, function(key, value) {
if (key == 'rules') {
$.each(value, function(subkey, subvalue) {
if (subvalue.data == undefined) {
}
added_cols[subvalue.field] = subvalue.field;
});
}
});
show_cols(grid, added_cols);
}
},
onReset: function() {
clean_cols(grid, added_cols);
}
};
original_cols = grid.jqGrid('getGridParam', 'colModel');
<?php if ($allowOrder) {
?>
options = {
update: function (e, ui) {
var rowNum = jQuery("#sessions").getGridParam('rowNum');
var page = jQuery("#sessions").getGridParam('page');
page = page - 1;
var start = rowNum * page;
var list = jQuery('#sessions').jqGrid('getRowData');
var orderList = [];
$(list).each(function(index, e) {
index = index + start;
orderList.push({'order':index, 'id': e.id});
});
orderList = JSON.stringify(orderList);
$.get("<?php echo $orderUrl; ?>", "order="+orderList, function (result) {
});
}
};
// Sortable rows
grid.jqGrid('sortableRows', options);
<?php
} ?>
grid.jqGrid('navGrid','#sessions_pager',
{edit:false,add:false,del:false},
{height:280,reloadAfterSubmit:false}, // edit options
{height:280,reloadAfterSubmit:false}, // add options
{reloadAfterSubmit:false},// del options
prmSearch
);
<?php
// Create the searching dialog.
if (true !== $hideSearch) {
echo 'grid.searchGrid(prmSearch);';
}
?>
// Fixes search table.
var searchDialogAll = $("#fbox_"+grid[0].id);
searchDialogAll.addClass("table");
var searchDialog = $("#searchmodfbox_"+grid[0].id);
searchDialog.addClass("ui-jqgrid ui-widget ui-widget-content ui-corner-all");
searchDialog.css({position:"adsolute", "z-index":"100", "float":"left", "top":"55%", "left" : "25%", "padding" : "5px", "border": "1px solid #CCC"})
var gbox = $("#gbox_"+grid[0].id);
gbox.before(searchDialog);
gbox.css({clear:"left"});
// Select first elements by default
$('.input-elm').each(function(){
$(this).find('option:first').attr('selected', 'selected');
});
$('.delete-rule').each(function(){
$(this).click(function(){
$('.input-elm').each(function(){
$(this).find('option:first').attr('selected', 'selected');
});
});
});
});
</script>
<div class="actions">
<?php
echo '<a href="'.api_get_path(WEB_CODE_PATH).'session/session_add.php">'.
Display::return_icon('new_session.png', get_lang('AddSession'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_is_platform_admin()) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'session/add_many_session_to_category.php">'.
Display::return_icon('session_to_category.png', get_lang('AddSessionsInCategories'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'session/session_category_list.php">'.
Display::return_icon('folder.png', get_lang('ListSessionCategory'), '', ICON_SIZE_MEDIUM).'</a>';
}
/*if ($list_type == 'complete') {
echo '<a href="'.api_get_self().'?list_type=simple">'.
Display::return_icon('view_remove.png', get_lang('Simple'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
echo '<a href="'.api_get_self().'?list_type=complete">'.
Display::return_icon('view_text.png', get_lang('Complete'), '', ICON_SIZE_MEDIUM).'</a>';
}*/
echo $actions;
if (api_is_platform_admin()) {
echo '<div class="pull-right">';
// Create a search-box
$form = new FormValidator(
'search_simple',
'get',
'',
'',
[],
FormValidator::LAYOUT_INLINE
);
$form->addElement('text', 'keyword', null, [
'aria-label' => get_lang('Search'),
]);
$form->addButtonSearch(get_lang('Search'));
$form->display();
echo '</div>';
echo '<div class="pull-right">';
echo $sessionFilter->returnForm();
echo '</div>';
}
echo '</div>';
$tabs = [
[
'content' => get_lang('SessionListCustom'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php',
],
[
'content' => get_lang('SessionList'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list_simple.php',
],
[
'content' => get_lang('Complete'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list_simple.php?list_type=complete',
],
];
$default = 2;
if ('complete' === $list_type) {
$default = 3;
}
echo Display::tabsOnlyLink($tabs, $default);
echo '<div id="session-table" class="table-responsive">';
echo Display::grid_html('sessions');
echo '</div>';
Display::display_footer();
Loading…
Cancel
Save