1 |
dpavlin |
1 |
<?php |
2 |
|
|
/********************************************************** |
3 |
|
|
Function Library: update.php |
4 |
|
|
Original Author: Paul Bramscher <brams006@tc.umn.edu> |
5 |
|
|
Last Modified: 09.30.2003 by Paul Bramscher |
6 |
|
|
*********************************************************** |
7 |
|
|
Comments: |
8 |
|
|
This library brings together all SQL update functions for |
9 |
|
|
LibData general setup tables. Those pertaining to |
10 |
|
|
PageScribe and SubjectBuilder are located in |
11 |
|
|
scribe_application.php and subject_builder.php |
12 |
|
|
respectively. |
13 |
|
|
*********************************************************** |
14 |
|
|
Table of Contents: |
15 |
|
|
|
16 |
|
|
purgePassword |
17 |
|
|
updateCoursesub |
18 |
|
|
updateFaculty |
19 |
|
|
updateFeature |
20 |
|
|
updateInfotype |
21 |
|
|
updateLibunit |
22 |
|
|
updateLocation |
23 |
|
|
updatePassword |
24 |
|
|
updateResource |
25 |
|
|
updateService |
26 |
|
|
updateSingleField |
27 |
|
|
updateStaff |
28 |
|
|
updateStyle |
29 |
|
|
updateSubject |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
**********************************************************/ |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/********************************************************** |
36 |
|
|
Function: purgePassword |
37 |
|
|
Author: Paul Bramscher |
38 |
|
|
Last Modified: 06.23.2003 |
39 |
|
|
*********************************************************** |
40 |
|
|
Purpose: |
41 |
|
|
This function purges the locally encrypted mySQL stored |
42 |
|
|
password for the supplied staff id (sets to NULL). Note |
43 |
|
|
that at no point does this system actually retrieve the |
44 |
|
|
value of the password and bring it to an HTML form, neither |
45 |
|
|
in plaintext nor in a "password" type HTML form field. |
46 |
|
|
**********************************************************/ |
47 |
|
|
function purgePassword($con, $staff_id){ |
48 |
|
|
|
49 |
|
|
// Draw form heading |
50 |
|
|
printf("<center><h3>Purging Password...</h3>"); |
51 |
|
|
|
52 |
|
|
// Table |
53 |
|
|
printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">"); |
54 |
|
|
printf("<tr><td><br>"); |
55 |
|
|
printf("<strong>Messages:</strong><br>"); |
56 |
|
|
|
57 |
|
|
// Problem flag for each step |
58 |
|
|
$problem = 0; |
59 |
|
|
|
60 |
|
|
if ($staff_id > 0) { |
61 |
dpavlin |
54 |
$sql = "UPDATE staff SET password = NULL WHERE staff_id = ?"; |
62 |
dpavlin |
1 |
|
63 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $staff_id)){ |
64 |
dpavlin |
1 |
$problem = 1; |
65 |
|
|
sql_err($sql); |
66 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
67 |
dpavlin |
1 |
bailout(); |
68 |
|
|
} |
69 |
|
|
else { |
70 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
71 |
dpavlin |
1 |
printf("Purged password successfully for this staff account.<br><BR>\n"); |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
} |
75 |
|
|
else printf("Staff ID not found.</b>.<br><br>\n"); |
76 |
|
|
|
77 |
|
|
printf("</td></tr></table>\n"); |
78 |
|
|
printf("</center>\n"); |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
|
82 |
|
|
/********************************************************** |
83 |
|
|
Function: updateCoursesub |
84 |
|
|
Author: Paul Bramscher |
85 |
|
|
Last Modified: 06.03.2003 |
86 |
|
|
*********************************************************** |
87 |
|
|
Purpose: |
88 |
|
|
Update supplied course subject id. |
89 |
|
|
**********************************************************/ |
90 |
|
|
function updateCoursesub($con, $campus_id, $cip_code, $coursesub, $coursesub_descr, $coursesub_id) { |
91 |
|
|
|
92 |
|
|
// Error flag |
93 |
|
|
$err_code = 0; |
94 |
|
|
|
95 |
|
|
// Need for display/uniqueness |
96 |
|
|
$coursesub_display = $coursesub; |
97 |
|
|
|
98 |
|
|
// Check to see if already exists |
99 |
|
|
$exists = recordCount($con, "coursesub", "coursesub", $coursesub_search, "A"); |
100 |
|
|
$exists_id = lookupField($con, "coursesub", "coursesub", $coursesub_search, "coursesub_id"); |
101 |
|
|
|
102 |
|
|
// If exists in the courseub table under a different coursesub_id |
103 |
|
|
if ($exists > 0 && $exists_id != $coursesub_id) { |
104 |
|
|
$err_code = 1; |
105 |
|
|
$err_msg = "Failed. '" . $coursesub_display . "' already exists in the course subject table."; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
// Check for blank entry |
109 |
|
|
if ($coursesub == "") { |
110 |
|
|
$err_code = 2; |
111 |
|
|
$err_msg = "Failed. Must supply some value for the course subject."; |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
printf("<center><h3>Updating Course Subject...</h3>\n"); |
115 |
|
|
|
116 |
|
|
// Table |
117 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
118 |
|
|
printf("<tr><td><br>\n"); |
119 |
|
|
printf("<strong>Messages:</strong><br>"); |
120 |
|
|
|
121 |
|
|
// Perform the update only if no errors encountered |
122 |
|
|
if ($err_code == 0) { |
123 |
|
|
|
124 |
|
|
// Build the SQL |
125 |
dpavlin |
54 |
$sql = "UPDATE coursesub SET coursesub = ?, coursesub_descr = ?, cip_code = ?, campus_id = ? WHERE coursesub_id = ?"; |
126 |
dpavlin |
1 |
|
127 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $coursesub, $coursesub_descr, $cip_code, $campus_id, $coursesub_id)){ |
128 |
dpavlin |
1 |
sql_err($sql); |
129 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
130 |
dpavlin |
1 |
bailout(); |
131 |
|
|
} |
132 |
|
|
else { |
133 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
134 |
dpavlin |
1 |
printf("Updated <b>%s</b> course subject.<BR><BR>\n", $coursesub_display); |
135 |
|
|
} |
136 |
|
|
} |
137 |
|
|
|
138 |
|
|
else printf("%s", $err_msg); |
139 |
|
|
|
140 |
|
|
printf("<br><br>\n"); |
141 |
|
|
printf("</td></tr></table>\n"); |
142 |
|
|
printf("</center>\n"); |
143 |
|
|
|
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
|
147 |
|
|
/********************************************************** |
148 |
|
|
Function: updateFaculty |
149 |
|
|
Author: Paul Bramscher |
150 |
|
|
Last Modified: 06.24.2003 |
151 |
|
|
*********************************************************** |
152 |
|
|
Purpose: |
153 |
|
|
Update supplied faculty id. |
154 |
|
|
**********************************************************/ |
155 |
|
|
function updateFaculty($con, $faculty_email, $faculty_firstname, |
156 |
|
|
$faculty_id, $faculty_lastname, $faculty_account) { |
157 |
|
|
|
158 |
|
|
/* |
159 |
|
|
Faculty must have both a unique non-blank staff_account, and non-blank last name. |
160 |
|
|
*/ |
161 |
|
|
|
162 |
|
|
// Error flag |
163 |
|
|
$err_code = 0; |
164 |
|
|
|
165 |
|
|
// Need for display/uniqueness |
166 |
|
|
$faculty_name_display = $faculty_firstname . " " . $faculty_lastname; |
167 |
|
|
|
168 |
|
|
// Check to see if already exists |
169 |
|
|
$exists_id = existsFaculty($con, $faculty_firstname, $faculty_lastname); |
170 |
|
|
|
171 |
|
|
if ($exists_id > 0 && $exists_id != $faculty_id) { |
172 |
|
|
$err_code = 1; |
173 |
|
|
$err_msg = "Failed. '" . $faculty_name_display . "' already exists in the Faculty table."; |
174 |
|
|
} |
175 |
|
|
|
176 |
|
|
// Check for blank last name |
177 |
|
|
if ($faculty_lastname == "") { |
178 |
|
|
$err_code = 2; |
179 |
|
|
$err_msg = "Failed. Cannot have a blank Last Name."; |
180 |
|
|
} |
181 |
|
|
|
182 |
|
|
|
183 |
|
|
printf("<center><h3>Updating Faculty...</h3>"); |
184 |
|
|
|
185 |
|
|
// Table |
186 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
187 |
|
|
printf("<tr><td><br>"); |
188 |
|
|
printf("<strong>Messages:</strong><br>"); |
189 |
|
|
|
190 |
|
|
if ($err_code == 0 ) { |
191 |
|
|
|
192 |
|
|
// Build the SQL |
193 |
dpavlin |
54 |
$sql = "UPDATE faculty SET faculty_lastname = ?, faculty_firstname = ?, faculty_email = ?, faculty_account = ? WHERE faculty_id = ?"; |
194 |
dpavlin |
1 |
|
195 |
dpavlin |
54 |
if (!xx_query ($sql,$faculty_lastname,$faculty_firstname,$faculty_account,$faculty_email,$faculty_id)){ |
196 |
dpavlin |
1 |
sql_err($sql); |
197 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
198 |
dpavlin |
1 |
bailout(); |
199 |
|
|
} |
200 |
|
|
else { |
201 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
202 |
dpavlin |
1 |
printf("Successfully updated Faculty <b>%s</b><BR><BR>\n", $faculty_name_display); |
203 |
|
|
} |
204 |
|
|
} |
205 |
|
|
|
206 |
|
|
else printf("%s", $err_msg); |
207 |
|
|
printf("<br><br>\n"); |
208 |
|
|
printf("</td></tr></table>\n"); |
209 |
|
|
printf("</center>\n"); |
210 |
|
|
|
211 |
|
|
} |
212 |
|
|
|
213 |
|
|
|
214 |
|
|
/********************************************************** |
215 |
|
|
Function: updateFeature |
216 |
|
|
Author: Paul Bramscher |
217 |
|
|
Last Modified: 05.21.2003 |
218 |
|
|
*********************************************************** |
219 |
|
|
Purpose: |
220 |
|
|
Update supplied feature id. |
221 |
|
|
**********************************************************/ |
222 |
|
|
function updateFeature($con, $feature, $feature_id, $image_alt, $image_path) { |
223 |
|
|
|
224 |
|
|
// Error flag |
225 |
|
|
$err_code = 0; |
226 |
|
|
|
227 |
|
|
// Need for display/uniqueness |
228 |
|
|
$feature_display = $feature; |
229 |
|
|
|
230 |
|
|
// Check to see if already exists |
231 |
|
|
$exists = recordCount($con, "feature", "feature", $feature_search, "A"); |
232 |
|
|
$exists_id = lookupField($con, "feature", "feature", $feature_search, "feature_id"); |
233 |
|
|
|
234 |
|
|
// If exists in the feature table under a different feature_id |
235 |
|
|
if ($exists > 0 && $exists_id != $feature_id) { |
236 |
|
|
$err_code = 1; |
237 |
|
|
$err_msg = "Failed. '" . $feature_display . "' already exists in the feature table."; |
238 |
|
|
} |
239 |
|
|
|
240 |
|
|
// Check for blank entry |
241 |
|
|
if ($feature == "") { |
242 |
|
|
$err_code = 2; |
243 |
|
|
$err_msg = "Failed. Must supply some value for the feature."; |
244 |
|
|
} |
245 |
|
|
|
246 |
|
|
printf("<center><h3>Updating Feature...</h3>\n"); |
247 |
|
|
|
248 |
|
|
// Table |
249 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
250 |
|
|
printf("<tr><td><br>\n"); |
251 |
|
|
printf("<strong>Messages:</strong><br>"); |
252 |
|
|
|
253 |
|
|
|
254 |
|
|
// Perform the update only if no errors encountered |
255 |
|
|
if ($err_code == 0) { |
256 |
|
|
|
257 |
|
|
// Build the SQL |
258 |
dpavlin |
54 |
$sql = "UPDATE feature SET feature = ?, image_alt = ?, image_path = ? WHERE feature_id = ?"; |
259 |
dpavlin |
1 |
|
260 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $feature, $image_alt, $image_path, $feature_id)){ |
261 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
262 |
dpavlin |
1 |
bailout(); |
263 |
|
|
} |
264 |
|
|
else { |
265 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
266 |
dpavlin |
1 |
printf("Updated <b>%s</b> feature.<BR><BR>\n", $feature_display); |
267 |
|
|
} |
268 |
|
|
} |
269 |
|
|
|
270 |
|
|
else printf("%s", $err_msg); |
271 |
|
|
|
272 |
|
|
printf("<br><br>\n"); |
273 |
|
|
printf("</td></tr></table>\n"); |
274 |
|
|
printf("</center>\n"); |
275 |
|
|
|
276 |
|
|
} |
277 |
|
|
|
278 |
|
|
|
279 |
|
|
/********************************************************** |
280 |
|
|
Function: updateInfotype |
281 |
|
|
Author: Paul Bramscher |
282 |
|
|
Last Modified: 06.05.2003 |
283 |
|
|
*********************************************************** |
284 |
|
|
Purpose: |
285 |
|
|
Update supplied infotype id. |
286 |
|
|
**********************************************************/ |
287 |
|
|
function updateInfotype($con, $infotype, $infotype_id, $masterinfotype_id, $mastersubject_id) { |
288 |
|
|
|
289 |
|
|
// Error flag |
290 |
|
|
$err_code = 0; |
291 |
|
|
|
292 |
|
|
// Need for display/uniqueness purposes |
293 |
|
|
$infotype_display = $infotype; |
294 |
|
|
|
295 |
|
|
// Check to see if already exists |
296 |
|
|
$exists = recordCount($con, "infotype", "infotype", $infotype_search, "A"); |
297 |
|
|
$exists_id = lookupField($con, "infotype", "infotype", $infotype_search, "infotype_id"); |
298 |
|
|
|
299 |
|
|
// If exists in the infotype table under a different infotype_id (not editing the name of this infotype) |
300 |
|
|
if ($exists > 0 && $exists_id != $infotype_id) { |
301 |
|
|
$err_code = 1; |
302 |
|
|
$err_msg = "Failed. <b>" . $infotype_display . "</b> already exists in the Information Type table."; |
303 |
|
|
} |
304 |
|
|
|
305 |
|
|
// Check for blank entry |
306 |
|
|
if ($infotype == "") { |
307 |
|
|
$err_code = 2; |
308 |
|
|
$err_msg = "Failed. Must supply some value for the Information Type name."; |
309 |
|
|
} |
310 |
|
|
|
311 |
|
|
printf("<center><h3>Updating Infotype...</h3>"); |
312 |
|
|
|
313 |
|
|
// Table |
314 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
315 |
|
|
printf("<tr><td><br>"); |
316 |
|
|
printf("<strong>Messages:</strong><br>"); |
317 |
|
|
|
318 |
|
|
// Proceed if no errors encountered |
319 |
|
|
if ($err_code == 0) { |
320 |
|
|
|
321 |
dpavlin |
54 |
// First, update affected RQS relationships |
322 |
|
|
$sql = "UPDATE res_sub_infotype SET masterinfotype_id = ? WHERE infotype_id = ?"; |
323 |
dpavlin |
1 |
|
324 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $masterinfotype_id, $infotype_id)){ |
325 |
dpavlin |
1 |
$err_code = 1; |
326 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
327 |
dpavlin |
1 |
bailout(); |
328 |
|
|
} |
329 |
|
|
else { |
330 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
331 |
dpavlin |
1 |
printf("Updated affected RQS relationships (if any)<BR>\n"); |
332 |
|
|
} |
333 |
|
|
} |
334 |
|
|
|
335 |
|
|
|
336 |
|
|
if ($err_code == 0) { |
337 |
|
|
|
338 |
|
|
// Build the SQL |
339 |
dpavlin |
54 |
$sql = "UPDATE infotype SET infotype = ?, masterinfotype_id = ?, mastersubject_id = ? WHERE infotype_id = ?"; |
340 |
dpavlin |
1 |
|
341 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $infotype, $masterinfotype_id, $mastersubject_id, $infotype_id)){ |
342 |
dpavlin |
1 |
$err_code = 1; |
343 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
344 |
dpavlin |
1 |
bailout(); |
345 |
|
|
} |
346 |
|
|
else { |
347 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
348 |
dpavlin |
1 |
printf("Updated Information Type to <b>%s</b>.<BR><BR>\n", $infotype_display); |
349 |
|
|
} |
350 |
|
|
|
351 |
|
|
} |
352 |
|
|
|
353 |
|
|
else printf("%s<BR><BR>", $err_msg); |
354 |
|
|
|
355 |
|
|
printf("<BR>"); |
356 |
|
|
printf("</td></tr></table><BR>"); |
357 |
|
|
printf("</center>"); |
358 |
|
|
|
359 |
|
|
} |
360 |
|
|
|
361 |
|
|
|
362 |
|
|
/********************************************************** |
363 |
|
|
Function: updateLibunit |
364 |
|
|
Author: Paul Bramscher |
365 |
|
|
Last Modified: 05.22.2003 |
366 |
|
|
*********************************************************** |
367 |
|
|
Purpose: |
368 |
|
|
Updates the supplied library unit id with new information. |
369 |
|
|
**********************************************************/ |
370 |
|
|
function updateLibunit($con, $head_staff_id, $libunit, $libunit_abbrev, $libunit_id) { |
371 |
|
|
|
372 |
|
|
/* |
373 |
|
|
Library Units must have both a unique name and unique abbreviation |
374 |
|
|
e.g. "Digital Library Developement Laboratory" and "DLDL" |
375 |
|
|
Additionally, empty values are not allowed. |
376 |
|
|
*/ |
377 |
|
|
|
378 |
|
|
// Error flag |
379 |
|
|
$err_code = 0; |
380 |
|
|
|
381 |
|
|
// Need for display/uniqueness purposes |
382 |
|
|
$libunit_display = $libunit; |
383 |
|
|
$libunit_abbrev_display = $libunit_abbrev; |
384 |
|
|
|
385 |
|
|
// Check to see if libunit already exists |
386 |
|
|
$exists = recordCount($con, "libunit", "libunit", $libunit_search, "A"); |
387 |
|
|
$exists_id = lookupField($con, "libunit", "libunit", $libunit_search, "libunit_id"); |
388 |
|
|
if ($exists > 0 && $exists_id != $libunit_id) { |
389 |
|
|
$err_code = 1; |
390 |
|
|
$err_msg = "Failed. '" . $libunit_display . "' already exists in the Library Unit table."; |
391 |
|
|
} |
392 |
|
|
|
393 |
|
|
// Check to see if libunit abbreviation already exists |
394 |
|
|
$exists = recordCount($con, "libunit", "libunit_abbrev", $libunit_abbrev_search, "A"); |
395 |
|
|
$exists_id = lookupField($con, "libunit", "libunit_abbrev", $libunit_abbrev_search, "libunit_id"); |
396 |
|
|
|
397 |
|
|
if ($exists > 0 && $exists_id != $libunit_id) { |
398 |
|
|
$err_code = 2; |
399 |
|
|
$err_msg = "Failed. '" . $libunit_abbrev_display . "' abbreviation already exists in the Library Unit table."; |
400 |
|
|
} |
401 |
|
|
|
402 |
|
|
// Check for blank linunit entry |
403 |
|
|
if ($libunit == "") { |
404 |
|
|
$err_code = 3; |
405 |
|
|
$err_msg = "Failed. Cannot enter a blank Library Unit."; |
406 |
|
|
} |
407 |
|
|
|
408 |
|
|
// Check for blank linunit abbrev entry |
409 |
|
|
if ($libunit_abbrev == "") { |
410 |
|
|
$err_code = 4; |
411 |
|
|
$err_msg = "Failed. Cannot enter a blank Library Unit abbreviation."; |
412 |
|
|
} |
413 |
|
|
|
414 |
|
|
// Add only if no errors encountered |
415 |
|
|
if ($err_code == 0) { |
416 |
|
|
|
417 |
|
|
// Build the SQL |
418 |
dpavlin |
54 |
$sql = "UPDATE libunit SET libunit = ?, libunit_abbrev = ?, head_staff_id = ? WHERE libunit_id = ?"; |
419 |
dpavlin |
1 |
|
420 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $libunit, $libunit_abbrev, $head_staff_id, $libunit_id)){ |
421 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
422 |
dpavlin |
1 |
bailout(); |
423 |
|
|
} |
424 |
|
|
else { |
425 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
426 |
dpavlin |
1 |
|
427 |
|
|
// Call the libunit form back |
428 |
|
|
formLibunit($con, $libunit_id); |
429 |
|
|
} |
430 |
|
|
} |
431 |
|
|
|
432 |
|
|
else { |
433 |
|
|
printf("<center><h3>Updating Library Unit...</h3>"); |
434 |
|
|
|
435 |
|
|
// Table |
436 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
437 |
|
|
printf("<tr><td><br>\n"); |
438 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
439 |
|
|
printf("%s", $err_msg); |
440 |
|
|
printf("<BR><BR>\n"); |
441 |
|
|
printf("</td></tr></table>\n"); |
442 |
|
|
printf("</center>\n"); |
443 |
|
|
} |
444 |
|
|
} |
445 |
|
|
|
446 |
|
|
|
447 |
|
|
/********************************************************** |
448 |
|
|
Function: updateLocation |
449 |
|
|
Author: Paul Bramscher |
450 |
|
|
Last Modified: 04.21.2003 |
451 |
|
|
*********************************************************** |
452 |
|
|
Purpose: |
453 |
|
|
Update supplied location id. |
454 |
|
|
**********************************************************/ |
455 |
|
|
function updateLocation($con, $address1, $address2, |
456 |
|
|
$address3, $address4, $campus, $hoursURL, $location, $location_descr, |
457 |
|
|
$location_id, $mainURL, $mapURL, $referenceURL, $telephone) { |
458 |
|
|
|
459 |
|
|
// Error flag |
460 |
|
|
$err_code = 0; |
461 |
|
|
|
462 |
|
|
// Need for display/uniqueness purposes |
463 |
|
|
$location_display = $location; |
464 |
|
|
|
465 |
|
|
// Check to see if already exists |
466 |
|
|
$exists = recordCount($con, "location", "location", $location_search, "A"); |
467 |
|
|
$exists_id = lookupField($con, "location", "location", $location_search, "location_id"); |
468 |
|
|
|
469 |
|
|
// If exists in the location table under a different location_id |
470 |
|
|
if ($exists > 0 && $exists_id != $location_id) { |
471 |
|
|
$err_code = 1; |
472 |
|
|
$err_msg = "Failed. '" . $location_display . "' already exists in the location table."; |
473 |
|
|
} |
474 |
|
|
|
475 |
|
|
// Check for blank entry |
476 |
|
|
if ($location == "") { |
477 |
|
|
$err_code = 2; |
478 |
|
|
$err_msg = "Failed. Must supply some value for the location name."; |
479 |
|
|
} |
480 |
|
|
|
481 |
|
|
printf("<center><h3>Updating Location...</h3>\n"); |
482 |
|
|
|
483 |
|
|
// Table |
484 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
485 |
|
|
printf("<tr><td><br>\n"); |
486 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
487 |
|
|
|
488 |
|
|
// Perform the update only if no errors encountered |
489 |
|
|
if ($err_code == 0) { |
490 |
|
|
|
491 |
|
|
// Build the SQL |
492 |
dpavlin |
54 |
$sql = "UPDATE location SET location = ?, location_descr = ?, campus = ?, |
493 |
|
|
address1 = ?, address2 = ?, address3 = ?, address4 = ?, |
494 |
|
|
mainURL = ?, hoursURL = ?, referenceURL = ?, mapURL = ?, |
495 |
|
|
telephone = ? WHERE location_id = ?"; |
496 |
dpavlin |
1 |
|
497 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, |
498 |
|
|
$location,$location_descr,$campus, |
499 |
|
|
$address1,$address2,$address3,$address4, |
500 |
|
|
$mainURL,$hoursURL,$referenceURL,$mapURL, |
501 |
|
|
$telephone,$location_id)){ |
502 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
503 |
dpavlin |
1 |
bailout(); |
504 |
|
|
} |
505 |
|
|
else { |
506 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
507 |
dpavlin |
1 |
printf("Updated Location to <b>%s</b>.<BR><BR>\n", $location_display); |
508 |
|
|
} |
509 |
|
|
} |
510 |
|
|
else printf("%s", $err_msg); |
511 |
|
|
|
512 |
|
|
printf("<br><br>\n"); |
513 |
|
|
printf("</td></tr></table>\n"); |
514 |
|
|
printf("</center>\n"); |
515 |
|
|
|
516 |
|
|
} |
517 |
|
|
|
518 |
|
|
|
519 |
|
|
/********************************************************** |
520 |
|
|
Function: updatePassword |
521 |
|
|
Author: Paul Bramscher |
522 |
|
|
Last Modified: 06.23.2003 |
523 |
|
|
*********************************************************** |
524 |
|
|
Purpose: |
525 |
|
|
Changes the locally encrypted and mySQL stored password to |
526 |
|
|
the newly supplied value. Note that the new password and |
527 |
|
|
the "confirm" must match, and it must be 6 characters |
528 |
|
|
minimum. As with purgePassword, at no time does this |
529 |
|
|
system bring the password out of the database and present |
530 |
|
|
it on an HTML form, neither in plaintext nor in a |
531 |
|
|
"password" type HTML form field. The password in plaintext |
532 |
|
|
is never viewable to the system, nor to mySQL itself. If |
533 |
|
|
a user forgets his/her password, it must be reset by an |
534 |
|
|
administrator. |
535 |
|
|
**********************************************************/ |
536 |
|
|
function updatePassword($con, $password, $password_confirm, $staff_id) { |
537 |
|
|
|
538 |
|
|
// Error flag |
539 |
|
|
$err_code = 0; |
540 |
|
|
|
541 |
|
|
// Check for less than 6 char. |
542 |
|
|
if (strlen($password) < 6) { |
543 |
|
|
$err_code = 1; |
544 |
|
|
$err_msg = "Failed. Password must be 6 characters minimum."; |
545 |
|
|
} |
546 |
|
|
|
547 |
|
|
// Check for mis-matched password and confirm |
548 |
|
|
if ($password != $password_confirm) { |
549 |
|
|
$err_code = 2; |
550 |
|
|
$err_msg = "Failed. Password and confirm password didn't match."; |
551 |
|
|
} |
552 |
|
|
|
553 |
|
|
// Update only if no errors encountered |
554 |
|
|
if ($err_code == 0) { |
555 |
|
|
|
556 |
|
|
// Build the SQL |
557 |
dpavlin |
54 |
$sql = "UPDATE staff SET password = password(?) WHERE staff_id = ?"; |
558 |
dpavlin |
1 |
|
559 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $password, $staff_id)){ |
560 |
dpavlin |
1 |
sql_err($sql); |
561 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
562 |
dpavlin |
1 |
bailout(); |
563 |
|
|
} |
564 |
|
|
else { |
565 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
566 |
dpavlin |
1 |
|
567 |
|
|
// Call the staff form back |
568 |
|
|
formStaff($con, $staff_id); |
569 |
|
|
} |
570 |
|
|
} |
571 |
|
|
|
572 |
|
|
else { |
573 |
|
|
printf("<center><h3>Updating Local Password...</h3>"); |
574 |
|
|
|
575 |
|
|
// Table |
576 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
577 |
|
|
printf("<tr><td><br>\n"); |
578 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
579 |
|
|
printf("%s", $err_msg); |
580 |
|
|
printf("<BR><BR>\n"); |
581 |
|
|
printf("</td></tr></table>\n"); |
582 |
|
|
printf("</center>\n"); |
583 |
|
|
} |
584 |
|
|
} |
585 |
|
|
|
586 |
|
|
|
587 |
|
|
/********************************************************** |
588 |
|
|
Function: updateResource |
589 |
|
|
Author: Paul Bramscher |
590 |
|
|
Last Modified: 05.07.2003 |
591 |
|
|
*********************************************************** |
592 |
|
|
Purpose: |
593 |
|
|
Update supplied resource id, and call formResource back |
594 |
|
|
again. |
595 |
|
|
**********************************************************/ |
596 |
|
|
function updateResource($con, $annotation, $author, $call_no, $cat_num, $coverage_detail, |
597 |
|
|
$edition, $infotype_id, $key_id, $other_title, $pub_date, $publisher, $sess_staff_account, |
598 |
|
|
$sources_indexed, $title, $url) { |
599 |
|
|
|
600 |
|
|
// Set up SQL |
601 |
dpavlin |
54 |
$sql = "UPDATE resource SET |
602 |
|
|
annotation = ?, author = ?, call_no = ?, cat_num = ?, coverage_detail = ?, |
603 |
|
|
date_modified = now(), edition = ?, infotype_id = ?, other_title = ?, pub_date = ?, publisher = ?, |
604 |
|
|
sources_indexed = ?, title = ?, url = ?, vendor_id = ?, account_modified = ? WHERE resource_id = ?"; |
605 |
dpavlin |
1 |
|
606 |
dpavlin |
54 |
// printf("sql was: %s<br><br>\n", $sql); |
607 |
dpavlin |
1 |
|
608 |
|
|
// Edit the record |
609 |
dpavlin |
42 |
xx_query ("LOCK TABLE resource WRITE", $con); |
610 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, |
611 |
|
|
$annotation, $author, $call_no, $cat_num, $coverage_detail, |
612 |
|
|
$edition, $infotype_id, $other_title, $pub_date, $publisher, |
613 |
|
|
$sources_indexed, $title, $url, $vendor_id, $sess_staff_account, $key_id)) { |
614 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
615 |
dpavlin |
1 |
bailout(); |
616 |
|
|
} |
617 |
|
|
else { |
618 |
dpavlin |
42 |
xx_query("UNLOCK TABLES", $con); |
619 |
dpavlin |
1 |
formResource($con, $key_id, 0, 0, ''); |
620 |
|
|
} |
621 |
|
|
|
622 |
|
|
} |
623 |
|
|
|
624 |
|
|
|
625 |
|
|
/********************************************************** |
626 |
|
|
Function: updateService |
627 |
|
|
Author: Paul Bramscher |
628 |
|
|
Last Modified: 05.21.2003 |
629 |
|
|
*********************************************************** |
630 |
|
|
Purpose: |
631 |
|
|
Update supplied service id and call formService back again. |
632 |
|
|
**********************************************************/ |
633 |
|
|
function updateService($con, $address1, $address2, $address3, $address4, $email, |
634 |
|
|
$fax, $nonaff, $service, $serviceDescr, $service_id, $serviceURL, $telephone) { |
635 |
|
|
|
636 |
|
|
// Error flag |
637 |
|
|
$err_code = 0; |
638 |
|
|
|
639 |
|
|
// Need for display/uniqueness |
640 |
|
|
$service_display = $service; |
641 |
|
|
$service_search = textSearchmySQL($service); |
642 |
|
|
|
643 |
|
|
// Check to see if already exists |
644 |
|
|
$exists = recordCount($con, "service", "service", $service_search, "A"); |
645 |
|
|
$exists_id = lookupField($con, "service", "service", $service_search, "service_id"); |
646 |
|
|
|
647 |
|
|
if ($exists > 0 && $exists_id != $service_id) { |
648 |
|
|
$err_code = 1; |
649 |
|
|
$err_msg = "Failed. '" . $service_display . "' already exists in the service table."; |
650 |
|
|
} |
651 |
|
|
|
652 |
|
|
// Check for blank entry |
653 |
|
|
if ($service == "") { |
654 |
|
|
$err_code = 2; |
655 |
|
|
$err_msg = "Failed. Cannot enter a blank service."; |
656 |
|
|
} |
657 |
|
|
|
658 |
|
|
if ($err_code == 0) { |
659 |
|
|
|
660 |
|
|
// Build the SQL |
661 |
dpavlin |
54 |
$sql = "UPDATE service SET service = ?, serviceDescr = ?, |
662 |
|
|
address1 = ?, address2 = ?, address3 = ?, address4 = ?, |
663 |
|
|
serviceURL = ?, email = ?, fax = ?, telephone = ?, nonaff = ? WHERE service_id = ?"; |
664 |
dpavlin |
1 |
|
665 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $service, $serviceDescr, |
666 |
|
|
$address1, $address2, $address3, $address4, |
667 |
|
|
$serviceURL, $email, $fax, $telephone, $nonaff, $service_id)){ |
668 |
dpavlin |
1 |
sql_err($sql); |
669 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
670 |
dpavlin |
1 |
bailout(); |
671 |
|
|
} |
672 |
|
|
else { |
673 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
674 |
dpavlin |
1 |
|
675 |
|
|
// Call the service form back |
676 |
|
|
formService($con, $service_id); |
677 |
|
|
} |
678 |
|
|
|
679 |
|
|
} |
680 |
|
|
|
681 |
|
|
else { |
682 |
|
|
printf("<center><h3>Updating Service...</h3>"); |
683 |
|
|
|
684 |
|
|
// Table |
685 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
686 |
|
|
printf("<tr><td><br>\n"); |
687 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
688 |
|
|
printf("%s", $err_msg); |
689 |
|
|
printf("<BR><BR>\n"); |
690 |
|
|
printf("</td></tr></table>\n"); |
691 |
|
|
printf("</center>\n"); |
692 |
|
|
} |
693 |
|
|
|
694 |
|
|
} |
695 |
|
|
|
696 |
|
|
|
697 |
|
|
/********************************************************** |
698 |
|
|
Function: updateSingleField |
699 |
|
|
Author: Paul Bramscher |
700 |
|
|
Last Modified: 05.21.2003 |
701 |
|
|
*********************************************************** |
702 |
|
|
Purpose: |
703 |
|
|
Updates any single field in any supplied table. Checks |
704 |
|
|
for uniqueness and blank value. |
705 |
|
|
**********************************************************/ |
706 |
|
|
function updateSingleField($con, $display, $display_field, $key_field, |
707 |
|
|
$key_id, $newValue, $table){ |
708 |
|
|
|
709 |
|
|
// Error flag |
710 |
|
|
$err_code = 0; |
711 |
|
|
|
712 |
|
|
$newValue_search = textSearchmySQL($newValue); |
713 |
|
|
|
714 |
|
|
// Check to see if already exists |
715 |
|
|
$exists = recordCount($con, $table, $display_field, $newValue_search, "A"); |
716 |
|
|
$exists_id = lookupField($con, $table, $display_field, $newValue_search, $key_field); |
717 |
|
|
|
718 |
|
|
// If exists in the infotype table under a different infotype_id (not editing the name of this infotype) |
719 |
|
|
if ($exists > 0 && $exists_id != $key_field) { |
720 |
|
|
$err_code = 1; |
721 |
|
|
$err_msg = "Failed. <b>" . $newValue . "</b> already exists in the <b>" |
722 |
|
|
. $table |
723 |
|
|
. "</b> table.\n"; |
724 |
|
|
} |
725 |
|
|
|
726 |
|
|
// Check for blank entry |
727 |
|
|
if ($newValue == "") { |
728 |
|
|
$err_code = 2; |
729 |
|
|
$err_msg = "Failed. Must supply some value for the <b>" |
730 |
|
|
. $display |
731 |
|
|
. "</b>."; |
732 |
|
|
} |
733 |
|
|
|
734 |
|
|
// Draw page heading |
735 |
|
|
printf("<center><h3>Updating %s...</h3>", $display); |
736 |
|
|
|
737 |
|
|
printf("<table width =\"50%%\" border = \"3\" class=\"backLight\">"); |
738 |
|
|
printf("<tr><td><font face = \"Arial\">"); |
739 |
|
|
printf("<b>Messages:</b><br>\n"); |
740 |
|
|
|
741 |
|
|
// Continue if no errors |
742 |
|
|
if ($err_code == 0) { |
743 |
|
|
|
744 |
|
|
$newValue_display = $newValue; |
745 |
|
|
|
746 |
|
|
// Build the SQL |
747 |
dpavlin |
54 |
$sql = "UPDATE ! SET ! = ? WHERE ! = ?"; |
748 |
dpavlin |
1 |
|
749 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $table, $display_field, $newValue, $key_field, $key_id)){ |
750 |
dpavlin |
1 |
sql_err($sql); |
751 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
752 |
dpavlin |
1 |
bailout(); |
753 |
|
|
} |
754 |
|
|
else { |
755 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
756 |
dpavlin |
1 |
printf("%s successfully changed to <b>%s</b>.\n", $display, $newValue_display); |
757 |
|
|
} |
758 |
|
|
|
759 |
|
|
} |
760 |
|
|
|
761 |
|
|
else printf("%s", $err_msg); |
762 |
|
|
|
763 |
|
|
printf("<br><br></td></tr></table><br>"); |
764 |
|
|
printf("</center>"); |
765 |
|
|
} |
766 |
|
|
|
767 |
|
|
|
768 |
|
|
/********************************************************** |
769 |
|
|
Function: updateStaff |
770 |
|
|
Author: Paul Bramscher |
771 |
|
|
Last Modified: 06.23.2003 |
772 |
|
|
*********************************************************** |
773 |
|
|
Purpose: |
774 |
|
|
Updates the supplied staff id with new information. |
775 |
|
|
**********************************************************/ |
776 |
|
|
function updateStaff($con, $access_id, $first_name, |
777 |
|
|
$last_name, $sess_access_level, $staff_account, $staff_email, $staff_id, $stafftitle_id) { |
778 |
|
|
|
779 |
|
|
/* |
780 |
|
|
Staff must have, at a minimum, a last name, first name, and unique staff account |
781 |
|
|
name. Uniqueness is enforced only on staff_account. |
782 |
|
|
*/ |
783 |
|
|
|
784 |
|
|
// Error flag |
785 |
|
|
$err_code = 0; |
786 |
|
|
|
787 |
|
|
// Need for display/uniqueness purposes |
788 |
|
|
$staff_account_display = $staff_account; |
789 |
|
|
$staff_account_search = textSearchmySQL($staff_account); |
790 |
|
|
|
791 |
|
|
// Check to see if the staff_account already exists |
792 |
|
|
$exists = recordCount($con, "staff", "staff_account", $staff_account_search, "A"); |
793 |
|
|
$exists_id = lookupField($con, "staff", "staff_account", $staff_account_search, "staff_id"); |
794 |
|
|
|
795 |
|
|
if ($exists > 0 && $exists_id != $staff_id) { |
796 |
|
|
$err_code = 1; |
797 |
|
|
$err_msg = "Failed. '" . $staff_account_display . "' already exists in the Staff table."; |
798 |
|
|
} |
799 |
|
|
|
800 |
|
|
// Check for blank first name or last name |
801 |
|
|
if ($first_name == "" || $last_name == "") { |
802 |
|
|
$err_code = 2; |
803 |
|
|
$err_msg = "Failed. A first and last name must be supplied for all staff."; |
804 |
|
|
} |
805 |
|
|
|
806 |
|
|
// Check for blank staff_account |
807 |
|
|
if ($staff_account == "") { |
808 |
|
|
$err_code = 3; |
809 |
|
|
$err_msg = "Failed. A staff account must be supplied for all staff."; |
810 |
|
|
} |
811 |
|
|
|
812 |
|
|
// Check for access level higher than current access |
813 |
|
|
$this_access_level = lookupfield($con, "access", "access_id", $access_id, "access_level"); |
814 |
|
|
if ($this_access_level > $sess_access_level) { |
815 |
|
|
$err_code = 4; |
816 |
|
|
$err_msg = "Failed. You may not promote staff to higher privileges than your own."; |
817 |
|
|
} |
818 |
|
|
|
819 |
|
|
// Continue only if no errors. |
820 |
|
|
if ($err_code == 0) { |
821 |
|
|
|
822 |
|
|
// Clean up strings |
823 |
|
|
if (strlen($first_name) > 0) $first_name = textInmySQL($first_name); |
824 |
|
|
if (strlen($last_name) > 0) $last_name = textInmySQL($last_name); |
825 |
|
|
if (strlen($staff_account) > 0) $staff_account = textInmySQL($staff_account); |
826 |
|
|
if (strlen($staff_email) > 0) $staff_email = textInmySQL($staff_email); |
827 |
|
|
|
828 |
|
|
// Build the SQL |
829 |
dpavlin |
54 |
$sql = "UPDATE staff SET access_id = ?, first_name = ?, last_name = ?, stafftitle_id = ?, staff_account = ?, staff_email = ? WHERE staff_id = ?"; |
830 |
dpavlin |
1 |
|
831 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $access_id, $first_name, $last_name, $stafftitle_id, $staff_account, $staff_email, $staff_id)){ |
832 |
dpavlin |
1 |
sql_err($sql); |
833 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
834 |
dpavlin |
1 |
bailout(); |
835 |
|
|
} |
836 |
|
|
else { |
837 |
|
|
// Success. Call formStaff back. |
838 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
839 |
dpavlin |
1 |
formStaff($con, $staff_id); |
840 |
|
|
} |
841 |
|
|
} |
842 |
|
|
else { |
843 |
|
|
|
844 |
|
|
printf("<center><h3>Updating Staff...</h3>\n"); |
845 |
|
|
|
846 |
|
|
// Table |
847 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
848 |
|
|
printf("<tr><td><br>\n"); |
849 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
850 |
|
|
|
851 |
|
|
printf("%s<BR><BR>\n", $err_msg); |
852 |
|
|
printf("</td></tr></table>\n"); |
853 |
|
|
printf("</center>\n"); |
854 |
|
|
} |
855 |
|
|
} |
856 |
|
|
|
857 |
|
|
|
858 |
|
|
/********************************************************** |
859 |
|
|
Function: updateStyle |
860 |
|
|
Author: Paul Bramscher |
861 |
|
|
Last Modified: 05.22.2003 |
862 |
|
|
*********************************************************** |
863 |
|
|
Purpose: |
864 |
|
|
Update the supplied style id. As with the insert transaction, |
865 |
|
|
no error checking is done to ensure that the supplied files |
866 |
|
|
actually exist and have proper permissions. |
867 |
|
|
**********************************************************/ |
868 |
|
|
function updateStyle($con, $css_file, $footer_file, $header_file, $style_id, $style_title) { |
869 |
|
|
|
870 |
|
|
// Error flag |
871 |
|
|
$err_code = 0; |
872 |
|
|
|
873 |
|
|
// Need for display/uniqueness |
874 |
|
|
$style_title_display = $style_title; |
875 |
|
|
$style_title_search = textSearchmySQL($style_title); |
876 |
|
|
|
877 |
|
|
// Check to see if already exists under a different style_id |
878 |
|
|
$exists = recordCount($con, "style", "style_title", $style_title_search, "A"); |
879 |
|
|
$exists_id = lookupField($con, "style", "style_title", $style_title_search, "style_id"); |
880 |
|
|
|
881 |
|
|
if ($exists > 0 && $exists_id != $style_id) { |
882 |
|
|
$err_code = 1; |
883 |
|
|
$err_msg = "Failed. '" . $style_title_display . "' already exists in the style table."; |
884 |
|
|
} |
885 |
|
|
|
886 |
|
|
// Check for blank entry |
887 |
|
|
if ($style_title == "") { |
888 |
|
|
$err_code = 2; |
889 |
|
|
$err_msg = "Failed. Cannot enter a blank style."; |
890 |
|
|
} |
891 |
|
|
|
892 |
|
|
printf("<center><h3>Updating Style...</h3>"); |
893 |
|
|
|
894 |
|
|
// Table |
895 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
896 |
|
|
printf("<tr><td><br>"); |
897 |
|
|
printf("<strong>Messages:</strong><br>"); |
898 |
|
|
|
899 |
|
|
if ($err_code == 0) { |
900 |
|
|
|
901 |
|
|
// Clean up strings |
902 |
|
|
if (strlen($css_file) > 0) $css_file = textInmySQL($css_file); |
903 |
|
|
if (strlen($footer_file) > 0) $footer_file = textInmySQL($footer_file); |
904 |
|
|
if (strlen($header_file) > 0) $header_file = textInmySQL($header_file); |
905 |
|
|
if (strlen($style_title) > 0) $style_title = textInmySQL($style_title); |
906 |
|
|
|
907 |
|
|
// Build the SQL |
908 |
dpavlin |
54 |
$sql = "UPDATE style SET style_title = ?, css_file = ?, footer_file = ?, header_file = ? WHERE style_id = ?"; |
909 |
dpavlin |
1 |
|
910 |
dpavlin |
54 |
if (!xx_prepare_execute($sql, $style_title, $css_file, $footer_file, $header_file, $style_id)){ |
911 |
dpavlin |
1 |
sql_err($sql); |
912 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
913 |
dpavlin |
1 |
bailout(); |
914 |
|
|
} |
915 |
|
|
else { |
916 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
917 |
dpavlin |
1 |
printf("Successfully updated <b>%s</b> style.", $style_title_display); |
918 |
|
|
} |
919 |
|
|
} |
920 |
|
|
else printf("%s", $err_msg); |
921 |
|
|
|
922 |
|
|
printf("<br><br>\n"); |
923 |
|
|
printf("</td></tr></table>\n"); |
924 |
|
|
printf("</center>\n"); |
925 |
|
|
|
926 |
|
|
} |
927 |
|
|
|
928 |
|
|
|
929 |
|
|
/********************************************************** |
930 |
|
|
Function: updateSubject |
931 |
|
|
Author: Paul Bramscher |
932 |
|
|
Last Modified: 06.11.2003 |
933 |
|
|
*********************************************************** |
934 |
|
|
Purpose: |
935 |
|
|
Update the supplied subject id, and call formSubject back |
936 |
|
|
again. |
937 |
|
|
**********************************************************/ |
938 |
|
|
function updateSubject($con, $subject, $subject_descr, $subject_id, $sublocation_id) { |
939 |
|
|
|
940 |
|
|
// Error flag |
941 |
|
|
$err_code = 0; |
942 |
|
|
|
943 |
|
|
// Need for display/uniqueness purposes |
944 |
|
|
$subject_display = $subject; |
945 |
|
|
$subject_search = textSearchmySQL($subject); |
946 |
|
|
|
947 |
|
|
// Check to see if already exists |
948 |
|
|
$exists = recordCount($con, "subject", "subject", $subject_search, "A"); |
949 |
|
|
$exists_id = lookupField($con, "subject", "subject", $subject_search, "subject_id"); |
950 |
|
|
|
951 |
|
|
// If exists in the subject table under a different subject_id (not editing the name of this subject) |
952 |
|
|
if ($exists > 0 && $exists_id != $subject_id) { |
953 |
|
|
$err_code = 1; |
954 |
|
|
$err_msg = "Failed. '" . $subject . "' already exists in the subject table."; |
955 |
|
|
} |
956 |
|
|
|
957 |
|
|
// Check for blank entry |
958 |
|
|
if ($subject == "") { |
959 |
|
|
$err_code = 2; |
960 |
|
|
$err_msg = "Failed. Must supply some value for the subject name."; |
961 |
|
|
} |
962 |
|
|
|
963 |
|
|
// Perform the update only if no errors encountered |
964 |
|
|
if ($err_code == 0) { |
965 |
|
|
|
966 |
|
|
// Clean up strings |
967 |
|
|
$subject = textInmySQL($subject); |
968 |
|
|
if (strlen($subject_descr) > 0) $subject_descr = textInmySQL($subject_descr); |
969 |
|
|
|
970 |
|
|
// Build the SQL |
971 |
dpavlin |
54 |
$sql = "UPDATE subject SET subject = ?, subject_descr = ?, sublocation_id = ? WHERE subject_id = ?"; |
972 |
dpavlin |
1 |
|
973 |
dpavlin |
54 |
if (!xx_query ($sql, $subject, $subject_descr, $sublocation_id, $subject_id)){ |
974 |
dpavlin |
1 |
sql_err($sql); |
975 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
976 |
dpavlin |
1 |
bailout(); |
977 |
|
|
} |
978 |
|
|
else { |
979 |
dpavlin |
42 |
xx_query ("UNLOCK TABLES", $con); |
980 |
dpavlin |
1 |
formSubject($con, $subject_id); |
981 |
|
|
} // updated subject |
982 |
|
|
|
983 |
|
|
} |
984 |
|
|
|
985 |
|
|
else { |
986 |
|
|
|
987 |
|
|
printf("<center><h3>Updating subject...</h3>"); |
988 |
|
|
|
989 |
|
|
// Table |
990 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
991 |
|
|
printf("<tr><td><br>"); |
992 |
|
|
printf("<strong>Messages:</strong><br>"); |
993 |
|
|
|
994 |
|
|
printf("%s<BR><BR>", $err_msg); |
995 |
|
|
printf("</td></tr></table>"); |
996 |
|
|
printf("</center>"); |
997 |
|
|
} |
998 |
|
|
} |
999 |
|
|
?> |