1 |
dpavlin |
1 |
<?php |
2 |
|
|
/********************************************************** |
3 |
|
|
Function Library: delete.php |
4 |
|
|
Original Author: Paul Bramscher <brams006@tc.umn.edu> |
5 |
|
|
Last Modified: 11.04.2003 by Paul Bramscher |
6 |
|
|
*********************************************************** |
7 |
|
|
Comments: |
8 |
|
|
This library brings together all SQL delete functions |
9 |
|
|
and "confirm" type promots for LibData general setup |
10 |
|
|
tables. Those pertaining to CLPS and RQS are located in |
11 |
|
|
scribe_application.php and are located in subject_builder.php |
12 |
|
|
respectively. |
13 |
|
|
*********************************************************** |
14 |
|
|
Table of Contents: |
15 |
|
|
deleteCampus |
16 |
|
|
deleteCampusConfirm |
17 |
|
|
deleteCoursesub |
18 |
|
|
deleteCoursesubConfirm |
19 |
|
|
deleteFaculty |
20 |
|
|
deleteFacultyConfirm |
21 |
|
|
deleteFeature |
22 |
|
|
deleteFeatureConfirm |
23 |
|
|
deleteInfotype |
24 |
|
|
deleteInfotypeConfirm |
25 |
|
|
deleteLibunit |
26 |
|
|
deleteLibunitConfirm |
27 |
|
|
deleteLibunitStaff |
28 |
|
|
deleteLocation |
29 |
|
|
deleteLocationConfirm |
30 |
|
|
deleteMasterinfotype |
31 |
|
|
deleteMasterinfotypeConfirm |
32 |
|
|
deleteMastersubject |
33 |
|
|
deleteMastersubjectConfirm |
34 |
|
|
deleteResFeature |
35 |
|
|
deleteResLoc |
36 |
|
|
deleteResource |
37 |
|
|
deleteResourceConfirm |
38 |
|
|
deleteService |
39 |
|
|
deleteServiceConfirm |
40 |
|
|
deleteServicetype |
41 |
|
|
deleteServicetypeConfirm |
42 |
|
|
deleteServLoc |
43 |
|
|
deleteServServtype |
44 |
|
|
deleteStaff |
45 |
|
|
deleteStaffConfirm |
46 |
|
|
deleteStaffLibunit |
47 |
|
|
deleteStaffSub |
48 |
|
|
deleteStafftitle |
49 |
|
|
deleteStafftitleConfirm |
50 |
|
|
deleteStyle |
51 |
|
|
deleteStyleConfirm |
52 |
|
|
deleteSubCoursesub |
53 |
|
|
deleteSubject |
54 |
|
|
deleteSubjectConfirm |
55 |
|
|
deleteSubLoc |
56 |
|
|
deleteSubMaster |
57 |
|
|
deleteSubStaff |
58 |
|
|
deleteTerm |
59 |
|
|
deleteTermConfirm |
60 |
|
|
**********************************************************/ |
61 |
|
|
|
62 |
|
|
|
63 |
|
|
/********************************************************** |
64 |
|
|
Function: deleteCampus |
65 |
|
|
Author: Paul Bramscher |
66 |
|
|
Last Modified: 06.04.2003 |
67 |
|
|
*********************************************************** |
68 |
|
|
Purpose: |
69 |
|
|
Deletes a supplied campus id, sets affected course |
70 |
|
|
pages to NULL campus. |
71 |
|
|
**********************************************************/ |
72 |
|
|
function deleteCampus($con, $campus_id){ |
73 |
|
|
|
74 |
|
|
// Draw form heading |
75 |
|
|
printf("<center><h3>Deleting Campus...</h3>"); |
76 |
|
|
|
77 |
|
|
// Table |
78 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
79 |
|
|
printf("<tr><td><br>"); |
80 |
|
|
printf("<strong>Messages:</strong><br>"); |
81 |
|
|
|
82 |
|
|
// Problem flag for each delete step |
83 |
|
|
$problem = 0; |
84 |
|
|
|
85 |
|
|
// Cannot delete placeholder #1. |
86 |
|
|
if ($campus_id > 1) { |
87 |
|
|
|
88 |
|
|
// First clear out any coursescribe pages |
89 |
|
|
$sql = "UPDATE course SET campus_id = NULL WHERE campus_id = " |
90 |
|
|
. $campus_id; |
91 |
|
|
|
92 |
|
|
if (!mysql_query ($sql, $con)){ |
93 |
|
|
$problem = 1; |
94 |
|
|
sql_err($sql); |
95 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
96 |
|
|
bailout(); |
97 |
|
|
} |
98 |
|
|
else { |
99 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
100 |
|
|
printf("Campus purged from assignments to course pages.<BR>\n"); |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
// Delete from the coursesub table |
104 |
|
|
if ($problem == 0) { |
105 |
|
|
$sql = "UPDATE coursesub SET campus_id = 1 WHERE campus_id =" . $campus_id; |
106 |
|
|
|
107 |
|
|
if (!mysql_query ($sql, $con)){ |
108 |
|
|
$problem = 1; |
109 |
|
|
sql_err($sql); |
110 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
111 |
|
|
bailout(); |
112 |
|
|
} |
113 |
|
|
else { |
114 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
115 |
|
|
printf("Removed from affected Course Subjects.<BR>\n"); |
116 |
|
|
} |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
// Delete from the campus table |
120 |
|
|
if ($problem == 0) { |
121 |
|
|
$sql = "DELETE FROM campus WHERE campus_id =" . $campus_id; |
122 |
|
|
|
123 |
|
|
if (!mysql_query ($sql, $con)){ |
124 |
|
|
$problem = 1; |
125 |
|
|
sql_err($sql); |
126 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
127 |
|
|
bailout(); |
128 |
|
|
} |
129 |
|
|
else { |
130 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
131 |
|
|
printf("Removed this campus successfully.<BR><BR>\n"); |
132 |
|
|
} |
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
} |
136 |
|
|
else printf("Cannot delete <b>Campus ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
137 |
|
|
|
138 |
|
|
printf("</td></tr></table>"); |
139 |
|
|
printf("</center>"); |
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
|
143 |
|
|
/********************************************************** |
144 |
|
|
Function: deleteCampusConfirm |
145 |
|
|
Author: Paul Bramscher |
146 |
|
|
Last Modified: 04.21.2003 |
147 |
|
|
*********************************************************** |
148 |
|
|
Purpose: |
149 |
|
|
Confirm prompt for deleting the selected campus. |
150 |
|
|
**********************************************************/ |
151 |
|
|
function deleteCampusConfirm($con, $key_id){ |
152 |
|
|
|
153 |
|
|
// Make sure we have a valid integer type |
154 |
|
|
$campus_id = (int) $key_id; |
155 |
|
|
|
156 |
|
|
// Draw page heading |
157 |
|
|
printf("<center><h3>Delete Campus ID# %s?</h3>", $campus_id); |
158 |
|
|
|
159 |
|
|
// Check to see if its possible |
160 |
|
|
$exists = existsRow($con, "campus", "campus_id", $campus_id); |
161 |
|
|
if ($exists > 0){ |
162 |
|
|
|
163 |
|
|
// Table |
164 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
165 |
|
|
printf("<tr><td>"); |
166 |
|
|
|
167 |
|
|
// Lookup the descriptive title |
168 |
|
|
$campus = lookupField($con, "campus", "campus_id", $campus_id, "campus"); |
169 |
|
|
printf("<strong>Campus:</strong> %s<br><br>\n ", $campus); |
170 |
|
|
|
171 |
|
|
// Form to draw the delete button |
172 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
173 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteCampus\" >"); |
174 |
|
|
printf("<input type = \"Hidden\" name = \"campus_id\" value = \"%d\" >", $campus_id); |
175 |
|
|
printf("This will <b>permanently</b> remove this campus and its various assignments from the system. Some CourseScribe pages may lose their campus association.<BR><BR>"); |
176 |
|
|
printf("<center>"); |
177 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
178 |
|
|
printf("</center>"); |
179 |
|
|
printf("</form><br>"); |
180 |
|
|
|
181 |
|
|
// Close table |
182 |
|
|
printf("</td></tr></table>"); |
183 |
|
|
} |
184 |
|
|
|
185 |
|
|
// Failed for whatever reason |
186 |
|
|
else if ($exists < 1) printf ("Campus not found. Operation cancelled.<br>\n"); |
187 |
|
|
|
188 |
|
|
printf("</center>"); |
189 |
|
|
} |
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
/********************************************************** |
195 |
|
|
Function: deleteCoursesub |
196 |
|
|
Author: Paul Bramscher |
197 |
|
|
Last Modified: 06.04.2003 |
198 |
|
|
*********************************************************** |
199 |
|
|
Purpose: |
200 |
|
|
Deletes a supplied course subject id |
201 |
|
|
**********************************************************/ |
202 |
|
|
function deleteCoursesub($con, $coursesub_id){ |
203 |
|
|
|
204 |
|
|
// Draw form heading |
205 |
|
|
printf("<center><h3>Deleting Course Subject...</h3>"); |
206 |
|
|
|
207 |
|
|
// Table |
208 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
209 |
|
|
printf("<tr><td><br>"); |
210 |
|
|
printf("<strong>Messages:</strong><br>"); |
211 |
|
|
|
212 |
|
|
// Problem flag for each delete step |
213 |
|
|
$problem = 0; |
214 |
|
|
|
215 |
|
|
// Cannot delete placeholder #1. |
216 |
|
|
if ($coursesub_id > 1) { |
217 |
|
|
|
218 |
|
|
// Check to see if there are affected courselib pages |
219 |
|
|
$exists_courselib = existsRow($con, "course", "coursesub_id", $coursesub_id); |
220 |
|
|
|
221 |
|
|
if ($exists_courselib > 0) { |
222 |
|
|
printf("Cannot delete this Course Subject. There are courses which are currently using it."); |
223 |
|
|
} |
224 |
|
|
|
225 |
|
|
// Delete from the campus table |
226 |
|
|
else { |
227 |
|
|
|
228 |
|
|
// Delete from the sub_coursesub table |
229 |
|
|
$sql = "DELETE FROM sub_coursesub WHERE coursesub_id = " . $coursesub_id; |
230 |
|
|
|
231 |
|
|
if (!mysql_query ($sql, $con)){ |
232 |
|
|
$problem = 0; |
233 |
|
|
sql_err($sql); |
234 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
235 |
|
|
bailout(); |
236 |
|
|
} |
237 |
|
|
else { |
238 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
239 |
|
|
printf("Subject-Course Subject assignments removed.<BR>\n"); |
240 |
|
|
|
241 |
|
|
} |
242 |
|
|
|
243 |
|
|
// Delete from the coursesub table |
244 |
|
|
if ($problem == 0) { |
245 |
|
|
|
246 |
|
|
$sql = "DELETE FROM coursesub WHERE coursesub_id =" . $coursesub_id; |
247 |
|
|
|
248 |
|
|
if (!mysql_query ($sql, $con)){ |
249 |
|
|
sql_err($sql); |
250 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
251 |
|
|
bailout(); |
252 |
|
|
} |
253 |
|
|
else { |
254 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
255 |
|
|
printf("Removed this Course Subject successfully.<BR><BR>\n"); |
256 |
|
|
} |
257 |
|
|
|
258 |
|
|
} |
259 |
|
|
} |
260 |
|
|
|
261 |
|
|
} |
262 |
|
|
else printf("Cannot delete <b>Course Subject ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
263 |
|
|
|
264 |
|
|
printf("</td></tr></table>"); |
265 |
|
|
printf("</center>"); |
266 |
|
|
} |
267 |
|
|
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
/********************************************************** |
271 |
|
|
Function: deleteCoursesubConfirm |
272 |
|
|
Author: Paul Bramscher |
273 |
|
|
Last Modified: 05.29.2003 |
274 |
|
|
*********************************************************** |
275 |
|
|
Purpose: |
276 |
|
|
Confirm prompt for deleting the selected campus. |
277 |
|
|
**********************************************************/ |
278 |
|
|
function deleteCoursesubConfirm($con, $coursesub_id){ |
279 |
|
|
|
280 |
|
|
// Make sure we have a valid integer type |
281 |
|
|
$coursesub_id = (int) $coursesub_id; |
282 |
|
|
|
283 |
|
|
// Check to see if its possible |
284 |
|
|
$exists = existsRow($con, "coursesub", "coursesub_id", $coursesub_id); |
285 |
|
|
if ($exists > 0){ |
286 |
|
|
|
287 |
|
|
// Lookup the descriptive title |
288 |
|
|
$coursesub = lookupField($con, "coursesub", "coursesub_id", $coursesub_id, "coursesub"); |
289 |
|
|
|
290 |
|
|
// Draw page heading |
291 |
|
|
printf("<center><h3>Delete Course Subject '%s'?</h3>", $coursesub); |
292 |
|
|
|
293 |
|
|
// Table |
294 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
295 |
|
|
printf("<tr><td><br>"); |
296 |
|
|
printf("<b>Messages:</b><br>\n"); |
297 |
|
|
|
298 |
|
|
// Check to see if there are affected courselib pages |
299 |
|
|
$exists_courselib = existsRow($con, "course", "coursesub_id", $coursesub_id); |
300 |
|
|
|
301 |
|
|
if ($exists_courselib > 0) { |
302 |
|
|
|
303 |
|
|
// Cannot delete, dependencies exist |
304 |
|
|
printf("This course subject is currently used on one or more course pages. "); |
305 |
|
|
printf("It may not be edited or deleted until all affected courses are moved to "); |
306 |
|
|
printf("an alternate course subject. Follow the link below for a list of "); |
307 |
|
|
printf("affected pages.<br><br>"); |
308 |
|
|
printf("<a href=\"page_results_brief.phtml?coursesub_id=%s\">", $coursesub_id); |
309 |
|
|
printf("page_results_brief.phtml?coursesub_id=%s", $coursesub_id); |
310 |
|
|
printf("</a><br><br>"); |
311 |
|
|
|
312 |
|
|
} |
313 |
|
|
|
314 |
|
|
else { |
315 |
|
|
|
316 |
|
|
// Form to draw the delete button |
317 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
318 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteCoursesub\" >"); |
319 |
|
|
printf("<input type = \"Hidden\" name = \"coursesub_id\" value = \"%d\" >", $coursesub_id); |
320 |
|
|
printf("This will <b>permanently</b> remove this Course Subject.<BR><BR>"); |
321 |
|
|
printf("<center>"); |
322 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
323 |
|
|
printf("</center>"); |
324 |
|
|
printf("</form><br>"); |
325 |
|
|
|
326 |
|
|
} |
327 |
|
|
|
328 |
|
|
// Close table |
329 |
|
|
printf("</td></tr></table>"); |
330 |
|
|
|
331 |
|
|
} |
332 |
|
|
|
333 |
|
|
// Failed for whatever reason |
334 |
|
|
else if ($exists < 1) printf ("Course Subject not found. Operation cancelled.<br>\n"); |
335 |
|
|
|
336 |
|
|
printf("</center>"); |
337 |
|
|
} |
338 |
|
|
|
339 |
|
|
|
340 |
|
|
/********************************************************** |
341 |
|
|
Function: deleteFaculty |
342 |
|
|
Author: Paul Bramscher |
343 |
|
|
Last Modified: 04.21.2003 |
344 |
|
|
*********************************************************** |
345 |
|
|
Purpose: |
346 |
|
|
Deletes the supplied faculty id, and removes any relations |
347 |
|
|
to affected courses. |
348 |
|
|
**********************************************************/ |
349 |
|
|
function deleteFaculty($con, $faculty_id){ |
350 |
|
|
|
351 |
|
|
// Draw form heading |
352 |
|
|
printf("<center><h3>Deleting Faculty...</h3>"); |
353 |
|
|
|
354 |
|
|
// Table |
355 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
356 |
|
|
printf("<tr><td><br>"); |
357 |
|
|
printf("<strong>Messages:</strong><br>"); |
358 |
|
|
|
359 |
|
|
// Problem flag for each delete step |
360 |
|
|
$problem = 0; |
361 |
|
|
|
362 |
|
|
// Cannot delete placeholder #1. |
363 |
|
|
if ($faculty_id > 1) { |
364 |
|
|
|
365 |
|
|
// First clear out the course_personnel assignments |
366 |
|
|
$sql = "DELETE FROM course_personnel WHERE faculty_id = " |
367 |
|
|
. $faculty_id; |
368 |
|
|
|
369 |
|
|
if (!mysql_query ($sql, $con)){ |
370 |
|
|
$problem = 1; |
371 |
|
|
sql_err($sql); |
372 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
373 |
|
|
bailout(); |
374 |
|
|
} |
375 |
|
|
else { |
376 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
377 |
|
|
printf("Faculty person purged from assignments to course pages.<BR>\n"); |
378 |
|
|
} |
379 |
|
|
|
380 |
|
|
// Delete from the faculty table |
381 |
|
|
if ($problem == 0) { |
382 |
|
|
$sql = "DELETE FROM faculty WHERE faculty_id =" . $faculty_id; |
383 |
|
|
|
384 |
|
|
if (!mysql_query ($sql, $con)){ |
385 |
|
|
$problem = 1; |
386 |
|
|
sql_err($sql); |
387 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
388 |
|
|
bailout(); |
389 |
|
|
} |
390 |
|
|
else { |
391 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
392 |
|
|
printf("Removed this faculty person successfully.<BR><BR>\n"); |
393 |
|
|
} |
394 |
|
|
} |
395 |
|
|
|
396 |
|
|
} |
397 |
|
|
else printf("Cannot delete <b>Faculty ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
398 |
|
|
|
399 |
|
|
printf("</td></tr></table>"); |
400 |
|
|
printf("</center>"); |
401 |
|
|
} |
402 |
|
|
|
403 |
|
|
|
404 |
|
|
/********************************************************** |
405 |
|
|
Function: deleteFacultyConfirm |
406 |
|
|
Author: Paul Bramscher |
407 |
|
|
Last Modified: 04.21.2003 |
408 |
|
|
*********************************************************** |
409 |
|
|
Purpose: |
410 |
|
|
Confirm prompt for deleting the selected faculty person. |
411 |
|
|
**********************************************************/ |
412 |
|
|
function deleteFacultyConfirm($con, $faculty_id){ |
413 |
|
|
|
414 |
|
|
// Make sure we have a valid integer type |
415 |
|
|
$faculty_id = (int) $faculty_id; |
416 |
|
|
|
417 |
|
|
// Draw page heading |
418 |
|
|
printf("<center><h3>Delete Faculty ID# %s?</h3>", $faculty_id); |
419 |
|
|
|
420 |
|
|
// Check to see if its possible |
421 |
|
|
$exists = existsRow($con, "faculty", "faculty_id", $faculty_id); |
422 |
|
|
if ($exists > 0){ |
423 |
|
|
|
424 |
|
|
// Table |
425 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
426 |
|
|
printf("<tr><td>"); |
427 |
|
|
|
428 |
|
|
// Lookup the descriptive title |
429 |
|
|
$faculty_name = lookupFaculty($con, $faculty_id); |
430 |
|
|
printf("<strong>Faculty Person:</strong> %s<br>\n ", $faculty_name); |
431 |
|
|
|
432 |
|
|
// Form to draw the delete button |
433 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
434 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteFaculty\" >"); |
435 |
|
|
printf("<input type = \"Hidden\" name = \"faculty_id\" value = \"%d\" >", $faculty_id); |
436 |
|
|
printf("This will <b>permanently</b> remove the faculty person and his/her various assignments from the system. Some CourseScribe pages may have no personnel.<BR><BR>"); |
437 |
|
|
printf("<center>"); |
438 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
439 |
|
|
printf("</center>"); |
440 |
|
|
printf("</form><br>"); |
441 |
|
|
|
442 |
|
|
// Close table |
443 |
|
|
printf("</td></tr></table>"); |
444 |
|
|
} |
445 |
|
|
|
446 |
|
|
// Failed for whatever reason |
447 |
|
|
else if ($exists < 1) printf ("Faculty not found. Operation cancelled.<br>\n"); |
448 |
|
|
|
449 |
|
|
printf("</center>"); |
450 |
|
|
} |
451 |
|
|
|
452 |
|
|
|
453 |
|
|
/********************************************************** |
454 |
|
|
Function: deleteFeature |
455 |
|
|
Author: Paul Bramscher |
456 |
|
|
Last Modified: 04.21.2003 |
457 |
|
|
*********************************************************** |
458 |
|
|
Purpose: |
459 |
|
|
Deletes the supplied feature id, and removes any relations to |
460 |
|
|
affected resources. |
461 |
|
|
**********************************************************/ |
462 |
|
|
function deleteFeature($con, $feature_id){ |
463 |
|
|
|
464 |
|
|
// Draw form heading |
465 |
|
|
printf("<center><h3>Deleting Feature...</h3>"); |
466 |
|
|
|
467 |
|
|
// Table |
468 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
469 |
|
|
printf("<tr><td><br>"); |
470 |
|
|
printf("<strong>Messages:</strong><br>"); |
471 |
|
|
|
472 |
|
|
// Problem flag for each delete step |
473 |
|
|
$problem = 0; |
474 |
|
|
|
475 |
|
|
// Cannot delete placeholder #1 |
476 |
|
|
if ($feature_id > 1) { |
477 |
|
|
|
478 |
|
|
// Delete all resource_feature assignments |
479 |
|
|
$sql = "DELETE from res_feature WHERE feature_id =" . $feature_id; |
480 |
|
|
|
481 |
|
|
if (!mysql_query ($sql, $con)){ |
482 |
|
|
$problem = 1; |
483 |
|
|
sql_err($sql); |
484 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
485 |
|
|
bailout(); |
486 |
|
|
} |
487 |
|
|
else { |
488 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
489 |
|
|
printf("Removed resource-feature associations.<BR>\n"); |
490 |
|
|
|
491 |
|
|
if ($problem == 0) { |
492 |
|
|
|
493 |
|
|
// Delete from feature table |
494 |
|
|
$sql = "DELETE FROM feature WHERE feature_id =" . $feature_id; |
495 |
|
|
|
496 |
|
|
if (!mysql_query ($sql, $con)){ |
497 |
|
|
$problem = 1; |
498 |
|
|
sql_err($sql); |
499 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
500 |
|
|
bailout(); |
501 |
|
|
} |
502 |
|
|
else { |
503 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
504 |
|
|
printf("Removed feature successfully.<BR><BR>\n"); |
505 |
|
|
} |
506 |
|
|
} |
507 |
|
|
} |
508 |
|
|
} |
509 |
|
|
|
510 |
|
|
else printf("Cannot delete <b>Feature ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
511 |
|
|
|
512 |
|
|
printf("</td></tr></table>"); |
513 |
|
|
printf("</center>"); |
514 |
|
|
} |
515 |
|
|
|
516 |
|
|
|
517 |
|
|
/********************************************************** |
518 |
|
|
Function: deleteFeatureConfirm |
519 |
|
|
Author: Paul Bramscher |
520 |
|
|
Last Modified: 04.21.2003 |
521 |
|
|
*********************************************************** |
522 |
|
|
Purpose: |
523 |
|
|
Confirm prompt for deleting the supplied feature id. |
524 |
|
|
**********************************************************/ |
525 |
|
|
function deleteFeatureConfirm($con, $key_id){ |
526 |
|
|
|
527 |
|
|
// Make sure we have a valid integer type |
528 |
|
|
$feature_id = (int) $key_id; |
529 |
|
|
|
530 |
|
|
// Draw page heading |
531 |
|
|
printf("<center><h3>Delete Feature ID# %s?</h3>", $feature_id); |
532 |
|
|
|
533 |
|
|
// Check to see if its possible |
534 |
|
|
$exists = existsRow($con, "feature", "feature_id", $feature_id); |
535 |
|
|
if ($exists > 0){ |
536 |
|
|
|
537 |
|
|
// Table |
538 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
539 |
|
|
printf("<tr><td>"); |
540 |
|
|
|
541 |
|
|
// Lookup the descriptive title |
542 |
|
|
$feature = lookupField($con, "feature", "feature_id", $feature_id, "feature"); |
543 |
|
|
printf("<strong>Feature:</strong> %s<br>\n ", $feature); |
544 |
|
|
|
545 |
|
|
// Form to draw the delete button |
546 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
547 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteFeature\" >"); |
548 |
|
|
printf("<input type = \"Hidden\" name = \"feature_id\" value = \"%d\" >", $feature_id); |
549 |
|
|
printf("This will <b>permanently</b> remove the feature and its various assignments from the system. Some resources may no longer have icons.<BR><BR>"); |
550 |
|
|
printf("<center>"); |
551 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
552 |
|
|
printf("</center>"); |
553 |
|
|
printf("</form><br>"); |
554 |
|
|
|
555 |
|
|
// Close table |
556 |
|
|
printf("</td></tr></table>"); |
557 |
|
|
} |
558 |
|
|
|
559 |
|
|
// Failed for whatever reason |
560 |
|
|
else if ($exists < 1) printf ("Feature not found. Operation cancelled.<br>\n"); |
561 |
|
|
|
562 |
|
|
printf("</center>"); |
563 |
|
|
} |
564 |
|
|
|
565 |
|
|
|
566 |
|
|
/********************************************************** |
567 |
|
|
Function: deleteInfotype |
568 |
|
|
Author: Paul Bramscher |
569 |
|
|
Last Modified: 04.21.2003 |
570 |
|
|
*********************************************************** |
571 |
|
|
Purpose: |
572 |
|
|
Deletes the supplied information type id, and removes |
573 |
|
|
assocations in the resource and resource-subject-information |
574 |
|
|
type tables. |
575 |
|
|
**********************************************************/ |
576 |
|
|
function deleteInfotype($con, $infotype_id){ |
577 |
|
|
|
578 |
|
|
// Draw form heading |
579 |
|
|
printf("<center><h3>Deleting Information Type...</h3>"); |
580 |
|
|
|
581 |
|
|
// Table |
582 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
583 |
|
|
printf("<tr><td><br>"); |
584 |
|
|
printf("<strong>Messages:</strong><br>"); |
585 |
|
|
|
586 |
|
|
// Problem flag for each delete step |
587 |
|
|
$problem = 0; |
588 |
|
|
|
589 |
|
|
// Cannot delete placeholder #1 |
590 |
|
|
if ($infotype_id > 1) { |
591 |
|
|
|
592 |
|
|
// Delete all res_sub_infotype assignments |
593 |
|
|
$sql = "DELETE from res_sub_infotype WHERE infotype_id =" . $infotype_id; |
594 |
|
|
|
595 |
|
|
if (!mysql_query ($sql, $con)){ |
596 |
|
|
$problem = 1; |
597 |
|
|
sql_err($sql); |
598 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
599 |
|
|
bailout(); |
600 |
|
|
} |
601 |
|
|
else { |
602 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
603 |
|
|
printf("Removed resource-subject-infotype associations.<BR>\n"); |
604 |
|
|
|
605 |
|
|
|
606 |
|
|
if ($problem == 0) { |
607 |
|
|
|
608 |
|
|
// Set (N/A) type in resource table |
609 |
|
|
$sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; |
610 |
|
|
|
611 |
|
|
if (!mysql_query ($sql, $con)){ |
612 |
|
|
$problem = 1; |
613 |
|
|
sql_err($sql); |
614 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
615 |
|
|
bailout(); |
616 |
|
|
} |
617 |
|
|
else { |
618 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
619 |
|
|
printf("Set default information types for affects resources to (N/A).<BR>\n"); |
620 |
|
|
} |
621 |
|
|
} |
622 |
|
|
|
623 |
|
|
|
624 |
|
|
if ($problem == 0) { |
625 |
|
|
|
626 |
|
|
// Delete from infotype table |
627 |
|
|
$sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; |
628 |
|
|
|
629 |
|
|
if (!mysql_query ($sql, $con)){ |
630 |
|
|
$problem = 1; |
631 |
|
|
sql_err($sql); |
632 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
633 |
|
|
bailout(); |
634 |
|
|
} |
635 |
|
|
else { |
636 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
637 |
|
|
printf("Removed this information type successfully.<BR><BR>\n"); |
638 |
|
|
} |
639 |
|
|
} |
640 |
|
|
|
641 |
|
|
} |
642 |
|
|
} |
643 |
|
|
|
644 |
|
|
else printf("Cannot delete <b>Information Type ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
645 |
|
|
|
646 |
|
|
printf("</td></tr></table>"); |
647 |
|
|
printf("</center>"); |
648 |
|
|
} |
649 |
|
|
|
650 |
|
|
|
651 |
|
|
/********************************************************** |
652 |
|
|
Function: deleteInfotypeConfirm |
653 |
|
|
Author: Paul Bramscher |
654 |
|
|
Last Modified: 04.21.2003 |
655 |
|
|
*********************************************************** |
656 |
|
|
Purpose: |
657 |
|
|
Confirm prompt to delete the supplied information type id. |
658 |
|
|
**********************************************************/ |
659 |
|
|
function deleteInfotypeConfirm($con, $key_id){ |
660 |
|
|
|
661 |
|
|
// Make sure we have a valid integer type |
662 |
|
|
$infotype_id = (int) $key_id; |
663 |
|
|
|
664 |
|
|
// Draw page heading |
665 |
|
|
printf("<center><h3>Delete Information Type ID# %s?</h3>", $infotype_id); |
666 |
|
|
|
667 |
|
|
// Check to see if its possible |
668 |
|
|
$exists = existsRow($con, "infotype", "infotype_id", $infotype_id); |
669 |
|
|
if ($exists > 0){ |
670 |
|
|
|
671 |
|
|
// Table |
672 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
673 |
|
|
printf("<tr><td>"); |
674 |
|
|
|
675 |
|
|
// Lookup the descriptive title |
676 |
|
|
$infotype = lookupField($con, "infotype", "infotype_id", $infotype_id, "infotype"); |
677 |
|
|
printf("<strong>Information Type:</strong> %s<br><br>\n ", $infotype); |
678 |
|
|
|
679 |
|
|
// Form to draw the delete button |
680 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
681 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteInfotype\" >"); |
682 |
|
|
printf("<input type = \"Hidden\" name = \"infotype_id\" value = \"%d\" >", $infotype_id); |
683 |
|
|
printf("This will <b>permanently</b> remove the Information Type and its various assignments from the system. <b>Affected resource-subject-infotype assignments on RQS pages will be broken, and therefore removed!</b> Be sure to re-assign important resources to another information type before deleting this one.<BR><BR>"); |
684 |
|
|
printf("Check the <b><a href=\"infotype_drill.phtml?infotype_id=%d\">Information Type Detail<a></b> page to display affected RQS pages.", $infotype_id); |
685 |
|
|
printf("<br><br>\n"); |
686 |
|
|
printf("<center>"); |
687 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
688 |
|
|
printf("</center>"); |
689 |
|
|
printf("</form><br>"); |
690 |
|
|
|
691 |
|
|
// Close table |
692 |
|
|
printf("</td></tr></table>"); |
693 |
|
|
} |
694 |
|
|
|
695 |
|
|
// Failed for whatever reason |
696 |
|
|
else if ($exists < 1) printf ("Information Type not found. Operation cancelled.<br>\n"); |
697 |
|
|
|
698 |
|
|
printf("</center>"); |
699 |
|
|
} |
700 |
|
|
|
701 |
|
|
|
702 |
|
|
/********************************************************** |
703 |
|
|
Function: deleteLocation |
704 |
|
|
Author: Paul Bramscher |
705 |
|
|
Last Modified: 05.27.2003 |
706 |
|
|
*********************************************************** |
707 |
|
|
Purpose: |
708 |
|
|
Deletes the supplied location id, and removes associations |
709 |
|
|
in the resource-location, subject-location, and |
710 |
|
|
service-location tables. Also converts any relational |
711 |
|
|
location references in Page/CourseScribe pages to text-type |
712 |
|
|
fields (non-relational), as well as all user copy-paste |
713 |
|
|
buffers. |
714 |
|
|
**********************************************************/ |
715 |
|
|
function deleteLocation($con, $delMessage, $location_id){ |
716 |
|
|
|
717 |
|
|
// Draw form heading |
718 |
|
|
printf("<center><h3>Deleting Location...</h3>"); |
719 |
|
|
|
720 |
|
|
// Table |
721 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
722 |
|
|
printf("<tr><td><br>"); |
723 |
|
|
printf("<strong>Messages:</strong><br>"); |
724 |
|
|
|
725 |
|
|
// Problem flag for each delete step |
726 |
|
|
$problem = 0; |
727 |
|
|
|
728 |
|
|
// Cannot delete placeholder #1 |
729 |
|
|
if ($location_id > 1) { |
730 |
|
|
|
731 |
|
|
// First delete from res_loc |
732 |
|
|
$sql = "DELETE FROM res_loc WHERE location_id = " . $location_id; |
733 |
|
|
|
734 |
|
|
if (!mysql_query ($sql, $con)){ |
735 |
|
|
$problem = 1; |
736 |
|
|
sql_err($sql); |
737 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
738 |
|
|
bailout(); |
739 |
|
|
} |
740 |
|
|
else { |
741 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
742 |
|
|
printf("Affected resource-location assignments removed.<BR>\n"); |
743 |
|
|
} |
744 |
|
|
|
745 |
|
|
// Delete from sub_loc |
746 |
|
|
if ($problem == 0) { |
747 |
|
|
$sql = "DELETE FROM sub_loc WHERE location_id =" . $location_id; |
748 |
|
|
|
749 |
|
|
if (!mysql_query ($sql, $con)){ |
750 |
|
|
$problem = 1; |
751 |
|
|
sql_err($sql); |
752 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
753 |
|
|
bailout(); |
754 |
|
|
} |
755 |
|
|
else { |
756 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
757 |
|
|
printf("Affected subject-location assignments removed.<BR>\n"); |
758 |
|
|
} |
759 |
|
|
} |
760 |
|
|
|
761 |
|
|
// Delete primary subject locations |
762 |
|
|
if ($problem == 0) { |
763 |
|
|
$sql = "UPDATE subject SET sublocation_id = NULL WHERE sublocation_id =" . $location_id; |
764 |
|
|
|
765 |
|
|
if (!mysql_query ($sql, $con)){ |
766 |
|
|
$problem = 1; |
767 |
|
|
sql_err($sql); |
768 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
769 |
|
|
bailout(); |
770 |
|
|
} |
771 |
|
|
else { |
772 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
773 |
|
|
printf("Affected primary subject locations set to NULL.<BR>\n"); |
774 |
|
|
} |
775 |
|
|
} |
776 |
|
|
|
777 |
|
|
// Delete from serv_loc |
778 |
|
|
if ($problem == 0) { |
779 |
|
|
$sql = "DELETE FROM serv_loc WHERE location_id =" . $location_id; |
780 |
|
|
|
781 |
|
|
if (!mysql_query ($sql, $con)){ |
782 |
|
|
$problem = 1; |
783 |
|
|
sql_err($sql); |
784 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
785 |
|
|
bailout(); |
786 |
|
|
} |
787 |
|
|
else { |
788 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
789 |
|
|
printf("Affected service-location assignments removed.<BR>\n"); |
790 |
|
|
} |
791 |
|
|
} |
792 |
|
|
|
793 |
|
|
// Update affected PageScribe pages |
794 |
|
|
if ($problem == 0) { |
795 |
|
|
|
796 |
|
|
// First, get the default location description and title |
797 |
|
|
$sql = "SELECT location, location_descr FROM location WHERE location_id = " |
798 |
|
|
. $location_id; |
799 |
|
|
$rs = mysql_query($sql, $con); |
800 |
|
|
$row = mysql_fetch_array ($rs); |
801 |
|
|
$location = $row["location"]; |
802 |
|
|
$location_descr = $row["location_descr"]; |
803 |
|
|
|
804 |
|
|
// Clean up strings |
805 |
|
|
$location_descr = textInmySQL($location_descr); |
806 |
|
|
$location = textInmySQL($location); |
807 |
|
|
$delMessage = textInmySQL($delMessage); |
808 |
|
|
|
809 |
|
|
// Next, append the reason for deletion to the description |
810 |
|
|
if (strlen($location_descr) > 0) $location_descr .= "<BR>" . $delMessage; |
811 |
|
|
else $location_descr = $delMessage; |
812 |
|
|
|
813 |
|
|
// Update all of the elements using this resource with a custom description. |
814 |
|
|
$sql = "UPDATE element SET label = '" |
815 |
|
|
. $location |
816 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
817 |
|
|
. $delMessage |
818 |
|
|
. "'), location_id = NULL WHERE location_id =" . $location_id |
819 |
|
|
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
820 |
|
|
|
821 |
|
|
if (!mysql_query ($sql, $con)){ |
822 |
|
|
$problem = 1; |
823 |
|
|
sql_err($sql); |
824 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
825 |
|
|
bailout(); |
826 |
|
|
} |
827 |
|
|
else { |
828 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
829 |
|
|
printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
830 |
|
|
} |
831 |
|
|
|
832 |
|
|
|
833 |
|
|
// Next, update all of the elements using this resource without a custom description. |
834 |
|
|
$sql = "UPDATE element SET label = '" |
835 |
|
|
. $location |
836 |
|
|
. "', element_descr = '" |
837 |
|
|
. $location_descr |
838 |
|
|
. "', location_id = NULL WHERE location_id =" . $location_id |
839 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
840 |
|
|
|
841 |
|
|
if (!mysql_query ($sql, $con)){ |
842 |
|
|
$problem = 1; |
843 |
|
|
sql_err($sql); |
844 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
845 |
|
|
bailout(); |
846 |
|
|
} |
847 |
|
|
else { |
848 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
849 |
|
|
printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
850 |
|
|
} |
851 |
|
|
|
852 |
|
|
|
853 |
|
|
} |
854 |
|
|
|
855 |
|
|
|
856 |
|
|
// Update affected PageScribe copy buffers |
857 |
|
|
if ($problem == 0) { |
858 |
|
|
|
859 |
|
|
// Update all of the elements using this location with a custom description. |
860 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
861 |
|
|
. $location |
862 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
863 |
|
|
. $delMessage |
864 |
|
|
. "'), location_id = NULL WHERE location_id =" . $location_id |
865 |
|
|
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
866 |
|
|
|
867 |
|
|
if (!mysql_query ($sql, $con)){ |
868 |
|
|
$problem = 1; |
869 |
|
|
sql_err($sql); |
870 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
871 |
|
|
bailout(); |
872 |
|
|
} |
873 |
|
|
else { |
874 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
875 |
|
|
printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
876 |
|
|
} |
877 |
|
|
|
878 |
|
|
|
879 |
|
|
// Next, update all of the elements using this location without a custom description. |
880 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
881 |
|
|
. $location |
882 |
|
|
. "', element_descr = '" |
883 |
|
|
. $location_descr |
884 |
|
|
. "', location_id = NULL WHERE location_id =" . $location_id |
885 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
886 |
|
|
|
887 |
|
|
if (!mysql_query ($sql, $con)){ |
888 |
|
|
$problem = 1; |
889 |
|
|
sql_err($sql); |
890 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
891 |
|
|
bailout(); |
892 |
|
|
} |
893 |
|
|
else { |
894 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
895 |
|
|
printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
896 |
|
|
} |
897 |
|
|
|
898 |
|
|
|
899 |
|
|
} |
900 |
|
|
|
901 |
|
|
// Delete from location |
902 |
|
|
if ($problem == 0) { |
903 |
|
|
$sql = "DELETE FROM location WHERE location_id =" . $location_id; |
904 |
|
|
|
905 |
|
|
if (!mysql_query ($sql, $con)){ |
906 |
|
|
$problem = 1; |
907 |
|
|
sql_err($sql); |
908 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
909 |
|
|
bailout(); |
910 |
|
|
} |
911 |
|
|
else { |
912 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
913 |
|
|
printf("Location successfully removed.<BR><BR>\n"); |
914 |
|
|
} |
915 |
|
|
} |
916 |
|
|
|
917 |
|
|
} |
918 |
|
|
else printf("Cannot delete <b>Location ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
919 |
|
|
|
920 |
|
|
printf("</td></tr></table>\n"); |
921 |
|
|
printf("</center><BR>\n"); |
922 |
|
|
} |
923 |
|
|
|
924 |
|
|
|
925 |
|
|
/********************************************************** |
926 |
|
|
Function: deleteLocationConfirm |
927 |
|
|
Author: Paul Bramscher |
928 |
|
|
Last Modified: 04.21.2003 |
929 |
|
|
*********************************************************** |
930 |
|
|
Purpose: |
931 |
|
|
Confirm prompt to delete the supplied location id. |
932 |
|
|
**********************************************************/ |
933 |
|
|
function deleteLocationConfirm($con, $key_id){ |
934 |
|
|
|
935 |
|
|
// Make sure we have a valid integer type |
936 |
|
|
$location_id = (int) $key_id; |
937 |
|
|
|
938 |
|
|
printf("<center>\n"); |
939 |
|
|
|
940 |
|
|
// Check to see if its possible |
941 |
|
|
$exists = existsRow($con, "location", "location_id", $location_id); |
942 |
|
|
if ($exists > 0){ |
943 |
|
|
|
944 |
|
|
// Table |
945 |
|
|
printf("<table width=\"60%%\" class=\"backLight\" border=\"1\" cellpadding=\"4\">\n"); |
946 |
|
|
|
947 |
|
|
// Row header |
948 |
|
|
printf("<tr><td class=\"cellPlain\">\n"); |
949 |
|
|
printf("Delete Location ID# %s?", $location_id); |
950 |
|
|
printf("</td></tr>\n"); |
951 |
|
|
printf("<tr><td>\n"); |
952 |
|
|
|
953 |
|
|
// Lookup the name of the location |
954 |
|
|
$location = lookupField($con, "location", "location_id", $location_id, "location"); |
955 |
|
|
printf("<b>Location:</b> %s<br><br>\n ", $location); |
956 |
|
|
|
957 |
|
|
// Form to draw the delete button |
958 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
959 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteLocation\" >\n"); |
960 |
|
|
printf("<input type = \"Hidden\" name = \"location_id\" value = \"%d\" >\n", $location_id); |
961 |
|
|
|
962 |
|
|
// Delete message |
963 |
|
|
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
964 |
|
|
printf("<input type=\"text\" name=\"delMessage\" value=\"[Location no longer available]\" size=\"75\"><br><br>\n"); |
965 |
|
|
|
966 |
|
|
// Warning |
967 |
|
|
printf("This will <b>permanently</b> remove the location and its various assignments from the system.<BR><BR>\n"); |
968 |
|
|
|
969 |
|
|
// Delete button |
970 |
|
|
printf("<center>\n"); |
971 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
972 |
|
|
printf("</center>\n"); |
973 |
|
|
printf("</form><br>\n"); |
974 |
|
|
|
975 |
|
|
// Close table |
976 |
|
|
printf("</td></tr></table>\n"); |
977 |
|
|
printf("<BR>\n"); |
978 |
|
|
} |
979 |
|
|
|
980 |
|
|
// Failed for whatever reason |
981 |
|
|
else if ($exists < 1) printf ("Location #%d not found. Operation cancelled.<br><br>\n", $location_id); |
982 |
|
|
|
983 |
|
|
printf("</center>\n"); |
984 |
|
|
} |
985 |
|
|
|
986 |
|
|
|
987 |
|
|
/********************************************************** |
988 |
|
|
Function: deleteMasterinfotype |
989 |
|
|
Author: Paul Bramscher |
990 |
|
|
Last Modified: 04.21.2003 |
991 |
|
|
*********************************************************** |
992 |
|
|
Purpose: |
993 |
|
|
Delete the supplied master information type id. Note that |
994 |
|
|
this function has some additional relational constraints |
995 |
|
|
on it. All information types below it are also deleted |
996 |
|
|
(not merely having their relationships removed!), as |
997 |
|
|
well as their resource-subject-information type assignments. |
998 |
|
|
This can have potentially large impact. |
999 |
|
|
**********************************************************/ |
1000 |
|
|
function deleteMasterinfotype($con, $masterinfotype_id){ |
1001 |
|
|
|
1002 |
|
|
// Draw form heading |
1003 |
|
|
printf("<center><h3>Deleting Master Information Type...</h3>"); |
1004 |
|
|
|
1005 |
|
|
// Table |
1006 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
1007 |
|
|
printf("<tr><td><br>"); |
1008 |
|
|
printf("<strong>Messages:</strong><br>"); |
1009 |
|
|
|
1010 |
|
|
// Problem flag for each delete step |
1011 |
|
|
$problem = 0; |
1012 |
|
|
|
1013 |
|
|
// Cannot delete placeholder #1 |
1014 |
|
|
if ($masterinfotype_id > 1) { |
1015 |
|
|
|
1016 |
|
|
// Do the following for every information type affected |
1017 |
|
|
$sql = "SELECT infotype, infotype_id FROM infotype where masterinfotype_id = " |
1018 |
|
|
. $masterinfotype_id; |
1019 |
|
|
|
1020 |
|
|
// Fetch the values |
1021 |
|
|
$rs = mysql_query($sql, $con); |
1022 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
1023 |
|
|
$infotype_id = $row["infotype_id"]; |
1024 |
|
|
$infotype = $row["infotype"]; |
1025 |
|
|
|
1026 |
|
|
// Display the affected information type currently being processed |
1027 |
|
|
printf("Deleting affected Information Type <b>%s</b> (%d)<BR>\n", $infotype, $infotype_id); |
1028 |
|
|
|
1029 |
|
|
// Delete all res_sub_infotype assignments |
1030 |
|
|
$sql = "DELETE from res_sub_infotype WHERE infotype_id =" . $infotype_id; |
1031 |
|
|
|
1032 |
|
|
if (!mysql_query ($sql, $con)){ |
1033 |
|
|
$problem = 1; |
1034 |
|
|
sql_err($sql); |
1035 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1036 |
|
|
bailout(); |
1037 |
|
|
} |
1038 |
|
|
else { |
1039 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1040 |
|
|
printf("Removed resource-subject-infotype associations.<BR>\n"); |
1041 |
|
|
|
1042 |
|
|
|
1043 |
|
|
if ($problem == 0) { |
1044 |
|
|
|
1045 |
|
|
// Set (N/A) type in resource table |
1046 |
|
|
$sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; |
1047 |
|
|
|
1048 |
|
|
if (!mysql_query ($sql, $con)){ |
1049 |
|
|
$problem = 1; |
1050 |
|
|
sql_err($sql); |
1051 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1052 |
|
|
bailout(); |
1053 |
|
|
} |
1054 |
|
|
else { |
1055 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1056 |
|
|
printf("Set default information types for affects resources to (N/A).<BR>\n"); |
1057 |
|
|
} |
1058 |
|
|
} |
1059 |
|
|
|
1060 |
|
|
|
1061 |
|
|
if ($problem == 0) { |
1062 |
|
|
|
1063 |
|
|
// Delete from infotype table |
1064 |
|
|
$sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; |
1065 |
|
|
|
1066 |
|
|
if (!mysql_query ($sql, $con)){ |
1067 |
|
|
$problem = 1; |
1068 |
|
|
sql_err($sql); |
1069 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1070 |
|
|
bailout(); |
1071 |
|
|
} |
1072 |
|
|
else { |
1073 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1074 |
|
|
printf("Removed affected specific information types.<BR>\n"); |
1075 |
|
|
} |
1076 |
|
|
} // successful delete of a specific information type |
1077 |
|
|
|
1078 |
|
|
} // end of delete for an affected infotype |
1079 |
|
|
|
1080 |
|
|
} // all affected infotypes below this masterinfotype |
1081 |
|
|
|
1082 |
|
|
// Delete the masterinfotype itself |
1083 |
|
|
|
1084 |
|
|
if ($problem == 0) { |
1085 |
|
|
|
1086 |
|
|
// Delete from masterinfotype table |
1087 |
|
|
$sql = "DELETE FROM masterinfotype WHERE masterinfotype_id =" . $masterinfotype_id; |
1088 |
|
|
|
1089 |
|
|
if (!mysql_query ($sql, $con)){ |
1090 |
|
|
$problem = 1; |
1091 |
|
|
sql_err($sql); |
1092 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1093 |
|
|
bailout(); |
1094 |
|
|
} |
1095 |
|
|
else { |
1096 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1097 |
|
|
printf("Removed Master Information Type successfully.<BR><BR>\n"); |
1098 |
|
|
} |
1099 |
|
|
} // delete masterinfotype itself |
1100 |
|
|
|
1101 |
|
|
} // masterinfotype > 1 (cannot delete N/A). |
1102 |
|
|
|
1103 |
|
|
else printf("Cannot delete <b>Master Information Type ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
1104 |
|
|
|
1105 |
|
|
printf("</td></tr></table>"); |
1106 |
|
|
printf("</center>"); |
1107 |
|
|
} |
1108 |
|
|
|
1109 |
|
|
|
1110 |
|
|
/********************************************************** |
1111 |
|
|
Function: deleteMasterinfotypeConfirm |
1112 |
|
|
Author: Paul Bramscher |
1113 |
|
|
Last Modified: 05.21.2003 |
1114 |
|
|
*********************************************************** |
1115 |
|
|
Purpose: |
1116 |
|
|
Confirm prompt for deleting the supplied master information |
1117 |
|
|
type id. Note the dire warning. |
1118 |
|
|
**********************************************************/ |
1119 |
|
|
function deleteMasterinfotypeConfirm($con, $key_id){ |
1120 |
|
|
|
1121 |
|
|
// Make sure we have a valid integer type |
1122 |
|
|
$masterinfotype_id = (int) $key_id; |
1123 |
|
|
|
1124 |
|
|
// Draw page heading |
1125 |
|
|
printf("<center><h3>Delete Master Information Type ID# %s?</h3>", $masterinfotype_id); |
1126 |
|
|
|
1127 |
|
|
// Check to see if its possible |
1128 |
|
|
$exists = existsRow($con, "masterinfotype", "masterinfotype_id", $masterinfotype_id); |
1129 |
|
|
if ($exists > 0){ |
1130 |
|
|
|
1131 |
|
|
// Table |
1132 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
1133 |
|
|
printf("<tr><td>"); |
1134 |
|
|
|
1135 |
|
|
// Lookup the descriptive title |
1136 |
|
|
$masterinfotype = lookupField($con, "masterinfotype", "masterinfotype_id", $masterinfotype_id, "masterinfotype"); |
1137 |
|
|
printf("<strong>Master Information Type:</strong> %s<br><br>\n ", $masterinfotype); |
1138 |
|
|
|
1139 |
|
|
// Form to draw the delete button |
1140 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
1141 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteMasterinfotype\" >"); |
1142 |
|
|
printf("<input type = \"Hidden\" name = \"masterinfotype_id\" value = \"%d\" >", $masterinfotype_id); |
1143 |
|
|
printf("This will <b>permanently</b> remove the Master Information Type and its various assignments from the system. "); |
1144 |
|
|
printf("A potentially large deletion cascade may result, since deleting a Master Information Type will delete all Information Types below it. "); |
1145 |
|
|
printf("<b>All affected resource-subject-infotype assignments on RQS pages will be broken, and therefore removed!</b> "); |
1146 |
|
|
printf("Be sure to re-assign important resources to another specific Information Type, and assign it to a safe Master Information Type before deleting this one.<br><br>"); |
1147 |
|
|
printf("Do not proceed unless you are <b>VERY</b> sure of what you're doing.<br><br>\n"); |
1148 |
|
|
printf("Check the <b><a href=\"masterinfotype_drill.phtml?masterinfotype_id=%d\">Master Information Type Detail<a></b> page to display affected Information Types and drill down further.", $masterinfotype_id); |
1149 |
|
|
printf("<br><br>\n"); |
1150 |
|
|
printf("<center>"); |
1151 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
1152 |
|
|
printf("</center>"); |
1153 |
|
|
printf("</form><br>"); |
1154 |
|
|
|
1155 |
|
|
// Close table |
1156 |
|
|
printf("</td></tr></table>"); |
1157 |
|
|
} |
1158 |
|
|
|
1159 |
|
|
// Failed for whatever reason |
1160 |
|
|
else if ($exists < 1) printf ("Master Information Type not found. Operation cancelled.<br>\n"); |
1161 |
|
|
|
1162 |
|
|
printf("</center>"); |
1163 |
|
|
} |
1164 |
|
|
|
1165 |
|
|
|
1166 |
|
|
/********************************************************** |
1167 |
|
|
Function: deleteMastersubject |
1168 |
|
|
Author: Paul Bramscher |
1169 |
|
|
Last Modified: 04.21.2003 |
1170 |
|
|
*********************************************************** |
1171 |
|
|
Purpose: |
1172 |
|
|
Delete the supplied master subject id, and removes |
1173 |
|
|
associations in the subject-mastersubject, |
1174 |
|
|
resource-mastersubject tables. Currently the system will |
1175 |
|
|
prompt the user, telling them that dependencies were |
1176 |
|
|
found, and offer the mastersubject drill down page. So, |
1177 |
|
|
theoretically, the additional cascades here aren't |
1178 |
|
|
necessary. |
1179 |
|
|
**********************************************************/ |
1180 |
|
|
function deleteMastersubject($con, $mastersubject_id){ |
1181 |
|
|
|
1182 |
|
|
// Draw form heading |
1183 |
|
|
printf("<center><h3>Deleting Master Subject...</h3>"); |
1184 |
|
|
|
1185 |
|
|
// Table |
1186 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
1187 |
|
|
printf("<tr><td><br>"); |
1188 |
|
|
printf("<strong>Messages:</strong><br>"); |
1189 |
|
|
|
1190 |
|
|
// Problem flag for each delete step |
1191 |
|
|
$problem = 0; |
1192 |
|
|
|
1193 |
|
|
// Cannot delete placeholder #1 |
1194 |
|
|
if ($mastersubject_id > 1) { |
1195 |
|
|
|
1196 |
|
|
// Delete from sub_mastersubject |
1197 |
|
|
if ($problem == 0) { |
1198 |
|
|
$sql = "DELETE FROM sub_mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
1199 |
|
|
|
1200 |
|
|
if (!mysql_query ($sql, $con)){ |
1201 |
|
|
$problem = 1; |
1202 |
|
|
sql_err($sql); |
1203 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1204 |
|
|
bailout(); |
1205 |
|
|
} |
1206 |
|
|
else { |
1207 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1208 |
|
|
printf("Affected subject-mastersubject assignments removed.<BR>\n"); |
1209 |
|
|
} |
1210 |
|
|
} |
1211 |
|
|
|
1212 |
|
|
// Delete from res_mastersubject |
1213 |
|
|
if ($problem == 0) { |
1214 |
|
|
$sql = "DELETE FROM res_mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
1215 |
|
|
|
1216 |
|
|
if (!mysql_query ($sql, $con)){ |
1217 |
|
|
$problem = 1; |
1218 |
|
|
sql_err($sql); |
1219 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1220 |
|
|
bailout(); |
1221 |
|
|
} |
1222 |
|
|
else { |
1223 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1224 |
|
|
printf("Affected resource-mastersubject assignments removed.<BR>\n"); |
1225 |
|
|
} |
1226 |
|
|
} |
1227 |
|
|
|
1228 |
|
|
// Delete from mastersubject table |
1229 |
|
|
if ($problem == 0) { |
1230 |
|
|
$sql = "DELETE FROM mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
1231 |
|
|
|
1232 |
|
|
if (!mysql_query ($sql, $con)){ |
1233 |
|
|
$problem = 1; |
1234 |
|
|
sql_err($sql); |
1235 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1236 |
|
|
bailout(); |
1237 |
|
|
} |
1238 |
|
|
else { |
1239 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1240 |
|
|
printf("Removed Master Subject successfully.<BR><BR>\n"); |
1241 |
|
|
} |
1242 |
|
|
} |
1243 |
|
|
|
1244 |
|
|
} // mastersubject > 1 (cannot delete N/A). |
1245 |
|
|
|
1246 |
|
|
else printf("Cannot delete <b>Master Subject ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
1247 |
|
|
|
1248 |
|
|
printf("</td></tr></table>"); |
1249 |
|
|
printf("</center>"); |
1250 |
|
|
} |
1251 |
|
|
|
1252 |
|
|
|
1253 |
|
|
/********************************************************** |
1254 |
|
|
Function: deleteMastersubjectConfirm |
1255 |
|
|
Author: Paul Bramscher |
1256 |
|
|
Last Modified: 04.21.2003 |
1257 |
|
|
*********************************************************** |
1258 |
|
|
Purpose: |
1259 |
|
|
Confirm prompt to delete the supplied mastersubject id. |
1260 |
|
|
This function also performs some lookups to determine |
1261 |
|
|
whether any subjects or resources might be affected by |
1262 |
|
|
a delete operation. If so, the user is presented with a |
1263 |
|
|
link to the drilldown page and may not delete this |
1264 |
|
|
mastersubject. |
1265 |
|
|
**********************************************************/ |
1266 |
|
|
function deleteMastersubjectConfirm($con, $key_id){ |
1267 |
|
|
|
1268 |
|
|
// Make sure we have a valid integer type |
1269 |
|
|
$mastersubject_id = (int) $key_id; |
1270 |
|
|
|
1271 |
|
|
// Draw page heading |
1272 |
|
|
printf("<center><h3>Delete Master Subject ID# %s?</h3>", $mastersubject_id); |
1273 |
|
|
|
1274 |
|
|
// Check to see if its possible |
1275 |
|
|
$exists = existsRow($con, "mastersubject", "mastersubject_id", $mastersubject_id); |
1276 |
|
|
if ($exists > 0 && $mastersubject_id > 2){ |
1277 |
|
|
|
1278 |
|
|
// Table |
1279 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
1280 |
|
|
printf("<tr><td>"); |
1281 |
|
|
|
1282 |
|
|
// Lookup the descriptive title |
1283 |
|
|
$mastersubject = lookupField($con, "mastersubject", "mastersubject_id", $mastersubject_id, "mastersubject"); |
1284 |
|
|
printf("<strong>Master Subject:</strong> %s<br><br>\n ", $mastersubject); |
1285 |
|
|
|
1286 |
|
|
// Determine whether any subjects or resources are affected |
1287 |
|
|
$problem = 0; |
1288 |
|
|
|
1289 |
|
|
// Check subjects |
1290 |
|
|
$sql = "SELECT COUNT(sm.subject_id) as num_subjects FROM sub_mastersubject sm WHERE sm.mastersubject_id =" |
1291 |
|
|
. $mastersubject_id; |
1292 |
|
|
$rs = mysql_query($sql, $con); |
1293 |
|
|
$row = mysql_fetch_array ($rs); |
1294 |
|
|
$num_subjects = $row["num_subjects"]; |
1295 |
|
|
if ($num_subjects > 0) $problem = 1; |
1296 |
|
|
|
1297 |
|
|
// Check resources |
1298 |
|
|
else { |
1299 |
|
|
// Check resources |
1300 |
|
|
$sql = "SELECT COUNT(rm.resource_id) as num_resources FROM res_mastersubject rm WHERE rm.mastersubject_id = " |
1301 |
|
|
. $mastersubject_id; |
1302 |
|
|
$rs = mysql_query($sql, $con); |
1303 |
|
|
$row = mysql_fetch_array ($rs); |
1304 |
|
|
$num_resources = $row["num_resources"]; |
1305 |
|
|
|
1306 |
|
|
if ($num_resources > 1) $problem = 1; |
1307 |
|
|
} |
1308 |
|
|
|
1309 |
|
|
// Proceed only if no subjects or resources are affected |
1310 |
|
|
if ($problem == 0) { |
1311 |
|
|
// Form to draw the delete button |
1312 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
1313 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteMastersubject\" >"); |
1314 |
|
|
printf("<input type = \"Hidden\" name = \"mastersubject_id\" value = \"%d\" >", $mastersubject_id); |
1315 |
|
|
printf("This will <b>permanently</b> remove the Master Subject from the system. "); |
1316 |
|
|
printf("Are you sure you want to proceed?<br><br>\n"); |
1317 |
|
|
printf("<center>"); |
1318 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
1319 |
|
|
printf("</center>"); |
1320 |
|
|
printf("</form><br>"); |
1321 |
|
|
} |
1322 |
|
|
|
1323 |
|
|
// There was a problem of some sort. |
1324 |
|
|
else { |
1325 |
|
|
printf("Dependencies were found. Master Subjects may not be deleted if there are resources or "); |
1326 |
|
|
printf("specific subjects assigned to them. "); |
1327 |
|
|
printf("Examine the <a href=\"admin_mastersubject_detail.phtml?mastersubject_id=%d\">Master Subject Detail</a></b> page.\n", $mastersubject_id); |
1328 |
|
|
printf("<br><br>\n"); |
1329 |
|
|
} |
1330 |
|
|
|
1331 |
|
|
// Close table |
1332 |
|
|
printf("</td></tr></table>"); |
1333 |
|
|
|
1334 |
|
|
} |
1335 |
|
|
|
1336 |
|
|
// Failed for whatever reason |
1337 |
|
|
else if ($exists < 1) printf ("Master Subject not found. Operation cancelled.<br>\n"); |
1338 |
|
|
else if ($mastersubject_id < 3) printf("Master Subjects #1 and #2 cannot be deleted.<br>\n"); |
1339 |
|
|
|
1340 |
|
|
printf("</center>"); |
1341 |
|
|
} |
1342 |
|
|
|
1343 |
|
|
|
1344 |
|
|
/********************************************************** |
1345 |
|
|
Function: deleteResFeature |
1346 |
|
|
Author: Paul Bramscher |
1347 |
|
|
Last Modified: 04.21.2003 |
1348 |
|
|
*********************************************************** |
1349 |
|
|
Purpose: |
1350 |
|
|
Deletes resource-feature associations based on the supplied |
1351 |
|
|
feature id (possibly multiple) and calls formResource back |
1352 |
|
|
again. |
1353 |
|
|
**********************************************************/ |
1354 |
|
|
function deleteResFeature($con, $key_list_array, $resource_id){ |
1355 |
|
|
|
1356 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1357 |
|
|
|
1358 |
|
|
$sql = "DELETE FROM res_feature WHERE resource_id = " |
1359 |
|
|
. $resource_id |
1360 |
|
|
. " AND feature_id = " |
1361 |
|
|
. $key_list_array[$element]; |
1362 |
|
|
|
1363 |
|
|
// Failed |
1364 |
|
|
if (!mysql_query ($sql, $con)){ |
1365 |
|
|
sql_err($sql); |
1366 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1367 |
|
|
bailout(); |
1368 |
|
|
} |
1369 |
|
|
|
1370 |
|
|
// Succeeded |
1371 |
|
|
else { |
1372 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1373 |
|
|
} |
1374 |
|
|
} |
1375 |
|
|
// Call the resource form back |
1376 |
|
|
formResource($con, $resource_id, 0, 0, ''); |
1377 |
|
|
} |
1378 |
|
|
|
1379 |
|
|
|
1380 |
|
|
/********************************************************** |
1381 |
|
|
Function: deleteResLoc |
1382 |
|
|
Author: Paul Bramscher |
1383 |
|
|
Last Modified: 04.21.2003 |
1384 |
|
|
*********************************************************** |
1385 |
|
|
Purpose: |
1386 |
|
|
Deletes resource-location associations based on the supplied |
1387 |
|
|
location id (possibly multiple) and calls formResource back |
1388 |
|
|
again. |
1389 |
|
|
**********************************************************/ |
1390 |
|
|
function deleteResLoc($con, $key_list_array, $resource_id){ |
1391 |
|
|
|
1392 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1393 |
|
|
$sql = "DELETE FROM res_loc WHERE resource_id = " |
1394 |
|
|
. $resource_id |
1395 |
|
|
. " AND location_id = " |
1396 |
|
|
. $key_list_array[$element]; |
1397 |
|
|
|
1398 |
|
|
// Failed |
1399 |
|
|
if (!mysql_query ($sql, $con)){ |
1400 |
|
|
sql_err($sql); |
1401 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1402 |
|
|
bailout(); |
1403 |
|
|
} |
1404 |
|
|
|
1405 |
|
|
// Succeeded |
1406 |
|
|
else { |
1407 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1408 |
|
|
} |
1409 |
|
|
} |
1410 |
|
|
// Call the resource form back |
1411 |
|
|
formResource($con, $resource_id, 0, 0, ''); |
1412 |
|
|
} |
1413 |
|
|
|
1414 |
|
|
|
1415 |
|
|
/********************************************************** |
1416 |
|
|
Function: deleteResMastersubject |
1417 |
|
|
Author: Paul Bramscher |
1418 |
|
|
Last Modified: 04.21.2003 |
1419 |
|
|
*********************************************************** |
1420 |
|
|
Purpose: |
1421 |
|
|
Deletes resource-mastersubject associations based on the |
1422 |
|
|
supplied mastersubject id (possibly multiple) and calls |
1423 |
|
|
formResource back again. |
1424 |
|
|
**********************************************************/ |
1425 |
|
|
function deleteResMastersubject($con, $key_list_array, $resource_id){ |
1426 |
|
|
|
1427 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1428 |
|
|
|
1429 |
|
|
$sql = "DELETE FROM res_mastersubject WHERE resource_id = " |
1430 |
|
|
. $resource_id |
1431 |
|
|
. " AND mastersubject_id = " |
1432 |
|
|
. $key_list_array[$element]; |
1433 |
|
|
|
1434 |
|
|
// Failed |
1435 |
|
|
if (!mysql_query ($sql, $con)){ |
1436 |
|
|
sql_err($sql); |
1437 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1438 |
|
|
bailout(); |
1439 |
|
|
} |
1440 |
|
|
|
1441 |
|
|
// Succeeded |
1442 |
|
|
else { |
1443 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1444 |
|
|
} |
1445 |
|
|
} |
1446 |
|
|
// Call the resource form back |
1447 |
|
|
formResource($con, $resource_id, 0, 0, ''); |
1448 |
|
|
} |
1449 |
|
|
|
1450 |
|
|
|
1451 |
|
|
/********************************************************** |
1452 |
|
|
Function: deleteResource |
1453 |
|
|
Author: Paul Bramscher |
1454 |
|
|
Last Modified: 04.21.2003 |
1455 |
|
|
*********************************************************** |
1456 |
|
|
Purpose: |
1457 |
|
|
Deletes the supplied resource id, and removes associations |
1458 |
|
|
in the resource-subject-informationtype, resource-location, |
1459 |
|
|
resource-mastersubject, and resource-feature tables. |
1460 |
|
|
Also converts any relational resource references in |
1461 |
|
|
Page/CourseScribe pages to text-type fields (non-relational), |
1462 |
|
|
as well as all user copy-paste buffers. |
1463 |
|
|
**********************************************************/ |
1464 |
|
|
function deleteResource($con, $delMessage, $resource_id){ |
1465 |
|
|
|
1466 |
|
|
// Table |
1467 |
|
|
printf("<center>\n"); |
1468 |
|
|
printf("<table width=\"50%%\" class=\"backLight\" border=\"1\" cellpadding=\"4\">\n"); |
1469 |
|
|
|
1470 |
|
|
// Row header |
1471 |
|
|
printf("<tr><td class=\"cellPlain\">\n"); |
1472 |
|
|
printf("Delete Messages"); |
1473 |
|
|
printf("</td></tr>\n"); |
1474 |
|
|
|
1475 |
|
|
// New row |
1476 |
|
|
printf("<tr><td>\n"); |
1477 |
|
|
|
1478 |
|
|
// Set up a problem flag. |
1479 |
|
|
$problem = 0; |
1480 |
|
|
|
1481 |
|
|
// First delete all related rows in res_sub_infotype |
1482 |
|
|
$sql = "DELETE FROM res_sub_infotype WHERE resource_id = " . $resource_id; |
1483 |
|
|
|
1484 |
|
|
if (!mysql_query ($sql, $con)){ |
1485 |
|
|
$problem = 1; |
1486 |
|
|
sql_err($sql); |
1487 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1488 |
|
|
bailout(); |
1489 |
|
|
} |
1490 |
|
|
|
1491 |
|
|
else { |
1492 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1493 |
|
|
printf("Resource removed from all resource-subject-infotype assignments.<BR>\n"); |
1494 |
|
|
|
1495 |
|
|
} |
1496 |
|
|
|
1497 |
|
|
// Delete from the res_loc table |
1498 |
|
|
if ($problem == 0) { |
1499 |
|
|
$sql = "DELETE FROM res_loc WHERE resource_id =" . $resource_id; |
1500 |
|
|
|
1501 |
|
|
if (!mysql_query ($sql, $con)){ |
1502 |
|
|
$problem = 1; |
1503 |
|
|
sql_err($sql); |
1504 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1505 |
|
|
bailout(); |
1506 |
|
|
} |
1507 |
|
|
else { |
1508 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1509 |
|
|
printf("Removed from resource-location table.<BR>\n"); |
1510 |
|
|
} |
1511 |
|
|
} |
1512 |
|
|
|
1513 |
|
|
// Delete from the res_mastersubject table |
1514 |
|
|
if ($problem == 0) { |
1515 |
|
|
|
1516 |
|
|
$sql = "DELETE FROM res_mastersubject WHERE resource_id =" . $resource_id; |
1517 |
|
|
|
1518 |
|
|
if (!mysql_query ($sql, $con)){ |
1519 |
|
|
$problem = 1; |
1520 |
|
|
sql_err($sql); |
1521 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1522 |
|
|
bailout(); |
1523 |
|
|
} |
1524 |
|
|
else { |
1525 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1526 |
|
|
printf("Removed from resource-mastersubject table.<BR>\n"); |
1527 |
|
|
} |
1528 |
|
|
} |
1529 |
|
|
|
1530 |
|
|
// Delete from the res_feature table |
1531 |
|
|
if ($problem == 0) { |
1532 |
|
|
|
1533 |
|
|
$sql = "DELETE FROM res_feature WHERE resource_id =" . $resource_id; |
1534 |
|
|
|
1535 |
|
|
if (!mysql_query ($sql, $con)){ |
1536 |
|
|
$problem = 1; |
1537 |
|
|
sql_err($sql); |
1538 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1539 |
|
|
bailout(); |
1540 |
|
|
} |
1541 |
|
|
else { |
1542 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1543 |
|
|
printf("Removed from resource-feature table.<BR>\n"); |
1544 |
|
|
} |
1545 |
|
|
} |
1546 |
|
|
|
1547 |
|
|
// Update affected PageScribe pages |
1548 |
|
|
if ($problem == 0) { |
1549 |
|
|
|
1550 |
|
|
// First, get the default resource description and title |
1551 |
|
|
$sql = "SELECT annotation, title FROM resource WHERE resource_id = " |
1552 |
|
|
. $resource_id; |
1553 |
|
|
$rs = mysql_query($sql, $con); |
1554 |
|
|
$row = mysql_fetch_array ($rs); |
1555 |
|
|
$annotation = $row["annotation"]; |
1556 |
|
|
$title = $row["title"]; |
1557 |
|
|
|
1558 |
|
|
// Clean up |
1559 |
|
|
$title = textInmySQL($title); |
1560 |
|
|
$annotation = textInmySQL($annotation); |
1561 |
|
|
$delMessage = textInmySQL($delMessage); |
1562 |
|
|
|
1563 |
|
|
// Next, append the reason for deletion to the annotation |
1564 |
|
|
if (strlen($annotation) > 0) $annotation .= "<BR>" . $delMessage; |
1565 |
|
|
else $annotation = $delMessage; |
1566 |
|
|
|
1567 |
|
|
// Update all of the elements using this resource with a custom description. |
1568 |
|
|
$sql = "UPDATE element SET label = '" |
1569 |
|
|
. $title |
1570 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
1571 |
|
|
. $delMessage |
1572 |
|
|
. "'), resource_id = NULL WHERE resource_id =" . $resource_id |
1573 |
|
|
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1574 |
|
|
|
1575 |
|
|
if (!mysql_query ($sql, $con)){ |
1576 |
|
|
$problem = 1; |
1577 |
|
|
sql_err($sql); |
1578 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1579 |
|
|
bailout(); |
1580 |
|
|
} |
1581 |
|
|
else { |
1582 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1583 |
|
|
printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1584 |
|
|
} |
1585 |
|
|
|
1586 |
|
|
|
1587 |
|
|
// Next, update all of the elements using this resource without a custom description. |
1588 |
|
|
$sql = "UPDATE element SET label = '" |
1589 |
|
|
. $title |
1590 |
|
|
. "', element_descr = '" |
1591 |
|
|
. $annotation |
1592 |
|
|
. "', resource_id = NULL WHERE resource_id =" . $resource_id |
1593 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
1594 |
|
|
|
1595 |
|
|
if (!mysql_query ($sql, $con)){ |
1596 |
|
|
$problem = 1; |
1597 |
|
|
sql_err($sql); |
1598 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1599 |
|
|
bailout(); |
1600 |
|
|
} |
1601 |
|
|
else { |
1602 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1603 |
|
|
printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
1604 |
|
|
} |
1605 |
|
|
|
1606 |
|
|
|
1607 |
|
|
} |
1608 |
|
|
|
1609 |
|
|
|
1610 |
|
|
// Update affected PageScribe copy buffers |
1611 |
|
|
if ($problem == 0) { |
1612 |
|
|
|
1613 |
|
|
// Update all of the elements using this resource with a custom description. |
1614 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
1615 |
|
|
. $title |
1616 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
1617 |
|
|
. $delMessage |
1618 |
|
|
. "'), resource_id = NULL WHERE resource_id =" . $resource_id |
1619 |
|
|
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1620 |
|
|
|
1621 |
|
|
if (!mysql_query ($sql, $con)){ |
1622 |
|
|
$problem = 1; |
1623 |
|
|
sql_err($sql); |
1624 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1625 |
|
|
bailout(); |
1626 |
|
|
} |
1627 |
|
|
else { |
1628 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1629 |
|
|
printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
1630 |
|
|
} |
1631 |
|
|
|
1632 |
|
|
|
1633 |
|
|
// Next, update all of the elements using this resource without a custom description. |
1634 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
1635 |
|
|
. $title |
1636 |
|
|
. "', element_descr = '" |
1637 |
|
|
. $annotation |
1638 |
|
|
. "', resource_id = NULL WHERE resource_id =" . $resource_id |
1639 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
1640 |
|
|
|
1641 |
|
|
if (!mysql_query ($sql, $con)){ |
1642 |
|
|
$problem = 1; |
1643 |
|
|
sql_err($sql); |
1644 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1645 |
|
|
bailout(); |
1646 |
|
|
} |
1647 |
|
|
else { |
1648 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1649 |
|
|
printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
1650 |
|
|
} |
1651 |
|
|
|
1652 |
|
|
|
1653 |
|
|
} |
1654 |
|
|
|
1655 |
|
|
|
1656 |
|
|
// Delete from the resource table |
1657 |
|
|
if ($problem == 0) { |
1658 |
|
|
|
1659 |
|
|
$sql = "DELETE FROM resource WHERE resource_id =" . $resource_id; |
1660 |
|
|
|
1661 |
|
|
if (!mysql_query ($sql, $con)){ |
1662 |
|
|
$problem = 1; |
1663 |
|
|
sql_err($sql); |
1664 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1665 |
|
|
bailout(); |
1666 |
|
|
} |
1667 |
|
|
|
1668 |
|
|
else { |
1669 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1670 |
|
|
} |
1671 |
|
|
} |
1672 |
|
|
|
1673 |
|
|
if ($problem == 0) printf("Successfully removed from all tables.<BR><BR>\n"); |
1674 |
|
|
|
1675 |
|
|
printf("</td></tr></table>\n"); |
1676 |
|
|
printf("</center><BR>\n"); |
1677 |
|
|
} |
1678 |
|
|
|
1679 |
|
|
|
1680 |
|
|
/********************************************************** |
1681 |
|
|
Function: deleteResourceConfirm |
1682 |
|
|
Author: Paul Bramscher |
1683 |
|
|
Last Modified: 04.21.2003 |
1684 |
|
|
*********************************************************** |
1685 |
|
|
Purpose: |
1686 |
|
|
Confirm prompt to delete the supplied resource id. |
1687 |
|
|
**********************************************************/ |
1688 |
|
|
function deleteResourceConfirm($con, $resource_id){ |
1689 |
|
|
|
1690 |
|
|
// Make sure we have a valid integer type |
1691 |
|
|
$resource_id = (int) $resource_id; |
1692 |
|
|
|
1693 |
|
|
printf("<center>\n"); |
1694 |
|
|
|
1695 |
|
|
// Check to see if its possible |
1696 |
|
|
$exists = existsRow($con, "resource", "resource_id", $resource_id); |
1697 |
|
|
if ($exists > 0){ |
1698 |
|
|
|
1699 |
|
|
// Table |
1700 |
|
|
printf("<table width=\"60%%\" class=\"backLight\" border=\"1\" cellpadding=\"4\">\n"); |
1701 |
|
|
|
1702 |
|
|
// Row header |
1703 |
|
|
printf("<tr><td class=\"cellPlain\">\n"); |
1704 |
|
|
printf("Delete Resource ID# %s?", $resource_id); |
1705 |
|
|
printf("</td></tr>\n"); |
1706 |
|
|
printf("<tr><td>\n"); |
1707 |
|
|
|
1708 |
|
|
// Lookup the title & author |
1709 |
|
|
$title = lookupField($con, "resource", "resource_id", $resource_id, "title"); |
1710 |
|
|
$author = lookupField($con, "resource", "resource_id", $resource_id, "author"); |
1711 |
|
|
printf("<b>Title:</b> %s<br>\n ", $title); |
1712 |
|
|
printf("<b>Author:</b> %s<br><br>\n ", $author); |
1713 |
|
|
|
1714 |
|
|
// Offer a call to the resource drilldown page |
1715 |
|
|
printf("If this resource is used anywhere on the system, deleting it will affect those places. You may want to examine the <b><a href=\"res_drill.phtml?resource_id=%d\">Resource Detail</a></b> page to check usage before deleting it.<br><br>", $resource_id); |
1716 |
|
|
|
1717 |
|
|
// Form to draw the delete button |
1718 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1719 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteResource\" >\n"); |
1720 |
|
|
printf("<input type = \"Hidden\" name = \"resource_id\" value = \"%d\" >\n", $resource_id); |
1721 |
|
|
|
1722 |
|
|
// Delete message |
1723 |
|
|
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
1724 |
|
|
printf("<input type=\"text\" name=\"delMessage\" value=\"[Resource no longer available]\" size=\"75\"><br><br>\n"); |
1725 |
|
|
|
1726 |
|
|
// Warning |
1727 |
|
|
printf("This will <b>permanently</b> remove the resource and its various assignments from the system.<BR><BR>\n"); |
1728 |
|
|
|
1729 |
|
|
// Delete button |
1730 |
|
|
printf("<center>\n"); |
1731 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1732 |
|
|
printf("</center>\n"); |
1733 |
|
|
printf("</form><br>\n"); |
1734 |
|
|
|
1735 |
|
|
// Close table |
1736 |
|
|
printf("</td></tr></table>\n"); |
1737 |
|
|
printf("<BR>\n"); |
1738 |
|
|
} |
1739 |
|
|
|
1740 |
|
|
// Failed for whatever reason |
1741 |
|
|
else if ($exists < 1) printf ("Resource #%d not found. Operation cancelled.<br><br>\n", $resource_id); |
1742 |
|
|
|
1743 |
|
|
printf("</center>\n"); |
1744 |
|
|
} |
1745 |
|
|
|
1746 |
|
|
|
1747 |
|
|
/********************************************************** |
1748 |
|
|
Function: deleteService |
1749 |
|
|
Author: Paul Bramscher |
1750 |
|
|
Last Modified: 05.21.2003 |
1751 |
|
|
*********************************************************** |
1752 |
|
|
Purpose: |
1753 |
|
|
Deletes the supplied service id, and removes associations |
1754 |
|
|
in the service-servicetype and service-location tables. |
1755 |
|
|
Also converts any relational resource references in |
1756 |
|
|
Page/CourseScribe pages to text-type fields (non-relational), |
1757 |
|
|
as well as all user copy-paste buffers. |
1758 |
|
|
**********************************************************/ |
1759 |
|
|
function deleteService($con, $delMessage, $service_id){ |
1760 |
|
|
|
1761 |
|
|
// Table |
1762 |
|
|
printf("<center>\n"); |
1763 |
|
|
printf("<table width=\"50%%\" class=\"backLight\" border=\"1\" cellpadding=\"4\">\n"); |
1764 |
|
|
|
1765 |
|
|
// Row header |
1766 |
|
|
printf("<tr><td class=\"cellPlain\">\n"); |
1767 |
|
|
printf("Delete Messages"); |
1768 |
|
|
printf("</td></tr>\n"); |
1769 |
|
|
|
1770 |
|
|
// New row |
1771 |
|
|
printf("<tr><td>\n"); |
1772 |
|
|
|
1773 |
|
|
// Set up a problem flag. |
1774 |
|
|
$problem = 0; |
1775 |
|
|
|
1776 |
|
|
// First delete all related rows in serv_servtype |
1777 |
|
|
$sql = "DELETE FROM serv_servtype WHERE service_id = " . $service_id; |
1778 |
|
|
|
1779 |
|
|
if (!mysql_query ($sql, $con)){ |
1780 |
|
|
$problem = 1; |
1781 |
|
|
sql_err($sql); |
1782 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1783 |
|
|
bailout(); |
1784 |
|
|
} |
1785 |
|
|
|
1786 |
|
|
else { |
1787 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1788 |
|
|
printf("Service removed from all service-servicetype assignments.<BR>\n"); |
1789 |
|
|
|
1790 |
|
|
} |
1791 |
|
|
|
1792 |
|
|
// Delete from the serv_loc table |
1793 |
|
|
if ($problem == 0) { |
1794 |
|
|
$sql = "DELETE FROM serv_loc WHERE service_id =" . $service_id; |
1795 |
|
|
|
1796 |
|
|
if (!mysql_query ($sql, $con)){ |
1797 |
|
|
$problem = 1; |
1798 |
|
|
sql_err($sql); |
1799 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1800 |
|
|
bailout(); |
1801 |
|
|
} |
1802 |
|
|
else { |
1803 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1804 |
|
|
printf("Removed from service-location table.<BR>\n"); |
1805 |
|
|
} |
1806 |
|
|
} |
1807 |
|
|
|
1808 |
|
|
|
1809 |
|
|
// Update affected PageScribe pages |
1810 |
|
|
if ($problem == 0) { |
1811 |
|
|
|
1812 |
|
|
// First, get the default service description and title |
1813 |
|
|
$sql = "SELECT service, serviceDescr FROM service WHERE service_id = " |
1814 |
|
|
. $service_id; |
1815 |
|
|
$rs = mysql_query($sql, $con); |
1816 |
|
|
$row = mysql_fetch_array ($rs); |
1817 |
|
|
$service = $row["service"]; |
1818 |
|
|
$serviceDescr = $row["serviceDescr"]; |
1819 |
|
|
|
1820 |
|
|
// Clean up strings |
1821 |
|
|
$service = textInmySQL($service); |
1822 |
|
|
$serviceDescr = textInmySQL($serviceDescr); |
1823 |
|
|
$delMessage = textInmySQL($delMessage); |
1824 |
|
|
|
1825 |
|
|
// Next, append the reason for deletion to the annotation |
1826 |
|
|
if (strlen($serviceDescr) > 0) $serviceDescr .= "<BR>" . $delMessage; |
1827 |
|
|
else $serviceDescr = $delMessage; |
1828 |
|
|
|
1829 |
|
|
// Update all of the elements using this service with a custom description. |
1830 |
|
|
$sql = "UPDATE element SET label = '" |
1831 |
|
|
. $service |
1832 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
1833 |
|
|
. $delMessage |
1834 |
|
|
. "'), service_id = NULL WHERE service_id =" . $service_id |
1835 |
|
|
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1836 |
|
|
|
1837 |
|
|
if (!mysql_query ($sql, $con)){ |
1838 |
|
|
$problem = 1; |
1839 |
|
|
sql_err($sql); |
1840 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1841 |
|
|
bailout(); |
1842 |
|
|
} |
1843 |
|
|
else { |
1844 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1845 |
|
|
printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1846 |
|
|
} |
1847 |
|
|
|
1848 |
|
|
|
1849 |
|
|
// Next, update all of the elements using this service without a custom description. |
1850 |
|
|
$sql = "UPDATE element SET label = '" |
1851 |
|
|
. $service |
1852 |
|
|
. "', element_descr = '" |
1853 |
|
|
. $serviceDescr |
1854 |
|
|
. "', service_id = NULL WHERE service_id =" . $service_id |
1855 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
1856 |
|
|
|
1857 |
|
|
if (!mysql_query ($sql, $con)){ |
1858 |
|
|
$problem = 1; |
1859 |
|
|
sql_err($sql); |
1860 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1861 |
|
|
bailout(); |
1862 |
|
|
} |
1863 |
|
|
else { |
1864 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1865 |
|
|
printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
1866 |
|
|
} |
1867 |
|
|
|
1868 |
|
|
|
1869 |
|
|
} |
1870 |
|
|
|
1871 |
|
|
|
1872 |
|
|
// Update affected PageScribe copy buffers |
1873 |
|
|
if ($problem == 0) { |
1874 |
|
|
|
1875 |
|
|
// Update all of the elements using this service with a custom description. |
1876 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
1877 |
|
|
. $service |
1878 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
1879 |
|
|
. $delMessage |
1880 |
|
|
. "'), service_id = NULL WHERE service_id =" . $service_id |
1881 |
|
|
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1882 |
|
|
|
1883 |
|
|
if (!mysql_query ($sql, $con)){ |
1884 |
|
|
$problem = 1; |
1885 |
|
|
sql_err($sql); |
1886 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1887 |
|
|
bailout(); |
1888 |
|
|
} |
1889 |
|
|
else { |
1890 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1891 |
|
|
printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
1892 |
|
|
} |
1893 |
|
|
|
1894 |
|
|
|
1895 |
|
|
// Next, update all of the elements using this service without a custom description. |
1896 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
1897 |
|
|
. $service |
1898 |
|
|
. "', element_descr = '" |
1899 |
|
|
. $serviceDescr |
1900 |
|
|
. "', service_id = NULL WHERE service_id =" . $service_id |
1901 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
1902 |
|
|
|
1903 |
|
|
if (!mysql_query ($sql, $con)){ |
1904 |
|
|
$problem = 1; |
1905 |
|
|
sql_err($sql); |
1906 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1907 |
|
|
bailout(); |
1908 |
|
|
} |
1909 |
|
|
else { |
1910 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1911 |
|
|
printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
1912 |
|
|
} |
1913 |
|
|
|
1914 |
|
|
|
1915 |
|
|
} |
1916 |
|
|
|
1917 |
|
|
|
1918 |
|
|
// Delete from the service table |
1919 |
|
|
if ($problem == 0) { |
1920 |
|
|
|
1921 |
|
|
$sql = "DELETE FROM service WHERE service_id =" . $service_id; |
1922 |
|
|
|
1923 |
|
|
if (!mysql_query ($sql, $con)){ |
1924 |
|
|
$problem = 1; |
1925 |
|
|
sql_err($sql); |
1926 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1927 |
|
|
bailout(); |
1928 |
|
|
} |
1929 |
|
|
|
1930 |
|
|
else { |
1931 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1932 |
|
|
} |
1933 |
|
|
} |
1934 |
|
|
|
1935 |
|
|
if ($problem == 0) printf("Successfully removed from all tables.<BR><BR>\n"); |
1936 |
|
|
|
1937 |
|
|
printf("</td></tr></table>\n"); |
1938 |
|
|
printf("</center><BR>\n"); |
1939 |
|
|
} |
1940 |
|
|
|
1941 |
|
|
|
1942 |
|
|
/********************************************************** |
1943 |
|
|
Function: deleteServiceConfirm |
1944 |
|
|
Author: Paul Bramscher |
1945 |
|
|
Last Modified: 04.21.2003 |
1946 |
|
|
*********************************************************** |
1947 |
|
|
Purpose: |
1948 |
|
|
Confirm prompt to delete the supplied service id. |
1949 |
|
|
**********************************************************/ |
1950 |
|
|
function deleteServiceConfirm($con, $key_id){ |
1951 |
|
|
|
1952 |
|
|
// Make sure we have a valid integer type |
1953 |
|
|
$service_id = (int) $key_id; |
1954 |
|
|
|
1955 |
|
|
printf("<center>\n"); |
1956 |
|
|
|
1957 |
|
|
// Check to see if its possible |
1958 |
|
|
$exists = existsRow($con, "service", "service_id", $service_id); |
1959 |
|
|
if ($exists > 0){ |
1960 |
|
|
|
1961 |
|
|
// Table |
1962 |
|
|
printf("<table width=\"60%%\" class=\"backLight\" border=\"1\" cellpadding=\"4\">\n"); |
1963 |
|
|
|
1964 |
|
|
// Row header |
1965 |
|
|
printf("<tr><td class=\"cellPlain\">\n"); |
1966 |
|
|
printf("Delete Service ID# %s?", $service_id); |
1967 |
|
|
printf("</td></tr>\n"); |
1968 |
|
|
printf("<tr><td>\n"); |
1969 |
|
|
|
1970 |
|
|
// Lookup the descriptive title |
1971 |
|
|
$service = lookupField($con, "service", "service_id", $service_id, "service"); |
1972 |
|
|
printf("<b>Service:</b> %s<br><br>\n ", $service); |
1973 |
|
|
|
1974 |
|
|
// Form to draw the delete button |
1975 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1976 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteService\" >\n"); |
1977 |
|
|
printf("<input type = \"Hidden\" name = \"service_id\" value = \"%d\" >\n", $service_id); |
1978 |
|
|
|
1979 |
|
|
// Delete message |
1980 |
|
|
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
1981 |
|
|
printf("<input type=\"text\" name=\"delMessage\" value=\"[Service no longer available]\" size=\"75\"><br><br>\n"); |
1982 |
|
|
|
1983 |
|
|
// Warning |
1984 |
|
|
printf("This will <b>permanently</b> remove the service and its various assignments from the system.<BR><BR>\n"); |
1985 |
|
|
|
1986 |
|
|
// Delete button |
1987 |
|
|
printf("<center>\n"); |
1988 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1989 |
|
|
printf("</center>\n"); |
1990 |
|
|
printf("</form><br>\n"); |
1991 |
|
|
|
1992 |
|
|
// Close table |
1993 |
|
|
printf("</td></tr></table>\n"); |
1994 |
|
|
printf("<BR>\n"); |
1995 |
|
|
} |
1996 |
|
|
|
1997 |
|
|
// Failed for whatever reason |
1998 |
|
|
else if ($exists < 1) printf ("Service #%d not found. Operation cancelled.<br><br>\n", $service_id); |
1999 |
|
|
|
2000 |
|
|
printf("</center>\n"); |
2001 |
|
|
} |
2002 |
|
|
|
2003 |
|
|
|
2004 |
|
|
/********************************************************** |
2005 |
|
|
Function: deleteServicetype |
2006 |
|
|
Author: Paul Bramscher |
2007 |
|
|
Last Modified: 04.21.2003 |
2008 |
|
|
*********************************************************** |
2009 |
|
|
Purpose: |
2010 |
|
|
Delete the supplied service type id. This will render |
2011 |
|
|
some services without a type, but this does not break |
2012 |
|
|
anything. |
2013 |
|
|
**********************************************************/ |
2014 |
|
|
function deleteServicetype($con, $servicetype_id){ |
2015 |
|
|
|
2016 |
|
|
// Draw form heading |
2017 |
|
|
printf("<center><h3>Deleting Service Type...</h3>"); |
2018 |
|
|
|
2019 |
|
|
// Table |
2020 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
2021 |
|
|
printf("<tr><td><br>"); |
2022 |
|
|
printf("<strong>Messages:</strong><br>"); |
2023 |
|
|
|
2024 |
|
|
// Cannot delete placeholder #1 |
2025 |
|
|
if ($servicetype_id > 1) { |
2026 |
|
|
|
2027 |
|
|
// Delete from servicetype table |
2028 |
|
|
$sql = "DELETE FROM servicetype WHERE servicetype_id =" . $servicetype_id; |
2029 |
|
|
|
2030 |
|
|
if (!mysql_query ($sql, $con)){ |
2031 |
|
|
$problem = 1; |
2032 |
|
|
sql_err($sql); |
2033 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2034 |
|
|
bailout(); |
2035 |
|
|
} |
2036 |
|
|
else { |
2037 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2038 |
|
|
printf("Removed Service Type successfully.<BR><BR>\n"); |
2039 |
|
|
} |
2040 |
|
|
|
2041 |
|
|
} |
2042 |
|
|
|
2043 |
|
|
else printf("Cannot delete <b>Service Type ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
2044 |
|
|
|
2045 |
|
|
printf("</td></tr></table>"); |
2046 |
|
|
printf("</center>"); |
2047 |
|
|
} |
2048 |
|
|
|
2049 |
|
|
|
2050 |
|
|
/********************************************************** |
2051 |
|
|
Function: deleteServicetypeConfirm |
2052 |
|
|
Author: Paul Bramscher |
2053 |
|
|
Last Modified: 04.21.2003 |
2054 |
|
|
*********************************************************** |
2055 |
|
|
Purpose: |
2056 |
|
|
Confirm prompt to delete the supplied service type id. |
2057 |
|
|
**********************************************************/ |
2058 |
|
|
function deleteServicetypeConfirm($con, $key_id){ |
2059 |
|
|
|
2060 |
|
|
// Make sure we have a valid integer type |
2061 |
|
|
$servicetype_id = (int) $key_id; |
2062 |
|
|
|
2063 |
|
|
printf("<center>\n"); |
2064 |
|
|
|
2065 |
|
|
// Check to see if its possible |
2066 |
|
|
$exists = existsRow($con, "servicetype", "servicetype_id", $servicetype_id); |
2067 |
|
|
if ($exists > 0){ |
2068 |
|
|
|
2069 |
|
|
// Table |
2070 |
|
|
printf("<table width=\"60%%\" class=\"backLight\" border=\"1\" cellpadding=\"4\">\n"); |
2071 |
|
|
|
2072 |
|
|
// Row header |
2073 |
|
|
printf("<tr><td class=\"cellPlain\">\n"); |
2074 |
|
|
printf("Delete Service Type ID# %s?", $servicetype_id); |
2075 |
|
|
printf("</td></tr>\n"); |
2076 |
|
|
printf("<tr><td>\n"); |
2077 |
|
|
|
2078 |
|
|
// Lookup the descriptive title |
2079 |
|
|
$servicetype = lookupField($con, "servicetype", "servicetype_id", $servicetype_id, "servicetype"); |
2080 |
|
|
printf("<b>Service Type:</b> %s<br><br>\n ", $servicetype); |
2081 |
|
|
|
2082 |
|
|
// Form to draw the delete button |
2083 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
2084 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteServicetype\" >\n"); |
2085 |
|
|
printf("<input type = \"Hidden\" name = \"servicetype_id\" value = \"%d\" >\n", $servicetype_id); |
2086 |
|
|
|
2087 |
|
|
// Warning |
2088 |
|
|
printf("This will <b>permanently</b> remove this Service Type. Note that Services which rely exlusively on this Service Type will be left without a Service Type.<br><br>\n"); |
2089 |
|
|
|
2090 |
|
|
// Delete button |
2091 |
|
|
printf("<center>\n"); |
2092 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
2093 |
|
|
printf("</center>\n"); |
2094 |
|
|
printf("</form><br>\n"); |
2095 |
|
|
|
2096 |
|
|
// Close table |
2097 |
|
|
printf("</td></tr></table>\n"); |
2098 |
|
|
printf("<BR>\n"); |
2099 |
|
|
} |
2100 |
|
|
|
2101 |
|
|
// Failed for whatever reason |
2102 |
|
|
else if ($exists < 1) printf ("Service Type #%d not found. Operation cancelled.<br><br>\n", $servicetype_id); |
2103 |
|
|
|
2104 |
|
|
printf("</center>\n"); |
2105 |
|
|
} |
2106 |
|
|
|
2107 |
|
|
|
2108 |
|
|
/********************************************************** |
2109 |
|
|
Function: deleteServLoc |
2110 |
|
|
Author: Paul Bramscher |
2111 |
|
|
Last Modified: 04.21.2003 |
2112 |
|
|
*********************************************************** |
2113 |
|
|
Purpose: |
2114 |
|
|
Deletes service-location associations based on the supplied |
2115 |
|
|
location id (possibly multiple) and calls formService back |
2116 |
|
|
again. |
2117 |
|
|
**********************************************************/ |
2118 |
|
|
function deleteServLoc($con, $key_list_array, $service_id){ |
2119 |
|
|
|
2120 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2121 |
|
|
|
2122 |
|
|
$sql = "DELETE FROM serv_loc WHERE service_id = " |
2123 |
|
|
. $service_id |
2124 |
|
|
. " AND location_id = " |
2125 |
|
|
. $key_list_array[$element]; |
2126 |
|
|
|
2127 |
|
|
// Failed |
2128 |
|
|
if (!mysql_query ($sql, $con)){ |
2129 |
|
|
sql_err($sql); |
2130 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2131 |
|
|
bailout(); |
2132 |
|
|
} |
2133 |
|
|
|
2134 |
|
|
// Succeeded |
2135 |
|
|
else { |
2136 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2137 |
|
|
} |
2138 |
|
|
} |
2139 |
|
|
// Call the service form back |
2140 |
|
|
formService($con, $service_id, 0, 0); |
2141 |
|
|
} |
2142 |
|
|
|
2143 |
|
|
|
2144 |
|
|
/********************************************************** |
2145 |
|
|
Function: deleteServServtype |
2146 |
|
|
Author: Paul Bramscher |
2147 |
|
|
Last Modified: 04.21.2003 |
2148 |
|
|
*********************************************************** |
2149 |
|
|
Purpose: |
2150 |
|
|
Deletes service-servicetype associations based on the |
2151 |
|
|
supplied servicetype id (possibly multiple) and calls |
2152 |
|
|
formService back again. |
2153 |
|
|
**********************************************************/ |
2154 |
|
|
function deleteServServtype($con, $key_list_array, $service_id){ |
2155 |
|
|
|
2156 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2157 |
|
|
|
2158 |
|
|
$sql = "DELETE FROM serv_servtype WHERE service_id = " |
2159 |
|
|
. $service_id |
2160 |
|
|
. " AND servicetype_id = " |
2161 |
|
|
. $key_list_array[$element]; |
2162 |
|
|
|
2163 |
|
|
// Failed |
2164 |
|
|
if (!mysql_query ($sql, $con)){ |
2165 |
|
|
sql_err($sql); |
2166 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2167 |
|
|
bailout(); |
2168 |
|
|
} |
2169 |
|
|
|
2170 |
|
|
// Succeeded |
2171 |
|
|
else { |
2172 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2173 |
|
|
} |
2174 |
|
|
} |
2175 |
|
|
// Call the service form back |
2176 |
|
|
formService($con, $service_id, 0, 0); |
2177 |
|
|
} |
2178 |
|
|
|
2179 |
|
|
|
2180 |
|
|
/********************************************************** |
2181 |
|
|
Function: deleteSubCoursesub |
2182 |
|
|
Author: Paul Bramscher |
2183 |
|
|
Last Modified: 06.04.2003 |
2184 |
|
|
*********************************************************** |
2185 |
|
|
Purpose: |
2186 |
|
|
Deletes subject-coursesub associations based on the supplied |
2187 |
|
|
coursesub id (possibly multiple) and calls formSubject back |
2188 |
|
|
again. |
2189 |
|
|
**********************************************************/ |
2190 |
|
|
function deleteSubCoursesub($con, $key_list_array, $subject_id){ |
2191 |
|
|
|
2192 |
|
|
// For the given subject, delete every location in the array |
2193 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2194 |
|
|
|
2195 |
|
|
$sql = "DELETE FROM sub_coursesub WHERE subject_id = " |
2196 |
|
|
. $subject_id |
2197 |
|
|
. " AND coursesub_id = " |
2198 |
|
|
. $key_list_array[$element]; |
2199 |
|
|
|
2200 |
|
|
// Failed |
2201 |
|
|
if (!mysql_query ($sql, $con)){ |
2202 |
|
|
sql_err($sql); |
2203 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2204 |
|
|
bailout(); |
2205 |
|
|
} |
2206 |
|
|
|
2207 |
|
|
// Succeeded |
2208 |
|
|
else { |
2209 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2210 |
|
|
} |
2211 |
|
|
} |
2212 |
|
|
// Call the subject form back |
2213 |
|
|
formSubject($con, $subject_id); |
2214 |
|
|
} |
2215 |
|
|
|
2216 |
|
|
|
2217 |
|
|
/********************************************************** |
2218 |
|
|
Function: deleteSubject |
2219 |
|
|
Author: Paul Bramscher |
2220 |
|
|
Last Modified: 06.17.2003 |
2221 |
|
|
*********************************************************** |
2222 |
|
|
Purpose: |
2223 |
|
|
Deletes a subject, and removes associations in the |
2224 |
|
|
resource-subject-informationtype, subject-location, |
2225 |
|
|
subject-mastersubject, subject-coursesub, and |
2226 |
|
|
subject-staff tables. |
2227 |
|
|
**********************************************************/ |
2228 |
|
|
function deleteSubject($con, $delMessage, $subject_id){ |
2229 |
|
|
|
2230 |
|
|
// Draw form heading |
2231 |
|
|
printf("<center><h3>Deleting Subject...</h3>"); |
2232 |
|
|
|
2233 |
|
|
// Table |
2234 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
2235 |
|
|
printf("<tr><td><br>"); |
2236 |
|
|
printf("<strong>Messages:</strong><br>"); |
2237 |
|
|
|
2238 |
|
|
// Problem flag for each delete step |
2239 |
|
|
$problem = 0; |
2240 |
|
|
|
2241 |
|
|
// Cannot delete placeholder #1 |
2242 |
|
|
if ($subject_id > 1) { |
2243 |
|
|
// First delete all related rows in res_sub_infotype |
2244 |
|
|
$sql = "DELETE FROM res_sub_infotype WHERE subject_id = " . $subject_id; |
2245 |
|
|
|
2246 |
|
|
if (!mysql_query ($sql, $con)){ |
2247 |
|
|
$problem = 1; |
2248 |
|
|
sql_err($sql); |
2249 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2250 |
|
|
bailout(); |
2251 |
|
|
} |
2252 |
|
|
else { |
2253 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2254 |
|
|
printf("Resource-subject-information type associations removed.<BR>\n"); |
2255 |
|
|
} |
2256 |
|
|
|
2257 |
|
|
// Delete from the sub_loc table |
2258 |
|
|
if ($problem == 0) { |
2259 |
|
|
$sql = "DELETE FROM sub_loc WHERE subject_id =" . $subject_id; |
2260 |
|
|
|
2261 |
|
|
if (!mysql_query ($sql, $con)){ |
2262 |
|
|
$problem = 1; |
2263 |
|
|
sql_err($sql); |
2264 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2265 |
|
|
bailout(); |
2266 |
|
|
} |
2267 |
|
|
else { |
2268 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2269 |
|
|
printf("Subject-location associations removed.<BR>\n"); |
2270 |
|
|
} |
2271 |
|
|
} |
2272 |
|
|
|
2273 |
|
|
// Delete from the sub_mastersubject table |
2274 |
|
|
if ($problem == 0) { |
2275 |
|
|
$sql = "DELETE FROM sub_mastersubject WHERE subject_id =" . $subject_id; |
2276 |
|
|
|
2277 |
|
|
if (!mysql_query ($sql, $con)){ |
2278 |
|
|
$problem = 1; |
2279 |
|
|
sql_err($sql); |
2280 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2281 |
|
|
bailout(); |
2282 |
|
|
} |
2283 |
|
|
else { |
2284 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2285 |
|
|
printf("Subject-mastersubject associations removed.<BR>\n"); |
2286 |
|
|
|
2287 |
|
|
} |
2288 |
|
|
} |
2289 |
|
|
|
2290 |
|
|
// Delete from the sub_staff table |
2291 |
|
|
if ($problem == 0) { |
2292 |
|
|
$sql = "DELETE FROM sub_staff WHERE subject_id =" . $subject_id; |
2293 |
|
|
|
2294 |
|
|
if (!mysql_query ($sql, $con)){ |
2295 |
|
|
$problem = 1; |
2296 |
|
|
sql_err($sql); |
2297 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2298 |
|
|
bailout(); |
2299 |
|
|
} |
2300 |
|
|
else { |
2301 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2302 |
|
|
printf("Subject-staff assignments removed.<BR>\n"); |
2303 |
|
|
|
2304 |
|
|
} |
2305 |
|
|
} |
2306 |
|
|
|
2307 |
|
|
// Delete from the sub_coursesub table |
2308 |
|
|
if ($problem == 0) { |
2309 |
|
|
$sql = "DELETE FROM sub_coursesub WHERE subject_id =" . $subject_id; |
2310 |
|
|
|
2311 |
|
|
if (!mysql_query ($sql, $con)){ |
2312 |
|
|
$problem = 1; |
2313 |
|
|
sql_err($sql); |
2314 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2315 |
|
|
bailout(); |
2316 |
|
|
} |
2317 |
|
|
else { |
2318 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2319 |
|
|
printf("Subject-Course Subject assignments removed.<BR>\n"); |
2320 |
|
|
|
2321 |
|
|
} |
2322 |
|
|
} |
2323 |
|
|
|
2324 |
|
|
// Delete from the sub_page table |
2325 |
|
|
if ($problem == 0) { |
2326 |
|
|
$sql = "DELETE FROM sub_page WHERE subject_id =" . $subject_id; |
2327 |
|
|
|
2328 |
|
|
if (!mysql_query ($sql, $con)){ |
2329 |
|
|
$problem = 1; |
2330 |
|
|
sql_err($sql); |
2331 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2332 |
|
|
bailout(); |
2333 |
|
|
} |
2334 |
|
|
else { |
2335 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2336 |
|
|
printf("Subject-Page assignments removed.<BR>\n"); |
2337 |
|
|
|
2338 |
|
|
} |
2339 |
|
|
} |
2340 |
|
|
|
2341 |
|
|
// Delete from the sub_othersub table |
2342 |
|
|
if ($problem == 0) { |
2343 |
|
|
$sql = "DELETE FROM sub_othersub WHERE othersub_id =" |
2344 |
|
|
. $subject_id |
2345 |
|
|
. " OR subject_id = " |
2346 |
|
|
. $subject_id; |
2347 |
|
|
|
2348 |
|
|
if (!mysql_query ($sql, $con)){ |
2349 |
|
|
$problem = 1; |
2350 |
|
|
sql_err($sql); |
2351 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2352 |
|
|
bailout(); |
2353 |
|
|
} |
2354 |
|
|
else { |
2355 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2356 |
|
|
printf("Subject-Other Subject assignments removed.<BR>\n"); |
2357 |
|
|
|
2358 |
|
|
} |
2359 |
|
|
} |
2360 |
|
|
|
2361 |
|
|
// Update affected PageScribe pages |
2362 |
|
|
if ($problem == 0) { |
2363 |
|
|
|
2364 |
|
|
// First, get the default subject description and title |
2365 |
|
|
$sql = "SELECT subject, subject_descr FROM subject WHERE subject_id = " |
2366 |
|
|
. $subject_id; |
2367 |
|
|
$rs = mysql_query($sql, $con); |
2368 |
|
|
$row = mysql_fetch_array ($rs); |
2369 |
|
|
$subject = $row["subject"]; |
2370 |
|
|
$subject_descr = $row["subject_descr"]; |
2371 |
|
|
|
2372 |
|
|
// Clean up strings |
2373 |
|
|
$subject_descr = textInmySQL($subject_descr); |
2374 |
|
|
$subject = textInmySQL($subject); |
2375 |
|
|
$delMessage = textInmySQL($delMessage); |
2376 |
|
|
|
2377 |
|
|
// Next, append the reason for deletion to the description |
2378 |
|
|
if (strlen($subject_descr) > 0) $subject_descr .= "<BR>" . $delMessage; |
2379 |
|
|
else $subject_descr = $delMessage; |
2380 |
|
|
|
2381 |
|
|
// Update all of the elements using this resource with a custom description. |
2382 |
|
|
$sql = "UPDATE element SET label = '" |
2383 |
|
|
. $subject |
2384 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
2385 |
|
|
. $delMessage |
2386 |
|
|
. "'), subject_id = NULL WHERE subject_id =" . $subject_id |
2387 |
|
|
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
2388 |
|
|
|
2389 |
|
|
if (!mysql_query ($sql, $con)){ |
2390 |
|
|
$problem = 1; |
2391 |
|
|
sql_err($sql); |
2392 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2393 |
|
|
bailout(); |
2394 |
|
|
} |
2395 |
|
|
else { |
2396 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2397 |
|
|
printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
2398 |
|
|
} |
2399 |
|
|
|
2400 |
|
|
|
2401 |
|
|
// Next, update all of the elements using this resource without a custom description. |
2402 |
|
|
$sql = "UPDATE element SET label = '" |
2403 |
|
|
. $subject |
2404 |
|
|
. "', element_descr = '" |
2405 |
|
|
. $subject_descr |
2406 |
|
|
. "', subject_id = NULL WHERE subject_id =" . $subject_id |
2407 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
2408 |
|
|
|
2409 |
|
|
if (!mysql_query ($sql, $con)){ |
2410 |
|
|
$problem = 1; |
2411 |
|
|
sql_err($sql); |
2412 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2413 |
|
|
bailout(); |
2414 |
|
|
} |
2415 |
|
|
else { |
2416 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2417 |
|
|
printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
2418 |
|
|
} |
2419 |
|
|
|
2420 |
|
|
|
2421 |
|
|
} |
2422 |
|
|
|
2423 |
|
|
|
2424 |
|
|
// Update affected PageScribe copy buffers |
2425 |
|
|
if ($problem == 0) { |
2426 |
|
|
|
2427 |
|
|
// Update all of the elements using this location with a custom description. |
2428 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
2429 |
|
|
. $subject |
2430 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
2431 |
|
|
. $delMessage |
2432 |
|
|
. "'), subject_id = NULL WHERE subject_id =" . $subject_id |
2433 |
|
|
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
2434 |
|
|
|
2435 |
|
|
if (!mysql_query ($sql, $con)){ |
2436 |
|
|
$problem = 1; |
2437 |
|
|
sql_err($sql); |
2438 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2439 |
|
|
bailout(); |
2440 |
|
|
} |
2441 |
|
|
else { |
2442 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2443 |
|
|
printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
2444 |
|
|
} |
2445 |
|
|
|
2446 |
|
|
|
2447 |
|
|
// Next, update all of the elements using this location without a custom description. |
2448 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
2449 |
|
|
. $subject |
2450 |
|
|
. "', element_descr = '" |
2451 |
|
|
. $subject_descr |
2452 |
|
|
. "', subject_id = NULL WHERE subject_id =" . $subject_id |
2453 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
2454 |
|
|
|
2455 |
|
|
if (!mysql_query ($sql, $con)){ |
2456 |
|
|
$problem = 1; |
2457 |
|
|
sql_err($sql); |
2458 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2459 |
|
|
bailout(); |
2460 |
|
|
} |
2461 |
|
|
else { |
2462 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2463 |
|
|
printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
2464 |
|
|
} |
2465 |
|
|
|
2466 |
|
|
|
2467 |
|
|
} |
2468 |
|
|
|
2469 |
|
|
// Finally delete from the subject table |
2470 |
|
|
if ($problem == 0) { |
2471 |
|
|
$sql = "DELETE FROM subject WHERE subject_id =" . $subject_id; |
2472 |
|
|
|
2473 |
|
|
if (!mysql_query ($sql, $con)){ |
2474 |
|
|
$problem = 1; |
2475 |
|
|
sql_err($sql); |
2476 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2477 |
|
|
bailout(); |
2478 |
|
|
} |
2479 |
|
|
else { |
2480 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2481 |
|
|
printf("Successfully removed this subject from the system.<BR><BR>\n"); |
2482 |
|
|
|
2483 |
|
|
} |
2484 |
|
|
} |
2485 |
|
|
} |
2486 |
|
|
else printf("Cannot delete <b>Subject ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
2487 |
|
|
|
2488 |
|
|
printf("</td></tr></table>"); |
2489 |
|
|
printf("</center>"); |
2490 |
|
|
} |
2491 |
|
|
|
2492 |
|
|
|
2493 |
|
|
/********************************************************** |
2494 |
|
|
Function: deleteSubjectConfirm |
2495 |
|
|
Author: Paul Bramscher |
2496 |
|
|
Last Modified: 06.11.2003 |
2497 |
|
|
*********************************************************** |
2498 |
|
|
Purpose: |
2499 |
|
|
Confirm prompt to delete the supplied subject id. |
2500 |
|
|
**********************************************************/ |
2501 |
|
|
function deleteSubjectConfirm($con, $key_id){ |
2502 |
|
|
|
2503 |
|
|
// Make sure we have a valid integer type |
2504 |
|
|
$subject_id = (int) $key_id; |
2505 |
|
|
|
2506 |
|
|
// Draw page heading |
2507 |
|
|
printf("<center><h3>Delete Subject ID# %s?</h3>", $subject_id); |
2508 |
|
|
|
2509 |
|
|
// Check to see if its possible |
2510 |
|
|
$exists = existsRow($con, "subject", "subject_id", $subject_id); |
2511 |
|
|
if ($exists > 0){ |
2512 |
|
|
|
2513 |
|
|
// Table |
2514 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
2515 |
|
|
printf("<tr><td>"); |
2516 |
|
|
|
2517 |
|
|
// Lookup the descriptive title |
2518 |
|
|
$subject = lookupField($con, "subject", "subject_id", $subject_id, "subject"); |
2519 |
|
|
printf("<strong>Subject:</strong> %s<br><br>\n ", $subject); |
2520 |
|
|
|
2521 |
|
|
// Form to draw the delete button |
2522 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
2523 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteSubject\" >"); |
2524 |
|
|
printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >", $subject_id); |
2525 |
|
|
|
2526 |
|
|
// Delete message |
2527 |
|
|
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
2528 |
|
|
printf("<input type=\"text\" name=\"delMessage\" value=\"[RQS subject no longer available]\" size=\"75\"><br><br>\n"); |
2529 |
|
|
|
2530 |
|
|
printf("This will <b>permanently</b> remove the subject and its various subject assignments from the system. |
2531 |
|
|
This includes assignments to resources, master/general subjects, locations and staff specialists.<BR><BR>"); |
2532 |
|
|
printf("<center>"); |
2533 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
2534 |
|
|
printf("</center>"); |
2535 |
|
|
printf("</form><br>"); |
2536 |
|
|
|
2537 |
|
|
// Close table |
2538 |
|
|
printf("</td></tr></table>"); |
2539 |
|
|
} |
2540 |
|
|
|
2541 |
|
|
// Failed for whatever reason |
2542 |
|
|
else if ($exists < 1) printf ("Subject not found. Operation cancelled.<br>\n"); |
2543 |
|
|
|
2544 |
|
|
printf("</center>"); |
2545 |
|
|
} |
2546 |
|
|
|
2547 |
|
|
|
2548 |
|
|
/********************************************************** |
2549 |
|
|
Function: deleteSubLoc |
2550 |
|
|
Author: Paul Bramscher |
2551 |
|
|
Last Modified: 04.21.2003 |
2552 |
|
|
*********************************************************** |
2553 |
|
|
Purpose: |
2554 |
|
|
Deletes subject-location associations based on the supplied |
2555 |
|
|
location id (possibly multiple) and calls formSubject back |
2556 |
|
|
again. |
2557 |
|
|
**********************************************************/ |
2558 |
|
|
function deleteSubLoc($con, $key_list_array, $subject_id){ |
2559 |
|
|
|
2560 |
|
|
// For the given subject, delete every location in the array |
2561 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2562 |
|
|
|
2563 |
|
|
$sql = "DELETE FROM sub_loc WHERE subject_id = " |
2564 |
|
|
. $subject_id |
2565 |
|
|
. " AND location_id = " |
2566 |
|
|
. $key_list_array[$element]; |
2567 |
|
|
|
2568 |
|
|
// Failed |
2569 |
|
|
if (!mysql_query ($sql, $con)){ |
2570 |
|
|
sql_err($sql); |
2571 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2572 |
|
|
bailout(); |
2573 |
|
|
} |
2574 |
|
|
|
2575 |
|
|
// Succeeded |
2576 |
|
|
else { |
2577 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2578 |
|
|
} |
2579 |
|
|
} |
2580 |
|
|
// Call the subject form back |
2581 |
|
|
formSubject($con, $subject_id); |
2582 |
|
|
} |
2583 |
|
|
|
2584 |
|
|
|
2585 |
|
|
/********************************************************** |
2586 |
|
|
Function: deleteSubMaster |
2587 |
|
|
Author: Paul Bramscher |
2588 |
|
|
Last Modified: 04.21.2003 |
2589 |
|
|
*********************************************************** |
2590 |
|
|
Purpose: |
2591 |
|
|
Deletes subject-mastersubject associations based on the |
2592 |
|
|
supplied mastersubject id (possibly multiple) and calls |
2593 |
|
|
formSubject back again. |
2594 |
|
|
**********************************************************/ |
2595 |
|
|
function deleteSubMaster($con, $key_list_array, $subject_id){ |
2596 |
|
|
|
2597 |
|
|
// For every mastersubject in the array, delete it from the bridging table |
2598 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2599 |
|
|
|
2600 |
|
|
$sql = "DELETE FROM sub_mastersubject WHERE subject_id = " |
2601 |
|
|
. $subject_id |
2602 |
|
|
. " AND mastersubject_id = " |
2603 |
|
|
. $key_list_array[$element]; |
2604 |
|
|
|
2605 |
|
|
// Failed |
2606 |
|
|
if (!mysql_query ($sql, $con)){ |
2607 |
|
|
sql_err($sql); |
2608 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2609 |
|
|
bailout(); |
2610 |
|
|
} |
2611 |
|
|
|
2612 |
|
|
// Succeeded |
2613 |
|
|
else { |
2614 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2615 |
|
|
} |
2616 |
|
|
} |
2617 |
|
|
// Call the subject form back |
2618 |
|
|
formSubject($con, $subject_id); |
2619 |
|
|
} |
2620 |
|
|
|
2621 |
|
|
|
2622 |
|
|
/********************************************************** |
2623 |
|
|
Function: deleteSubStaff |
2624 |
|
|
Author: Paul Bramscher |
2625 |
|
|
Last Modified: 04.21.2003 |
2626 |
|
|
*********************************************************** |
2627 |
|
|
Purpose: |
2628 |
|
|
Deletes staff-subject associations for the supplied staff |
2629 |
|
|
id (possibly multiple) and calls formSubject back again. |
2630 |
|
|
**********************************************************/ |
2631 |
|
|
function deleteSubStaff($con, $key_list_array, $subject_id){ |
2632 |
|
|
|
2633 |
|
|
// For a given subject, delete all staff in the array |
2634 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2635 |
|
|
|
2636 |
|
|
$sql = "DELETE FROM sub_staff WHERE subject_id = " |
2637 |
|
|
. $subject_id |
2638 |
|
|
. " AND staff_id = " |
2639 |
|
|
. $key_list_array[$element]; |
2640 |
|
|
|
2641 |
|
|
// Failed |
2642 |
|
|
if (!mysql_query ($sql, $con)){ |
2643 |
|
|
sql_err($sql); |
2644 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2645 |
|
|
bailout(); |
2646 |
|
|
} |
2647 |
|
|
|
2648 |
|
|
// Succeeded |
2649 |
|
|
else { |
2650 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2651 |
|
|
} |
2652 |
|
|
} |
2653 |
|
|
// Call the subject form back |
2654 |
|
|
formSubject($con, $subject_id); |
2655 |
|
|
} |
2656 |
|
|
|
2657 |
|
|
|
2658 |
|
|
/********************************************************** |
2659 |
|
|
Function: deleteLibunit |
2660 |
|
|
Author: Paul Bramscher |
2661 |
|
|
Last Modified: 04.29.2003 |
2662 |
|
|
*********************************************************** |
2663 |
|
|
Purpose: |
2664 |
|
|
Deletes the supplied libunit id, and any staff assignments |
2665 |
|
|
in that library unit. |
2666 |
|
|
**********************************************************/ |
2667 |
|
|
function deleteLibunit($con, $libunit_id){ |
2668 |
|
|
|
2669 |
|
|
// Draw form heading |
2670 |
|
|
printf("<center><h3>Deleting Library Unit...</h3>"); |
2671 |
|
|
|
2672 |
|
|
// Table |
2673 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
2674 |
|
|
printf("<tr><td><br>"); |
2675 |
|
|
printf("<strong>Messages:</strong><br>"); |
2676 |
|
|
|
2677 |
|
|
// Problem flag for each delete step |
2678 |
|
|
$problem = 0; |
2679 |
|
|
|
2680 |
|
|
// First delete from libunit_staff |
2681 |
|
|
if ($libunit_id > 1) { |
2682 |
|
|
$sql = "DELETE FROM libunit_staff WHERE libunit_id = " . $libunit_id; |
2683 |
|
|
|
2684 |
|
|
if (!mysql_query ($sql, $con)){ |
2685 |
|
|
$problem = 1; |
2686 |
|
|
sql_err($sql); |
2687 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2688 |
|
|
bailout(); |
2689 |
|
|
} |
2690 |
|
|
else { |
2691 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2692 |
|
|
printf("Deleted all Library Unit staff assignments.<BR>\n"); |
2693 |
|
|
} |
2694 |
|
|
|
2695 |
|
|
// Delete from the libunit table |
2696 |
|
|
if ($problem == 0) { |
2697 |
|
|
$sql = "DELETE FROM libunit WHERE libunit_id =" . $libunit_id; |
2698 |
|
|
|
2699 |
|
|
if (!mysql_query ($sql, $con)){ |
2700 |
|
|
$problem = 1; |
2701 |
|
|
sql_err($sql); |
2702 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2703 |
|
|
bailout(); |
2704 |
|
|
} |
2705 |
|
|
else { |
2706 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2707 |
|
|
printf("Removed this Library Unit successfully.<BR><BR>\n"); |
2708 |
|
|
} |
2709 |
|
|
} |
2710 |
|
|
|
2711 |
|
|
} |
2712 |
|
|
else printf("Cannot delete <b>Library Unit ID #1. It acts as a system placeholder.</b>.<br><br>\n"); |
2713 |
|
|
|
2714 |
|
|
printf("</td></tr></table>\n"); |
2715 |
|
|
printf("</center>\n"); |
2716 |
|
|
} |
2717 |
|
|
|
2718 |
|
|
|
2719 |
|
|
/********************************************************** |
2720 |
|
|
Function: deleteLibunitConfirm |
2721 |
|
|
Author: Paul Bramscher |
2722 |
|
|
Last Modified: 04.29.2003 |
2723 |
|
|
*********************************************************** |
2724 |
|
|
Purpose: |
2725 |
|
|
Confirm prompt for deleting the supplied libunit id. |
2726 |
|
|
**********************************************************/ |
2727 |
|
|
function deleteLibunitConfirm($con, $key_id){ |
2728 |
|
|
|
2729 |
|
|
// Make sure we have a valid integer type |
2730 |
|
|
$libunit_id = (int) $key_id; |
2731 |
|
|
|
2732 |
|
|
// Draw page heading |
2733 |
|
|
printf("<center><h3>Delete Libunit ID# %s?</h3>", $libunit_id); |
2734 |
|
|
|
2735 |
|
|
// Check to see if its possible |
2736 |
|
|
$exists = existsRow($con, "libunit", "libunit_id", $libunit_id); |
2737 |
|
|
if ($exists > 0){ |
2738 |
|
|
|
2739 |
|
|
// Table |
2740 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
2741 |
|
|
printf("<tr><td>"); |
2742 |
|
|
|
2743 |
|
|
// Lookup the descriptive title |
2744 |
|
|
$libunit = lookupField($con, "libunit", "libunit_id", $libunit_id, "libunit"); |
2745 |
|
|
printf("<strong>Libunit:</strong> %s<br>\n ", $libunit); |
2746 |
|
|
|
2747 |
|
|
// Form to draw the delete button |
2748 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
2749 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteLibunit\" >"); |
2750 |
|
|
printf("<input type = \"Hidden\" name = \"libunit_id\" value = \"%d\" >", $libunit_id); |
2751 |
|
|
printf("This will <b>permanently</b> remove this Library Unit from the system. This may render some staff without a unit.<BR><BR>"); |
2752 |
|
|
printf("<center>"); |
2753 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
2754 |
|
|
printf("</center>"); |
2755 |
|
|
printf("</form><br>"); |
2756 |
|
|
|
2757 |
|
|
// Close table |
2758 |
|
|
printf("</td></tr></table>"); |
2759 |
|
|
} |
2760 |
|
|
|
2761 |
|
|
// Failed for whatever reason |
2762 |
|
|
else if ($exists < 1) printf ("Unit not found. Operation cancelled.<br>\n"); |
2763 |
|
|
|
2764 |
|
|
printf("</center>"); |
2765 |
|
|
} |
2766 |
|
|
|
2767 |
|
|
|
2768 |
|
|
/********************************************************** |
2769 |
|
|
Function: deleteLibunitStaff |
2770 |
|
|
Author: Paul Bramscher |
2771 |
|
|
Last Modified: 12.09.2002 |
2772 |
|
|
*********************************************************** |
2773 |
|
|
Purpose: |
2774 |
|
|
Deletes staffperson assignments (possibly multiple) to the |
2775 |
|
|
supplied libunit id and calls formLibunit back again. |
2776 |
|
|
**********************************************************/ |
2777 |
|
|
function deleteLibunitStaff($con, $key_list_array, $libunit_id){ |
2778 |
|
|
|
2779 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2780 |
|
|
$sql = "DELETE FROM libunit_staff WHERE libunit_id = " |
2781 |
|
|
. $libunit_id |
2782 |
|
|
. " AND staff_id = " |
2783 |
|
|
. $key_list_array[$element]; |
2784 |
|
|
|
2785 |
|
|
// Failed |
2786 |
|
|
if (!mysql_query ($sql, $con)){ |
2787 |
|
|
sql_err($sql); |
2788 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2789 |
|
|
bailout(); |
2790 |
|
|
} |
2791 |
|
|
|
2792 |
|
|
// Succeeded |
2793 |
|
|
else { |
2794 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2795 |
|
|
} |
2796 |
|
|
} |
2797 |
|
|
// Call the libunit form back |
2798 |
|
|
formLibunit($con, $libunit_id); |
2799 |
|
|
} |
2800 |
|
|
|
2801 |
|
|
|
2802 |
|
|
/********************************************************** |
2803 |
|
|
Function: deleteStaff |
2804 |
|
|
Author: Paul Bramscher |
2805 |
|
|
Last Modified: 04.29.2003 |
2806 |
|
|
*********************************************************** |
2807 |
|
|
Purpose: |
2808 |
|
|
Deletes the supplied staff id. This function purges the |
2809 |
|
|
staffperson in various places of the system, and converts |
2810 |
|
|
any staffpersons-as-elements on PageScribe/CourseLib+ pages |
2811 |
|
|
intoto text-type fields (non-relational). The same is done |
2812 |
|
|
across all user copy-paste buffers. |
2813 |
|
|
**********************************************************/ |
2814 |
|
|
function deleteStaff($con, $delMessage, $staff_id){ |
2815 |
|
|
|
2816 |
|
|
// Draw form heading |
2817 |
|
|
printf("<center><h3>Deleting Staff Person...</h3>"); |
2818 |
|
|
|
2819 |
|
|
// Table |
2820 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
2821 |
|
|
printf("<tr><td><br>"); |
2822 |
|
|
printf("<strong>Messages:</strong><br>"); |
2823 |
|
|
|
2824 |
|
|
// Success flag for each delete step |
2825 |
|
|
// Can't delete myself (#2) or the '(N/A)' staff (#1) |
2826 |
|
|
if ($staff_id < 3) $problem = 2; |
2827 |
|
|
else $problem = 0; |
2828 |
|
|
|
2829 |
|
|
// First delete all related rows in sub_staff |
2830 |
|
|
if ($problem == 0) { |
2831 |
|
|
|
2832 |
|
|
$sql = "DELETE FROM sub_staff WHERE staff_id = " . $staff_id; |
2833 |
|
|
|
2834 |
|
|
if (!mysql_query ($sql, $con)){ |
2835 |
|
|
$problem = 1; |
2836 |
|
|
sql_err($sql); |
2837 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2838 |
|
|
bailout(); |
2839 |
|
|
} |
2840 |
|
|
else { |
2841 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2842 |
|
|
printf("All subject-staff assignments for this staff person removed.<BR>\n"); |
2843 |
|
|
} |
2844 |
|
|
} |
2845 |
|
|
|
2846 |
|
|
// Delete from the course_personnel table |
2847 |
|
|
if ($problem == 0) { |
2848 |
|
|
$sql = "DELETE FROM course_personnel WHERE staff_id =" . $staff_id; |
2849 |
|
|
|
2850 |
|
|
if (!mysql_query ($sql, $con)){ |
2851 |
|
|
$problem = 1; |
2852 |
|
|
sql_err($sql); |
2853 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2854 |
|
|
bailout(); |
2855 |
|
|
} |
2856 |
|
|
else { |
2857 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2858 |
|
|
printf("Removed this staff person from course personnel tables.<BR>\n"); |
2859 |
|
|
} |
2860 |
|
|
} // delete from course_personnel table |
2861 |
|
|
|
2862 |
|
|
// Delete all related rows in page_staff |
2863 |
|
|
if ($problem == 0) { |
2864 |
|
|
|
2865 |
|
|
$sql = "DELETE FROM page_staff WHERE staff_id = " . $staff_id; |
2866 |
|
|
|
2867 |
|
|
if (!mysql_query ($sql, $con)){ |
2868 |
|
|
$problem = 1; |
2869 |
|
|
sql_err($sql); |
2870 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2871 |
|
|
bailout(); |
2872 |
|
|
} |
2873 |
|
|
else { |
2874 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2875 |
|
|
printf("All page-staff assignments for this staff person removed.<BR>\n"); |
2876 |
|
|
} |
2877 |
|
|
} |
2878 |
|
|
|
2879 |
|
|
// Update affected PageScribe pages |
2880 |
|
|
if ($problem == 0) { |
2881 |
|
|
|
2882 |
|
|
// First, get the staff fields |
2883 |
|
|
$sql = "SELECT first_name, last_name FROM staff WHERE staff_id = " |
2884 |
|
|
. $staff_id; |
2885 |
|
|
$rs = mysql_query($sql, $con); |
2886 |
|
|
$row = mysql_fetch_array ($rs); |
2887 |
|
|
$first_name = $row["first_name"]; |
2888 |
|
|
$last_name = $row["last_name"]; |
2889 |
|
|
|
2890 |
|
|
// Clean up strings |
2891 |
|
|
$first_name = textInmySQL($first_name); |
2892 |
|
|
$last_name = textInmySQL($last_name); |
2893 |
|
|
$delMessage = textInmySQL($delMessage); |
2894 |
|
|
|
2895 |
|
|
// Build a concatenated name |
2896 |
|
|
if (strlen($first_name) > 0) $staff_name = $first_name . " " . $last_name; |
2897 |
|
|
else $staff_name = $last_name; |
2898 |
|
|
|
2899 |
|
|
// Update all of the elements using this staffperson with a custom description |
2900 |
|
|
$sql = "UPDATE element SET label = '" |
2901 |
|
|
. $staff_name |
2902 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
2903 |
|
|
. $delMessage |
2904 |
|
|
. "'), staff_id = NULL WHERE staff_id =" . $staff_id |
2905 |
|
|
. " AND element_descr IS NOT NULL AND element_descr <> ''"; |
2906 |
|
|
|
2907 |
|
|
if (!mysql_query ($sql, $con)){ |
2908 |
|
|
$problem = 1; |
2909 |
|
|
sql_err($sql); |
2910 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2911 |
|
|
bailout(); |
2912 |
|
|
} |
2913 |
|
|
else { |
2914 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2915 |
|
|
printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
2916 |
|
|
} |
2917 |
|
|
} |
2918 |
|
|
|
2919 |
|
|
// Handle blank staff description elements |
2920 |
|
|
if ($problem == 0) { |
2921 |
|
|
|
2922 |
|
|
$sql = "UPDATE element SET label = '" |
2923 |
|
|
. $staff_name |
2924 |
|
|
. "', element_descr = '" |
2925 |
|
|
. $delMessage |
2926 |
|
|
. "', staff_id = NULL WHERE staff_id =" . $staff_id |
2927 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
2928 |
|
|
|
2929 |
|
|
if (!mysql_query ($sql, $con)){ |
2930 |
|
|
$problem = 1; |
2931 |
|
|
sql_err($sql); |
2932 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2933 |
|
|
bailout(); |
2934 |
|
|
} |
2935 |
|
|
else { |
2936 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2937 |
|
|
printf("Added delete message to blank PageScribe descriptions.<BR>\n"); |
2938 |
|
|
} |
2939 |
|
|
|
2940 |
|
|
} |
2941 |
|
|
|
2942 |
|
|
// Update affected PageScribe buffers |
2943 |
|
|
if ($problem == 0) { |
2944 |
|
|
|
2945 |
|
|
// Update all of the elements using this staffperson with a custom description |
2946 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
2947 |
|
|
. $staff_name |
2948 |
|
|
. "', element_descr = CONCAT(element_descr, '<BR>" |
2949 |
|
|
. $delMessage |
2950 |
|
|
. "'), staff_id = NULL WHERE staff_id =" . $staff_id |
2951 |
|
|
. " AND element_descr IS NOT NULL AND element_descr <> ''"; |
2952 |
|
|
|
2953 |
|
|
if (!mysql_query ($sql, $con)){ |
2954 |
|
|
$problem = 1; |
2955 |
|
|
sql_err($sql); |
2956 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2957 |
|
|
bailout(); |
2958 |
|
|
} |
2959 |
|
|
else { |
2960 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2961 |
|
|
printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
2962 |
|
|
} |
2963 |
|
|
} |
2964 |
|
|
|
2965 |
|
|
// Handle blank staff description pastebuffer elements |
2966 |
|
|
if ($problem == 0) { |
2967 |
|
|
|
2968 |
|
|
$sql = "UPDATE pastebuffer SET label = '" |
2969 |
|
|
. $staff_name |
2970 |
|
|
. "', element_descr = '" |
2971 |
|
|
. $delMessage |
2972 |
|
|
. "', staff_id = NULL WHERE staff_id =" . $staff_id |
2973 |
|
|
. " AND (element_descr IS NULL OR element_descr = '')"; |
2974 |
|
|
|
2975 |
|
|
if (!mysql_query ($sql, $con)){ |
2976 |
|
|
$problem = 1; |
2977 |
|
|
sql_err($sql); |
2978 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2979 |
|
|
bailout(); |
2980 |
|
|
} |
2981 |
|
|
else { |
2982 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2983 |
|
|
printf("Added delete message to blank PageScribe descriptions.<BR>\n"); |
2984 |
|
|
} |
2985 |
|
|
|
2986 |
|
|
} |
2987 |
|
|
|
2988 |
|
|
// Delete from the staff table |
2989 |
|
|
if ($problem == 0) { |
2990 |
|
|
$sql = "DELETE FROM staff WHERE staff_id =" . $staff_id; |
2991 |
|
|
|
2992 |
|
|
if (!mysql_query ($sql, $con)){ |
2993 |
|
|
$problem = 1; |
2994 |
|
|
sql_err($sql); |
2995 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2996 |
|
|
bailout(); |
2997 |
|
|
} |
2998 |
|
|
else { |
2999 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3000 |
|
|
printf("Removed this staff person successfully.<BR><BR>\n"); |
3001 |
|
|
} |
3002 |
|
|
} // delete from staff table |
3003 |
|
|
|
3004 |
|
|
if ($problem == 2) printf("Cannot delete <b>Staff ID's #1-2</b>.<br><br>\n"); |
3005 |
|
|
|
3006 |
|
|
// Close the table |
3007 |
|
|
printf("</td></tr></table>\n"); |
3008 |
|
|
printf("</center><br>\n"); |
3009 |
|
|
|
3010 |
|
|
} // end function |
3011 |
|
|
|
3012 |
|
|
|
3013 |
|
|
/********************************************************** |
3014 |
|
|
Function: deleteStaffConfirm |
3015 |
|
|
Author: Paul Bramscher |
3016 |
|
|
Last Modified: 04.29.2003 |
3017 |
|
|
*********************************************************** |
3018 |
|
|
Purpose: |
3019 |
|
|
Confirm prompt to delete the supplied staff id. This |
3020 |
|
|
function also collects a "delete message" which is concatenated |
3021 |
|
|
to the description on affected PageScribe/CourseLib+ pages |
3022 |
|
|
as the staffperson is converted from a relational to a |
3023 |
|
|
text-type element. |
3024 |
|
|
**********************************************************/ |
3025 |
|
|
function deleteStaffConfirm($con, $staff_id){ |
3026 |
|
|
|
3027 |
|
|
// Make sure we have a valid integer type |
3028 |
|
|
$staff_id = (int) $staff_id; |
3029 |
|
|
|
3030 |
|
|
printf("<center>\n"); |
3031 |
|
|
|
3032 |
|
|
// Check to see if its possible |
3033 |
|
|
$exists = existsRow($con, "staff", "staff_id", $staff_id); |
3034 |
|
|
if ($exists > 0){ |
3035 |
|
|
|
3036 |
|
|
// Table |
3037 |
|
|
printf("<table width=\"60%%\" class=\"backLight\" border=\"1\" cellpadding=\"4\">\n"); |
3038 |
|
|
|
3039 |
|
|
// Row header |
3040 |
|
|
printf("<tr><td class=\"cellPlain\">\n"); |
3041 |
|
|
printf("Delete Staff ID# %s?", $staff_id); |
3042 |
|
|
printf("</td></tr>\n"); |
3043 |
|
|
printf("<tr><td>\n"); |
3044 |
|
|
|
3045 |
|
|
// Lookup the first and last names |
3046 |
|
|
$first_name = lookupField($con, "staff", "staff_id", $staff_id, "first_name"); |
3047 |
|
|
$last_name = lookupField($con, "staff", "staff_id", $staff_id, "last_name"); |
3048 |
|
|
printf("<b>Staffperson:</b> %s %s<br><br>\n ", $first_name, $last_name); |
3049 |
|
|
|
3050 |
|
|
// Form to draw the delete button |
3051 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
3052 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteStaff\" >\n"); |
3053 |
|
|
printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >\n", $staff_id); |
3054 |
|
|
|
3055 |
|
|
// Delete message |
3056 |
|
|
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
3057 |
|
|
printf("<input type=\"text\" name=\"delMessage\" value=\"[Staffperson no longer available]\" size=\"75\"><br><br>\n"); |
3058 |
|
|
|
3059 |
|
|
// Warning |
3060 |
|
|
printf("This will <b>permanently</b> remove this staffperson and his/her various assignments from the system.<BR><BR>\n"); |
3061 |
|
|
|
3062 |
|
|
// Delete button |
3063 |
|
|
printf("<center>\n"); |
3064 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
3065 |
|
|
printf("</center>\n"); |
3066 |
|
|
printf("</form><br>\n"); |
3067 |
|
|
|
3068 |
|
|
// Close table |
3069 |
|
|
printf("</td></tr></table>\n"); |
3070 |
|
|
printf("<BR>\n"); |
3071 |
|
|
} |
3072 |
|
|
|
3073 |
|
|
// Failed for whatever reason |
3074 |
|
|
else if ($exists < 1) printf ("Staff #%d not found. Operation cancelled.<br><br>\n", $staff_id); |
3075 |
|
|
|
3076 |
|
|
printf("</center>\n"); |
3077 |
|
|
} |
3078 |
|
|
|
3079 |
|
|
|
3080 |
|
|
/********************************************************** |
3081 |
|
|
Function: deleteStaffLibunit |
3082 |
|
|
Author: Paul Bramscher |
3083 |
|
|
Last Modified: 12.09.2002 |
3084 |
|
|
*********************************************************** |
3085 |
|
|
Purpose: |
3086 |
|
|
Delete the staff-libunit associations (possibly multiple) |
3087 |
|
|
for the supplied staff id, then calls formStaff back again. |
3088 |
|
|
This works the same table as deleteLibunitStaff, but with |
3089 |
|
|
emphasis on the other side of the multiple pick list. |
3090 |
|
|
**********************************************************/ |
3091 |
|
|
function deleteStaffLibunit($con, $key_list_array, $staff_id){ |
3092 |
|
|
|
3093 |
|
|
// For every libunit in the array, delete it from the bridging table |
3094 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
3095 |
|
|
|
3096 |
|
|
$sql = "DELETE FROM libunit_staff WHERE staff_id = " |
3097 |
|
|
. $staff_id |
3098 |
|
|
. " AND libunit_id = " |
3099 |
|
|
. $key_list_array[$element]; |
3100 |
|
|
|
3101 |
|
|
// Failed |
3102 |
|
|
if (!mysql_query ($sql, $con)){ |
3103 |
|
|
sql_err($sql); |
3104 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3105 |
|
|
bailout(); |
3106 |
|
|
} |
3107 |
|
|
|
3108 |
|
|
// Succeeded |
3109 |
|
|
else { |
3110 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3111 |
|
|
} |
3112 |
|
|
} |
3113 |
|
|
// Call the staff form back |
3114 |
|
|
formStaff($con, $staff_id); |
3115 |
|
|
} |
3116 |
|
|
|
3117 |
|
|
|
3118 |
|
|
/********************************************************** |
3119 |
|
|
Function: deleteStaffSub |
3120 |
|
|
Author: Paul Bramscher |
3121 |
|
|
Last Modified: 04.29.2003 |
3122 |
|
|
*********************************************************** |
3123 |
|
|
Purpose: |
3124 |
|
|
Deletes the staff-subject associations (possibly multiple) |
3125 |
|
|
for the supplied staff id, and calls formStaff back again. |
3126 |
|
|
This works the same table as deleteSubStaff (found in |
3127 |
|
|
application.php, not this ssl counterpart), but with |
3128 |
|
|
emphasis on the other side of the multiple pick list. |
3129 |
|
|
**********************************************************/ |
3130 |
|
|
function deleteStaffSub($con, $key_list_array, $staff_id){ |
3131 |
|
|
|
3132 |
|
|
// For a given staff person, delete every associated subject in the array |
3133 |
|
|
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
3134 |
|
|
|
3135 |
|
|
$sql = "DELETE FROM sub_staff where staff_id = " |
3136 |
|
|
. $staff_id |
3137 |
|
|
. " AND subject_id = " |
3138 |
|
|
. $key_list_array[$element]; |
3139 |
|
|
|
3140 |
|
|
// Failed |
3141 |
|
|
if (!mysql_query ($sql, $con)){ |
3142 |
|
|
sql_err($sql); |
3143 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3144 |
|
|
bailout(); |
3145 |
|
|
} |
3146 |
|
|
|
3147 |
|
|
// Succeeded |
3148 |
|
|
else { |
3149 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3150 |
|
|
} |
3151 |
|
|
} |
3152 |
|
|
// Call the staff form back |
3153 |
|
|
formStaff($con, $staff_id); |
3154 |
|
|
} |
3155 |
|
|
|
3156 |
|
|
|
3157 |
|
|
/********************************************************** |
3158 |
|
|
Function: deleteStafftitle |
3159 |
|
|
Author: Paul Bramscher |
3160 |
|
|
Last Modified: 04.29.2003 |
3161 |
|
|
*********************************************************** |
3162 |
|
|
Purpose: |
3163 |
|
|
Deletes the supplied staff job title id. Any staff currently |
3164 |
|
|
using this title are set to the (N/A) placeholder title. |
3165 |
|
|
**********************************************************/ |
3166 |
|
|
function deleteStafftitle($con, $stafftitle_id){ |
3167 |
|
|
|
3168 |
|
|
// Draw form heading |
3169 |
|
|
printf("<center><h3>Deleting Job Title...</h3>"); |
3170 |
|
|
|
3171 |
|
|
// Table |
3172 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
3173 |
|
|
printf("<tr><td><br>"); |
3174 |
|
|
printf("<strong>Messages:</strong><br>"); |
3175 |
|
|
|
3176 |
|
|
// Problem flag for each delete step |
3177 |
|
|
$problem = 0; |
3178 |
|
|
|
3179 |
|
|
// First update all rows in staff to (N/A) |
3180 |
|
|
if ($stafftitle_id > 1) { |
3181 |
|
|
$sql = "UPDATE staff SET stafftitle_id = 1 WHERE stafftitle_id = " . $stafftitle_id; |
3182 |
|
|
|
3183 |
|
|
if (!mysql_query ($sql, $con)){ |
3184 |
|
|
$problem = 1; |
3185 |
|
|
sql_err($sql); |
3186 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3187 |
|
|
bailout(); |
3188 |
|
|
} |
3189 |
|
|
else { |
3190 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3191 |
|
|
printf("Successfully set affected staff person job titles to (N/A).<BR>\n"); |
3192 |
|
|
} |
3193 |
|
|
|
3194 |
|
|
// Delete from the title table |
3195 |
|
|
if ($problem == 0) { |
3196 |
|
|
$sql = "DELETE FROM stafftitle WHERE stafftitle_id =" . $stafftitle_id; |
3197 |
|
|
|
3198 |
|
|
if (!mysql_query ($sql, $con)){ |
3199 |
|
|
$problem = 1; |
3200 |
|
|
sql_err($sql); |
3201 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3202 |
|
|
bailout(); |
3203 |
|
|
} |
3204 |
|
|
else { |
3205 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3206 |
|
|
printf("Removed this job title successfully.<BR><BR>\n"); |
3207 |
|
|
} |
3208 |
|
|
} |
3209 |
|
|
|
3210 |
|
|
} |
3211 |
|
|
else printf("Cannot delete <b>Job Title ID #1.</b> It acts as a system placeholder.</b>.<br><br>\n"); |
3212 |
|
|
|
3213 |
|
|
printf("</td></tr></table>"); |
3214 |
|
|
printf("</center>"); |
3215 |
|
|
} |
3216 |
|
|
|
3217 |
|
|
|
3218 |
|
|
/********************************************************** |
3219 |
|
|
Function: deleteStafftitleConfirm |
3220 |
|
|
Author: Paul Bramscher |
3221 |
|
|
Last Modified: 04.29.2003 |
3222 |
|
|
*********************************************************** |
3223 |
|
|
Purpose: |
3224 |
|
|
Confirm prompt for deleting the supplied staff title id. |
3225 |
|
|
**********************************************************/ |
3226 |
|
|
function deleteStafftitleConfirm($con, $key_id){ |
3227 |
|
|
|
3228 |
|
|
// Make sure we have a valid integer type |
3229 |
|
|
$stafftitle_id = (int) $key_id; |
3230 |
|
|
|
3231 |
|
|
// Draw page heading |
3232 |
|
|
printf("<center><h3>Delete Job Title ID# %s?</h3>\n", $stafftitle_id); |
3233 |
|
|
|
3234 |
|
|
// Check to see if its possible |
3235 |
|
|
$exists = existsRow($con, "stafftitle", "stafftitle_id", $stafftitle_id); |
3236 |
|
|
if ($exists > 0){ |
3237 |
|
|
|
3238 |
|
|
// Table |
3239 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
3240 |
|
|
printf("<tr><td>\n"); |
3241 |
|
|
|
3242 |
|
|
// Lookup the descriptive title |
3243 |
|
|
$stafftitle = lookupField($con, "stafftitle", "stafftitle_id", $stafftitle_id, "stafftitle"); |
3244 |
|
|
printf("<strong>Staff Title:</strong> %s<br>\n ", $stafftitle); |
3245 |
|
|
|
3246 |
|
|
// Form to draw the delete button |
3247 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
3248 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteStafftitle\" >\n"); |
3249 |
|
|
printf("<input type = \"Hidden\" name = \"stafftitle_id\" value = \"%d\" >\n", $stafftitle_id); |
3250 |
|
|
printf("<BR>This will <b>permanently</b> remove this job title and its various assignments from the system. Some staff will be set to (N/A).<BR><BR>\n"); |
3251 |
|
|
printf("<center>\n"); |
3252 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
3253 |
|
|
printf("</center>\n"); |
3254 |
|
|
printf("</form><br>\n"); |
3255 |
|
|
|
3256 |
|
|
// Close table |
3257 |
|
|
printf("</td></tr></table>"); |
3258 |
|
|
} |
3259 |
|
|
|
3260 |
|
|
// Failed for whatever reason |
3261 |
|
|
else if ($exists < 1) printf ("Job title not found. Operation cancelled.<br>\n"); |
3262 |
|
|
|
3263 |
|
|
printf("</center>\n"); |
3264 |
|
|
} |
3265 |
|
|
|
3266 |
|
|
|
3267 |
|
|
/********************************************************** |
3268 |
|
|
Function: deleteStyle |
3269 |
|
|
Author: Paul Bramscher |
3270 |
|
|
Last Modified: 05.22.2003 |
3271 |
|
|
*********************************************************** |
3272 |
|
|
Purpose: |
3273 |
|
|
Deletes the supplied style id. Any pages currently |
3274 |
|
|
using this style are set to the (N/A) placeholder style. |
3275 |
|
|
Note that the actual header, footer, and css files are |
3276 |
|
|
not deleted -- only the references to them. |
3277 |
|
|
**********************************************************/ |
3278 |
|
|
function deleteStyle($con, $style_id){ |
3279 |
|
|
|
3280 |
|
|
// Draw form heading |
3281 |
|
|
printf("<center><h3>Deleting Style...</h3>"); |
3282 |
|
|
|
3283 |
|
|
// Table |
3284 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
3285 |
|
|
printf("<tr><td><br>"); |
3286 |
|
|
printf("<strong>Messages:</strong><br>"); |
3287 |
|
|
|
3288 |
|
|
// Problem flag for each delete step |
3289 |
|
|
$problem = 0; |
3290 |
|
|
|
3291 |
|
|
// First update all affected rows in page to (N/A) |
3292 |
|
|
if ($style_id > 2) { |
3293 |
|
|
$sql = "UPDATE page SET style_id = 1 WHERE style_id = " . $style_id; |
3294 |
|
|
|
3295 |
|
|
if (!mysql_query ($sql, $con)){ |
3296 |
|
|
$problem = 1; |
3297 |
|
|
sql_err($sql); |
3298 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3299 |
|
|
bailout(); |
3300 |
|
|
} |
3301 |
|
|
else { |
3302 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3303 |
|
|
printf("Successfully set affected page styles to (N/A).<BR>\n"); |
3304 |
|
|
} |
3305 |
|
|
|
3306 |
|
|
// Delete from the style table |
3307 |
|
|
if ($problem == 0) { |
3308 |
|
|
$sql = "DELETE FROM style WHERE style_id =" . $style_id; |
3309 |
|
|
|
3310 |
|
|
if (!mysql_query ($sql, $con)){ |
3311 |
|
|
$problem = 1; |
3312 |
|
|
sql_err($sql); |
3313 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3314 |
|
|
bailout(); |
3315 |
|
|
} |
3316 |
|
|
else { |
3317 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3318 |
|
|
printf("Removed this style successfully.<BR><BR>\n"); |
3319 |
|
|
} |
3320 |
|
|
} |
3321 |
|
|
|
3322 |
|
|
} |
3323 |
|
|
else { |
3324 |
|
|
printf("Cannot delete <b>Style ID #1-2.</b> #1 acts as a system placeholder, #2 "); |
3325 |
|
|
printf("is the default style for new pages, but may be renamed or redefined as "); |
3326 |
|
|
printf("needed </b>.<br><br>\n"); |
3327 |
|
|
} |
3328 |
|
|
|
3329 |
|
|
|
3330 |
|
|
printf("</td></tr></table>"); |
3331 |
|
|
printf("</center>"); |
3332 |
|
|
} |
3333 |
|
|
|
3334 |
|
|
|
3335 |
|
|
/********************************************************** |
3336 |
|
|
Function: deleteStyleConfirm |
3337 |
|
|
Author: Paul Bramscher |
3338 |
|
|
Last Modified: 05.22.2003 |
3339 |
|
|
*********************************************************** |
3340 |
|
|
Purpose: |
3341 |
|
|
Confirm prompt for deleting the supplied style id |
3342 |
|
|
**********************************************************/ |
3343 |
|
|
function deleteStyleConfirm($con, $key_id){ |
3344 |
|
|
|
3345 |
|
|
// Make sure we have a valid integer type |
3346 |
|
|
$style_id = (int) $key_id; |
3347 |
|
|
|
3348 |
|
|
// Draw page heading |
3349 |
|
|
printf("<center><h3>Delete Style ID# %s?</h3>\n", $style_id); |
3350 |
|
|
|
3351 |
|
|
// Check to see if its possible |
3352 |
|
|
$exists = existsRow($con, "style", "style_id", $style_id); |
3353 |
|
|
if ($exists > 0){ |
3354 |
|
|
|
3355 |
|
|
// Table |
3356 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
3357 |
|
|
printf("<tr><td>\n"); |
3358 |
|
|
|
3359 |
|
|
// Lookup the descriptive title |
3360 |
|
|
$style_title = lookupField($con, "style", "style_id", $style_id, "style_title"); |
3361 |
|
|
printf("<strong>Style Title:</strong> %s<br>\n ", $style_title); |
3362 |
|
|
|
3363 |
|
|
// Form to draw the delete button |
3364 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
3365 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteStyle\" >\n"); |
3366 |
|
|
printf("<input type = \"Hidden\" name = \"style_id\" value = \"%d\" >\n", $style_id); |
3367 |
|
|
printf("<BR>This will <b>permanently</b> remove this style and "); |
3368 |
|
|
printf("assign affected pages to the (N/A) style. Note that this function does "); |
3369 |
|
|
printf("not actually delete any header, footer or css files -- only the references "); |
3370 |
|
|
printf("to them. If a default page style is not properly configured, pages without "); |
3371 |
|
|
printf("a style may fail to display properly, and should be assigned a new style.<BR><BR>\n"); |
3372 |
|
|
printf("<center>\n"); |
3373 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
3374 |
|
|
printf("</center>\n"); |
3375 |
|
|
printf("</form><br>\n"); |
3376 |
|
|
|
3377 |
|
|
// Close table |
3378 |
|
|
printf("</td></tr></table>\n"); |
3379 |
|
|
} |
3380 |
|
|
|
3381 |
|
|
// Failed for whatever reason |
3382 |
|
|
else if ($exists < 1) printf ("Job title not found. Operation cancelled.<br>\n"); |
3383 |
|
|
|
3384 |
|
|
printf("</center>\n"); |
3385 |
|
|
} |
3386 |
|
|
|
3387 |
|
|
|
3388 |
|
|
/********************************************************** |
3389 |
|
|
Function: deleteTerm |
3390 |
|
|
Author: Paul Bramscher |
3391 |
|
|
Last Modified: 05.07.2003 |
3392 |
|
|
*********************************************************** |
3393 |
|
|
Purpose: |
3394 |
|
|
Deletes the supplied term id, and removes references in |
3395 |
|
|
the course table. |
3396 |
|
|
**********************************************************/ |
3397 |
|
|
function deleteTerm($con, $term_id){ |
3398 |
|
|
|
3399 |
|
|
// Draw form heading |
3400 |
|
|
printf("<center><h3>Deleting Academic Term...</h3>"); |
3401 |
|
|
|
3402 |
|
|
// Table |
3403 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
3404 |
|
|
printf("<tr><td><br>"); |
3405 |
|
|
printf("<strong>Messages:</strong><br>"); |
3406 |
|
|
|
3407 |
|
|
// Problem flag for each delete step |
3408 |
|
|
$problem = 0; |
3409 |
|
|
|
3410 |
|
|
// Cannot delete placeholder #1 |
3411 |
|
|
if ($term_id > 1) { |
3412 |
|
|
|
3413 |
|
|
// Delete all course term assignments |
3414 |
|
|
$sql = "UPDATE course SET term_id = NULL WHERE term_id =" . $term_id; |
3415 |
|
|
|
3416 |
|
|
if (!mysql_query ($sql, $con)){ |
3417 |
|
|
$problem = 1; |
3418 |
|
|
sql_err($sql); |
3419 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3420 |
|
|
bailout(); |
3421 |
|
|
} |
3422 |
|
|
else { |
3423 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3424 |
|
|
printf("Removed this term from affected course pages.<BR>\n"); |
3425 |
|
|
} |
3426 |
|
|
|
3427 |
|
|
|
3428 |
|
|
if ($problem == 0) { |
3429 |
|
|
|
3430 |
|
|
// Delete from term table |
3431 |
|
|
$sql = "DELETE FROM term WHERE term_id =" . $term_id; |
3432 |
|
|
|
3433 |
|
|
if (!mysql_query ($sql, $con)){ |
3434 |
|
|
$problem = 1; |
3435 |
|
|
sql_err($sql); |
3436 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3437 |
|
|
bailout(); |
3438 |
|
|
} |
3439 |
|
|
else { |
3440 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3441 |
|
|
printf("Removed term successfully.<BR><BR>\n"); |
3442 |
|
|
} |
3443 |
|
|
} |
3444 |
|
|
} |
3445 |
|
|
|
3446 |
|
|
else printf("Cannot delete <b>Term ID#1</b>, it acts as a system placeholder.<br><br>\n"); |
3447 |
|
|
|
3448 |
|
|
printf("</td></tr></table>"); |
3449 |
|
|
printf("</center>"); |
3450 |
|
|
} |
3451 |
|
|
|
3452 |
|
|
|
3453 |
|
|
/********************************************************** |
3454 |
|
|
Function: deleteTermConfirm |
3455 |
|
|
Author: Paul Bramscher |
3456 |
|
|
Last Modified: 05.07.2003 |
3457 |
|
|
*********************************************************** |
3458 |
|
|
Purpose: |
3459 |
|
|
Confirm prompt for deleting the supplied term id. |
3460 |
|
|
**********************************************************/ |
3461 |
|
|
function deleteTermConfirm($con, $key_id){ |
3462 |
|
|
|
3463 |
|
|
// Make sure we have a valid integer type |
3464 |
|
|
$term_id = (int) $key_id; |
3465 |
|
|
|
3466 |
|
|
// Draw page heading |
3467 |
|
|
printf("<center><h3>Delete Term ID# %s?</h3>", $term_id); |
3468 |
|
|
|
3469 |
|
|
// Check to see if its possible |
3470 |
|
|
$exists = existsRow($con, "term", "term_id", $term_id); |
3471 |
|
|
if ($exists > 0){ |
3472 |
|
|
|
3473 |
|
|
// Table |
3474 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
3475 |
|
|
printf("<tr><td>"); |
3476 |
|
|
|
3477 |
|
|
// Lookup the descriptive title |
3478 |
|
|
$term = lookupField($con, "term", "term_id", $term_id, "term"); |
3479 |
|
|
printf("<strong>Term:</strong> %s<br>\n ", $term); |
3480 |
|
|
|
3481 |
|
|
// Form to draw the delete button |
3482 |
|
|
printf("<form method = \"POST\" action = \"delete.phtml\" >"); |
3483 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteTerm\" >"); |
3484 |
|
|
printf("<input type = \"Hidden\" name = \"term_id\" value = \"%d\" >", $term_id); |
3485 |
|
|
printf("This will <b>permanently</b> remove this academic term. Some courses may no longer have terms.<BR><BR>"); |
3486 |
|
|
printf("<center>"); |
3487 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">"); |
3488 |
|
|
printf("</center>"); |
3489 |
|
|
printf("</form><br>"); |
3490 |
|
|
|
3491 |
|
|
// Close table |
3492 |
|
|
printf("</td></tr></table>"); |
3493 |
|
|
} |
3494 |
|
|
|
3495 |
|
|
// Failed for whatever reason |
3496 |
|
|
else if ($exists < 1) printf ("Term not found. Operation cancelled.<br>\n"); |
3497 |
|
|
|
3498 |
|
|
printf("</center>"); |
3499 |
|
|
} |
3500 |
|
|
?> |