예제 #1
0
echo Display::grid_js('usergroups', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
?>
});
</script>
<?php 
// Tool introduction
Display::display_introduction_section(get_lang('Classes'));
$usergroup = new UserGroup();
$usergroup->showGroupTypeSetting = true;
// Action handling: Adding a note
if (isset($_GET['action']) && $_GET['action'] == 'add') {
    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
        api_not_allowed();
    }
    $form = new FormValidator('usergroup', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']));
    $usergroup->setForm($form, 'add');
    // Setting the defaults
    $form->setDefaults(['visibility' => 2]);
    // The validation or display
    if ($form->validate()) {
        $values = $form->exportValues();
        $res = $usergroup->save($values);
        if ($res) {
            Display::display_confirmation_message(get_lang('ItemAdded'));
        } else {
            Display::display_warning_message(Security::remove_XSS($values['name']) . ': ' . get_lang('AlreadyExists'));
        }
        $usergroup->display();
    } else {
        echo '<div class="actions">';
        echo '<a href="' . api_get_self() . '">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
예제 #2
0
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
$usergroup = new UserGroup();
$group_data = $usergroup->get($group_id);
if (empty($group_data)) {
    header('Location: groups.php?id=' . $group_id);
    exit;
}
//only group admins can edit the group
if (!$usergroup->is_group_admin($group_id)) {
    api_not_allowed();
}
// Create the form
$form = new FormValidator('group_edit', 'post', '', '');
$form->addElement('hidden', 'id', $group_id);
$usergroup->setGroupType($usergroup::SOCIAL_CLASS);
$usergroup->setForm($form, 'edit', $group_data);
// Set default values
$form->setDefaults($group_data);
// Validate form
if ($form->validate()) {
    $group = $form->exportValues();
    $group['id'] = $group_id;
    $group['type'] = $usergroup::SOCIAL_CLASS;
    $usergroup->update($group);
    $tok = Security::get_token();
    header('Location: groups.php?id=' . $group_id . '&action=show_message&message=' . urlencode(get_lang('GroupUpdated')) . '&sec_token=' . $tok);
    exit;
}
$social_left_content = SocialManager::show_social_menu('group_edit', $group_id);
$social_right_content = '<div class="span9">';
$social_right_content .= $form->return_form();
예제 #3
0
 */
$language_file = 'userInfo';
$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
    api_not_allowed();
}
if (api_get_setting('allow_students_to_create_groups_in_social') == 'false' && !api_is_allowed_to_edit()) {
    api_not_allowed();
}
$table_message = Database::get_main_table(TABLE_MESSAGE);
$usergroup = new UserGroup();
$form = new FormValidator('add_group');
$usergroup->setGroupType($usergroup::SOCIAL_CLASS);
$usergroup->setForm($form, 'add', array());
if ($form->validate()) {
    $values = $form->exportValues();
    $values['group_type'] = UserGroup::SOCIAL_CLASS;
    $values['relation_type'] = GROUP_USER_PERMISSION_ADMIN;
    $groupId = $usergroup->save($values);
    Display::addFlash(DIsplay::return_message(get_lang('GroupAdded')));
    header('Location: group_view.php?id=' . $groupId);
    exit;
}
$nameTools = get_lang('AddGroup');
$this_section = SECTION_SOCIAL;
$interbreadcrumb[] = array('url' => 'home.php', 'name' => get_lang('Social'));
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '#', 'name' => $nameTools);
$social_avatar_block = SocialManager::show_social_avatar_block('group_add');