1 |
<?php |
2 |
/********************************************************** |
3 |
Function Library: delete.php |
4 |
Original Author: Paul Bramscher <brams006@umn.edu> |
5 |
Last Modified: 03.16.2004 by Paul Bramscher |
6 |
*********************************************************** |
7 |
Comments: |
8 |
This library brings together all SQL delete functions |
9 |
and confirm delete prompts for LibData general setup |
10 |
tables. Those pertaining to PageScribe and SubjectBuilder |
11 |
are located in scribe_application.php and |
12 |
subject_builder.php 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 |
deleteResMastersubject |
37 |
deleteResource |
38 |
deleteResourceConfirm |
39 |
deleteService |
40 |
deleteServiceConfirm |
41 |
deleteServicetype |
42 |
deleteServicetypeConfirm |
43 |
deleteServLoc |
44 |
deleteServServtype |
45 |
deleteStaff |
46 |
deleteStaffConfirm |
47 |
deleteStaffLibunit |
48 |
deleteStaffSub |
49 |
deleteStafftitle |
50 |
deleteStafftitleConfirm |
51 |
deleteStyle |
52 |
deleteStyleConfirm |
53 |
deleteSubCoursesub |
54 |
deleteSubject |
55 |
deleteSubjectConfirm |
56 |
deleteSubLoc |
57 |
deleteSubMaster |
58 |
deleteSubStaff |
59 |
deleteTerm |
60 |
deleteTermConfirm |
61 |
deleteVendor |
62 |
deleteVendorConfirm |
63 |
**********************************************************/ |
64 |
|
65 |
|
66 |
/********************************************************** |
67 |
Function: deleteCampus |
68 |
Author: Paul Bramscher |
69 |
Last Modified: 03.16.2004 |
70 |
*********************************************************** |
71 |
Purpose: |
72 |
Deletes a supplied campus id, sets affected course |
73 |
pages to NULL campus. |
74 |
**********************************************************/ |
75 |
function deleteCampus($campus_id){ |
76 |
|
77 |
msgTableOpen(1, "Deleting Campus (ID# " . $campus_id . ")"); |
78 |
printf("<b>Messages:</b><br>\n"); |
79 |
|
80 |
// Cannot delete placeholder #1. |
81 |
if ($campus_id > 1) { |
82 |
|
83 |
// First clear out any coursescribe pages |
84 |
$sql = "UPDATE course SET campus_id = NULL WHERE campus_id = " . $campus_id; |
85 |
if (xx_tryquery($sql)) printf("Campus purged from assignments to course pages.<br>\n"); |
86 |
|
87 |
// Delete from the coursesub table |
88 |
$sql = "UPDATE coursesub SET campus_id = 1 WHERE campus_id =" . $campus_id; |
89 |
if (xx_tryquery ($sql)) printf("Removed from affected Course Subjects.<br>\n"); |
90 |
|
91 |
// Delete from the campus table |
92 |
$sql = "DELETE FROM campus WHERE campus_id =" . $campus_id; |
93 |
if (xx_tryquery ($sql)) printf("Removed this campus successfully."); |
94 |
|
95 |
} |
96 |
else printf("Cannot delete Campus ID# 1, it acts as a system placeholder."); |
97 |
|
98 |
printf("<br><br>\n"); |
99 |
msgTableClose(); |
100 |
} |
101 |
|
102 |
|
103 |
/********************************************************** |
104 |
Function: deleteCampusConfirm |
105 |
Author: Paul Bramscher |
106 |
Last Modified: 03.16.2004 |
107 |
*********************************************************** |
108 |
Purpose: |
109 |
Confirm prompt for deleting the selected campus. |
110 |
**********************************************************/ |
111 |
function deleteCampusConfirm($key_id){ |
112 |
|
113 |
$campus_id = (int) $key_id; |
114 |
msgTableOpen(1, "Delete Campus (ID# " . $campus_id . ")?"); |
115 |
|
116 |
// Check to see if its possible |
117 |
$exists = existsRow("campus", "campus_id", $campus_id); |
118 |
if ($exists > 0){ |
119 |
|
120 |
// Lookup the descriptive title |
121 |
$campus = lookupField("campus", "campus_id", $campus_id, "campus"); |
122 |
printf("<b>Campus:</b> %s<br><br>\n ", $campus); |
123 |
printf("This will permanently remove this campus and its various assignments from the system. Some CourseScribe pages may lose their campus association.<BR><BR>\n"); |
124 |
|
125 |
// Form to draw the delete button |
126 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
127 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteCampus\" >\n"); |
128 |
printf("<input type = \"Hidden\" name = \"campus_id\" value = \"%d\" >\n", $campus_id); |
129 |
printf("<center>\n"); |
130 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
131 |
printf("</center>\n"); |
132 |
printf("</form>\n"); |
133 |
|
134 |
} |
135 |
else if ($exists < 1) printf ("Campus not found. Operation cancelled.<br><br>\n"); |
136 |
|
137 |
msgTableClose(); |
138 |
|
139 |
} |
140 |
|
141 |
|
142 |
/********************************************************** |
143 |
Function: deleteCoursesub |
144 |
Author: Paul Bramscher |
145 |
Last Modified: 03.16.2004 |
146 |
*********************************************************** |
147 |
Purpose: |
148 |
Deletes a supplied course subject id |
149 |
**********************************************************/ |
150 |
function deleteCoursesub($coursesub_id){ |
151 |
|
152 |
msgTableOpen(1, "Deleting Course Subject (ID# " . $coursesub_id . ")"); |
153 |
printf("<b>Messages:</b><br>\n"); |
154 |
|
155 |
// Cannot delete placeholder #1. |
156 |
if ($coursesub_id > 1) { |
157 |
|
158 |
// Check to see if there are affected courselib pages |
159 |
$exists_courselib = existsRow("course", "coursesub_id", $coursesub_id); |
160 |
|
161 |
if ($exists_courselib > 0) { |
162 |
printf("Cannot delete this Course Subject. There are courses which are currently using it."); |
163 |
} |
164 |
|
165 |
// Delete |
166 |
else { |
167 |
// Delete from the sub_coursesub table |
168 |
$sql = "DELETE FROM sub_coursesub WHERE coursesub_id = " . $coursesub_id; |
169 |
if (xx_tryquery ($sql)) printf("Subject-Course Subject assignments removed.<BR>\n"); |
170 |
|
171 |
// Delete from the coursesub table |
172 |
$sql = "DELETE FROM coursesub WHERE coursesub_id =" . $coursesub_id; |
173 |
if (xx_tryquery ($sql)) printf("Removed this Course Subject successfully."); |
174 |
} |
175 |
|
176 |
} |
177 |
else printf ("Cannot delete Course Subject ID# 1, it acts as a system placeholder."); |
178 |
|
179 |
printf("<br><br>\n"); |
180 |
msgTableClose(); |
181 |
} |
182 |
|
183 |
|
184 |
/********************************************************** |
185 |
Function: deleteCoursesubConfirm |
186 |
Author: Paul Bramscher |
187 |
Last Modified: 03.16.2004 |
188 |
*********************************************************** |
189 |
Purpose: |
190 |
Confirm prompt for deleting the selected campus. |
191 |
**********************************************************/ |
192 |
function deleteCoursesubConfirm($coursesub_id){ |
193 |
|
194 |
$coursesub_id = (int) $coursesub_id; |
195 |
msgTableOpen(1, "Delete Course Subject (ID# " . $coursesub_id . ")?"); |
196 |
|
197 |
// Check to see if its possible |
198 |
$exists = existsRow("coursesub", "coursesub_id", $coursesub_id); |
199 |
if ($exists > 0){ |
200 |
|
201 |
// Lookup the descriptive title |
202 |
$coursesub = lookupField("coursesub", "coursesub_id", $coursesub_id, "coursesub"); |
203 |
|
204 |
// Check to see if there are affected courselib pages |
205 |
$exists_courselib = existsRow("course", "coursesub_id", $coursesub_id); |
206 |
|
207 |
if ($exists_courselib > 0) { |
208 |
|
209 |
// Cannot delete, dependencies exist |
210 |
printf("<b>Messages:</b><br>\n"); |
211 |
printf("This course subject is currently used on one or more course pages. "); |
212 |
printf("It may not be edited or deleted until all affected courses are moved to "); |
213 |
printf("an alternate course subject. Follow the link below for a list of "); |
214 |
printf("affected pages.<br><br>"); |
215 |
printf("<a href=\"page_results_brief.phtml?coursesub_id=%s\">", $coursesub_id); |
216 |
printf("page_results_brief.phtml?coursesub_id=%s", $coursesub_id); |
217 |
printf("</a><br><br>\n"); |
218 |
|
219 |
} |
220 |
|
221 |
else { |
222 |
|
223 |
// Form to draw the delete button |
224 |
printf("<b>Course Subject:</b> %s<br><br>\n ", $coursesub); |
225 |
printf("This will permanently remove this Course Subject.<BR><BR>\n"); |
226 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
227 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteCoursesub\" >\n"); |
228 |
printf("<input type = \"Hidden\" name = \"coursesub_id\" value = \"%d\" >\n", $coursesub_id); |
229 |
printf("<center>\n"); |
230 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
231 |
printf("</center>\n"); |
232 |
printf("</form>\n"); |
233 |
|
234 |
} |
235 |
|
236 |
} |
237 |
else if ($exists < 1) printf ("Course Subject not found. Operation cancelled.<br><br>\n"); |
238 |
|
239 |
msgTableClose(); |
240 |
} |
241 |
|
242 |
|
243 |
/********************************************************** |
244 |
Function: deleteFaculty |
245 |
Author: Paul Bramscher |
246 |
Last Modified: 03.16.2004 |
247 |
*********************************************************** |
248 |
Purpose: |
249 |
Deletes the supplied faculty id, and removes any relations |
250 |
to affected courses. |
251 |
**********************************************************/ |
252 |
function deleteFaculty($faculty_id){ |
253 |
|
254 |
msgTableOpen(1, "Deleting Faculty (ID# " . $faculty_id . ")"); |
255 |
printf("<b>Messages:</b><br>\n"); |
256 |
|
257 |
// Cannot delete placeholder #1. |
258 |
if ($faculty_id > 1) { |
259 |
|
260 |
// First clear out the course_personnel assignments |
261 |
$sql = "DELETE FROM course_personnel WHERE faculty_id = " . $faculty_id; |
262 |
if (xx_tryquery ($sql)) printf("Faculty person purged from assignments to course pages.<BR>\n"); |
263 |
|
264 |
// Delete from the faculty table |
265 |
$sql = "DELETE FROM faculty WHERE faculty_id =" . $faculty_id; |
266 |
if (xx_tryquery ($sql)) printf("Removed this faculty person successfully."); |
267 |
|
268 |
} |
269 |
else printf ("Cannot delete Faculty ID# 1, it acts as a system placeholder."); |
270 |
|
271 |
printf("<br><br>\n"); |
272 |
msgTableClose(); |
273 |
} |
274 |
|
275 |
|
276 |
/********************************************************** |
277 |
Function: deleteFacultyConfirm |
278 |
Author: Paul Bramscher |
279 |
Last Modified: 03.16.2004 |
280 |
*********************************************************** |
281 |
Purpose: |
282 |
Confirm prompt for deleting the selected faculty person. |
283 |
**********************************************************/ |
284 |
function deleteFacultyConfirm($faculty_id){ |
285 |
|
286 |
$faculty_id = (int) $faculty_id; |
287 |
msgTableOpen(1, "Delete Faculty (ID# " . $faculty_id . ")?"); |
288 |
|
289 |
// Check to see if its possible |
290 |
$exists = existsRow("faculty", "faculty_id", $faculty_id); |
291 |
if ($exists > 0){ |
292 |
|
293 |
// Lookup the descriptive title |
294 |
$faculty_name = lookupFaculty($faculty_id); |
295 |
printf("<b>Faculty Person:</b> %s<br><br>\n ", $faculty_name); |
296 |
printf("This will permanently remove the faculty person and his/her various assignments from the system. Some CourseScribe pages may have no personnel.<BR><BR>\n"); |
297 |
|
298 |
// Form to draw the delete button |
299 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
300 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteFaculty\" >\n"); |
301 |
printf("<input type = \"Hidden\" name = \"faculty_id\" value = \"%d\" >\n", $faculty_id); |
302 |
printf("<center>\n"); |
303 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
304 |
printf("</center>\n"); |
305 |
printf("</form>\n"); |
306 |
} |
307 |
else if ($exists < 1) printf ("Faculty not found. Operation cancelled.<br><br>\n"); |
308 |
|
309 |
msgTableClose(); |
310 |
} |
311 |
|
312 |
|
313 |
/********************************************************** |
314 |
Function: deleteFeature |
315 |
Author: Paul Bramscher |
316 |
Last Modified: 03.16.2004 |
317 |
*********************************************************** |
318 |
Purpose: |
319 |
Deletes the supplied feature id, and removes any relations to |
320 |
affected resources. |
321 |
**********************************************************/ |
322 |
function deleteFeature($feature_id){ |
323 |
|
324 |
msgTableOpen(1, "Deleting Feature (ID# " . $feature_id . ")"); |
325 |
printf("<b>Messages:</b><br>\n"); |
326 |
|
327 |
// Cannot delete placeholder #1 |
328 |
if ($feature_id > 1) { |
329 |
|
330 |
// Delete all resource_feature assignments |
331 |
$sql = "DELETE from res_feature WHERE feature_id =" . $feature_id; |
332 |
if (xx_tryquery ($sql)) printf("Removed resource-feature associations.<BR>\n"); |
333 |
|
334 |
// Delete from feature table |
335 |
$sql = "DELETE FROM feature WHERE feature_id =" . $feature_id; |
336 |
if (xx_tryquery ($sql)) printf("Removed feature successfully."); |
337 |
|
338 |
} |
339 |
else printf ("Cannot delete Feature ID# 1, it acts as a system placeholder."); |
340 |
|
341 |
printf("<br><br>\n"); |
342 |
msgTableClose(); |
343 |
} |
344 |
|
345 |
|
346 |
/********************************************************** |
347 |
Function: deleteFeatureConfirm |
348 |
Author: Paul Bramscher |
349 |
Last Modified: 03.15.2004 |
350 |
*********************************************************** |
351 |
Purpose: |
352 |
Confirm prompt for deleting the supplied feature id. |
353 |
**********************************************************/ |
354 |
function deleteFeatureConfirm($key_id){ |
355 |
|
356 |
$feature_id = (int) $key_id; |
357 |
msgTableOpen(1, "Delete Feature (ID# " . $feature_id . ")?"); |
358 |
|
359 |
// Check to see if its possible |
360 |
$exists = existsRow("feature", "feature_id", $feature_id); |
361 |
if ($exists > 0){ |
362 |
|
363 |
// Lookup the descriptive title |
364 |
$feature = lookupField("feature", "feature_id", $feature_id, "feature"); |
365 |
printf("<b>Feature:</b> %s<br><br>\n ", $feature); |
366 |
printf("This will permanently remove the feature and its various assignments from the system. Some resources may no longer have icons.<BR><BR>\n"); |
367 |
|
368 |
// Form to draw the delete button |
369 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
370 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteFeature\" >\n"); |
371 |
printf("<input type = \"Hidden\" name = \"feature_id\" value = \"%d\" >\n", $feature_id); |
372 |
printf("<center>\n"); |
373 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
374 |
printf("</center>\n"); |
375 |
printf("</form>\n"); |
376 |
} |
377 |
else if ($exists < 1) printf ("Feature not found. Operation cancelled.<br><br>\n"); |
378 |
|
379 |
msgTableClose(); |
380 |
} |
381 |
|
382 |
|
383 |
/********************************************************** |
384 |
Function: deleteInfotype |
385 |
Author: Paul Bramscher |
386 |
Last Modified: 03.16.2004 |
387 |
*********************************************************** |
388 |
Purpose: |
389 |
Deletes the supplied information type id, and removes |
390 |
assocations in the resource and resource-subject-information |
391 |
type tables. |
392 |
**********************************************************/ |
393 |
function deleteInfotype($infotype_id){ |
394 |
|
395 |
msgTableOpen(1, "Deleting Information Type (ID# " . $infotype_id . ")"); |
396 |
printf("<b>Messages:</b><br>\n"); |
397 |
|
398 |
// Cannot delete placeholder #1 |
399 |
if ($infotype_id > 1) { |
400 |
|
401 |
// Delete all res_sub_infotype assignments |
402 |
$sql = "DELETE from res_sub_infotype WHERE infotype_id =" . $infotype_id; |
403 |
if (xx_tryquery ($sql)) printf("Removed resource-subject-infotype associations.<BR>\n"); |
404 |
|
405 |
// Set (N/A) type in resource table |
406 |
$sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; |
407 |
if (xx_tryquery ($sql)) printf("Set default information types for affects resources to (N/A).<BR>\n"); |
408 |
|
409 |
// Delete from infotype table |
410 |
$sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; |
411 |
if (xx_tryquery ($sql)) printf("Removed this information type successfully."); |
412 |
} |
413 |
else printf ("Cannot delete Information Type ID# 1, it acts as a system placeholder."); |
414 |
|
415 |
printf("<br><br>\n"); |
416 |
msgTableClose(); |
417 |
} |
418 |
|
419 |
|
420 |
/********************************************************** |
421 |
Function: deleteInfotypeConfirm |
422 |
Author: Paul Bramscher |
423 |
Last Modified: 03.16.2004 |
424 |
*********************************************************** |
425 |
Purpose: |
426 |
Confirm prompt to delete the supplied information type id. |
427 |
**********************************************************/ |
428 |
function deleteInfotypeConfirm($key_id){ |
429 |
|
430 |
$infotype_id = (int) $key_id; |
431 |
msgTableOpen(1, "Delete Information Type (ID# " . $infotype_id . ")?"); |
432 |
|
433 |
// Check to see if its possible |
434 |
$exists = existsRow("infotype", "infotype_id", $infotype_id); |
435 |
if ($exists > 0){ |
436 |
|
437 |
// Lookup the descriptive title |
438 |
$infotype = lookupField("infotype", "infotype_id", $infotype_id, "infotype"); |
439 |
printf("<b>Information Type:</b> %s<br><br>\n ", $infotype); |
440 |
printf("This will permanently 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>\n"); |
441 |
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); |
442 |
|
443 |
// Form to draw the delete button |
444 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
445 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteInfotype\" >\n"); |
446 |
printf("<input type = \"Hidden\" name = \"infotype_id\" value = \"%d\" >\n", $infotype_id); |
447 |
printf("<br><br>\n"); |
448 |
printf("<center>\n"); |
449 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
450 |
printf("</center>\n"); |
451 |
printf("</form>\n"); |
452 |
} |
453 |
else if ($exists < 1) printf ("Information Type not found. Operation cancelled.<br><br>\n"); |
454 |
|
455 |
msgTableClose(); |
456 |
} |
457 |
|
458 |
|
459 |
/********************************************************** |
460 |
Function: deleteLibunit |
461 |
Author: Paul Bramscher |
462 |
Last Modified: 03.16.2004 |
463 |
*********************************************************** |
464 |
Purpose: |
465 |
Deletes the supplied libunit id, and any staff assignments |
466 |
in that library unit. |
467 |
**********************************************************/ |
468 |
function deleteLibunit($libunit_id){ |
469 |
|
470 |
msgTableOpen(1, "Deleting Library Unit (ID# " . $libunit_id . ")"); |
471 |
printf("<b>Messages:</b><br>\n"); |
472 |
|
473 |
// First delete from libunit_staff |
474 |
if ($libunit_id > 1) { |
475 |
$sql = "DELETE FROM libunit_staff WHERE libunit_id = " . $libunit_id; |
476 |
if (xx_tryquery ($sql)) printf("Deleted affected Library Unit staff assignments.<BR>\n"); |
477 |
|
478 |
// Delete from the libunit table |
479 |
$sql = "DELETE FROM libunit WHERE libunit_id =" . $libunit_id; |
480 |
if (xx_tryquery ($sql)) printf("Removed this Library Unit successfully."); |
481 |
|
482 |
} |
483 |
else printf ("Cannot delete Library Unit ID# 1, it acts as a system placeholder."); |
484 |
|
485 |
printf("<br><br>\n"); |
486 |
msgTableClose(); |
487 |
} |
488 |
|
489 |
|
490 |
/********************************************************** |
491 |
Function: deleteLibunitConfirm |
492 |
Author: Paul Bramscher |
493 |
Last Modified: 03.16.2004 |
494 |
*********************************************************** |
495 |
Purpose: |
496 |
Confirm prompt for deleting the supplied libunit id. |
497 |
**********************************************************/ |
498 |
function deleteLibunitConfirm($key_id){ |
499 |
|
500 |
$libunit_id = (int) $key_id; |
501 |
msgTableOpen(1, "Delete Library Unit (ID# " . $libunit_id . ")?"); |
502 |
|
503 |
// Check to see if its possible |
504 |
$exists = existsRow("libunit", "libunit_id", $libunit_id); |
505 |
if ($exists > 0){ |
506 |
|
507 |
// Lookup the descriptive title |
508 |
$libunit = lookupField("libunit", "libunit_id", $libunit_id, "libunit"); |
509 |
printf("<b>Libunit:</b> %s<br><br>\n ", $libunit); |
510 |
printf("This will permanently remove this Library Unit from the system. This may render some staff without a unit.<BR><BR>"); |
511 |
|
512 |
// Form to draw the delete button |
513 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
514 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteLibunit\" >\n"); |
515 |
printf("<input type = \"Hidden\" name = \"libunit_id\" value = \"%d\" >\n", $libunit_id); |
516 |
printf("<center>\n"); |
517 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
518 |
printf("</center>\n"); |
519 |
printf("</form>\n"); |
520 |
} |
521 |
else if ($exists < 1) printf ("Library Unit not found. Operation cancelled.<br><br>\n"); |
522 |
|
523 |
msgTableClose(); |
524 |
} |
525 |
|
526 |
|
527 |
/********************************************************** |
528 |
Function: deleteLibunitStaff |
529 |
Author: Paul Bramscher |
530 |
Last Modified: 03.03.2004 |
531 |
*********************************************************** |
532 |
Purpose: |
533 |
Deletes staffperson assignments (possibly multiple) to the |
534 |
supplied libunit id and calls formLibunit back again. |
535 |
**********************************************************/ |
536 |
function deleteLibunitStaff($key_list_array, $libunit_id){ |
537 |
|
538 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
539 |
$sql = "DELETE FROM libunit_staff WHERE libunit_id = " |
540 |
. $libunit_id |
541 |
. " AND staff_id = " |
542 |
. $key_list_array[$element]; |
543 |
xx_tryquery($sql); |
544 |
} |
545 |
// Call the libunit form back |
546 |
formLibunit($libunit_id); |
547 |
} |
548 |
|
549 |
|
550 |
/********************************************************** |
551 |
Function: deleteLocation |
552 |
Author: Paul Bramscher |
553 |
Last Modified: 03.15.2004 |
554 |
*********************************************************** |
555 |
Purpose: |
556 |
Deletes the supplied location id, and removes associations |
557 |
in the resource-location, subject-location, and |
558 |
service-location tables. Also converts any relational |
559 |
location references in Page/CourseScribe pages to text-type |
560 |
fields (non-relational), as well as all user copy-paste |
561 |
buffers. |
562 |
**********************************************************/ |
563 |
function deleteLocation($delMessage, $location_id){ |
564 |
|
565 |
msgTableOpen(1, "Deleting Location (ID# " . $location_id . ")"); |
566 |
printf("<b>Messages:</b><br>\n"); |
567 |
|
568 |
// Cannot delete placeholder #1 |
569 |
if ($location_id > 1) { |
570 |
|
571 |
// First delete from res_loc |
572 |
$sql = "DELETE FROM res_loc WHERE location_id = " . $location_id; |
573 |
if (xx_tryquery ($sql)) printf("Affected resource-location assignments removed.<BR>\n"); |
574 |
|
575 |
// Delete from sub_loc |
576 |
$sql = "DELETE FROM sub_loc WHERE location_id =" . $location_id; |
577 |
if (xx_tryquery ($sql)) printf("Affected subject-location assignments removed.<BR>\n"); |
578 |
|
579 |
// Delete primary subject locations |
580 |
$sql = "UPDATE subject SET sublocation_id = NULL WHERE sublocation_id =" . $location_id; |
581 |
if (xx_tryquery ($sql)) printf("Affected primary subject locations set to NULL.<BR>\n"); |
582 |
|
583 |
// Delete from serv_loc |
584 |
$sql = "DELETE FROM serv_loc WHERE location_id =" . $location_id; |
585 |
if (xx_tryquery ($sql)) printf("Affected service-location assignments removed.<BR>\n"); |
586 |
|
587 |
/******************************** |
588 |
** Update affected CL/PS pages ** |
589 |
********************************/ |
590 |
|
591 |
// First, get the default location description and title |
592 |
$sql = "SELECT location, location_descr FROM location WHERE location_id = " |
593 |
. $location_id; |
594 |
$rs = xx_tryquery($sql); |
595 |
$row = xx_fetch_array ($rs, xx_ASSOC); |
596 |
$location = $row["location"]; |
597 |
$location_descr = $row["location_descr"]; |
598 |
|
599 |
// Clean up strings |
600 |
$location_descr = textInmySQL($location_descr); |
601 |
$location = textInmySQL($location); |
602 |
$delMessage = textInmySQL($delMessage); |
603 |
|
604 |
// Next, append the reason for deletion to the description |
605 |
if (strlen($location_descr) > 0) $location_descr .= "<BR>" . $delMessage; |
606 |
else $location_descr = $delMessage; |
607 |
|
608 |
// Update all of the elements using this resource with a custom description. |
609 |
$sql = "UPDATE element SET label = '" |
610 |
. $location |
611 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
612 |
. $delMessage |
613 |
. "'), location_id = NULL WHERE location_id =" . $location_id |
614 |
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
615 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
616 |
|
617 |
// Next, update all of the elements using this resource without a custom description. |
618 |
$sql = "UPDATE element SET label = '" |
619 |
. $location |
620 |
. "', element_descr = '" |
621 |
. $location_descr |
622 |
. "', location_id = NULL WHERE location_id =" . $location_id |
623 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
624 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
625 |
|
626 |
/********************************** |
627 |
** Update affected CL/PS buffers ** |
628 |
**********************************/ |
629 |
|
630 |
// Update all of the elements using this location with a custom description. |
631 |
$sql = "UPDATE pastebuffer SET label = '" |
632 |
. $location |
633 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
634 |
. $delMessage |
635 |
. "'), location_id = NULL WHERE location_id =" . $location_id |
636 |
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
637 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
638 |
|
639 |
// Next, update all of the elements using this location without a custom description. |
640 |
$sql = "UPDATE pastebuffer SET label = '" |
641 |
. $location |
642 |
. "', element_descr = '" |
643 |
. $location_descr |
644 |
. "', location_id = NULL WHERE location_id =" . $location_id |
645 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
646 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
647 |
|
648 |
// Delete from location |
649 |
$sql = "DELETE FROM location WHERE location_id =" . $location_id; |
650 |
if (xx_tryquery ($sql)) printf("Location successfully removed."); |
651 |
|
652 |
} |
653 |
else printf ("Cannot delete Location ID# 1, it acts as a system placeholder."); |
654 |
|
655 |
printf("<br><br>\n"); |
656 |
msgTableClose(); |
657 |
} |
658 |
|
659 |
|
660 |
/********************************************************** |
661 |
Function: deleteLocationConfirm |
662 |
Author: Paul Bramscher |
663 |
Last Modified: 03.16.2004 |
664 |
*********************************************************** |
665 |
Purpose: |
666 |
Confirm prompt to delete the supplied location id. |
667 |
**********************************************************/ |
668 |
function deleteLocationConfirm($key_id){ |
669 |
|
670 |
$location_id = (int) $key_id; |
671 |
msgTableOpen(1, "Delete Location (ID# " . $location_id . ")?"); |
672 |
|
673 |
// Check to see if its possible |
674 |
$exists = existsRow("location", "location_id", $location_id); |
675 |
if ($exists > 0){ |
676 |
|
677 |
// Lookup the name of the location |
678 |
$location = lookupField("location", "location_id", $location_id, "location"); |
679 |
printf("<b>Location:</b> %s<br><br>\n ", $location); |
680 |
|
681 |
// Form to draw the delete button |
682 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
683 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteLocation\" >\n"); |
684 |
printf("<input type = \"Hidden\" name = \"location_id\" value = \"%d\" >\n", $location_id); |
685 |
|
686 |
// Delete message |
687 |
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
688 |
printf("<input type=\"text\" name=\"delMessage\" value=\"[Location no longer available]\" size=\"75\"><br><br>\n"); |
689 |
|
690 |
// Warning |
691 |
printf("This will permanently remove the location and its various assignments from the system.<BR><BR>\n"); |
692 |
|
693 |
// Delete button |
694 |
printf("<center>\n"); |
695 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
696 |
printf("</center>\n"); |
697 |
printf("</form>\n"); |
698 |
} |
699 |
else if ($exists < 1) printf ("Location not found. Operation cancelled.<br><br>\n"); |
700 |
|
701 |
msgTableClose(); |
702 |
} |
703 |
|
704 |
|
705 |
/********************************************************** |
706 |
Function: deleteMasterinfotype |
707 |
Author: Paul Bramscher |
708 |
Last Modified: 03.16.2004 |
709 |
*********************************************************** |
710 |
Purpose: |
711 |
Delete the supplied master information type id. Note that |
712 |
this function has some additional relational constraints |
713 |
on it. All information types below it are also deleted |
714 |
(not merely having their relationships removed!), as |
715 |
well as their resource-subject-information type assignments. |
716 |
This can have potentially large impact. |
717 |
**********************************************************/ |
718 |
function deleteMasterinfotype($masterinfotype_id){ |
719 |
|
720 |
msgTableOpen(1, "Deleting Master Information Type (ID# " . $masterinfotype_id . ")"); |
721 |
printf("<b>Messages:</b><br>\n"); |
722 |
|
723 |
// Cannot delete placeholder #1 |
724 |
if ($masterinfotype_id > 1) { |
725 |
|
726 |
// Do the following for every information type affected |
727 |
$sql = "SELECT infotype, infotype_id FROM infotype where masterinfotype_id = " |
728 |
. $masterinfotype_id; |
729 |
|
730 |
// Fetch the values |
731 |
$rs = xx_tryquery($sql); |
732 |
while ($row = xx_fetch_array ($rs, xx_ASSOC)) { |
733 |
$infotype_id = $row["infotype_id"]; |
734 |
$infotype = $row["infotype"]; |
735 |
|
736 |
// Display the affected information type currently being processed |
737 |
printf("Deleting affected Information Type <b>%s</b> (%d)<BR>\n", $infotype, $infotype_id); |
738 |
|
739 |
// Delete all res_sub_infotype assignments |
740 |
$sql = "DELETE from res_sub_infotype WHERE infotype_id =" . $infotype_id; |
741 |
if (xx_tryquery ($sql)) printf("Removed resource-subject-infotype associations.<BR>\n"); |
742 |
|
743 |
// Set (N/A) type in resource table |
744 |
$sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; |
745 |
if (xx_tryquery ($sql)) printf("Set default information types for affects resources to (N/A).<BR>\n"); |
746 |
|
747 |
// Delete from infotype table |
748 |
$sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; |
749 |
if (xx_tryquery ($sql)) printf("Removed affected specific information types.<BR>\n"); |
750 |
} |
751 |
|
752 |
// Delete from masterinfotype table |
753 |
$sql = "DELETE FROM masterinfotype WHERE masterinfotype_id =" . $masterinfotype_id; |
754 |
if (xx_tryquery ($sql)) printf("Removed Master Information Type successfully."); |
755 |
|
756 |
} |
757 |
else printf ("Cannot delete Master Information Type ID# 1, it acts as a system placeholder."); |
758 |
|
759 |
printf("<br><br>\n"); |
760 |
msgTableClose(); |
761 |
} |
762 |
|
763 |
|
764 |
/********************************************************** |
765 |
Function: deleteMasterinfotypeConfirm |
766 |
Author: Paul Bramscher |
767 |
Last Modified: 03.16.2004 |
768 |
*********************************************************** |
769 |
Purpose: |
770 |
Confirm prompt for deleting the supplied master information |
771 |
type id. Note the dire warning. |
772 |
**********************************************************/ |
773 |
function deleteMasterinfotypeConfirm($key_id){ |
774 |
|
775 |
$masterinfotype_id = (int) $key_id; |
776 |
msgTableOpen(1, "Delete Master Information Type (ID# " . $masterinfotype_id . ")?"); |
777 |
|
778 |
// Check to see if its possible |
779 |
$exists = existsRow("masterinfotype", "masterinfotype_id", $masterinfotype_id); |
780 |
if ($exists > 0){ |
781 |
|
782 |
// Lookup the descriptive title |
783 |
$masterinfotype = lookupField("masterinfotype", "masterinfotype_id", $masterinfotype_id, "masterinfotype"); |
784 |
printf("<b>Master Information Type:</b> %s<br><br>\n ", $masterinfotype); |
785 |
printf("This will permanently remove the Master Information Type and its various assignments from the system. "); |
786 |
printf("A potentially large deletion cascade may result, since deleting a Master Information Type will delete all Information Types below it. "); |
787 |
printf("<b>All affected resource-subject-infotype assignments on RQS pages will be broken, and therefore removed!</b> "); |
788 |
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>"); |
789 |
printf("Do not proceed unless you are <b>VERY</b> sure of what you're doing.<br><br>\n"); |
790 |
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); |
791 |
printf("<br><br>\n"); |
792 |
|
793 |
// Form to draw the delete button |
794 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
795 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteMasterinfotype\" >\n"); |
796 |
printf("<input type = \"Hidden\" name = \"masterinfotype_id\" value = \"%d\" >\n", $masterinfotype_id); |
797 |
printf("<center>\n"); |
798 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
799 |
printf("</center>\n"); |
800 |
printf("</form>\n"); |
801 |
} |
802 |
else if ($exists < 1) printf ("Master Information Type not found. Operation cancelled.<br><br>\n"); |
803 |
|
804 |
msgTableClose(); |
805 |
} |
806 |
|
807 |
|
808 |
/********************************************************** |
809 |
Function: deleteMastersubject |
810 |
Author: Paul Bramscher |
811 |
Last Modified: 03.16.2004 |
812 |
*********************************************************** |
813 |
Purpose: |
814 |
Delete the supplied master subject id, and removes |
815 |
associations in the subject-mastersubject, |
816 |
resource-mastersubject tables. Currently the system will |
817 |
prompt the user, telling them that dependencies were |
818 |
found, and offer the mastersubject drill down page. So, |
819 |
theoretically, the additional cascades here aren't |
820 |
necessary. |
821 |
**********************************************************/ |
822 |
function deleteMastersubject($mastersubject_id){ |
823 |
|
824 |
msgTableOpen(1, "Deleting Master Subject (ID# " . $mastersubject_id . ")"); |
825 |
printf("<b>Messages:</b><br>\n"); |
826 |
|
827 |
// Cannot delete placeholder #1 |
828 |
if ($mastersubject_id > 1) { |
829 |
|
830 |
// Delete from sub_mastersubject |
831 |
$sql = "DELETE FROM sub_mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
832 |
if (xx_tryquery ($sql)) printf("Affected subject-mastersubject assignments removed.<BR>\n"); |
833 |
|
834 |
// Delete from res_mastersubject |
835 |
$sql = "DELETE FROM res_mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
836 |
if (xx_tryquery ($sql)) printf("Affected resource-mastersubject assignments removed.<BR>\n"); |
837 |
|
838 |
// Delete from mastersubject table |
839 |
$sql = "DELETE FROM mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
840 |
if (xx_tryquery ($sql)) printf("Removed Master Subject successfully."); |
841 |
|
842 |
} |
843 |
else printf ("Cannot delete Master Subject ID# 1, it acts as a system placeholder."); |
844 |
|
845 |
printf("<br><br>\n"); |
846 |
msgTableClose(); |
847 |
} |
848 |
|
849 |
|
850 |
/********************************************************** |
851 |
Function: deleteMastersubjectConfirm |
852 |
Author: Paul Bramscher |
853 |
Last Modified: 03.16.2004 |
854 |
*********************************************************** |
855 |
Purpose: |
856 |
Confirm prompt to delete the supplied mastersubject id. |
857 |
This function also performs some lookups to determine |
858 |
whether any subjects or resources might be affected by |
859 |
a delete operation. If so, the user is presented with a |
860 |
link to the drilldown page and may not delete this |
861 |
mastersubject. |
862 |
**********************************************************/ |
863 |
function deleteMastersubjectConfirm($key_id){ |
864 |
|
865 |
$mastersubject_id = (int) $key_id; |
866 |
msgTableOpen(1, "Delete Master Subject (ID# " . $mastersubject_id . ")?"); |
867 |
|
868 |
// Check to see if its possible |
869 |
$exists = existsRow("mastersubject", "mastersubject_id", $mastersubject_id); |
870 |
if ($exists > 0 && $mastersubject_id > 2){ |
871 |
|
872 |
// Lookup the descriptive title |
873 |
$mastersubject = lookupField("mastersubject", "mastersubject_id", $mastersubject_id, "mastersubject"); |
874 |
printf("<b>Master Subject:</b> %s<br><br>\n ", $mastersubject); |
875 |
|
876 |
// Determine whether any subjects or resources are affected |
877 |
$problem = 0; |
878 |
|
879 |
// Check subjects |
880 |
$sql = "SELECT COUNT(sm.subject_id) as num_subjects FROM sub_mastersubject sm WHERE sm.mastersubject_id =" |
881 |
. $mastersubject_id; |
882 |
$rs = xx_tryquery($sql); |
883 |
$row = xx_fetch_array ($rs, xx_ASSOC); |
884 |
$num_subjects = $row["num_subjects"]; |
885 |
if ($num_subjects > 0) $problem = 1; |
886 |
|
887 |
// Check resources |
888 |
$sql = "SELECT COUNT(rm.resource_id) as num_resources FROM res_mastersubject rm WHERE rm.mastersubject_id = " |
889 |
. $mastersubject_id; |
890 |
$rs = xx_tryquery($sql); |
891 |
$row = xx_fetch_array ($rs, xx_ASSOC); |
892 |
$num_resources = $row["num_resources"]; |
893 |
if ($num_resources > 0) $problem = 1; |
894 |
|
895 |
// Proceed only if no subjects or resources are affected |
896 |
if ($problem == 0) { |
897 |
// Form to draw the delete button |
898 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
899 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteMastersubject\" >\n"); |
900 |
printf("<input type = \"Hidden\" name = \"mastersubject_id\" value = \"%d\" >\n", $mastersubject_id); |
901 |
printf("This will permanently remove the Master Subject from the system. "); |
902 |
printf("Are you sure you want to proceed?<br><br>\n"); |
903 |
printf("<center>\n"); |
904 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
905 |
printf("</center>\n"); |
906 |
printf("</form>\n"); |
907 |
} |
908 |
|
909 |
// There was a problem of some sort. |
910 |
else { |
911 |
printf("Dependencies were found. Master Subjects may not be deleted if there are resources or "); |
912 |
printf("specific subjects assigned to them. "); |
913 |
printf("Examine the <a href=\"mastersubject_drill.phtml?mastersubject_id=%d\">Master Subject Detail</a></b> page.\n", $mastersubject_id); |
914 |
printf("<br><br>\n"); |
915 |
} |
916 |
|
917 |
} |
918 |
else if ($exists < 1) printf ("Master Subject not found. Operation cancelled.<br><br>\n"); |
919 |
else if ($mastersubject_id < 3) printf("Master Subjects ID's #1 and #2 cannot be deleted.<br><br>\n"); |
920 |
|
921 |
msgTableClose(); |
922 |
} |
923 |
|
924 |
|
925 |
/********************************************************** |
926 |
Function: deleteResFeature |
927 |
Author: Paul Bramscher |
928 |
Last Modified: 03.02.2004 |
929 |
*********************************************************** |
930 |
Purpose: |
931 |
Deletes resource-feature associations based on the supplied |
932 |
feature id (possibly multiple) and calls formResource back |
933 |
again. |
934 |
**********************************************************/ |
935 |
function deleteResFeature($key_list_array, $resource_id){ |
936 |
|
937 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
938 |
|
939 |
$sql = "DELETE FROM res_feature WHERE resource_id = " |
940 |
. $resource_id |
941 |
. " AND feature_id = " |
942 |
. $key_list_array[$element]; |
943 |
xx_tryquery ($sql); |
944 |
} |
945 |
// Call the resource form back |
946 |
formResource($resource_id, 0, 0, ''); |
947 |
} |
948 |
|
949 |
|
950 |
/********************************************************** |
951 |
Function: deleteResLoc |
952 |
Author: Paul Bramscher |
953 |
Last Modified: 03.02.2004 |
954 |
*********************************************************** |
955 |
Purpose: |
956 |
Deletes resource-location associations based on the supplied |
957 |
location id (possibly multiple) and calls formResource back |
958 |
again. |
959 |
**********************************************************/ |
960 |
function deleteResLoc($key_list_array, $resource_id){ |
961 |
|
962 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
963 |
$sql = "DELETE FROM res_loc WHERE resource_id = " |
964 |
. $resource_id |
965 |
. " AND location_id = " |
966 |
. $key_list_array[$element]; |
967 |
xx_tryquery ($sql); |
968 |
} |
969 |
// Call the resource form back |
970 |
formResource($resource_id, 0, 0, ''); |
971 |
} |
972 |
|
973 |
|
974 |
/********************************************************** |
975 |
Function: deleteResMastersubject |
976 |
Author: Paul Bramscher |
977 |
Last Modified: 03.02.2004 |
978 |
*********************************************************** |
979 |
Purpose: |
980 |
Deletes resource-mastersubject associations based on the |
981 |
supplied mastersubject id (possibly multiple) and calls |
982 |
formResource back again. |
983 |
**********************************************************/ |
984 |
function deleteResMastersubject($key_list_array, $resource_id){ |
985 |
|
986 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
987 |
|
988 |
$sql = "DELETE FROM res_mastersubject WHERE resource_id = " |
989 |
. $resource_id |
990 |
. " AND mastersubject_id = " |
991 |
. $key_list_array[$element]; |
992 |
xx_tryquery ($sql); |
993 |
} |
994 |
// Call the resource form back |
995 |
formResource($resource_id, 0, 0, ''); |
996 |
} |
997 |
|
998 |
|
999 |
/********************************************************** |
1000 |
Function: deleteResource |
1001 |
Author: Paul Bramscher |
1002 |
Last Modified: 03.16.2004 |
1003 |
*********************************************************** |
1004 |
Purpose: |
1005 |
Deletes the supplied resource id, and removes associations |
1006 |
in the resource-subject-informationtype, resource-location, |
1007 |
resource-mastersubject, and resource-feature tables. |
1008 |
Also converts any relational resource references in |
1009 |
Page/CourseScribe pages to text-type fields (non-relational), |
1010 |
as well as all user copy-paste buffers. |
1011 |
**********************************************************/ |
1012 |
function deleteResource($delMessage, $resource_id){ |
1013 |
|
1014 |
msgTableOpen(1, "Deleting Resource (ID# " . $resource_id . ")"); |
1015 |
printf("<b>Messages:</b><br>\n"); |
1016 |
|
1017 |
// First delete all related rows in res_sub_infotype |
1018 |
$sql = "DELETE FROM res_sub_infotype WHERE resource_id = " . $resource_id; |
1019 |
if (xx_tryquery ($sql)) printf("Resource removed from all resource-subject-infotype assignments.<BR>\n"); |
1020 |
|
1021 |
// Delete from the res_loc table |
1022 |
$sql = "DELETE FROM res_loc WHERE resource_id =" . $resource_id; |
1023 |
if (xx_tryquery ($sql)) printf("Removed from resource-location table.<BR>\n"); |
1024 |
|
1025 |
// Delete from the res_mastersubject table |
1026 |
$sql = "DELETE FROM res_mastersubject WHERE resource_id =" . $resource_id; |
1027 |
if (xx_tryquery ($sql)) printf("Removed from resource-mastersubject table.<BR>\n"); |
1028 |
|
1029 |
// Delete from the res_feature table |
1030 |
$sql = "DELETE FROM res_feature WHERE resource_id =" . $resource_id; |
1031 |
if (xx_tryquery ($sql)) printf("Removed from resource-feature table.<BR>\n"); |
1032 |
|
1033 |
/******************************** |
1034 |
** Update affected CL/PS pages ** |
1035 |
********************************/ |
1036 |
|
1037 |
// First, get the default resource description and title |
1038 |
$sql = "SELECT annotation, title FROM resource WHERE resource_id = " |
1039 |
. $resource_id; |
1040 |
$rs = xx_tryquery($sql); |
1041 |
$row = xx_fetch_array ($rs, xx_ASSOC); |
1042 |
$annotation = $row["annotation"]; |
1043 |
$title = $row["title"]; |
1044 |
|
1045 |
// Clean up |
1046 |
$title = textInmySQL($title); |
1047 |
$annotation = textInmySQL($annotation); |
1048 |
$delMessage = textInmySQL($delMessage); |
1049 |
|
1050 |
// Next, append the reason for deletion to the annotation |
1051 |
if (strlen($annotation) > 0) $annotation .= "<BR>" . $delMessage; |
1052 |
else $annotation = $delMessage; |
1053 |
|
1054 |
// Update all of the elements using this resource with a custom description. |
1055 |
$sql = "UPDATE element SET label = '" |
1056 |
. $title |
1057 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
1058 |
. $delMessage |
1059 |
. "'), resource_id = NULL WHERE resource_id =" . $resource_id |
1060 |
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1061 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1062 |
|
1063 |
// Next, update all of the elements using this resource without a custom description. |
1064 |
$sql = "UPDATE element SET label = '" |
1065 |
. $title |
1066 |
. "', element_descr = '" |
1067 |
. $annotation |
1068 |
. "', resource_id = NULL WHERE resource_id =" . $resource_id |
1069 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
1070 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
1071 |
|
1072 |
/*************************************** |
1073 |
** Update affected CL/PS copy buffers ** |
1074 |
***************************************/ |
1075 |
|
1076 |
// Update all of the elements using this resource with a custom description. |
1077 |
$sql = "UPDATE pastebuffer SET label = '" |
1078 |
. $title |
1079 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
1080 |
. $delMessage |
1081 |
. "'), resource_id = NULL WHERE resource_id =" . $resource_id |
1082 |
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1083 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
1084 |
|
1085 |
// Next, update all of the elements using this resource without a custom description. |
1086 |
$sql = "UPDATE pastebuffer SET label = '" |
1087 |
. $title |
1088 |
. "', element_descr = '" |
1089 |
. $annotation |
1090 |
. "', resource_id = NULL WHERE resource_id =" . $resource_id |
1091 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
1092 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
1093 |
|
1094 |
// Delete from the resource table |
1095 |
$sql = "DELETE FROM resource WHERE resource_id =" . $resource_id; |
1096 |
if (xx_tryquery ($sql)) printf("Successfully removed from all tables."); |
1097 |
|
1098 |
printf("<br><br>\n"); |
1099 |
msgTableClose(); |
1100 |
} |
1101 |
|
1102 |
|
1103 |
/********************************************************** |
1104 |
Function: deleteResourceConfirm |
1105 |
Author: Paul Bramscher |
1106 |
Last Modified: 03.16.2004 |
1107 |
*********************************************************** |
1108 |
Purpose: |
1109 |
Confirm prompt to delete the supplied resource id. |
1110 |
**********************************************************/ |
1111 |
function deleteResourceConfirm($resource_id){ |
1112 |
|
1113 |
$resource_id = (int) $resource_id; |
1114 |
msgTableOpen(1, "Delete Resource (ID# " . $resource_id . ")?"); |
1115 |
|
1116 |
// Check to see if its possible |
1117 |
$exists = existsRow("resource", "resource_id", $resource_id); |
1118 |
if ($exists > 0){ |
1119 |
|
1120 |
// Lookup the title & author |
1121 |
$title = lookupField("resource", "resource_id", $resource_id, "title"); |
1122 |
$author = lookupField("resource", "resource_id", $resource_id, "author"); |
1123 |
printf("<b>Title:</b> %s<br>\n ", $title); |
1124 |
printf("<b>Author:</b> %s<br><br>\n ", $author); |
1125 |
|
1126 |
// Offer a call to the resource drilldown page |
1127 |
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); |
1128 |
|
1129 |
// Form to draw the delete button |
1130 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1131 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteResource\" >\n"); |
1132 |
printf("<input type = \"Hidden\" name = \"resource_id\" value = \"%d\" >\n", $resource_id); |
1133 |
|
1134 |
// Delete message |
1135 |
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
1136 |
printf("<input type=\"text\" name=\"delMessage\" value=\"[Resource no longer available]\" size=\"75\"><br><br>\n"); |
1137 |
|
1138 |
// Warning |
1139 |
printf("This will permanently remove the resource and its various assignments from the system.<BR><BR>\n"); |
1140 |
|
1141 |
// Delete button |
1142 |
printf("<center>\n"); |
1143 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1144 |
printf("</center>\n"); |
1145 |
printf("</form>\n"); |
1146 |
} |
1147 |
else if ($exists < 1) printf ("Resource not found. Operation cancelled.<br><br>\n"); |
1148 |
|
1149 |
msgTableClose(); |
1150 |
} |
1151 |
|
1152 |
|
1153 |
/********************************************************** |
1154 |
Function: deleteService |
1155 |
Author: Paul Bramscher |
1156 |
Last Modified: 03.16.2004 |
1157 |
*********************************************************** |
1158 |
Purpose: |
1159 |
Deletes the supplied service id, and removes associations |
1160 |
in the service-servicetype and service-location tables. |
1161 |
Also converts any relational resource references in |
1162 |
Page/CourseScribe pages to text-type fields (non-relational), |
1163 |
as well as all user copy-paste buffers. |
1164 |
**********************************************************/ |
1165 |
function deleteService($delMessage, $service_id){ |
1166 |
|
1167 |
msgTableOpen(1, "Deleting Service (ID# " . $service_id . ")"); |
1168 |
printf("<b>Messages:</b><br>\n"); |
1169 |
|
1170 |
// First delete all related rows in serv_servtype |
1171 |
$sql = "DELETE FROM serv_servtype WHERE service_id = " . $service_id; |
1172 |
if (xx_tryquery ($sql)) printf("Service removed from all service-servicetype assignments.<BR>\n"); |
1173 |
|
1174 |
// Delete from the serv_loc table |
1175 |
$sql = "DELETE FROM serv_loc WHERE service_id =" . $service_id; |
1176 |
if (xx_tryquery ($sql)) printf("Removed from service-location table.<BR>\n"); |
1177 |
|
1178 |
/******************************** |
1179 |
** Update affected CL/PS pages ** |
1180 |
********************************/ |
1181 |
|
1182 |
// First, get the default service description and title |
1183 |
$sql = "SELECT service, serviceDescr FROM service WHERE service_id = " |
1184 |
. $service_id; |
1185 |
$rs = xx_tryquery($sql); |
1186 |
$row = xx_fetch_array ($rs, xx_ASSOC); |
1187 |
$service = $row["service"]; |
1188 |
$serviceDescr = $row["serviceDescr"]; |
1189 |
|
1190 |
// Clean up strings |
1191 |
$service = textInmySQL($service); |
1192 |
$serviceDescr = textInmySQL($serviceDescr); |
1193 |
$delMessage = textInmySQL($delMessage); |
1194 |
|
1195 |
// Next, append the reason for deletion to the annotation |
1196 |
if (strlen($serviceDescr) > 0) $serviceDescr .= "<BR>" . $delMessage; |
1197 |
else $serviceDescr = $delMessage; |
1198 |
|
1199 |
// Update all of the elements using this service with a custom description. |
1200 |
$sql = "UPDATE element SET label = '" |
1201 |
. $service |
1202 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
1203 |
. $delMessage |
1204 |
. "'), service_id = NULL WHERE service_id =" . $service_id |
1205 |
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1206 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1207 |
|
1208 |
// Next, update all of the elements using this service without a custom description. |
1209 |
$sql = "UPDATE element SET label = '" |
1210 |
. $service |
1211 |
. "', element_descr = '" |
1212 |
. $serviceDescr |
1213 |
. "', service_id = NULL WHERE service_id =" . $service_id |
1214 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
1215 |
|
1216 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
1217 |
|
1218 |
/*************************************** |
1219 |
** Update affected CP/PS copy buffers ** |
1220 |
***************************************/ |
1221 |
|
1222 |
// Update all of the elements using this service with a custom description. |
1223 |
$sql = "UPDATE pastebuffer SET label = '" |
1224 |
. $service |
1225 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
1226 |
. $delMessage |
1227 |
. "'), service_id = NULL WHERE service_id =" . $service_id |
1228 |
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1229 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
1230 |
|
1231 |
// Next, update all of the elements using this service without a custom description. |
1232 |
$sql = "UPDATE pastebuffer SET label = '" |
1233 |
. $service |
1234 |
. "', element_descr = '" |
1235 |
. $serviceDescr |
1236 |
. "', service_id = NULL WHERE service_id =" . $service_id |
1237 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
1238 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
1239 |
|
1240 |
// Delete from the service table |
1241 |
$sql = "DELETE FROM service WHERE service_id =" . $service_id; |
1242 |
if (xx_tryquery ($sql)) printf("Successfully removed from all tables."); |
1243 |
|
1244 |
printf("<br><br>\n"); |
1245 |
msgTableClose(); |
1246 |
} |
1247 |
|
1248 |
|
1249 |
/********************************************************** |
1250 |
Function: deleteServiceConfirm |
1251 |
Author: Paul Bramscher |
1252 |
Last Modified: 03.16.2004 |
1253 |
*********************************************************** |
1254 |
Purpose: |
1255 |
Confirm prompt to delete the supplied service id. |
1256 |
**********************************************************/ |
1257 |
function deleteServiceConfirm($key_id){ |
1258 |
|
1259 |
$service_id = (int) $key_id; |
1260 |
msgTableOpen(1, "Delete Service (ID# " . $service_id . ")?"); |
1261 |
|
1262 |
// Check to see if its possible |
1263 |
$exists = existsRow("service", "service_id", $service_id); |
1264 |
if ($exists > 0){ |
1265 |
|
1266 |
// Lookup the descriptive title |
1267 |
$service = lookupField("service", "service_id", $service_id, "service"); |
1268 |
printf("<b>Service:</b> %s<br><br>\n ", $service); |
1269 |
|
1270 |
// Form to draw the delete button |
1271 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1272 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteService\" >\n"); |
1273 |
printf("<input type = \"Hidden\" name = \"service_id\" value = \"%d\" >\n", $service_id); |
1274 |
|
1275 |
// Delete message |
1276 |
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
1277 |
printf("<input type=\"text\" name=\"delMessage\" value=\"[Service no longer available]\" size=\"75\"><br><br>\n"); |
1278 |
|
1279 |
// Warning |
1280 |
printf("This will permanently remove the service and its various assignments from the system.<BR><BR>\n"); |
1281 |
|
1282 |
// Delete button |
1283 |
printf("<center>\n"); |
1284 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1285 |
printf("</center>\n"); |
1286 |
printf("</form>\n"); |
1287 |
} |
1288 |
else if ($exists < 1) printf ("Service not found. Operation cancelled.<br><br>\n"); |
1289 |
|
1290 |
msgTableClose(); |
1291 |
} |
1292 |
|
1293 |
|
1294 |
/********************************************************** |
1295 |
Function: deleteServicetype |
1296 |
Author: Paul Bramscher |
1297 |
Last Modified: 03.15.2004 |
1298 |
*********************************************************** |
1299 |
Purpose: |
1300 |
Delete the supplied service type id. This will render |
1301 |
some services without a type, but this does not break |
1302 |
anything. |
1303 |
**********************************************************/ |
1304 |
function deleteServicetype($servicetype_id){ |
1305 |
|
1306 |
msgTableOpen(1, "Deleting Service Type (ID# " . $servicetype_id . ")"); |
1307 |
printf("<b>Messages:</b><br>\n"); |
1308 |
|
1309 |
// Cannot delete placeholder #1 |
1310 |
if ($servicetype_id > 1) { |
1311 |
|
1312 |
// Delete from serv_servtype table |
1313 |
$sql = "DELETE FROM serv_servtype WHERE servicetype_id =" . $servicetype_id; |
1314 |
if (xx_tryquery ($sql)) printf("Removed Service-Service Type associations.<BR>\n"); |
1315 |
|
1316 |
// Delete from servicetype table |
1317 |
$sql = "DELETE FROM servicetype WHERE servicetype_id =" . $servicetype_id; |
1318 |
if (xx_tryquery ($sql)) printf("Removed Service Type successfully."); |
1319 |
|
1320 |
} |
1321 |
else printf ("Cannot delete Service Type ID# 1, it acts as a system placeholder."); |
1322 |
|
1323 |
printf("<br><br>\n"); |
1324 |
msgTableClose(); |
1325 |
} |
1326 |
|
1327 |
|
1328 |
/********************************************************** |
1329 |
Function: deleteServicetypeConfirm |
1330 |
Author: Paul Bramscher |
1331 |
Last Modified: 03.16.2004 |
1332 |
*********************************************************** |
1333 |
Purpose: |
1334 |
Confirm prompt to delete the supplied service type id. |
1335 |
**********************************************************/ |
1336 |
function deleteServicetypeConfirm($key_id){ |
1337 |
|
1338 |
$servicetype_id = (int) $key_id; |
1339 |
msgTableOpen(1, "Delete Service Type (ID# " . $servicetype_id . ")?"); |
1340 |
|
1341 |
// Check to see if its possible |
1342 |
$exists = existsRow("servicetype", "servicetype_id", $servicetype_id); |
1343 |
if ($exists > 0){ |
1344 |
|
1345 |
// Lookup the descriptive title |
1346 |
$servicetype = lookupField("servicetype", "servicetype_id", $servicetype_id, "servicetype"); |
1347 |
printf("<b>Service Type:</b> %s<br><br>\n ", $servicetype); |
1348 |
printf("This will permanently remove this Service Type. Note that Services which rely exclusively on this Service Type will be left without a Service Type.<br><br>\n"); |
1349 |
|
1350 |
// Form to draw the delete button |
1351 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1352 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteServicetype\" >\n"); |
1353 |
printf("<input type = \"Hidden\" name = \"servicetype_id\" value = \"%d\" >\n", $servicetype_id); |
1354 |
|
1355 |
// Delete button |
1356 |
printf("<center>\n"); |
1357 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1358 |
printf("</center>\n"); |
1359 |
printf("</form>\n"); |
1360 |
} |
1361 |
else if ($exists < 1) printf ("Service Type not found. Operation cancelled.<br><br>\n"); |
1362 |
|
1363 |
msgTableClose(); |
1364 |
} |
1365 |
|
1366 |
|
1367 |
/********************************************************** |
1368 |
Function: deleteServLoc |
1369 |
Author: Paul Bramscher |
1370 |
Last Modified: 03.02.2004 |
1371 |
*********************************************************** |
1372 |
Purpose: |
1373 |
Deletes service-location associations based on the supplied |
1374 |
location id (possibly multiple) and calls formService back |
1375 |
again. |
1376 |
**********************************************************/ |
1377 |
function deleteServLoc($key_list_array, $service_id){ |
1378 |
|
1379 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1380 |
|
1381 |
$sql = "DELETE FROM serv_loc WHERE service_id = " |
1382 |
. $service_id |
1383 |
. " AND location_id = " |
1384 |
. $key_list_array[$element]; |
1385 |
xx_tryquery ($sql); |
1386 |
} |
1387 |
// Call the service form back |
1388 |
formService($service_id, 0, 0); |
1389 |
} |
1390 |
|
1391 |
|
1392 |
/********************************************************** |
1393 |
Function: deleteServServtype |
1394 |
Author: Paul Bramscher |
1395 |
Last Modified: 03.02.2004 |
1396 |
*********************************************************** |
1397 |
Purpose: |
1398 |
Deletes service-servicetype associations based on the |
1399 |
supplied servicetype id (possibly multiple) and calls |
1400 |
formService back again. |
1401 |
**********************************************************/ |
1402 |
function deleteServServtype($key_list_array, $service_id){ |
1403 |
|
1404 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1405 |
|
1406 |
$sql = "DELETE FROM serv_servtype WHERE service_id = " |
1407 |
. $service_id |
1408 |
. " AND servicetype_id = " |
1409 |
. $key_list_array[$element]; |
1410 |
xx_tryquery ($sql); |
1411 |
} |
1412 |
// Call the service form back |
1413 |
formService($service_id, 0, 0); |
1414 |
} |
1415 |
|
1416 |
|
1417 |
/********************************************************** |
1418 |
Function: deleteStaff |
1419 |
Author: Paul Bramscher |
1420 |
Last Modified: 03.15.2004 |
1421 |
*********************************************************** |
1422 |
Purpose: |
1423 |
Deletes the supplied staff id. This function purges the |
1424 |
staffperson in various places of the system, and converts |
1425 |
any staffpersons-as-elements on PageScribe/CourseLib+ pages |
1426 |
intoto text-type fields (non-relational). The same is done |
1427 |
across all user copy-paste buffers. |
1428 |
**********************************************************/ |
1429 |
function deleteStaff($delMessage, $staff_id){ |
1430 |
|
1431 |
msgTableOpen(1, "Deleting Staff (ID# " . $staff_id . ")"); |
1432 |
printf("<b>Messages:</b><br>\n"); |
1433 |
|
1434 |
// Can't delete admin account (#2) or the '(N/A)' staff (#1) |
1435 |
if ($staff_id > 2) { |
1436 |
|
1437 |
// First delete all related rows in sub_staff |
1438 |
$sql = "DELETE FROM sub_staff WHERE staff_id = " . $staff_id; |
1439 |
if (xx_tryquery ($sql)) printf("All subject-staff assignments for this staff person removed.<BR>\n"); |
1440 |
|
1441 |
// Delete from the course_personnel table |
1442 |
$sql = "DELETE FROM course_personnel WHERE staff_id =" . $staff_id; |
1443 |
if (xx_tryquery ($sql)) printf("Removed this staff person from course personnel tables.<BR>\n"); |
1444 |
|
1445 |
// Delete all related rows in page_staff |
1446 |
$sql = "DELETE FROM page_staff WHERE staff_id = " . $staff_id; |
1447 |
if (xx_tryquery ($sql)) printf("All page-staff assignments for this staff person removed.<BR>\n"); |
1448 |
|
1449 |
/******************************** |
1450 |
** Update affected CL/PS pages ** |
1451 |
********************************/ |
1452 |
|
1453 |
// First, get the staff fields |
1454 |
$sql = "SELECT first_name, last_name FROM staff WHERE staff_id = " |
1455 |
. $staff_id; |
1456 |
$rs = xx_tryquery($sql); |
1457 |
$row = xx_fetch_array ($rs, xx_ASSOC); |
1458 |
$first_name = $row["first_name"]; |
1459 |
$last_name = $row["last_name"]; |
1460 |
|
1461 |
// Clean up strings |
1462 |
$first_name = textInmySQL($first_name); |
1463 |
$last_name = textInmySQL($last_name); |
1464 |
$delMessage = textInmySQL($delMessage); |
1465 |
|
1466 |
// Build a concatenated name |
1467 |
if (strlen($first_name) > 0) $staff_name = $first_name . " " . $last_name; |
1468 |
else $staff_name = $last_name; |
1469 |
|
1470 |
// Update all of the elements using this staffperson with a custom description |
1471 |
$sql = "UPDATE element SET label = '" |
1472 |
. $staff_name |
1473 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
1474 |
. $delMessage |
1475 |
. "'), staff_id = NULL WHERE staff_id =" . $staff_id |
1476 |
. " AND element_descr IS NOT NULL AND element_descr <> ''"; |
1477 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1478 |
|
1479 |
// Handle blank staff description elements |
1480 |
$sql = "UPDATE element SET label = '" |
1481 |
. $staff_name |
1482 |
. "', element_descr = '" |
1483 |
. $delMessage |
1484 |
. "', staff_id = NULL WHERE staff_id =" . $staff_id |
1485 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
1486 |
if (xx_tryquery ($sql)) printf("Added delete message to blank PageScribe descriptions.<BR>\n"); |
1487 |
|
1488 |
/********************************** |
1489 |
** Update affected CL/PS buffers ** |
1490 |
**********************************/ |
1491 |
|
1492 |
// Update all of the elements using this staffperson with a custom description |
1493 |
$sql = "UPDATE pastebuffer SET label = '" |
1494 |
. $staff_name |
1495 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
1496 |
. $delMessage |
1497 |
. "'), staff_id = NULL WHERE staff_id =" . $staff_id |
1498 |
. " AND element_descr IS NOT NULL AND element_descr <> ''"; |
1499 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1500 |
|
1501 |
// Handle blank staff description pastebuffer elements |
1502 |
$sql = "UPDATE pastebuffer SET label = '" |
1503 |
. $staff_name |
1504 |
. "', element_descr = '" |
1505 |
. $delMessage |
1506 |
. "', staff_id = NULL WHERE staff_id =" . $staff_id |
1507 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
1508 |
if (xx_tryquery ($sql)) printf("Added delete message to blank PageScribe descriptions.<BR>\n"); |
1509 |
|
1510 |
// Delete from the staff table |
1511 |
$sql = "DELETE FROM staff WHERE staff_id =" . $staff_id; |
1512 |
if (xx_tryquery ($sql)) printf("Removed this staff person successfully."); |
1513 |
} |
1514 |
else printf ("Cannot delete Staff ID's #1-2. Operation cancelled."); |
1515 |
|
1516 |
printf("<br><br>\n"); |
1517 |
msgTableClose(); |
1518 |
|
1519 |
} // end function |
1520 |
|
1521 |
|
1522 |
/********************************************************** |
1523 |
Function: deleteStaffConfirm |
1524 |
Author: Paul Bramscher |
1525 |
Last Modified: 03.16.2004 |
1526 |
*********************************************************** |
1527 |
Purpose: |
1528 |
Confirm prompt to delete the supplied staff id. This |
1529 |
function also collects a "delete message" which is concatenated |
1530 |
to the description on affected PageScribe/CourseLib+ pages |
1531 |
as the staffperson is converted from a relational to a |
1532 |
text-type element. |
1533 |
**********************************************************/ |
1534 |
function deleteStaffConfirm($staff_id){ |
1535 |
|
1536 |
$staff_id = (int) $staff_id; |
1537 |
msgTableOpen(1, "Delete Staff (ID# " . $staff_id . ")?"); |
1538 |
|
1539 |
// Check to see if its possible |
1540 |
$exists = existsRow("staff", "staff_id", $staff_id); |
1541 |
if ($exists > 0){ |
1542 |
|
1543 |
// Lookup the first and last names |
1544 |
$first_name = lookupField("staff", "staff_id", $staff_id, "first_name"); |
1545 |
$last_name = lookupField("staff", "staff_id", $staff_id, "last_name"); |
1546 |
printf("<b>Staffperson:</b> %s %s<br><br>\n ", $first_name, $last_name); |
1547 |
|
1548 |
// Form to draw the delete button |
1549 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1550 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteStaff\" >\n"); |
1551 |
printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >\n", $staff_id); |
1552 |
|
1553 |
// Delete message |
1554 |
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
1555 |
printf("<input type=\"text\" name=\"delMessage\" value=\"[Staffperson no longer available]\" size=\"75\"><br><br>\n"); |
1556 |
|
1557 |
// Warning |
1558 |
printf("This will permanently remove this staffperson and his/her various assignments from the system.<BR><BR>\n"); |
1559 |
|
1560 |
// Delete button |
1561 |
printf("<center>\n"); |
1562 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1563 |
printf("</center>\n"); |
1564 |
printf("</form>\n"); |
1565 |
} |
1566 |
else if ($exists < 1) printf ("Staffperson not found. Operation cancelled.<br><br>\n"); |
1567 |
|
1568 |
msgTableClose(); |
1569 |
} |
1570 |
|
1571 |
|
1572 |
/********************************************************** |
1573 |
Function: deleteStaffLibunit |
1574 |
Author: Paul Bramscher |
1575 |
Last Modified: 03.03.2004 |
1576 |
*********************************************************** |
1577 |
Purpose: |
1578 |
Delete the staff-libunit associations (possibly multiple) |
1579 |
for the supplied staff id, then calls formStaff back again. |
1580 |
This works the same table as deleteLibunitStaff, but with |
1581 |
emphasis on the other side of the multiple pick list. |
1582 |
**********************************************************/ |
1583 |
function deleteStaffLibunit($key_list_array, $staff_id){ |
1584 |
|
1585 |
// For every libunit in the array, delete it from the bridging table |
1586 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1587 |
|
1588 |
$sql = "DELETE FROM libunit_staff WHERE staff_id = " |
1589 |
. $staff_id |
1590 |
. " AND libunit_id = " |
1591 |
. $key_list_array[$element]; |
1592 |
xx_tryquery($sql); |
1593 |
} |
1594 |
// Call the staff form back |
1595 |
formStaff($staff_id); |
1596 |
} |
1597 |
|
1598 |
|
1599 |
/********************************************************** |
1600 |
Function: deleteStaffSub |
1601 |
Author: Paul Bramscher |
1602 |
Last Modified: 03.03.2004 |
1603 |
*********************************************************** |
1604 |
Purpose: |
1605 |
Deletes the staff-subject associations (possibly multiple) |
1606 |
for the supplied staff id, and calls formStaff back again. |
1607 |
This works the same table as deleteSubStaff (found in |
1608 |
application.php, not this ssl counterpart), but with |
1609 |
emphasis on the other side of the multiple pick list. |
1610 |
**********************************************************/ |
1611 |
function deleteStaffSub($key_list_array, $staff_id){ |
1612 |
|
1613 |
// For a given staff person, delete every associated subject in the array |
1614 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1615 |
|
1616 |
$sql = "DELETE FROM sub_staff where staff_id = " |
1617 |
. $staff_id |
1618 |
. " AND subject_id = " |
1619 |
. $key_list_array[$element]; |
1620 |
xx_tryquery($sql); |
1621 |
} |
1622 |
// Call the staff form back |
1623 |
formStaff($staff_id); |
1624 |
} |
1625 |
|
1626 |
|
1627 |
/********************************************************** |
1628 |
Function: deleteStafftitle |
1629 |
Author: Paul Bramscher |
1630 |
Last Modified: 03.16.2004 |
1631 |
*********************************************************** |
1632 |
Purpose: |
1633 |
Deletes the supplied staff job title id. Any staff currently |
1634 |
using this title are set to the (N/A) placeholder title. |
1635 |
**********************************************************/ |
1636 |
function deleteStafftitle($stafftitle_id){ |
1637 |
|
1638 |
msgTableOpen(1, "Deleting Staff Title (ID# " . $stafftitle_id . ")"); |
1639 |
printf("<b>Messages:</b><br>\n"); |
1640 |
|
1641 |
if ($stafftitle_id > 1) { |
1642 |
// First update all rows in staff to (N/A) |
1643 |
$sql = "UPDATE staff SET stafftitle_id = 1 WHERE stafftitle_id = " . $stafftitle_id; |
1644 |
if (xx_tryquery ($sql)) printf("Successfully set affected staff titles to (N/A).<BR>\n"); |
1645 |
|
1646 |
// Delete from the title table |
1647 |
$sql = "DELETE FROM stafftitle WHERE stafftitle_id =" . $stafftitle_id; |
1648 |
if (xx_tryquery ($sql)) printf("Removed this staff title successfully."); |
1649 |
|
1650 |
} |
1651 |
else printf ("Cannot delete Staff Title ID# 1, it acts as a system placeholder."); |
1652 |
|
1653 |
printf("<br><br>\n"); |
1654 |
msgTableClose(); |
1655 |
} |
1656 |
|
1657 |
|
1658 |
/********************************************************** |
1659 |
Function: deleteStafftitleConfirm |
1660 |
Author: Paul Bramscher |
1661 |
Last Modified: 03.16.2004 |
1662 |
*********************************************************** |
1663 |
Purpose: |
1664 |
Confirm prompt for deleting the supplied staff title id. |
1665 |
**********************************************************/ |
1666 |
function deleteStafftitleConfirm($key_id){ |
1667 |
|
1668 |
$stafftitle_id = (int) $key_id; |
1669 |
msgTableOpen(1, "Delete Staff Title (ID# " . $stafftitle_id . ")?"); |
1670 |
|
1671 |
// Check to see if its possible |
1672 |
$exists = existsRow("stafftitle", "stafftitle_id", $stafftitle_id); |
1673 |
if ($exists > 0){ |
1674 |
|
1675 |
// Lookup the descriptive title |
1676 |
$stafftitle = lookupField("stafftitle", "stafftitle_id", $stafftitle_id, "stafftitle"); |
1677 |
printf("<b>Staff Title:</b> %s<br><br>\n ", $stafftitle); |
1678 |
printf("This will permanently remove this staff title and its various assignments from the system. Some staff will be set to (N/A).<BR><BR>\n"); |
1679 |
|
1680 |
// Form to draw the delete button |
1681 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1682 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteStafftitle\" >\n"); |
1683 |
printf("<input type = \"Hidden\" name = \"stafftitle_id\" value = \"%d\" >\n", $stafftitle_id); |
1684 |
printf("<center>\n"); |
1685 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1686 |
printf("</center>\n"); |
1687 |
printf("</form>\n"); |
1688 |
} |
1689 |
else if ($exists < 1) printf ("Staff Title not found. Operation cancelled.<br><br>\n"); |
1690 |
|
1691 |
msgTableClose(); |
1692 |
} |
1693 |
|
1694 |
|
1695 |
/********************************************************** |
1696 |
Function: deleteStyle |
1697 |
Author: Paul Bramscher |
1698 |
Last Modified: 03.16.2004 |
1699 |
*********************************************************** |
1700 |
Purpose: |
1701 |
Deletes the supplied style id. Any pages currently |
1702 |
using this style are set to the (N/A) placeholder style. |
1703 |
Note that the actual header, footer, and css files are |
1704 |
not deleted -- only the references to them. |
1705 |
**********************************************************/ |
1706 |
function deleteStyle($style_id){ |
1707 |
|
1708 |
msgTableOpen(1, "Deleting Style (ID# " . $style_id . ")"); |
1709 |
printf("<b>Messages:</b><br>\n"); |
1710 |
|
1711 |
if ($style_id > 2) { |
1712 |
// First update all affected rows in page to (N/A) |
1713 |
$sql = "UPDATE page SET style_id = 1 WHERE style_id = " . $style_id; |
1714 |
if (xx_tryquery ($sql)) printf("Successfully set affected page styles to (N/A).<BR>\n"); |
1715 |
|
1716 |
// Delete from the style table |
1717 |
$sql = "DELETE FROM style WHERE style_id =" . $style_id; |
1718 |
if (xx_tryquery ($sql)) printf("Removed this style successfully."); |
1719 |
|
1720 |
} |
1721 |
else { |
1722 |
printf("Cannot delete Style ID's #1 and #2. #1 acts as a system placeholder, #2 "); |
1723 |
printf("is the default style for new pages, but may be renamed or redefined as "); |
1724 |
printf("needed."); |
1725 |
} |
1726 |
|
1727 |
printf("<br><br>\n"); |
1728 |
msgTableClose(); |
1729 |
} |
1730 |
|
1731 |
|
1732 |
/********************************************************** |
1733 |
Function: deleteStyleConfirm |
1734 |
Author: Paul Bramscher |
1735 |
Last Modified: 03.16.2004 |
1736 |
*********************************************************** |
1737 |
Purpose: |
1738 |
Confirm prompt for deleting the supplied style id |
1739 |
**********************************************************/ |
1740 |
function deleteStyleConfirm($key_id){ |
1741 |
|
1742 |
$style_id = (int) $key_id; |
1743 |
msgTableOpen(1, "Delete Style (ID# " . $style_id . ")?"); |
1744 |
|
1745 |
// Check to see if its possible |
1746 |
$exists = existsRow("style", "style_id", $style_id); |
1747 |
if ($exists > 0){ |
1748 |
|
1749 |
// Lookup the descriptive title |
1750 |
$style_title = lookupField("style", "style_id", $style_id, "style_title"); |
1751 |
printf("<b>Style Title:</b> %s<br><br>\n ", $style_title); |
1752 |
printf("This will permanently remove this style and "); |
1753 |
printf("assign affected pages to the (N/A) style. Note that this function does "); |
1754 |
printf("not actually delete any header, footer or css files -- only the references "); |
1755 |
printf("to them. If a default page style is not properly configured, pages without "); |
1756 |
printf("a style may fail to display properly, and should be assigned a new style.<BR><BR>\n"); |
1757 |
|
1758 |
// Form to draw the delete button |
1759 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1760 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteStyle\" >\n"); |
1761 |
printf("<input type = \"Hidden\" name = \"style_id\" value = \"%d\" >\n", $style_id); |
1762 |
printf("<center>\n"); |
1763 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1764 |
printf("</center>\n"); |
1765 |
printf("</form>\n"); |
1766 |
} |
1767 |
else if ($exists < 1) printf ("Style not found. Operation cancelled.<br><br>\n"); |
1768 |
|
1769 |
msgTableClose(); |
1770 |
} |
1771 |
|
1772 |
|
1773 |
/********************************************************** |
1774 |
Function: deleteSubCoursesub |
1775 |
Author: Paul Bramscher |
1776 |
Last Modified: 03.02.2004 |
1777 |
*********************************************************** |
1778 |
Purpose: |
1779 |
Deletes subject-coursesub associations based on the supplied |
1780 |
coursesub id (possibly multiple) and calls formSubject back |
1781 |
again. |
1782 |
**********************************************************/ |
1783 |
function deleteSubCoursesub($key_list_array, $subject_id){ |
1784 |
|
1785 |
// For the given subject, delete every location in the array |
1786 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1787 |
|
1788 |
$sql = "DELETE FROM sub_coursesub WHERE subject_id = " |
1789 |
. $subject_id |
1790 |
. " AND coursesub_id = " |
1791 |
. $key_list_array[$element]; |
1792 |
xx_tryquery ($sql); |
1793 |
} |
1794 |
// Call the subject form back |
1795 |
formSubject($subject_id); |
1796 |
} |
1797 |
|
1798 |
|
1799 |
/********************************************************** |
1800 |
Function: deleteSubject |
1801 |
Author: Paul Bramscher |
1802 |
Last Modified: 03.16.2004 |
1803 |
*********************************************************** |
1804 |
Purpose: |
1805 |
Deletes a subject, and removes associations in the |
1806 |
resource-subject-informationtype, subject-location, |
1807 |
subject-mastersubject, subject-coursesub, and |
1808 |
subject-staff tables. |
1809 |
**********************************************************/ |
1810 |
function deleteSubject($delMessage, $subject_id){ |
1811 |
|
1812 |
msgTableOpen(1, "Deleting Subject (ID# " . $subject_id .")"); |
1813 |
printf("<b>Messages:</b><br>\n"); |
1814 |
|
1815 |
// Cannot delete placeholder #1 |
1816 |
if ($subject_id > 1) { |
1817 |
|
1818 |
// First delete all related rows in res_sub_infotype |
1819 |
$sql = "DELETE FROM res_sub_infotype WHERE subject_id = " . $subject_id; |
1820 |
if (xx_tryquery ($sql)) printf("Resource-subject-information type associations removed.<BR>\n"); |
1821 |
|
1822 |
// Delete from the sub_loc table |
1823 |
$sql = "DELETE FROM sub_loc WHERE subject_id =" . $subject_id; |
1824 |
if (xx_tryquery ($sql)) printf("Subject-location associations removed.<BR>\n"); |
1825 |
|
1826 |
// Delete from the sub_mastersubject table |
1827 |
$sql = "DELETE FROM sub_mastersubject WHERE subject_id =" . $subject_id; |
1828 |
if (xx_tryquery ($sql)) printf("Subject-mastersubject associations removed.<BR>\n"); |
1829 |
|
1830 |
// Delete from the sub_staff table |
1831 |
$sql = "DELETE FROM sub_staff WHERE subject_id =" . $subject_id; |
1832 |
if (xx_tryquery ($sql)) printf("Subject-staff assignments removed.<BR>\n"); |
1833 |
|
1834 |
// Delete from the sub_coursesub table |
1835 |
$sql = "DELETE FROM sub_coursesub WHERE subject_id =" . $subject_id; |
1836 |
if (xx_tryquery ($sql)) printf("Subject-Course Subject assignments removed.<BR>\n"); |
1837 |
|
1838 |
// Delete from the sub_page table |
1839 |
$sql = "DELETE FROM sub_page WHERE subject_id =" . $subject_id; |
1840 |
if (xx_tryquery ($sql)) printf("Subject-Page assignments removed.<BR>\n"); |
1841 |
|
1842 |
// Delete from the sub_othersub table |
1843 |
$sql = "DELETE FROM sub_othersub WHERE othersub_id =" |
1844 |
. $subject_id |
1845 |
. " OR subject_id = " |
1846 |
. $subject_id; |
1847 |
if (xx_tryquery ($sql)) printf("Subject-Other Subject assignments removed.<BR>\n"); |
1848 |
|
1849 |
/******************************** |
1850 |
** Update affected CL/PS pages ** |
1851 |
********************************/ |
1852 |
|
1853 |
// First, get the default subject description and title |
1854 |
$sql = "SELECT subject, subject_descr FROM subject WHERE subject_id = " |
1855 |
. $subject_id; |
1856 |
$rs = xx_tryquery($sql); |
1857 |
$row = xx_fetch_array ($rs, xx_ASSOC); |
1858 |
$subject = $row["subject"]; |
1859 |
$subject_descr = $row["subject_descr"]; |
1860 |
|
1861 |
// Clean up strings |
1862 |
$subject_descr = textInmySQL($subject_descr); |
1863 |
$subject = textInmySQL($subject); |
1864 |
$delMessage = textInmySQL($delMessage); |
1865 |
|
1866 |
// Next, append the reason for deletion to the description |
1867 |
if (strlen($subject_descr) > 0) $subject_descr .= "<BR>" . $delMessage; |
1868 |
else $subject_descr = $delMessage; |
1869 |
|
1870 |
// Update all of the elements using this resource with a custom description. |
1871 |
$sql = "UPDATE element SET label = '" |
1872 |
. $subject |
1873 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
1874 |
. $delMessage |
1875 |
. "'), subject_id = NULL WHERE subject_id =" . $subject_id |
1876 |
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1877 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1878 |
|
1879 |
// Next, update all of the elements using this resource without a custom description. |
1880 |
$sql = "UPDATE element SET label = '" |
1881 |
. $subject |
1882 |
. "', element_descr = '" |
1883 |
. $subject_descr |
1884 |
. "', subject_id = NULL WHERE subject_id =" . $subject_id |
1885 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
1886 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
1887 |
|
1888 |
/*************************************** |
1889 |
** Update affected CL/PS copy buffers ** |
1890 |
***************************************/ |
1891 |
|
1892 |
// Update all of the elements using this location with a custom description. |
1893 |
$sql = "UPDATE pastebuffer SET label = '" |
1894 |
. $subject |
1895 |
. "', element_descr = CONCAT(element_descr, '<BR>" |
1896 |
. $delMessage |
1897 |
. "'), subject_id = NULL WHERE subject_id =" . $subject_id |
1898 |
. " AND (element_descr IS NOT NULL OR element_descr != '')"; |
1899 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
1900 |
|
1901 |
// Next, update all of the elements using this location without a custom description. |
1902 |
$sql = "UPDATE pastebuffer SET label = '" |
1903 |
. $subject |
1904 |
. "', element_descr = '" |
1905 |
. $subject_descr |
1906 |
. "', subject_id = NULL WHERE subject_id =" . $subject_id |
1907 |
. " AND (element_descr IS NULL OR element_descr = '')"; |
1908 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
1909 |
|
1910 |
// Finally delete from the subject table |
1911 |
$sql = "DELETE FROM subject WHERE subject_id =" . $subject_id; |
1912 |
if (xx_tryquery ($sql)) printf("Successfully removed this subject from the system."); |
1913 |
} |
1914 |
else printf ("Cannot delete Subject ID# 1, it acts as a system placeholder."); |
1915 |
|
1916 |
printf("<br><br>\n"); |
1917 |
msgTableClose(); |
1918 |
} |
1919 |
|
1920 |
|
1921 |
/********************************************************** |
1922 |
Function: deleteSubjectConfirm |
1923 |
Author: Paul Bramscher |
1924 |
Last Modified: 03.16.2004 |
1925 |
*********************************************************** |
1926 |
Purpose: |
1927 |
Confirm prompt to delete the supplied subject id. |
1928 |
**********************************************************/ |
1929 |
function deleteSubjectConfirm($key_id){ |
1930 |
|
1931 |
$subject_id = (int) $key_id; |
1932 |
msgTableOpen(1, "Delete Subject (ID# " . $subject_id . ")?"); |
1933 |
|
1934 |
// Check to see if its possible |
1935 |
$exists = existsRow("subject", "subject_id", $subject_id); |
1936 |
if ($exists > 0){ |
1937 |
|
1938 |
// Lookup the descriptive title |
1939 |
$subject = lookupField("subject", "subject_id", $subject_id, "subject"); |
1940 |
printf("<b>Subject:</b> %s<br><br>\n ", $subject); |
1941 |
|
1942 |
// Form to draw the delete button |
1943 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
1944 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteSubject\" >\n"); |
1945 |
printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id); |
1946 |
|
1947 |
// Delete message |
1948 |
printf("<b>Message to appear on affected PageScribe Pages</b> (75 char max.):<br>\n"); |
1949 |
printf("<input type=\"text\" name=\"delMessage\" value=\"[RQS subject no longer available]\" size=\"75\"><br><br>\n"); |
1950 |
|
1951 |
printf("This will permanently remove the subject and its various subject assignments from the system. |
1952 |
This includes assignments to resources, master/general subjects, locations and staff specialists.<BR><BR>"); |
1953 |
printf("<center>\n"); |
1954 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1955 |
printf("</center>\n"); |
1956 |
printf("</form>\n"); |
1957 |
} |
1958 |
else if ($exists < 1) printf ("Subject not found. Operation cancelled.<br><br>\n"); |
1959 |
|
1960 |
msgTableClose(); |
1961 |
} |
1962 |
|
1963 |
|
1964 |
/********************************************************** |
1965 |
Function: deleteSubLoc |
1966 |
Author: Paul Bramscher |
1967 |
Last Modified: 03.03.2004 |
1968 |
*********************************************************** |
1969 |
Purpose: |
1970 |
Deletes subject-location associations based on the supplied |
1971 |
location id (possibly multiple) and calls formSubject back |
1972 |
again. |
1973 |
**********************************************************/ |
1974 |
function deleteSubLoc($key_list_array, $subject_id){ |
1975 |
|
1976 |
// For the given subject, delete every location in the array |
1977 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
1978 |
|
1979 |
$sql = "DELETE FROM sub_loc WHERE subject_id = " |
1980 |
. $subject_id |
1981 |
. " AND location_id = " |
1982 |
. $key_list_array[$element]; |
1983 |
xx_tryquery($sql); |
1984 |
} |
1985 |
// Call the subject form back |
1986 |
formSubject($subject_id); |
1987 |
} |
1988 |
|
1989 |
|
1990 |
/********************************************************** |
1991 |
Function: deleteSubMaster |
1992 |
Author: Paul Bramscher |
1993 |
Last Modified: 03.03.2004 |
1994 |
*********************************************************** |
1995 |
Purpose: |
1996 |
Deletes subject-mastersubject associations based on the |
1997 |
supplied mastersubject id (possibly multiple) and calls |
1998 |
formSubject back again. |
1999 |
**********************************************************/ |
2000 |
function deleteSubMaster($key_list_array, $subject_id){ |
2001 |
|
2002 |
// For every mastersubject in the array, delete it from the bridging table |
2003 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2004 |
|
2005 |
$sql = "DELETE FROM sub_mastersubject WHERE subject_id = " |
2006 |
. $subject_id |
2007 |
. " AND mastersubject_id = " |
2008 |
. $key_list_array[$element]; |
2009 |
xx_tryquery($sql); |
2010 |
} |
2011 |
// Call the subject form back |
2012 |
formSubject($subject_id); |
2013 |
} |
2014 |
|
2015 |
|
2016 |
/********************************************************** |
2017 |
Function: deleteSubStaff |
2018 |
Author: Paul Bramscher |
2019 |
Last Modified: 03.03.2004 |
2020 |
*********************************************************** |
2021 |
Purpose: |
2022 |
Deletes staff-subject associations for the supplied staff |
2023 |
id (possibly multiple) and calls formSubject back again. |
2024 |
**********************************************************/ |
2025 |
function deleteSubStaff($key_list_array, $subject_id){ |
2026 |
|
2027 |
// For a given subject, delete all staff in the array |
2028 |
for ($element = 0; $element < sizeof($key_list_array); $element++) { |
2029 |
|
2030 |
$sql = "DELETE FROM sub_staff WHERE subject_id = " |
2031 |
. $subject_id |
2032 |
. " AND staff_id = " |
2033 |
. $key_list_array[$element]; |
2034 |
xx_tryquery($sql); |
2035 |
} |
2036 |
// Call the subject form back |
2037 |
formSubject($subject_id); |
2038 |
} |
2039 |
|
2040 |
|
2041 |
/********************************************************** |
2042 |
Function: deleteTerm |
2043 |
Author: Paul Bramscher |
2044 |
Last Modified: 03.16.2004 |
2045 |
*********************************************************** |
2046 |
Purpose: |
2047 |
Deletes the supplied term id, and removes references in |
2048 |
the course table. |
2049 |
**********************************************************/ |
2050 |
function deleteTerm($term_id){ |
2051 |
|
2052 |
msgTableOpen(1, "Deleting Term (ID# " . $term_id . ")"); |
2053 |
printf("<b>Messages:</b><br>\n"); |
2054 |
|
2055 |
// Cannot delete placeholder #1 |
2056 |
if ($term_id > 1) { |
2057 |
|
2058 |
// Delete all course term assignments |
2059 |
$sql = "UPDATE course SET term_id = NULL WHERE term_id =" . $term_id; |
2060 |
if (xx_tryquery ($sql)) printf("Removed this term from affected course pages.<BR>\n"); |
2061 |
|
2062 |
// Delete from term table |
2063 |
$sql = "DELETE FROM term WHERE term_id =" . $term_id; |
2064 |
if (xx_tryquery ($sql)) printf("Removed term successfully."); |
2065 |
} |
2066 |
else printf ("Cannot delete Term ID# 1, it acts as a system placeholder."); |
2067 |
|
2068 |
printf("<br><br>\n"); |
2069 |
msgTableClose(); |
2070 |
} |
2071 |
|
2072 |
|
2073 |
/********************************************************** |
2074 |
Function: deleteTermConfirm |
2075 |
Author: Paul Bramscher |
2076 |
Last Modified: 03.16.2004 |
2077 |
*********************************************************** |
2078 |
Purpose: |
2079 |
Confirm prompt for deleting the supplied term id. |
2080 |
**********************************************************/ |
2081 |
function deleteTermConfirm($key_id){ |
2082 |
|
2083 |
$term_id = (int) $key_id; |
2084 |
msgTableOpen(1, "Delete Term (ID# " . $term_id . ")?"); |
2085 |
|
2086 |
// Check to see if its possible |
2087 |
$exists = existsRow("term", "term_id", $term_id); |
2088 |
if ($exists > 0){ |
2089 |
|
2090 |
// Lookup the descriptive title |
2091 |
$term = lookupField("term", "term_id", $term_id, "term"); |
2092 |
printf("<b>Term:</b> %s<br><br>\n ", $term); |
2093 |
printf("This will permanently remove this academic term. Some courses may no longer have terms.<BR><BR>\n"); |
2094 |
|
2095 |
// Form to draw the delete button |
2096 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
2097 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteTerm\" >\n"); |
2098 |
printf("<input type = \"Hidden\" name = \"term_id\" value = \"%d\" >\n", $term_id); |
2099 |
printf("<center>\n"); |
2100 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
2101 |
printf("</center>\n"); |
2102 |
printf("</form>\n"); |
2103 |
} |
2104 |
else if ($exists < 1) printf ("Term not found. Operation cancelled.<br><br>\n"); |
2105 |
|
2106 |
msgTableClose(); |
2107 |
} |
2108 |
|
2109 |
|
2110 |
/********************************************************** |
2111 |
Function: deleteVendor |
2112 |
Author: Paul Bramscher |
2113 |
Last Modified: 03.15.2004 |
2114 |
*********************************************************** |
2115 |
Purpose: |
2116 |
Deletes a supplied vendor id, sets affected resources |
2117 |
to (N/A) vendor. |
2118 |
**********************************************************/ |
2119 |
function deleteVendor($vendor_id){ |
2120 |
|
2121 |
msgTableOpen(1, "Deleting Vendor (ID# " . $vendor_id . ")"); |
2122 |
printf("<b>Messages:</b><br>\n"); |
2123 |
|
2124 |
// Cannot delete placeholder #1. |
2125 |
if ($vendor_id > 1) { |
2126 |
|
2127 |
// First update affected resources |
2128 |
$sql = "UPDATE resource SET vendor_id = NULL WHERE vendor_id = " |
2129 |
. $vendor_id; |
2130 |
if (xx_tryquery ($sql)) printf("Vendor purged from assignments to resources.<BR>\n"); |
2131 |
|
2132 |
// Delete from the vendor table |
2133 |
$sql = "DELETE FROM vendor WHERE vendor_id =" . $vendor_id; |
2134 |
if (xx_tryquery ($sql)) printf("Removed this vendor successfully."); |
2135 |
|
2136 |
} |
2137 |
else printf ("Cannot delete Vendor ID# 1, it acts as a system placeholder."); |
2138 |
|
2139 |
printf("<br><br>\n"); |
2140 |
msgTableClose(); |
2141 |
} |
2142 |
|
2143 |
|
2144 |
/********************************************************** |
2145 |
Function: deleteVendorConfirm |
2146 |
Author: Paul Bramscher |
2147 |
Last Modified: 03.16.2004 |
2148 |
*********************************************************** |
2149 |
Purpose: |
2150 |
Confirm prompt for deleting the selected vendor. |
2151 |
**********************************************************/ |
2152 |
function deleteVendorConfirm($key_id){ |
2153 |
|
2154 |
$vendor_id = (int) $key_id; |
2155 |
msgTableOpen(1, "Delete Vendor (ID# " . $vendor_id . ")?"); |
2156 |
|
2157 |
// Check to see if its possible |
2158 |
$exists = existsRow("vendor", "vendor_id", $vendor_id); |
2159 |
if ($exists > 0){ |
2160 |
|
2161 |
// Lookup the descriptive title |
2162 |
$vendor = lookupField("vendor", "vendor_id", $vendor_id, "vendor"); |
2163 |
printf("<b>Vendor:</b> %s<br><br>\n ", $vendor); |
2164 |
printf("This will permanently remove this vendor and its various assignments from the system. Some resources may lose their vendor association.<BR><BR>"); |
2165 |
|
2166 |
// Form to draw the delete button |
2167 |
printf("<form method = \"POST\" action = \"delete.phtml\" >\n"); |
2168 |
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteVendor\" >\n"); |
2169 |
printf("<input type = \"Hidden\" name = \"vendor_id\" value = \"%d\" >\n", $vendor_id); |
2170 |
printf("<center>\n"); |
2171 |
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
2172 |
printf("</center>\n"); |
2173 |
printf("</form>\n"); |
2174 |
} |
2175 |
else if ($exists < 1) printf ("Vendor not found. Operation cancelled.<br><br>\n"); |
2176 |
|
2177 |
msgTableClose(); |
2178 |
} |
2179 |
?> |