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[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('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 = array(); $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 = array(); } 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(array(), array('name')); $elements_not_in = $elements_in = array(); 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( array('s.name' => array('operator' => 'LIKE', 'value' => "%$needle%")) ); } elseif ($type != 'single') { $session_list = SessionManager::get_sessions_list( array('s.name' => array('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 '