-
Notifications
You must be signed in to change notification settings - Fork 1
/
newusers.php
157 lines (128 loc) · 5.73 KB
/
newusers.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php require 'ldapconnect.php'; ?>
<?php
if (!isUserInGroup($con, $user, "gsag")) {
header( 'Location: index.php' );
}
$pageTitle = ' - New Members';
$mysqli = new mysqli($conf['db_host'], $conf['db_user'], $conf['db_pass'], $conf['db_name']);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($_GET['action'] == 'create') {
$returnMessage = addUser($_GET['uid'], $_GET['first'], $_GET['last'], $_GET['stuno'], $_GET['email']);
if (substr($returnMessage, 0, 1) =='S') {
$success = substr($returnMessage, 2);
} else {
$error = $returnMessage;
}
if (isset($success) && $stmt = $mysqli->prepare("UPDATE newusers SET IS_DELETED=true WHERE id = ?")) {
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$stmt->close();
}
else {
/* Error */
}
} elseif ($_GET['action'] == 'delete') {
if ($stmt = $mysqli->prepare("DELETE FROM newusers WHERE id = ?")) {
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$stmt->close();
}
else {
/* Error */
}
$success = "Deleted user from approval queue.";
}
/* Create the prepared statement */
if ($stmt = $mysqli->prepare("SELECT ID, firstname, lastname, username, studentnumber, email FROM newusers WHERE IS_DELETED = false")) {
/* Execute the prepared Statement */
$stmt->execute();
$stmt->bind_result($id, $first, $last, $uid, $stuno, $email);
while ($stmt->fetch()) {
// printf("%s %s %s %i %s\n", $first, $last, $uid, $stuno, $email);
$u['id'] = $id;
$u['first'] = $first;
$u['last'] = $last;
$u['uid'] = $uid;
$u['stuno'] = $stuno;
$u['email'] = $email;
$users[] = $u;
}
/* Close the statement */
$stmt->close();
}
else {
/* Error */
}
?>
<?php require 'header.php'; ?>
<?php require 'menu.php'; ?>
<div class="span10">
<?php if (count($users) == 0) : ?>
<div class="row">
<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; ?>
<feildset>
<legend>Approve New Members</legend>
</feildset>
<p>There are no new members to approve - get recruiting!</p>
</div>
</div>
<?php else : ?>
<table class="table ">
<thead>
<tr>
<th></th>
<th>Account Name</th>
<th>Full Name</th>
<th>Student Number</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody>
<?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; ?>
<?php foreach ($users as $user) : ?>
<tr>
<td><a href="newusers.php?action=create&uid=<?php echo $user['uid']."&first=".$user['first']."&last=".$user['last']."&stuno=".$user['stuno']."&email=".$user['email']."&id=".$user['id']; ?>" class="btn btn-mini">Create</a></td>
<td><?php echo $user['uid']; ?></td>
<td><?php echo $user['first'] . " " . $user['last']; ?></td>
<td><?php echo $user['stuno']; ?></td>
<td><a href="mailto:<?php echo $user['email']; ?>"><?php echo $user['email']; ?></a></td>
<td><a href="newusers.php?action=delete&id=<?php echo $user['id']; ?>" class="btn btn-danger btn-mini">Delete</a></td>
</tr>
<?php endforeach; ?>
<?php foreach ($created as $user) : ?>
<tr class="muted">
<td></td>
<td><?php echo $user['uid']; ?></td>
<td><?php echo $user['first'] . " " . $user['last']; ?></td>
<td><?php echo $user['stuno']; ?></td>
<td><a href="mailto:<?php echo $user['email']; ?>"><?php echo $user['email']; ?></a></td>
<td></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<p><a href="memberreport.php">Download CSV of all new members</a></p>
</div>
<?php require 'footer.php'; ?>