-
Notifications
You must be signed in to change notification settings - Fork 56
/
remove_group.php
116 lines (106 loc) · 3.72 KB
/
remove_group.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* This file is part of ProFTPd Admin
*
* @package ProFTPd-Admin
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
*
* @copyright Lex Brugman <lex_brugman@users.sourceforge.net>
* @copyright Christian Beer <djangofett@gmx.net>
* @copyright Ricardo Padilha <ricardo@droboports.com>
*
*/
include_once ("configs/config.php");
include_once ("includes/AdminClass.php");
global $cfg;
$ac = new AdminClass($cfg);
$field_gid = $cfg['field_gid'];
$field_newgid = "new_".$cfg['field_gid'];
$field_groupname = $cfg['field_groupname'];
$field_members = $cfg['field_members'];
if (empty($_REQUEST[$field_gid])) {
header("Location: groups.php");
die();
}
$gid = $_REQUEST[$field_gid];
if (!$ac->is_valid_id($gid)) {
$errormsg = 'Invalid GID; must be a positive integer.';
} else {
$group = $ac->get_group_by_gid($gid);
if (!is_array($group)) {
$errormsg = 'Group does not exist; cannot find GID '.$gid.' in the database.';
} else {
$groupname = $group[$field_groupname];
$members = $group[$field_members];
$users_main = $ac->get_users_by_gid($gid);
$users_add = $ac->get_add_users_by_gid($gid);
if ($users_main) {
$errormsg = 'Group cannot be removed; it is the main group of the user(s) '.implode(", ", $users_main);
}
if ($users_add) {
$warnmsg = 'Group in use; it is an additional group of the user(s): '.implode(", ", $users_add);
}
}
}
if (empty($errormsg) && !empty($_REQUEST["action"]) && $_REQUEST["action"] == "reallyremove") {
/* data validation passed */
if ($ac->delete_group_by_gid($gid)) {
$infomsg = 'Group "'.$groupname.'" removed successfully.';
} else {
$errormsg = 'Group "'.$groupname.'" removal failed; see log files for more information.';
}
}
include ("includes/header.php");
?>
<?php include ("includes/messages.php"); ?>
<?php if (!empty($_REQUEST["action"]) && $_REQUEST["action"] == "reallyremove") { ?>
<!-- action: reallyremove -->
<div class="col-xs-12 col-sm-8 col-md-6 center">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
<!-- Actions -->
<div class="form-group">
<div class="col-sm-12">
<a class="btn btn-primary pull-right" href="groups.php" role="button">View groups »</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } else { ?>
<!-- action: remove -->
<div class="col-xs-12 col-sm-8 col-md-6 center">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Remove group</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
<form role="form" class="form-horizontal" method="post">
<!-- GID -->
<div class="form-group">
<div class="col-sm-12">
<p>Please confirm removal of group "<?php echo $groupname; ?>" with GID <?php echo $gid; ?>.</p>
</div>
</div>
<!-- Actions -->
<div class="form-group">
<div class="col-sm-12">
<input type="hidden" name="<?php echo $field_gid; ?>" value="<?php echo $gid; ?>" />
<a class="btn btn-default" role="group" href="edit_group.php?action=show&<?php echo $field_gid; ?>=<?php echo $gid; ?>">Cancel</a>
<button type="submit" class="btn btn-danger pull-right" role="group" name="action" value="reallyremove" <?php if (isset($errormsg)) { echo 'disabled="disabled"'; } ?>>Remove group</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php include ("includes/footer.php"); ?>