get($id); $usergroup->protectScript($data); $xajax = new xajax(); $xajax->registerFunction('search'); // 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 courses'); $add_type = 'multiple'; if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') { $add_type = Security::remove_XSS($_REQUEST['add_type']); } $add = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null; $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) { $usergroup->subscribe_courses_to_usergroup($id, $elements_posted); Display::addFlash(Display::return_message(get_lang('Update successful'))); header('Location: usergroups.php'); exit; } } // Filters $filters = [ ['type' => 'text', 'name' => 'code', 'label' => get_lang('Code')], ['type' => 'text', 'name' => 'title', 'label' => get_lang('Title')], ]; $searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id); $searchForm->addHeader(get_lang('Advanced search')); $renderer = &$searchForm->defaultRenderer(); $searchForm->addElement('hidden', 'id', $id); foreach ($filters as $param) { $searchForm->addElement($param['type'], $param['name'], $param['label']); } $searchForm->addButtonSearch(); $filterData = []; if ($searchForm->validate()) { $filterData = $searchForm->getSubmitValues(); } $conditions = []; if (!empty($filters) && !empty($filterData)) { foreach ($filters as $filter) { if (isset($filter['name']) && isset($filterData[$filter['name']])) { $value = $filterData[$filter['name']]; if (!empty($value)) { $conditions[$filter['name']] = $value; } } } } $course_list_in = $usergroup->get_courses_by_usergroup($id, true); $onlyThisCourseList = []; if ($usergroup->allowTeachers()) { $userId = api_get_user_id(); $courseList = CourseManager::getCoursesFollowedByUser($userId, COURSEMANAGER); if (!empty($courseList)) { $onlyThisCourseList = array_column($courseList, 'id'); } } $course_list = CourseManager::get_courses_list( 0, 0, 'title', 'asc', -1, null, api_get_current_access_url_id(), false, $conditions, $onlyThisCourseList ); $elements_not_in = $elements_in = []; foreach ($course_list_in as $course) { $elements_in[$course['id']] = $course['title']." (".$course['visual_code'].")"; } if (!empty($course_list)) { foreach ($course_list as $item) { if (isset($elements_in[$item['id']])) { continue; } $elements_not_in[$item['id']] = $item['title']." (".$item['visual_code'].")"; } } $ajax_search = $add_type == 'unique' ? true : false; // checking for extra field with filter on function search($needle, $type) { global $elements_in; $xajax_response = new xajaxResponse(); $return = ''; if (!empty($needle) && !empty($type)) { if ($type != 'single') { $list = CourseManager::get_courses_list( 0, 0, 2, 'ASC', -1, $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); 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 ''; echo Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM).''; echo Display::url(get_lang('Advanced search'), '#', ['class' => 'advanced_options', 'id' => '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 courses').''; ?>