*/
$language_file = 'admin';
// resetting the course id
$cidReset = true;
////require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'urlmanager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'access_url_edit_users_to_url_functions.lib.php';
require_once '../inc/lib/xajax/xajax.inc.php';
$xajax = new xajax();
$xajax->registerFunction(array('search_users', 'Accessurledituserstourl', 'search_users'));
// 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;
}
// Database Table Definitions
// Database Table Definitions
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_access_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$tbl_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
// setting breadcrumbs
$tool_name = get_lang('EditUsersToURL');
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('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[] = '';
$form_sent = 0;
$errorMsg = '';
$UserList = array();
$message = '';
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$UserList = $_POST['sessionUsersList'];
if (!is_array($UserList)) {
$UserList = array();
}
if ($form_sent == 1) {
if ($access_url_id == 0) {
header('Location: access_url_edit_users_to_url.php?action=show_message&message=' . get_lang('SelectURL'));
exit;
} elseif (is_array($UserList)) {
$result = UrlManager::update_urls_rel_user($UserList, $access_url_id);
$url_info = UrlManager::get_url_data_from_id($access_url_id);
if (!empty($result)) {
$message .= 'URL: ' . $url_info['url'] . '
';
}
if (!empty($result['users_added'])) {
$message .= '