registerFunction('search_sessions'); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; // Access restrictions api_protect_admin_script(true); // setting breadcrumbs $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList')); // Database Table Definitions $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); // initializing variables $id_session=intval($_GET['id_session']); $user_id = intval($_GET['user']); $user_info = api_get_user_info($user_id); $user_anonymous = api_get_anonymous_id(); $current_user_id = api_get_user_id(); // setting the name of the tool if (UserManager::is_admin($user_id)) { $tool_name= get_lang('AssignSessionsToPlatformAdministrator'); } else if ($user_info['status'] == SESSIONADMIN) { $tool_name= get_lang('AssignSessionsToSessionsAdministrator'); } else { $tool_name= get_lang('AssignSessionsToHumanResourcesManager'); } $add_type = 'multiple'; if(isset($_GET['add_type']) && $_GET['add_type']!=''){ $add_type = Security::remove_XSS($_REQUEST['add_type']); } if (!api_is_platform_admin() && !api_is_session_admin()) { api_not_allowed(true); } function search_sessions($needle,$type) { global $_configuration, $tbl_session_rel_access_url, $tbl_session, $user_id; $xajax_response = new XajaxResponse(); $return = ''; if(!empty($needle) && !empty($type)) { // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = api_convert_encoding($needle, $charset, 'utf-8'); $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id); $assigned_sessions_id = array_keys($assigned_sessions_to_hrm); $without_assigned_sessions = ''; if (count($assigned_sessions_id) > 0) { $without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")"; } if ($_configuration['multiple_access_urls']) { $sql = " SELECT s.id, s.name FROM $tbl_session s LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id) WHERE s.name LIKE '$needle%' $without_assigned_sessions AND access_url_id = ".api_get_current_access_url_id().""; } else { $sql = "SELECT s.id, s.name FROM $tbl_session s WHERE s.name LIKE '$needle%' $without_assigned_sessions "; } $rs = Database::query($sql); $return .= ''; $xajax_response->addAssign('ajax_list_sessions_multiple','innerHTML',api_utf8_encode($return)); } return $xajax_response; } $xajax->processRequests(); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = ' '; $formSent=0; $errorMsg = $firstLetterSession = ''; $UserList = array(); $msg = ''; if (intval($_POST['formSent']) == 1) { $sessions_list = $_POST['SessionsList']; $affected_rows = SessionManager::suscribe_sessions_to_hr_manager($user_id,$sessions_list); if ($affected_rows) { $msg = get_lang('AssignedSessionsHaveBeenUpdatedSuccessfully'); } } // display header Display::display_header($tool_name); // actions echo '
'; if ($user_info['status'] != SESSIONADMIN) { echo ' '.Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignUsers').' '.Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignCourses').' '.sprintf(get_lang('AssignSessionsToX'),api_get_person_name($user_info['firstname'], $user_info['lastname'])).''; } else { echo ''.sprintf(get_lang('AssignSessionsToX'),api_get_person_name($user_info['firstname'], $user_info['lastname'])).''; } echo '
'; // ******************* $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id); $assigned_sessions_id = array_keys($assigned_sessions_to_hrm); $without_assigned_sessions = ''; if (count($assigned_sessions_id) > 0) { $without_assigned_sessions = " AND s.id NOT IN(".implode(',',$assigned_sessions_id).")"; } $needle = '%'; if (isset($_POST['firstLetterSession'])) { $needle = Database::escape_string($_POST['firstLetterSession']); $needle = "$needle%"; } if ($_configuration['multiple_access_urls']) { $sql = " SELECT s.id, s.name FROM $tbl_session s LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id) WHERE s.name LIKE '$needle%' $without_assigned_sessions AND access_url_id = ".api_get_current_access_url_id().""; } else { $sql = " SELECT s.id, s.name FROM $tbl_session s WHERE s.name LIKE '$needle%' $without_assigned_sessions "; } $result = Database::query($sql); ?>
>
 
:   :
:  








'.$tool_name.''; ?>