-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrpedit.php
More file actions
265 lines (222 loc) · 6.06 KB
/
grpedit.php
File metadata and controls
265 lines (222 loc) · 6.06 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
//
// GiftWeb: PHP/PostgreSQL online Gift Registry System
// Matthew T. Jachimstal
// Copyright (C) 2000-2008 Matthew T. Jachimstal
//
// email: matthew@jachimstal.com
//
// Snail mail: Matthew Jachimstal
// 1106 Canterbury Ct, Unit D
// Elgin, IL 60120
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
require "./main.inc";
require "./util.php";
$s = $_COOKIE["GiftWeb_Session"];
$uid = validatesession($s);
$conn = ADONewConnection($dbtype);
$conn->PConnect($dbhost, $dbuser, $dbpass, $dbname);
$sql = "SELECT * FROM giftweb WHERE admin='$uid'";
$result1 = $conn->Execute($sql);
if ($result1->RecordCount() == 0)
{
startpage_old("Error: Not Administrator", 0);
?>
<h2>Error: You are not the site administrator</h2>
<?php
redir("./main.php", "the main GiftWeb page", 3);
endpage_old(-1);
exit();
}
startpage_old("Edit Groups", 0);
?>
<h1>Warning: This page is broken!</h1>
<?php
if (isset($_POST["editgrps"]))
{
$userlist = prep_users();
$grplist = $_POST["grplist"];
$grpcnt = count($grplist);
for ($i=0; $i < $grpcnt; $i++)
{
$gid=$grplist[$i];
$sql = "SELECT * FROM groups WHERE gid='$gid'";
$result = $conn->Execute($sql);
if ($result->RecordCount() != 1)
{
echo "<h3>Error retrieving group information for gid $gid</h3>\n";
endpage_old(-1);
exit();
}
$gdesc = chop($result->fields["description"]);
$gadmin = $result->fields["admin"];
$gverify = $result->fields["verify_requests"];
if ($gverify == 't')
{
$vfy_yes = "CHECKED";
$vfy_no = "";
}
else
{
$vfy_yes = "";
$vfy_no = "CHECKED";
}
$sql2 = "SELECT * FROM users WHERE uid='$gadmin'";
$result2 = $conn->Execute($sql);
if ($result2->RecordCount() != 1)
{
$gad_fname = "";
$gad_lname = "Error finding admin";
}
else
{
$gad_fname = chop($result->fields["first_name"]);
$gad_lname = chop($result->fields["last_name"]);
}
// FIX: 5/27/05
// start the form outside the loop, need to make multiple
// hidden inputs, one for each group being edited, also
// make a hidden input to pass _how many_ groups are
// being edited
// Also, the radio button need to be named differently.
?>
<form method="post" action="./grpedit.php">
<input type=hidden name=gid value=<?php echo $gid?>
<table cellspacing=0 cellpadding=2 border=0>
<tr><td align=right>Group Name:</td>
<td align=left><input type="text" name="grp_desc" maxlength=20
size=20 value="<?php echo $gdesc?>"></td></tr>
<tr><td align=right>Group Admin:</td>
<td align=left><select name="grp_admin">
<?php list_users($userlist, $gadmin);?>
</select></td></tr>
<tr><td align=right>Verify requests<br>to join group:</td>
<td align=left>
<input type="radio" <?php echo $vfy_yes?> name="grp_vfy"
value="t" >Yes<br>
<input type="radio" <?php echo $vfy_no?> name="grp_vfy"
value="f">No</td></tr>
</table>
<p>
<hr>
<p>
<?php
}
?>
<input type=submit name="chg_grp" value="Save Changes">
<input type=reset name=reset value="Reset Form">
</form>
<?php
endpage_old(-1);
exit();
}
if (isset($_POST["chg_grp"]))
{
$grp_desc = $_POST["grp_desc"];
$grp_admin = $_POST["grp_admin"];
$grp_vfy = $_POST["grp_vfy"];
$gid = $_POST["gid"];
$sql = "UPDATE groups SET description='$grp_desc', admin='$grp_admin',";
$sql .= " verify_requests='$grp_vfy' WHERE gid='$gid'";
$result = $conn->Execute($sql);
?> <h3>Group changes complete</h3> <?php
}
$sql = "SELECT * FROM groups ORDER BY gid";
$result = $conn->Execute($sql);
?>
<form method="post" action="grpedit.php">
<table cellspacing=1 cellpadding=2 border=1>
<tr><th>Select</th>
<th>Group<br>Name</th>
<th>Group<br>Admin</th>
<th>Verify<br>Requests?</th></tr>
<?php
while (!$result->EOF)
{
$gid = $result->fields["gid"];
$gdesc = chop($result->fields["description"]);
$gadmin = $result->fields["admin"];
$gverify = $result->fields["verify_requests"];
if ($gverify == "t")
$verify = "Yes";
else
$verify = "No";
$sql2 = "SELECT * FROM users WHERE uid='$gadmin'";
$result2 = $conn->Execute($sql2);
if ($result2->RecordCount() != 1)
{
$gad_fname = "";
$gad_lname = "";
}
else
{
$gad_fname = chop($result2->fields["first_name"]);
$gad_lname = chop($result2->fields["last_name"]);
}
?>
<tr><td><input type=checkbox name="grplist[]"
value="<?php echo $gid?>"></td>
<td><?php echo $gdesc?></td>
<td><?php echo $gad_lname.", ".$gad_fname?></td>
<td><?php echo $verify?></td></tr>
<?php
$result->MoveNext();
}
?>
</table>
<input type=submit name="editgrps" value="Edit Groups">
</form>
<p>
<h3><a href="./siteadmin.php">Return to Site Admin page</a></h3>
<?php
endpage_old(0);
// prep the list of users
function prep_users()
{
global $conn;
$sql = "SELECT * FROM users ORDER BY last_name, first_name";
$result = $conn->Execute($sql);
$i=0;
while (!$result->EOF)
{
$userid = $result->fields["uid"];
$fname = chop($result->fields["first_name"]);
$lname = chop($result->fields["last_name"]);
$name = $lname.", ".$fname;
$users[$i][0] = $userid;
$users[$i++][1] = $name;
$result->MoveNext();
}
return $users;
}
// build the SELECT element of a form for choosing a user
function list_users($userlist, $selected)
{
$usercnt = count($userlist);
for ($i=0; $i < $usercnt; $i++)
{
if ($userlist[$i][0] == $selected)
$sel = "SELECTED";
else
$sel = "";
?>
<option value="<?php echo $userlist[$i][0]?>" <?php echo $sel?>">
<?php echo $userlist[$i][1]?>
<?php
}
}
?>