Example #1
0
// Security check
$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user');
if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) {
    accessforbidden();
}
$object = new Usergroup($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
/**
 *  Action remove group
 */
if ($action == 'confirm_delete' && $confirm == "yes") {
    if ($caneditperms) {
        $object->fetch($id);
        $object->delete();
        header("Location: index.php");
        exit;
    } else {
        $langs->load("errors");
        setEventMessages($langs->trans('ErrorForbidden'), null, 'errors');
    }
}
/**
 *  Action add group
 */
if ($action == 'add') {
    if ($caneditperms) {
        if (!$_POST["nom"]) {
            setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
            $action = "create";