For a full list of contributors, see "credits.txt". The full license can be read in "license.txt". This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the GNU General Public License for more details. Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com ============================================================================== */ /** ============================================================================== * @package dokeos.admin ============================================================================== */ // name of the language file that needs to be included $language_file='admin'; // resetting the course id $cidReset=true; // including some necessary dokeos files require('../inc/global.inc.php'); require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php'); require_once ('../inc/lib/xajax/xajax.inc.php'); $xajax = new xajax(); //$xajax->debugOn(); $xajax -> registerFunction ('search_users'); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; // Access restrictions api_protect_admin_script(); if (!$_configuration['multiple_access_urls']) header('Location: index.php'); // 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']); } function search_users($needle, $id) { global $tbl_user, $tbl_access_url_rel_user; $xajax_response = new XajaxResponse(); $return = ''; if(!empty($needle)) { // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_setting('platform_charset'); $needle = api_convert_encoding($needle, $charset, 'utf-8'); $needle = Database::escape_string($needle); // search users where username or firstname or lastname begins likes $needle $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u WHERE (username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%" OR lastname LIKE "'.$needle.'%")'. $order_clause. ' LIMIT 11'; $rs = Database::query($sql, __FILE__, __LINE__); $i=0; while ($user = Database :: fetch_array($rs)) { $i++; if ($i<=10) { $return .= ''.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')
'; } else { $return .= '...
'; } } } $xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return)); return $xajax_response; } $xajax -> processRequests(); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = ' '; $form_sent=0; $errorMsg=''; $UserList=$SessionList=array(); $users=$sessions=array(); if($_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')); } elseif(is_array($UserList) ) { UrlManager::update_urls_rel_user($UserList,$access_url_id); header('Location: access_urls.php?action=show_message&message='.get_lang('UsersWereEdited')); } } } Display::display_header($tool_name); echo '
'; echo '
'.Display::return_icon('view_more_stats.gif',get_lang('AddUserToURL'),'').get_lang('AddUsersToURL').'

'; echo '
'; api_display_tool_title($tool_name); if ($_GET['action'] == 'show_message') Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message']))); $nosessionUsersList = $sessionUsersList = array(); $ajax_search = $add_type == 'unique' ? true : false; if($ajax_search) { $Users=UrlManager::get_url_rel_user_data($access_url_id); foreach($Users as $user) { $sessionUsersList[$user['user_id']] = $user ; } } else { $Users=UrlManager::get_url_rel_user_data(); foreach($Users as $user) { if($user['access_url_id'] == $access_url_id) { $sessionUsersList[$user['user_id']] = $user ; } } $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $sql="SELECT u.user_id, lastname, firstname, username FROM $tbl_user u". $order_clause; $result=Database::query($sql,__FILE__,__LINE__); $Users=Database::store_result($result); $user_list_leys = array_keys($sessionUsersList); foreach($Users as $user) { if (!in_array($user['user_id'],$user_list_leys)) $nosessionUsersList[$user['user_id']] = $user ; } } 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(); ?>
 | 


>

: :









'; else echo ''; ?>