get($id); $usergroup->protectScript($data); $xajax = new xajax(); $xajax->registerFunction('search_usergroup_sessions'); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; // setting breadcrumbs $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')]; $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')]; // setting the name of the tool $tool_name = get_lang('Subscribe class to sessions'); $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[] = ''; $errorMsg = ''; 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; } } $session_list_in = $usergroup->get_sessions_by_usergroup($id); $onlyThisSessionList = []; if ($usergroup->allowTeachers()) { $userId = api_get_user_id(); $sessionList = SessionManager::getSessionsFollowedByUser($userId, COURSEMANAGER); if (!empty($sessionList)) { $onlyThisSessionList = array_column($sessionList, 'id'); } } $session_list = SessionManager::get_sessions_list([], ['name'], null, null, 0, $onlyThisSessionList); $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('Single registration').''; $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('Multiple registration'); } else { $link_add_type_unique = Display::return_icon('single.gif').get_lang('Single registration'); $link_add_type_multiple = ''. Display::return_icon('multiple.gif').get_lang('Multiple registration').''; } 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('Advanced search').''; 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('Subscribe class to sessions').''; ?>