*/ // resetting the course id $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; $xajax = new xajax(); $xajax->registerFunction( ['search_courses', 'Accessurleditcoursestourl', 'search_courses'] ); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; // Access restrictions api_protect_global_admin_script(); if (!api_get_multiple_access_url()) { header('Location: index.php'); exit; } // setting breadcrumbs $tool_name = get_lang('EditCoursesToURL'); $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')]; $interbreadcrumb[] = ['url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')]; $add_type = 'multiple'; if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') { $add_type = Security::remove_XSS($_REQUEST['add_type']); } $access_url_id = 1; if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id'] != '') { $access_url_id = Security::remove_XSS($_REQUEST['access_url_id']); } $xajax->processRequests(); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = ''; if (isset($_POST['form_sent']) && $_POST['form_sent']) { $form_sent = $_POST['form_sent']; $course_list = $_POST['course_list']; if (!is_array($course_list)) { $course_list = []; } if ($form_sent == 1) { if ($access_url_id == 0) { Display::addFlash(Display::return_message(get_lang('SelectURL'))); header('Location: access_url_edit_users_to_url.php?'); } elseif (is_array($course_list)) { UrlManager::update_urls_rel_course($course_list, $access_url_id); Display::addFlash(Display::return_message(get_lang('CoursesWereEdited'))); header('Location: access_urls.php?'); } exit; } } Display::display_header($tool_name); echo '
'; echo Display::url( Display::return_icon('view_more_stats.gif', get_lang('AddUserToURL')), api_get_path(WEB_CODE_PATH).'admin/access_url_add_courses_to_url.php' ); echo '
'; api_display_tool_title($tool_name); $no_course_list = $course_list = []; $ajax_search = $add_type == 'unique' ? true : false; if ($ajax_search) { $courses = UrlManager::get_url_rel_course_data($access_url_id); foreach ($courses as $course) { $course_list[$course['c_id']] = $course; } } else { $courses = UrlManager::get_url_rel_course_data(); foreach ($courses as $course) { if ($course['access_url_id'] == $access_url_id) { $course_list[$course['c_id']] = $course; } } $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $sql = "SELECT id, code, title FROM $tbl_course u ORDER BY title, code"; $result = Database::query($sql); $courses = Database::store_result($result); $course_list_leys = array_keys($course_list); foreach ($courses as $course) { if (!in_array($course['id'], $course_list_leys)) { $no_course_list[$course['id']] = $course; } } } if ($add_type == 'multiple') { $link_add_type_unique = ''. get_lang('SessionAddTypeUnique').''; $link_add_type_multiple = get_lang('SessionAddTypeMultiple'); } else { $link_add_type_unique = get_lang('SessionAddTypeUnique'); $link_add_type_multiple = ''. get_lang('SessionAddTypeMultiple').''; } $url_list = UrlManager::get_url_data(); ?>
 | 


>

:









'.get_lang('AddCoursesToURL').''; } else { echo ''; } ?>