document.formulaire.submit();
}
</script>';
$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) {
        $usergroup->subscribe_courses_to_usergroup($id, $elements_posted);
        header('Location: usergroups.php');
        exit;
    }
}
// Filters
$filters = array(array('type' => 'text', 'name' => 'code', 'label' => get_lang('CourseCode')), array('type' => 'text', 'name' => 'title', 'label' => get_lang('Title')));
$searchForm = new FormValidator('search', 'get', api_get_self() . '?id=' . $id);
$searchForm->addHeader(get_lang('AdvancedSearch'));
$renderer =& $searchForm->defaultRenderer();
$searchForm->addElement('hidden', 'id', $id);
foreach ($filters as $param) {
    $searchForm->addElement($param['type'], $param['name'], $param['label']);
}
$searchForm->addButtonSearch();
$filterData = array();
Exemple #2
0
        $actions .= '<a href="class.php?' . api_get_cidreq() . '&type=registered">' . Display::return_icon('back.png', get_lang("Classes"), array(), ICON_SIZE_MEDIUM) . '</a>';
        $form = new FormValidator('groups', 'post', api_get_self(), '', '', FormValidator::LAYOUT_INLINE);
        $options = [-1 => get_lang('All'), 1 => get_lang('SocialGroups'), 0 => get_lang('Classes')];
        $form->addSelect('group_filter', get_lang('Groups'), $options, ['id' => 'group_filter']);
        $form->setDefaults(['group_filter' => $groupFilter]);
        $actions .= $form->returnForm();
    }
    $actions .= '</div>';
}
if (api_is_allowed_to_edit()) {
    $action = isset($_GET['action']) ? $_GET['action'] : null;
    switch ($action) {
        case 'add_class_to_course':
            $id = $_GET['id'];
            if (!empty($id)) {
                $usergroup->subscribe_courses_to_usergroup($id, array(api_get_course_int_id()), false);
                Display::addFlash(Display::return_message(get_lang('Added')));
            }
            break;
        case 'remove_class_from_course':
            $id = $_GET['id'];
            if (!empty($id)) {
                $usergroup->unsubscribe_courses_from_usergroup($id, array(api_get_course_int_id()));
                Display::addFlash(Display::return_message(get_lang('Deleted')));
            }
            break;
    }
}
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_usergroups_teacher&type=' . $type . '&group_filter=' . $groupFilter;
//The order is important you need to check the the $column variable in the model.ajax.php file