-
Notifications
You must be signed in to change notification settings - Fork 1
/
editgroup.php
80 lines (67 loc) · 2.77 KB
/
editgroup.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
<?php require 'ldapconnect.php'; ?>
<?php
if (!isUserInGroup($con, $user, "gsag")) {
header( 'Location: index.php' );
}
$pageTitle = ' - Groups';
if (isset($_GET['group'])) {
$editGroup = TRUE;
$gname = $_GET['group'];
$pageTitle = " - Group: $gname";
if (isset($_POST['newuser'])) {
$newmember = $_POST['newuser'];
$entry['memberuid'] = $newmember;
ldap_mod_add($con, "cn=$gname,ou=groups,dc=geeksoc,dc=org", $entry);
if (ldap_error($con) != "Success") {
$error = ldap_error($con);
}
$success = "Added $newmember to group $gname.";
} elseif (isset($_GET['remove'])) {
$member = $_GET['remove'];
$entry['memberuid'] = $member;
ldap_mod_del($con, "cn=$gname,ou=groups,dc=geeksoc,dc=org", $entry);
if (ldap_error($con) != "Success") {
$error = ldap_error($con);
}
$success = "Removed $member from group $gname.";
}
$group = NULL;
foreach(getAllGroups($con) as $g) {
if ($g['cn'][0] == $gname) $group = $g;
}
}
?>
<?php require 'header.php'; ?>
<?php require 'menu.php'; ?>
<div class="span5">
<?php if (isset($error)) : ?>
<div class="alert alert-error">
<?php echo "$error"; ?>
</div>
<?php elseif (isset($success)) : ?>
<div class="alert alert-success">
<?php echo "$success"; ?>
</div>
<?php endif; ?>
<legend><?php echo $gname; ?></legend>
<table class="table">
<thead>
<th></th>
<th>Member</th>
</thead>
<tbody>
<?php foreach (array_slice($group['memberuid'], 1) as $member) : ?>
<tr>
<td><a href="editgroup.php?remove=<?php echo $member?>&group=<?php echo $gname ?>" class="btn btn-mini btn-danger">Remove</a>
</td>
<td><a href="edit.php?user=<?php echo $member; ?>"><?php echo $member; ?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<form class="well form-inline" action="editgroup.php?group=<?php echo $gname; ?>" method="post" id="form">
<input type="text" class="input-xlarge required" placeholder="Username" name="newuser">
<button type="submit" class="btn">Add Member</button>
</form>
</div>
<?php require 'footer.php'; ?>