/**
  * @param string $in_name is the name and the id of the <select>
  * @param string $in_default default value for option
  * @param string $in_onchange
  * @return string the html code of the <select>
  */
 public static function displayGroupMenu($in_name, $in_default, $in_onchange = "")
 {
     // check the default value of option
     $tabSelected = array($in_default => " selected='selected' ");
     $res = "";
     $res .= "<select name='{$in_name}' id='{$in_name}' onchange='" . $in_onchange . "' >";
     $res .= "<option value='-1'" . $tabSelected["-1"] . ">-- " . get_lang('AllGroups') . " --</option>";
     $res .= "<option value='0'" . $tabSelected["0"] . ">- " . get_lang('NotInAGroup') . " -</option>";
     $tabGroups = GroupManager::get_group_list();
     $currentCatId = 0;
     for ($i = 0; $i < count($tabGroups); $i++) {
         $tabCategory = GroupManager::get_category_from_group($tabGroups[$i]["id"]);
         if ($tabCategory["id"] != $currentCatId) {
             $res .= "<option value='-1' disabled='disabled'>" . $tabCategory["title"] . "</option>";
             $currentCatId = $tabCategory["id"];
         }
         $res .= "<option " . $tabSelected[$tabGroups[$i]["id"]] . "style='margin-left:40px' value='" . $tabGroups[$i]["id"] . "'>" . $tabGroups[$i]["name"] . "</option>";
     }
     $res .= "</select>";
     return $res;
 }
        $selected_users[] = $user['user_id'];
    }
}
$group_members_element = $form->addElement('advmultiselect', 'group_members', get_lang('GroupMembers'), $possible_users, 'style="width: 280px;"');
$form->addFormRule('check_group_members');
// submit button
$form->addButtonSave(get_lang('SaveSettings'));
if ($form->validate()) {
    $values = $form->exportValues();
    // Storing the users (we first remove all users and then add only those who were selected)
    GroupManager::unsubscribe_all_users($current_group['id']);
    if (isset($_POST['group_members']) && count($_POST['group_members']) > 0) {
        GroupManager::subscribe_users($values['group_members'], $current_group['id']);
    }
    // Returning to the group area (note: this is inconsistent with the rest of chamilo)
    $cat = GroupManager::get_category_from_group($current_group['id']);
    if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
        Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning'));
        header('Location: group.php?' . api_get_cidreq(true, false));
    } else {
        Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success'));
        header('Location: group.php?' . api_get_cidreq(true, false) . '&category=' . $cat['id']);
    }
    exit;
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
    case 'empty':
        if (api_is_allowed_to_edit(false, true)) {
            GroupManager::unsubscribe_all_users($group_id);
            Display::display_confirmation_message(get_lang('GroupEmptied'));
Exemple #3
0
    }
    $self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0;
    $self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0;
    $categoryId = isset($values['category_id']) ? $values['category_id'] : null;
    GroupManager::set_group_properties($current_group['id'], $values['name'], $values['description'], $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'], $values['wiki_state'], $values['chat_state'], $self_registration_allowed, $self_unregistration_allowed, $categoryId);
    if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
        Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning'));
        header('Location: group.php?' . api_get_cidreq(true, false));
    } else {
        Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success'));
        header('Location: group.php?' . api_get_cidreq(true, false) . '&category=' . $cat['id']);
    }
    exit;
}
$defaults = $current_group;
$category = GroupManager::get_category_from_group($group_id);
if (!empty($category)) {
    $defaults['category_id'] = $category['id'];
}
$action = isset($_GET['action']) ? $_GET['action'] : '';
$defaults['action'] = $action;
if ($defaults['maximum_number_of_students'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
    $defaults['max_member_no_limit'] = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else {
    $defaults['max_member_no_limit'] = 1;
    $defaults['max_member'] = $defaults['maximum_number_of_students'];
}
if (!empty($_GET['keyword']) && !empty($_GET['submit'])) {
    $keyword_name = Security::remove_XSS($_GET['keyword']);
    echo '<br/>' . get_lang('SearchResultsFor') . ' <span style="font-style: italic ;"> ' . $keyword_name . ' </span><br>';
}