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[] = ''; 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 (1 == $form_sent) { $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 = 'unique' == $add_type ? 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 ('single' != $type) { $list = CourseManager::get_courses_list( 0, 0, 2, 'ASC', -1, $needle ); } if ('single' != $type) { $return .= ''; $xajax_response->addAssign('ajax_list_multiple', 'innerHTML', api_utf8_encode($return)); } } return $xajax_response; } $xajax->processRequests(); Display::display_header($tool_name); if ('multiple' === $add_type) { $link_add_type_unique = ''. Display::getMdiIcon(ObjectIcon::SINGLE_ELEMENT, 'ch-tool-icon', null, ICON_SIZE_SMALL).get_lang('Single registration').''; $link_add_type_multiple = Display::getMdiIcon(ObjectIcon::MULTI_ELEMENT, 'ch-tool-icon', null, ICON_SIZE_SMALL).get_lang('Multiple registration'); } else { $link_add_type_unique = Display::getMdiIcon(ObjectIcon::SINGLE_ELEMENT, 'ch-tool-icon', null, ICON_SIZE_SMALL).get_lang('Single registration'); $link_add_type_multiple = ''. Display::getMdiIcon(ObjectIcon::MULTI_ELEMENT, 'ch-tool-icon', null, ICON_SIZE_SMALL).get_lang('Multiple registration').''; } $actions = Display::url( Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back')), 'usergroups.php' ); $actions .= Display::url(get_lang('Advanced search'), '#', ['class' => 'advanced_options btn', 'id' => 'advanced_search']); echo Display::toolbarAction('add_users', [$actions]); echo Display::page_header($data['name'].': '.$tool_name); echo ''; ?>
>
: :
:  
'width:360px', 'multiple' => 'multiple', 'id' => 'elements_not_in', 'size' => '15px'], false ); ?>








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

'.get_lang('Subscribe class to courses').''; ?>