debugOn(); $xajax->registerFunction('search_usergroup_sessions'); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; // Access restrictions api_protect_admin_script(true); // setting breadcrumbs $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')]; $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')]; // Database Table Definitions // setting the name of the tool $tool_name = get_lang('SubscribeClassToSessions'); $add_type = 'multiple'; if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') { $add_type = Security::remove_XSS($_REQUEST['add_type']); } $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = ''; $form_sent = 0; $errorMsg = ''; $sessions = []; $usergroup = new UserGroup(); $id = intval($_GET['id']); if (isset($_POST['form_sent']) && $_POST['form_sent']) { $form_sent = $_POST['form_sent']; $elements_posted = $_POST['elements_in_name']; if (!is_array($elements_posted)) { $elements_posted = []; } if ($form_sent == 1) { //added a parameter to send emails when registering a user $usergroup->subscribe_sessions_to_usergroup($id, $elements_posted); header('Location: usergroups.php'); exit; } } $data = $usergroup->get($id); $session_list_in = $usergroup->get_sessions_by_usergroup($id); $session_list = SessionManager::get_sessions_list([], ['name']); $elements_not_in = $elements_in = []; if (!empty($session_list)) { foreach ($session_list as $session) { if (in_array($session['id'], $session_list_in)) { $elements_in[$session['id']] = $session['name']; } else { $elements_not_in[$session['id']] = $session['name']; } } } $ajax_search = $add_type == 'unique' ? true : false; //checking for extra field with filter on function search_usergroup_sessions($needle, $type) { global $elements_in; $xajax_response = new xajaxResponse(); $return = ''; if (!empty($needle) && !empty($type)) { if ($type == 'searchbox') { $session_list = SessionManager::get_sessions_list( ['s.name' => ['operator' => 'LIKE', 'value' => "%$needle%"]] ); } elseif ($type != 'single') { $session_list = SessionManager::get_sessions_list( ['s.name' => ['operator' => 'LIKE', 'value' => "$needle%"]] ); } if ($type != 'single') { $return .= ''; $xajax_response->addAssign( 'ajax_list_multiple', 'innerHTML', api_utf8_encode($return) ); } } return $xajax_response; } $xajax->processRequests(); Display::display_header($tool_name); $add = (empty($_GET['add']) ? '' : Security::remove_XSS($_GET['add'])); if ($add_type == 'multiple') { $link_add_type_unique = ''. Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').''; $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); } else { $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); $link_add_type_multiple = ''. Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').''; } echo '
'; echo ''.Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).''; echo ' '. Display::return_icon('div_show.gif', get_lang('Show'), ['style'=>'vertical-align:middle']).' '.get_lang('AdvancedSearch').''; echo '
'; echo '
> '.$data['name'].': '.$tool_name.''; echo Display::input('hidden', 'id', $id); echo Display::input('hidden', 'form_sent', '1'); echo Display::input('hidden', 'add_type', null); if (!empty($errorMsg)) { echo Display::return_message($errorMsg, 'normal'); //main API } ?>
: :
: '; ?>  
'width:360px', 'multiple'=>'multiple', 'id'=>'elements_not_in', 'size'=>'15px'], false); ?>








'width:360px', 'multiple'=>'multiple', 'id'=>'elements_in', 'size'=>'15px'], false); unset($sessionUsersList); ?>

'.get_lang('SubscribeClassToSessions').''; ?>