1 |
dpavlin |
1 |
<?php |
2 |
|
|
/********************************************************** |
3 |
|
|
Function Library: delete.php |
4 |
dpavlin |
67 |
Original Author: Paul Bramscher <brams006@umn.edu> |
5 |
|
|
Last Modified: 03.16.2004 by Paul Bramscher |
6 |
dpavlin |
1 |
*********************************************************** |
7 |
|
|
Comments: |
8 |
|
|
This library brings together all SQL delete functions |
9 |
dpavlin |
67 |
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 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
deleteResMastersubject |
37 |
dpavlin |
1 |
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 |
dpavlin |
67 |
deleteVendor |
62 |
|
|
deleteVendorConfirm |
63 |
dpavlin |
1 |
**********************************************************/ |
64 |
|
|
|
65 |
|
|
|
66 |
|
|
/********************************************************** |
67 |
|
|
Function: deleteCampus |
68 |
|
|
Author: Paul Bramscher |
69 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
70 |
dpavlin |
1 |
*********************************************************** |
71 |
|
|
Purpose: |
72 |
|
|
Deletes a supplied campus id, sets affected course |
73 |
|
|
pages to NULL campus. |
74 |
|
|
**********************************************************/ |
75 |
dpavlin |
67 |
function deleteCampus($campus_id){ |
76 |
dpavlin |
1 |
|
77 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Campus (ID# " . $campus_id . ")"); |
78 |
|
|
printf("<b>Messages:</b><br>\n"); |
79 |
dpavlin |
1 |
|
80 |
|
|
// Cannot delete placeholder #1. |
81 |
|
|
if ($campus_id > 1) { |
82 |
|
|
|
83 |
|
|
// First clear out any coursescribe pages |
84 |
dpavlin |
67 |
$sql = "UPDATE course SET campus_id = NULL WHERE campus_id = " . $campus_id; |
85 |
dpavlin |
69 |
if (xx_tryquery($sql)) printf("Campus purged from assignments to course pages.<br>\n"); |
86 |
dpavlin |
1 |
|
87 |
|
|
// Delete from the coursesub table |
88 |
dpavlin |
67 |
$sql = "UPDATE coursesub SET campus_id = 1 WHERE campus_id =" . $campus_id; |
89 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed from affected Course Subjects.<br>\n"); |
90 |
dpavlin |
1 |
|
91 |
|
|
// Delete from the campus table |
92 |
dpavlin |
67 |
$sql = "DELETE FROM campus WHERE campus_id =" . $campus_id; |
93 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this campus successfully."); |
94 |
dpavlin |
1 |
|
95 |
|
|
} |
96 |
dpavlin |
67 |
else printf("Cannot delete Campus ID# 1, it acts as a system placeholder."); |
97 |
dpavlin |
1 |
|
98 |
dpavlin |
67 |
printf("<br><br>\n"); |
99 |
|
|
msgTableClose(); |
100 |
dpavlin |
1 |
} |
101 |
|
|
|
102 |
|
|
|
103 |
|
|
/********************************************************** |
104 |
|
|
Function: deleteCampusConfirm |
105 |
|
|
Author: Paul Bramscher |
106 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
107 |
dpavlin |
1 |
*********************************************************** |
108 |
|
|
Purpose: |
109 |
|
|
Confirm prompt for deleting the selected campus. |
110 |
|
|
**********************************************************/ |
111 |
dpavlin |
67 |
function deleteCampusConfirm($key_id){ |
112 |
dpavlin |
1 |
|
113 |
|
|
$campus_id = (int) $key_id; |
114 |
dpavlin |
67 |
msgTableOpen(1, "Delete Campus (ID# " . $campus_id . ")?"); |
115 |
dpavlin |
1 |
|
116 |
|
|
// Check to see if its possible |
117 |
dpavlin |
67 |
$exists = existsRow("campus", "campus_id", $campus_id); |
118 |
dpavlin |
1 |
if ($exists > 0){ |
119 |
dpavlin |
67 |
|
120 |
dpavlin |
1 |
// Lookup the descriptive title |
121 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
|
125 |
|
|
// Form to draw the delete button |
126 |
dpavlin |
67 |
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 |
dpavlin |
1 |
|
134 |
|
|
} |
135 |
dpavlin |
67 |
else if ($exists < 1) printf ("Campus not found. Operation cancelled.<br><br>\n"); |
136 |
dpavlin |
1 |
|
137 |
dpavlin |
67 |
msgTableClose(); |
138 |
|
|
|
139 |
dpavlin |
1 |
} |
140 |
|
|
|
141 |
|
|
|
142 |
|
|
/********************************************************** |
143 |
|
|
Function: deleteCoursesub |
144 |
|
|
Author: Paul Bramscher |
145 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
146 |
dpavlin |
1 |
*********************************************************** |
147 |
|
|
Purpose: |
148 |
|
|
Deletes a supplied course subject id |
149 |
|
|
**********************************************************/ |
150 |
dpavlin |
67 |
function deleteCoursesub($coursesub_id){ |
151 |
dpavlin |
1 |
|
152 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Course Subject (ID# " . $coursesub_id . ")"); |
153 |
|
|
printf("<b>Messages:</b><br>\n"); |
154 |
dpavlin |
1 |
|
155 |
|
|
// Cannot delete placeholder #1. |
156 |
|
|
if ($coursesub_id > 1) { |
157 |
|
|
|
158 |
|
|
// Check to see if there are affected courselib pages |
159 |
dpavlin |
67 |
$exists_courselib = existsRow("course", "coursesub_id", $coursesub_id); |
160 |
dpavlin |
1 |
|
161 |
|
|
if ($exists_courselib > 0) { |
162 |
|
|
printf("Cannot delete this Course Subject. There are courses which are currently using it."); |
163 |
|
|
} |
164 |
|
|
|
165 |
dpavlin |
67 |
// Delete |
166 |
dpavlin |
1 |
else { |
167 |
|
|
// Delete from the sub_coursesub table |
168 |
|
|
$sql = "DELETE FROM sub_coursesub WHERE coursesub_id = " . $coursesub_id; |
169 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Subject-Course Subject assignments removed.<BR>\n"); |
170 |
dpavlin |
1 |
|
171 |
|
|
// Delete from the coursesub table |
172 |
dpavlin |
67 |
$sql = "DELETE FROM coursesub WHERE coursesub_id =" . $coursesub_id; |
173 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this Course Subject successfully."); |
174 |
dpavlin |
1 |
} |
175 |
|
|
|
176 |
|
|
} |
177 |
dpavlin |
67 |
else printf ("Cannot delete Course Subject ID# 1, it acts as a system placeholder."); |
178 |
|
|
|
179 |
|
|
printf("<br><br>\n"); |
180 |
|
|
msgTableClose(); |
181 |
dpavlin |
1 |
} |
182 |
|
|
|
183 |
|
|
|
184 |
|
|
/********************************************************** |
185 |
|
|
Function: deleteCoursesubConfirm |
186 |
|
|
Author: Paul Bramscher |
187 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
188 |
dpavlin |
1 |
*********************************************************** |
189 |
|
|
Purpose: |
190 |
|
|
Confirm prompt for deleting the selected campus. |
191 |
|
|
**********************************************************/ |
192 |
dpavlin |
67 |
function deleteCoursesubConfirm($coursesub_id){ |
193 |
dpavlin |
1 |
|
194 |
|
|
$coursesub_id = (int) $coursesub_id; |
195 |
dpavlin |
67 |
msgTableOpen(1, "Delete Course Subject (ID# " . $coursesub_id . ")?"); |
196 |
dpavlin |
1 |
|
197 |
|
|
// Check to see if its possible |
198 |
dpavlin |
67 |
$exists = existsRow("coursesub", "coursesub_id", $coursesub_id); |
199 |
dpavlin |
1 |
if ($exists > 0){ |
200 |
|
|
|
201 |
|
|
// Lookup the descriptive title |
202 |
dpavlin |
67 |
$coursesub = lookupField("coursesub", "coursesub_id", $coursesub_id, "coursesub"); |
203 |
dpavlin |
1 |
|
204 |
|
|
// Check to see if there are affected courselib pages |
205 |
dpavlin |
67 |
$exists_courselib = existsRow("course", "coursesub_id", $coursesub_id); |
206 |
dpavlin |
1 |
|
207 |
|
|
if ($exists_courselib > 0) { |
208 |
|
|
|
209 |
|
|
// Cannot delete, dependencies exist |
210 |
dpavlin |
67 |
printf("<b>Messages:</b><br>\n"); |
211 |
dpavlin |
1 |
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 |
dpavlin |
67 |
printf("</a><br><br>\n"); |
218 |
dpavlin |
1 |
|
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
else { |
222 |
|
|
|
223 |
|
|
// Form to draw the delete button |
224 |
dpavlin |
67 |
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 |
dpavlin |
1 |
|
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
} |
237 |
dpavlin |
67 |
else if ($exists < 1) printf ("Course Subject not found. Operation cancelled.<br><br>\n"); |
238 |
dpavlin |
1 |
|
239 |
dpavlin |
67 |
msgTableClose(); |
240 |
dpavlin |
1 |
} |
241 |
|
|
|
242 |
|
|
|
243 |
|
|
/********************************************************** |
244 |
|
|
Function: deleteFaculty |
245 |
|
|
Author: Paul Bramscher |
246 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
247 |
dpavlin |
1 |
*********************************************************** |
248 |
|
|
Purpose: |
249 |
|
|
Deletes the supplied faculty id, and removes any relations |
250 |
|
|
to affected courses. |
251 |
|
|
**********************************************************/ |
252 |
dpavlin |
67 |
function deleteFaculty($faculty_id){ |
253 |
dpavlin |
1 |
|
254 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Faculty (ID# " . $faculty_id . ")"); |
255 |
|
|
printf("<b>Messages:</b><br>\n"); |
256 |
dpavlin |
1 |
|
257 |
|
|
// Cannot delete placeholder #1. |
258 |
|
|
if ($faculty_id > 1) { |
259 |
|
|
|
260 |
|
|
// First clear out the course_personnel assignments |
261 |
dpavlin |
67 |
$sql = "DELETE FROM course_personnel WHERE faculty_id = " . $faculty_id; |
262 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Faculty person purged from assignments to course pages.<BR>\n"); |
263 |
dpavlin |
1 |
|
264 |
|
|
// Delete from the faculty table |
265 |
dpavlin |
67 |
$sql = "DELETE FROM faculty WHERE faculty_id =" . $faculty_id; |
266 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this faculty person successfully."); |
267 |
dpavlin |
1 |
|
268 |
|
|
} |
269 |
dpavlin |
67 |
else printf ("Cannot delete Faculty ID# 1, it acts as a system placeholder."); |
270 |
|
|
|
271 |
|
|
printf("<br><br>\n"); |
272 |
|
|
msgTableClose(); |
273 |
dpavlin |
1 |
} |
274 |
|
|
|
275 |
|
|
|
276 |
|
|
/********************************************************** |
277 |
|
|
Function: deleteFacultyConfirm |
278 |
|
|
Author: Paul Bramscher |
279 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
280 |
dpavlin |
1 |
*********************************************************** |
281 |
|
|
Purpose: |
282 |
|
|
Confirm prompt for deleting the selected faculty person. |
283 |
|
|
**********************************************************/ |
284 |
dpavlin |
67 |
function deleteFacultyConfirm($faculty_id){ |
285 |
dpavlin |
1 |
|
286 |
|
|
$faculty_id = (int) $faculty_id; |
287 |
dpavlin |
67 |
msgTableOpen(1, "Delete Faculty (ID# " . $faculty_id . ")?"); |
288 |
dpavlin |
1 |
|
289 |
|
|
// Check to see if its possible |
290 |
dpavlin |
67 |
$exists = existsRow("faculty", "faculty_id", $faculty_id); |
291 |
dpavlin |
1 |
if ($exists > 0){ |
292 |
|
|
|
293 |
|
|
// Lookup the descriptive title |
294 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
|
298 |
|
|
// Form to draw the delete button |
299 |
dpavlin |
67 |
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 |
dpavlin |
1 |
} |
307 |
dpavlin |
67 |
else if ($exists < 1) printf ("Faculty not found. Operation cancelled.<br><br>\n"); |
308 |
dpavlin |
1 |
|
309 |
dpavlin |
67 |
msgTableClose(); |
310 |
dpavlin |
1 |
} |
311 |
|
|
|
312 |
|
|
|
313 |
|
|
/********************************************************** |
314 |
|
|
Function: deleteFeature |
315 |
|
|
Author: Paul Bramscher |
316 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
317 |
dpavlin |
1 |
*********************************************************** |
318 |
|
|
Purpose: |
319 |
|
|
Deletes the supplied feature id, and removes any relations to |
320 |
|
|
affected resources. |
321 |
|
|
**********************************************************/ |
322 |
dpavlin |
67 |
function deleteFeature($feature_id){ |
323 |
dpavlin |
1 |
|
324 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Feature (ID# " . $feature_id . ")"); |
325 |
|
|
printf("<b>Messages:</b><br>\n"); |
326 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed resource-feature associations.<BR>\n"); |
333 |
dpavlin |
1 |
|
334 |
dpavlin |
67 |
// Delete from feature table |
335 |
|
|
$sql = "DELETE FROM feature WHERE feature_id =" . $feature_id; |
336 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed feature successfully."); |
337 |
dpavlin |
1 |
|
338 |
|
|
} |
339 |
dpavlin |
67 |
else printf ("Cannot delete Feature ID# 1, it acts as a system placeholder."); |
340 |
dpavlin |
1 |
|
341 |
dpavlin |
67 |
printf("<br><br>\n"); |
342 |
|
|
msgTableClose(); |
343 |
dpavlin |
1 |
} |
344 |
|
|
|
345 |
|
|
|
346 |
|
|
/********************************************************** |
347 |
|
|
Function: deleteFeatureConfirm |
348 |
|
|
Author: Paul Bramscher |
349 |
dpavlin |
67 |
Last Modified: 03.15.2004 |
350 |
dpavlin |
1 |
*********************************************************** |
351 |
|
|
Purpose: |
352 |
|
|
Confirm prompt for deleting the supplied feature id. |
353 |
|
|
**********************************************************/ |
354 |
dpavlin |
67 |
function deleteFeatureConfirm($key_id){ |
355 |
dpavlin |
1 |
|
356 |
|
|
$feature_id = (int) $key_id; |
357 |
dpavlin |
67 |
msgTableOpen(1, "Delete Feature (ID# " . $feature_id . ")?"); |
358 |
dpavlin |
1 |
|
359 |
|
|
// Check to see if its possible |
360 |
dpavlin |
67 |
$exists = existsRow("feature", "feature_id", $feature_id); |
361 |
dpavlin |
1 |
if ($exists > 0){ |
362 |
|
|
|
363 |
|
|
// Lookup the descriptive title |
364 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
|
368 |
|
|
// Form to draw the delete button |
369 |
dpavlin |
67 |
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 |
dpavlin |
1 |
} |
377 |
dpavlin |
67 |
else if ($exists < 1) printf ("Feature not found. Operation cancelled.<br><br>\n"); |
378 |
dpavlin |
1 |
|
379 |
dpavlin |
67 |
msgTableClose(); |
380 |
dpavlin |
1 |
} |
381 |
|
|
|
382 |
|
|
|
383 |
|
|
/********************************************************** |
384 |
|
|
Function: deleteInfotype |
385 |
|
|
Author: Paul Bramscher |
386 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
387 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteInfotype($infotype_id){ |
394 |
dpavlin |
1 |
|
395 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Information Type (ID# " . $infotype_id . ")"); |
396 |
|
|
printf("<b>Messages:</b><br>\n"); |
397 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed resource-subject-infotype associations.<BR>\n"); |
404 |
dpavlin |
1 |
|
405 |
dpavlin |
67 |
// Set (N/A) type in resource table |
406 |
|
|
$sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; |
407 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Set default information types for affects resources to (N/A).<BR>\n"); |
408 |
dpavlin |
1 |
|
409 |
dpavlin |
67 |
// Delete from infotype table |
410 |
|
|
$sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; |
411 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this information type successfully."); |
412 |
dpavlin |
67 |
} |
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 |
dpavlin |
1 |
|
419 |
|
|
|
420 |
dpavlin |
67 |
/********************************************************** |
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 |
dpavlin |
1 |
|
430 |
dpavlin |
67 |
$infotype_id = (int) $key_id; |
431 |
|
|
msgTableOpen(1, "Delete Information Type (ID# " . $infotype_id . ")?"); |
432 |
dpavlin |
1 |
|
433 |
dpavlin |
67 |
// Check to see if its possible |
434 |
|
|
$exists = existsRow("infotype", "infotype_id", $infotype_id); |
435 |
|
|
if ($exists > 0){ |
436 |
dpavlin |
1 |
|
437 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
|
443 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
|
458 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Deleted affected Library Unit staff assignments.<BR>\n"); |
477 |
dpavlin |
67 |
|
478 |
|
|
// Delete from the libunit table |
479 |
|
|
$sql = "DELETE FROM libunit WHERE libunit_id =" . $libunit_id; |
480 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this Library Unit successfully."); |
481 |
dpavlin |
67 |
|
482 |
dpavlin |
1 |
} |
483 |
dpavlin |
67 |
else printf ("Cannot delete Library Unit ID# 1, it acts as a system placeholder."); |
484 |
dpavlin |
1 |
|
485 |
dpavlin |
67 |
printf("<br><br>\n"); |
486 |
|
|
msgTableClose(); |
487 |
dpavlin |
1 |
} |
488 |
|
|
|
489 |
|
|
|
490 |
|
|
/********************************************************** |
491 |
dpavlin |
67 |
Function: deleteLibunitConfirm |
492 |
dpavlin |
1 |
Author: Paul Bramscher |
493 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
494 |
dpavlin |
1 |
*********************************************************** |
495 |
|
|
Purpose: |
496 |
dpavlin |
67 |
Confirm prompt for deleting the supplied libunit id. |
497 |
dpavlin |
1 |
**********************************************************/ |
498 |
dpavlin |
67 |
function deleteLibunitConfirm($key_id){ |
499 |
dpavlin |
1 |
|
500 |
dpavlin |
67 |
$libunit_id = (int) $key_id; |
501 |
|
|
msgTableOpen(1, "Delete Library Unit (ID# " . $libunit_id . ")?"); |
502 |
dpavlin |
1 |
|
503 |
|
|
// Check to see if its possible |
504 |
dpavlin |
67 |
$exists = existsRow("libunit", "libunit_id", $libunit_id); |
505 |
dpavlin |
1 |
if ($exists > 0){ |
506 |
|
|
|
507 |
|
|
// Lookup the descriptive title |
508 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
|
512 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
} |
521 |
dpavlin |
67 |
else if ($exists < 1) printf ("Library Unit not found. Operation cancelled.<br><br>\n"); |
522 |
dpavlin |
1 |
|
523 |
dpavlin |
67 |
msgTableClose(); |
524 |
|
|
} |
525 |
dpavlin |
1 |
|
526 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
xx_tryquery($sql); |
544 |
dpavlin |
67 |
} |
545 |
|
|
// Call the libunit form back |
546 |
|
|
formLibunit($libunit_id); |
547 |
dpavlin |
1 |
} |
548 |
|
|
|
549 |
|
|
|
550 |
|
|
/********************************************************** |
551 |
|
|
Function: deleteLocation |
552 |
|
|
Author: Paul Bramscher |
553 |
dpavlin |
67 |
Last Modified: 03.15.2004 |
554 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteLocation($delMessage, $location_id){ |
564 |
dpavlin |
1 |
|
565 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Location (ID# " . $location_id . ")"); |
566 |
|
|
printf("<b>Messages:</b><br>\n"); |
567 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Affected resource-location assignments removed.<BR>\n"); |
574 |
dpavlin |
1 |
|
575 |
|
|
// Delete from sub_loc |
576 |
dpavlin |
67 |
$sql = "DELETE FROM sub_loc WHERE location_id =" . $location_id; |
577 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Affected subject-location assignments removed.<BR>\n"); |
578 |
dpavlin |
1 |
|
579 |
|
|
// Delete primary subject locations |
580 |
dpavlin |
67 |
$sql = "UPDATE subject SET sublocation_id = NULL WHERE sublocation_id =" . $location_id; |
581 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Affected primary subject locations set to NULL.<BR>\n"); |
582 |
dpavlin |
1 |
|
583 |
|
|
// Delete from serv_loc |
584 |
dpavlin |
67 |
$sql = "DELETE FROM serv_loc WHERE location_id =" . $location_id; |
585 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Affected service-location assignments removed.<BR>\n"); |
586 |
dpavlin |
1 |
|
587 |
dpavlin |
67 |
/******************************** |
588 |
|
|
** Update affected CL/PS pages ** |
589 |
|
|
********************************/ |
590 |
dpavlin |
1 |
|
591 |
dpavlin |
67 |
// First, get the default location description and title |
592 |
|
|
$sql = "SELECT location, location_descr FROM location WHERE location_id = " |
593 |
|
|
. $location_id; |
594 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
595 |
|
|
$row = xx_fetch_array ($rs, xx_ASSOC); |
596 |
dpavlin |
67 |
$location = $row["location"]; |
597 |
|
|
$location_descr = $row["location_descr"]; |
598 |
dpavlin |
1 |
|
599 |
dpavlin |
67 |
// Clean up strings |
600 |
|
|
$location_descr = textInmySQL($location_descr); |
601 |
|
|
$location = textInmySQL($location); |
602 |
|
|
$delMessage = textInmySQL($delMessage); |
603 |
dpavlin |
1 |
|
604 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
|
608 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
616 |
dpavlin |
1 |
|
617 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
625 |
dpavlin |
1 |
|
626 |
dpavlin |
67 |
/********************************** |
627 |
|
|
** Update affected CL/PS buffers ** |
628 |
|
|
**********************************/ |
629 |
dpavlin |
1 |
|
630 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
638 |
dpavlin |
1 |
|
639 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
647 |
dpavlin |
1 |
|
648 |
|
|
// Delete from location |
649 |
dpavlin |
67 |
$sql = "DELETE FROM location WHERE location_id =" . $location_id; |
650 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Location successfully removed."); |
651 |
dpavlin |
1 |
|
652 |
|
|
} |
653 |
dpavlin |
67 |
else printf ("Cannot delete Location ID# 1, it acts as a system placeholder."); |
654 |
|
|
|
655 |
|
|
printf("<br><br>\n"); |
656 |
|
|
msgTableClose(); |
657 |
dpavlin |
1 |
} |
658 |
|
|
|
659 |
|
|
|
660 |
|
|
/********************************************************** |
661 |
|
|
Function: deleteLocationConfirm |
662 |
|
|
Author: Paul Bramscher |
663 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
664 |
dpavlin |
1 |
*********************************************************** |
665 |
|
|
Purpose: |
666 |
|
|
Confirm prompt to delete the supplied location id. |
667 |
|
|
**********************************************************/ |
668 |
dpavlin |
67 |
function deleteLocationConfirm($key_id){ |
669 |
dpavlin |
1 |
|
670 |
|
|
$location_id = (int) $key_id; |
671 |
dpavlin |
67 |
msgTableOpen(1, "Delete Location (ID# " . $location_id . ")?"); |
672 |
dpavlin |
1 |
|
673 |
|
|
// Check to see if its possible |
674 |
dpavlin |
67 |
$exists = existsRow("location", "location_id", $location_id); |
675 |
dpavlin |
1 |
if ($exists > 0){ |
676 |
|
|
|
677 |
|
|
// Lookup the name of the location |
678 |
dpavlin |
67 |
$location = lookupField("location", "location_id", $location_id, "location"); |
679 |
dpavlin |
1 |
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 |
dpavlin |
67 |
printf("This will permanently remove the location and its various assignments from the system.<BR><BR>\n"); |
692 |
dpavlin |
1 |
|
693 |
|
|
// Delete button |
694 |
|
|
printf("<center>\n"); |
695 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
696 |
|
|
printf("</center>\n"); |
697 |
dpavlin |
67 |
printf("</form>\n"); |
698 |
|
|
} |
699 |
|
|
else if ($exists < 1) printf ("Location not found. Operation cancelled.<br><br>\n"); |
700 |
dpavlin |
1 |
|
701 |
dpavlin |
67 |
msgTableClose(); |
702 |
dpavlin |
1 |
} |
703 |
|
|
|
704 |
|
|
|
705 |
|
|
/********************************************************** |
706 |
|
|
Function: deleteMasterinfotype |
707 |
|
|
Author: Paul Bramscher |
708 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
709 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteMasterinfotype($masterinfotype_id){ |
719 |
dpavlin |
1 |
|
720 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Master Information Type (ID# " . $masterinfotype_id . ")"); |
721 |
|
|
printf("<b>Messages:</b><br>\n"); |
722 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
732 |
|
|
while ($row = xx_fetch_array ($rs, xx_ASSOC)) { |
733 |
dpavlin |
1 |
$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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed resource-subject-infotype associations.<BR>\n"); |
742 |
dpavlin |
1 |
|
743 |
dpavlin |
67 |
// Set (N/A) type in resource table |
744 |
|
|
$sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; |
745 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Set default information types for affects resources to (N/A).<BR>\n"); |
746 |
dpavlin |
1 |
|
747 |
dpavlin |
67 |
// Delete from infotype table |
748 |
|
|
$sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; |
749 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed affected specific information types.<BR>\n"); |
750 |
dpavlin |
67 |
} |
751 |
dpavlin |
1 |
|
752 |
dpavlin |
67 |
// Delete from masterinfotype table |
753 |
|
|
$sql = "DELETE FROM masterinfotype WHERE masterinfotype_id =" . $masterinfotype_id; |
754 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed Master Information Type successfully."); |
755 |
dpavlin |
1 |
|
756 |
dpavlin |
67 |
} |
757 |
|
|
else printf ("Cannot delete Master Information Type ID# 1, it acts as a system placeholder."); |
758 |
dpavlin |
1 |
|
759 |
dpavlin |
67 |
printf("<br><br>\n"); |
760 |
|
|
msgTableClose(); |
761 |
dpavlin |
1 |
} |
762 |
|
|
|
763 |
|
|
|
764 |
|
|
/********************************************************** |
765 |
|
|
Function: deleteMasterinfotypeConfirm |
766 |
|
|
Author: Paul Bramscher |
767 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
768 |
dpavlin |
1 |
*********************************************************** |
769 |
|
|
Purpose: |
770 |
|
|
Confirm prompt for deleting the supplied master information |
771 |
|
|
type id. Note the dire warning. |
772 |
|
|
**********************************************************/ |
773 |
dpavlin |
67 |
function deleteMasterinfotypeConfirm($key_id){ |
774 |
dpavlin |
1 |
|
775 |
|
|
$masterinfotype_id = (int) $key_id; |
776 |
dpavlin |
67 |
msgTableOpen(1, "Delete Master Information Type (ID# " . $masterinfotype_id . ")?"); |
777 |
dpavlin |
1 |
|
778 |
|
|
// Check to see if its possible |
779 |
dpavlin |
67 |
$exists = existsRow("masterinfotype", "masterinfotype_id", $masterinfotype_id); |
780 |
dpavlin |
1 |
if ($exists > 0){ |
781 |
|
|
|
782 |
|
|
// Lookup the descriptive title |
783 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
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 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
} |
802 |
dpavlin |
67 |
else if ($exists < 1) printf ("Master Information Type not found. Operation cancelled.<br><br>\n"); |
803 |
dpavlin |
1 |
|
804 |
dpavlin |
67 |
msgTableClose(); |
805 |
dpavlin |
1 |
} |
806 |
|
|
|
807 |
|
|
|
808 |
|
|
/********************************************************** |
809 |
|
|
Function: deleteMastersubject |
810 |
|
|
Author: Paul Bramscher |
811 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
812 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteMastersubject($mastersubject_id){ |
823 |
dpavlin |
1 |
|
824 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Master Subject (ID# " . $mastersubject_id . ")"); |
825 |
|
|
printf("<b>Messages:</b><br>\n"); |
826 |
dpavlin |
1 |
|
827 |
|
|
// Cannot delete placeholder #1 |
828 |
|
|
if ($mastersubject_id > 1) { |
829 |
|
|
|
830 |
|
|
// Delete from sub_mastersubject |
831 |
dpavlin |
67 |
$sql = "DELETE FROM sub_mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
832 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Affected subject-mastersubject assignments removed.<BR>\n"); |
833 |
dpavlin |
1 |
|
834 |
|
|
// Delete from res_mastersubject |
835 |
dpavlin |
67 |
$sql = "DELETE FROM res_mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
836 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Affected resource-mastersubject assignments removed.<BR>\n"); |
837 |
dpavlin |
1 |
|
838 |
|
|
// Delete from mastersubject table |
839 |
dpavlin |
67 |
$sql = "DELETE FROM mastersubject WHERE mastersubject_id =" . $mastersubject_id; |
840 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed Master Subject successfully."); |
841 |
dpavlin |
1 |
|
842 |
dpavlin |
67 |
} |
843 |
|
|
else printf ("Cannot delete Master Subject ID# 1, it acts as a system placeholder."); |
844 |
dpavlin |
1 |
|
845 |
dpavlin |
67 |
printf("<br><br>\n"); |
846 |
|
|
msgTableClose(); |
847 |
dpavlin |
1 |
} |
848 |
|
|
|
849 |
|
|
|
850 |
|
|
/********************************************************** |
851 |
|
|
Function: deleteMastersubjectConfirm |
852 |
|
|
Author: Paul Bramscher |
853 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
854 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteMastersubjectConfirm($key_id){ |
864 |
dpavlin |
1 |
|
865 |
|
|
$mastersubject_id = (int) $key_id; |
866 |
dpavlin |
67 |
msgTableOpen(1, "Delete Master Subject (ID# " . $mastersubject_id . ")?"); |
867 |
dpavlin |
1 |
|
868 |
|
|
// Check to see if its possible |
869 |
dpavlin |
67 |
$exists = existsRow("mastersubject", "mastersubject_id", $mastersubject_id); |
870 |
dpavlin |
1 |
if ($exists > 0 && $mastersubject_id > 2){ |
871 |
|
|
|
872 |
|
|
// Lookup the descriptive title |
873 |
dpavlin |
67 |
$mastersubject = lookupField("mastersubject", "mastersubject_id", $mastersubject_id, "mastersubject"); |
874 |
|
|
printf("<b>Master Subject:</b> %s<br><br>\n ", $mastersubject); |
875 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
883 |
|
|
$row = xx_fetch_array ($rs, xx_ASSOC); |
884 |
dpavlin |
1 |
$num_subjects = $row["num_subjects"]; |
885 |
|
|
if ($num_subjects > 0) $problem = 1; |
886 |
|
|
|
887 |
|
|
// Check resources |
888 |
dpavlin |
67 |
$sql = "SELECT COUNT(rm.resource_id) as num_resources FROM res_mastersubject rm WHERE rm.mastersubject_id = " |
889 |
|
|
. $mastersubject_id; |
890 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
891 |
|
|
$row = xx_fetch_array ($rs, xx_ASSOC); |
892 |
dpavlin |
67 |
$num_resources = $row["num_resources"]; |
893 |
|
|
if ($num_resources > 0) $problem = 1; |
894 |
dpavlin |
1 |
|
895 |
|
|
// Proceed only if no subjects or resources are affected |
896 |
|
|
if ($problem == 0) { |
897 |
|
|
// Form to draw the delete button |
898 |
dpavlin |
67 |
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 |
dpavlin |
1 |
printf("Are you sure you want to proceed?<br><br>\n"); |
903 |
dpavlin |
67 |
printf("<center>\n"); |
904 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
905 |
|
|
printf("</center>\n"); |
906 |
|
|
printf("</form>\n"); |
907 |
dpavlin |
1 |
} |
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 |
dpavlin |
67 |
printf("Examine the <a href=\"mastersubject_drill.phtml?mastersubject_id=%d\">Master Subject Detail</a></b> page.\n", $mastersubject_id); |
914 |
dpavlin |
1 |
printf("<br><br>\n"); |
915 |
|
|
} |
916 |
|
|
|
917 |
|
|
} |
918 |
dpavlin |
67 |
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 |
dpavlin |
1 |
|
921 |
dpavlin |
67 |
msgTableClose(); |
922 |
dpavlin |
1 |
} |
923 |
|
|
|
924 |
|
|
|
925 |
|
|
/********************************************************** |
926 |
|
|
Function: deleteResFeature |
927 |
|
|
Author: Paul Bramscher |
928 |
dpavlin |
67 |
Last Modified: 03.02.2004 |
929 |
dpavlin |
1 |
*********************************************************** |
930 |
|
|
Purpose: |
931 |
|
|
Deletes resource-feature associations based on the supplied |
932 |
|
|
feature id (possibly multiple) and calls formResource back |
933 |
|
|
again. |
934 |
|
|
**********************************************************/ |
935 |
dpavlin |
67 |
function deleteResFeature($key_list_array, $resource_id){ |
936 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
xx_tryquery ($sql); |
944 |
dpavlin |
1 |
} |
945 |
|
|
// Call the resource form back |
946 |
dpavlin |
67 |
formResource($resource_id, 0, 0, ''); |
947 |
dpavlin |
1 |
} |
948 |
|
|
|
949 |
|
|
|
950 |
|
|
/********************************************************** |
951 |
|
|
Function: deleteResLoc |
952 |
|
|
Author: Paul Bramscher |
953 |
dpavlin |
67 |
Last Modified: 03.02.2004 |
954 |
dpavlin |
1 |
*********************************************************** |
955 |
|
|
Purpose: |
956 |
|
|
Deletes resource-location associations based on the supplied |
957 |
|
|
location id (possibly multiple) and calls formResource back |
958 |
|
|
again. |
959 |
|
|
**********************************************************/ |
960 |
dpavlin |
67 |
function deleteResLoc($key_list_array, $resource_id){ |
961 |
dpavlin |
1 |
|
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 |
dpavlin |
67 |
. $key_list_array[$element]; |
967 |
dpavlin |
69 |
xx_tryquery ($sql); |
968 |
dpavlin |
1 |
} |
969 |
|
|
// Call the resource form back |
970 |
dpavlin |
67 |
formResource($resource_id, 0, 0, ''); |
971 |
dpavlin |
1 |
} |
972 |
|
|
|
973 |
|
|
|
974 |
|
|
/********************************************************** |
975 |
|
|
Function: deleteResMastersubject |
976 |
|
|
Author: Paul Bramscher |
977 |
dpavlin |
67 |
Last Modified: 03.02.2004 |
978 |
dpavlin |
1 |
*********************************************************** |
979 |
|
|
Purpose: |
980 |
|
|
Deletes resource-mastersubject associations based on the |
981 |
|
|
supplied mastersubject id (possibly multiple) and calls |
982 |
|
|
formResource back again. |
983 |
|
|
**********************************************************/ |
984 |
dpavlin |
67 |
function deleteResMastersubject($key_list_array, $resource_id){ |
985 |
dpavlin |
1 |
|
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 |
dpavlin |
67 |
. $key_list_array[$element]; |
992 |
dpavlin |
69 |
xx_tryquery ($sql); |
993 |
dpavlin |
1 |
} |
994 |
|
|
// Call the resource form back |
995 |
dpavlin |
67 |
formResource($resource_id, 0, 0, ''); |
996 |
dpavlin |
1 |
} |
997 |
|
|
|
998 |
|
|
|
999 |
|
|
/********************************************************** |
1000 |
|
|
Function: deleteResource |
1001 |
|
|
Author: Paul Bramscher |
1002 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1003 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteResource($delMessage, $resource_id){ |
1013 |
dpavlin |
1 |
|
1014 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Resource (ID# " . $resource_id . ")"); |
1015 |
|
|
printf("<b>Messages:</b><br>\n"); |
1016 |
dpavlin |
1 |
|
1017 |
|
|
// First delete all related rows in res_sub_infotype |
1018 |
|
|
$sql = "DELETE FROM res_sub_infotype WHERE resource_id = " . $resource_id; |
1019 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Resource removed from all resource-subject-infotype assignments.<BR>\n"); |
1020 |
dpavlin |
1 |
|
1021 |
|
|
// Delete from the res_loc table |
1022 |
dpavlin |
67 |
$sql = "DELETE FROM res_loc WHERE resource_id =" . $resource_id; |
1023 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed from resource-location table.<BR>\n"); |
1024 |
dpavlin |
1 |
|
1025 |
|
|
// Delete from the res_mastersubject table |
1026 |
dpavlin |
67 |
$sql = "DELETE FROM res_mastersubject WHERE resource_id =" . $resource_id; |
1027 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed from resource-mastersubject table.<BR>\n"); |
1028 |
dpavlin |
1 |
|
1029 |
|
|
// Delete from the res_feature table |
1030 |
dpavlin |
67 |
$sql = "DELETE FROM res_feature WHERE resource_id =" . $resource_id; |
1031 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed from resource-feature table.<BR>\n"); |
1032 |
dpavlin |
1 |
|
1033 |
dpavlin |
67 |
/******************************** |
1034 |
|
|
** Update affected CL/PS pages ** |
1035 |
|
|
********************************/ |
1036 |
dpavlin |
1 |
|
1037 |
dpavlin |
67 |
// First, get the default resource description and title |
1038 |
|
|
$sql = "SELECT annotation, title FROM resource WHERE resource_id = " |
1039 |
|
|
. $resource_id; |
1040 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
1041 |
|
|
$row = xx_fetch_array ($rs, xx_ASSOC); |
1042 |
dpavlin |
67 |
$annotation = $row["annotation"]; |
1043 |
|
|
$title = $row["title"]; |
1044 |
dpavlin |
1 |
|
1045 |
dpavlin |
67 |
// Clean up |
1046 |
|
|
$title = textInmySQL($title); |
1047 |
|
|
$annotation = textInmySQL($annotation); |
1048 |
|
|
$delMessage = textInmySQL($delMessage); |
1049 |
dpavlin |
1 |
|
1050 |
dpavlin |
67 |
// Next, append the reason for deletion to the annotation |
1051 |
|
|
if (strlen($annotation) > 0) $annotation .= "<BR>" . $delMessage; |
1052 |
|
|
else $annotation = $delMessage; |
1053 |
dpavlin |
1 |
|
1054 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1062 |
dpavlin |
1 |
|
1063 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
1071 |
dpavlin |
1 |
|
1072 |
dpavlin |
67 |
/*************************************** |
1073 |
|
|
** Update affected CL/PS copy buffers ** |
1074 |
|
|
***************************************/ |
1075 |
dpavlin |
1 |
|
1076 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
1084 |
dpavlin |
1 |
|
1085 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
1093 |
dpavlin |
1 |
|
1094 |
dpavlin |
67 |
// Delete from the resource table |
1095 |
|
|
$sql = "DELETE FROM resource WHERE resource_id =" . $resource_id; |
1096 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully removed from all tables."); |
1097 |
dpavlin |
1 |
|
1098 |
dpavlin |
67 |
printf("<br><br>\n"); |
1099 |
|
|
msgTableClose(); |
1100 |
dpavlin |
1 |
} |
1101 |
|
|
|
1102 |
|
|
|
1103 |
|
|
/********************************************************** |
1104 |
|
|
Function: deleteResourceConfirm |
1105 |
|
|
Author: Paul Bramscher |
1106 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1107 |
dpavlin |
1 |
*********************************************************** |
1108 |
|
|
Purpose: |
1109 |
|
|
Confirm prompt to delete the supplied resource id. |
1110 |
|
|
**********************************************************/ |
1111 |
dpavlin |
67 |
function deleteResourceConfirm($resource_id){ |
1112 |
dpavlin |
1 |
|
1113 |
|
|
$resource_id = (int) $resource_id; |
1114 |
dpavlin |
67 |
msgTableOpen(1, "Delete Resource (ID# " . $resource_id . ")?"); |
1115 |
dpavlin |
1 |
|
1116 |
|
|
// Check to see if its possible |
1117 |
dpavlin |
67 |
$exists = existsRow("resource", "resource_id", $resource_id); |
1118 |
dpavlin |
1 |
if ($exists > 0){ |
1119 |
|
|
|
1120 |
|
|
// Lookup the title & author |
1121 |
dpavlin |
67 |
$title = lookupField("resource", "resource_id", $resource_id, "title"); |
1122 |
|
|
$author = lookupField("resource", "resource_id", $resource_id, "author"); |
1123 |
dpavlin |
1 |
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 |
dpavlin |
67 |
printf("This will permanently remove the resource and its various assignments from the system.<BR><BR>\n"); |
1140 |
dpavlin |
1 |
|
1141 |
|
|
// Delete button |
1142 |
|
|
printf("<center>\n"); |
1143 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1144 |
|
|
printf("</center>\n"); |
1145 |
dpavlin |
67 |
printf("</form>\n"); |
1146 |
dpavlin |
1 |
} |
1147 |
dpavlin |
67 |
else if ($exists < 1) printf ("Resource not found. Operation cancelled.<br><br>\n"); |
1148 |
dpavlin |
1 |
|
1149 |
dpavlin |
67 |
msgTableClose(); |
1150 |
dpavlin |
1 |
} |
1151 |
|
|
|
1152 |
|
|
|
1153 |
|
|
/********************************************************** |
1154 |
|
|
Function: deleteService |
1155 |
|
|
Author: Paul Bramscher |
1156 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1157 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteService($delMessage, $service_id){ |
1166 |
dpavlin |
1 |
|
1167 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Service (ID# " . $service_id . ")"); |
1168 |
|
|
printf("<b>Messages:</b><br>\n"); |
1169 |
dpavlin |
1 |
|
1170 |
|
|
// First delete all related rows in serv_servtype |
1171 |
|
|
$sql = "DELETE FROM serv_servtype WHERE service_id = " . $service_id; |
1172 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Service removed from all service-servicetype assignments.<BR>\n"); |
1173 |
dpavlin |
1 |
|
1174 |
|
|
// Delete from the serv_loc table |
1175 |
dpavlin |
67 |
$sql = "DELETE FROM serv_loc WHERE service_id =" . $service_id; |
1176 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed from service-location table.<BR>\n"); |
1177 |
dpavlin |
1 |
|
1178 |
dpavlin |
67 |
/******************************** |
1179 |
|
|
** Update affected CL/PS pages ** |
1180 |
|
|
********************************/ |
1181 |
dpavlin |
1 |
|
1182 |
dpavlin |
67 |
// First, get the default service description and title |
1183 |
|
|
$sql = "SELECT service, serviceDescr FROM service WHERE service_id = " |
1184 |
|
|
. $service_id; |
1185 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
1186 |
|
|
$row = xx_fetch_array ($rs, xx_ASSOC); |
1187 |
dpavlin |
67 |
$service = $row["service"]; |
1188 |
|
|
$serviceDescr = $row["serviceDescr"]; |
1189 |
dpavlin |
1 |
|
1190 |
dpavlin |
67 |
// Clean up strings |
1191 |
|
|
$service = textInmySQL($service); |
1192 |
|
|
$serviceDescr = textInmySQL($serviceDescr); |
1193 |
|
|
$delMessage = textInmySQL($delMessage); |
1194 |
dpavlin |
1 |
|
1195 |
dpavlin |
67 |
// Next, append the reason for deletion to the annotation |
1196 |
|
|
if (strlen($serviceDescr) > 0) $serviceDescr .= "<BR>" . $delMessage; |
1197 |
|
|
else $serviceDescr = $delMessage; |
1198 |
dpavlin |
1 |
|
1199 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1207 |
dpavlin |
1 |
|
1208 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
|
1216 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
1217 |
dpavlin |
1 |
|
1218 |
dpavlin |
67 |
/*************************************** |
1219 |
|
|
** Update affected CP/PS copy buffers ** |
1220 |
|
|
***************************************/ |
1221 |
dpavlin |
1 |
|
1222 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
1230 |
dpavlin |
1 |
|
1231 |
dpavlin |
67 |
// 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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
1239 |
dpavlin |
1 |
|
1240 |
dpavlin |
67 |
// Delete from the service table |
1241 |
|
|
$sql = "DELETE FROM service WHERE service_id =" . $service_id; |
1242 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully removed from all tables."); |
1243 |
dpavlin |
1 |
|
1244 |
dpavlin |
67 |
printf("<br><br>\n"); |
1245 |
|
|
msgTableClose(); |
1246 |
dpavlin |
1 |
} |
1247 |
|
|
|
1248 |
|
|
|
1249 |
|
|
/********************************************************** |
1250 |
|
|
Function: deleteServiceConfirm |
1251 |
|
|
Author: Paul Bramscher |
1252 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1253 |
dpavlin |
1 |
*********************************************************** |
1254 |
|
|
Purpose: |
1255 |
|
|
Confirm prompt to delete the supplied service id. |
1256 |
|
|
**********************************************************/ |
1257 |
dpavlin |
67 |
function deleteServiceConfirm($key_id){ |
1258 |
dpavlin |
1 |
|
1259 |
|
|
$service_id = (int) $key_id; |
1260 |
dpavlin |
67 |
msgTableOpen(1, "Delete Service (ID# " . $service_id . ")?"); |
1261 |
dpavlin |
1 |
|
1262 |
|
|
// Check to see if its possible |
1263 |
dpavlin |
67 |
$exists = existsRow("service", "service_id", $service_id); |
1264 |
dpavlin |
1 |
if ($exists > 0){ |
1265 |
|
|
|
1266 |
|
|
// Lookup the descriptive title |
1267 |
dpavlin |
67 |
$service = lookupField("service", "service_id", $service_id, "service"); |
1268 |
dpavlin |
1 |
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 |
dpavlin |
67 |
printf("This will permanently remove the service and its various assignments from the system.<BR><BR>\n"); |
1281 |
dpavlin |
1 |
|
1282 |
|
|
// Delete button |
1283 |
|
|
printf("<center>\n"); |
1284 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1285 |
|
|
printf("</center>\n"); |
1286 |
dpavlin |
67 |
printf("</form>\n"); |
1287 |
dpavlin |
1 |
} |
1288 |
dpavlin |
67 |
else if ($exists < 1) printf ("Service not found. Operation cancelled.<br><br>\n"); |
1289 |
dpavlin |
1 |
|
1290 |
dpavlin |
67 |
msgTableClose(); |
1291 |
dpavlin |
1 |
} |
1292 |
|
|
|
1293 |
|
|
|
1294 |
|
|
/********************************************************** |
1295 |
|
|
Function: deleteServicetype |
1296 |
|
|
Author: Paul Bramscher |
1297 |
dpavlin |
67 |
Last Modified: 03.15.2004 |
1298 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteServicetype($servicetype_id){ |
1305 |
dpavlin |
1 |
|
1306 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Service Type (ID# " . $servicetype_id . ")"); |
1307 |
|
|
printf("<b>Messages:</b><br>\n"); |
1308 |
dpavlin |
1 |
|
1309 |
|
|
// Cannot delete placeholder #1 |
1310 |
|
|
if ($servicetype_id > 1) { |
1311 |
dpavlin |
67 |
|
1312 |
|
|
// Delete from serv_servtype table |
1313 |
|
|
$sql = "DELETE FROM serv_servtype WHERE servicetype_id =" . $servicetype_id; |
1314 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed Service-Service Type associations.<BR>\n"); |
1315 |
dpavlin |
1 |
|
1316 |
|
|
// Delete from servicetype table |
1317 |
|
|
$sql = "DELETE FROM servicetype WHERE servicetype_id =" . $servicetype_id; |
1318 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed Service Type successfully."); |
1319 |
dpavlin |
1 |
|
1320 |
|
|
} |
1321 |
dpavlin |
67 |
else printf ("Cannot delete Service Type ID# 1, it acts as a system placeholder."); |
1322 |
dpavlin |
1 |
|
1323 |
dpavlin |
67 |
printf("<br><br>\n"); |
1324 |
|
|
msgTableClose(); |
1325 |
dpavlin |
1 |
} |
1326 |
|
|
|
1327 |
|
|
|
1328 |
|
|
/********************************************************** |
1329 |
|
|
Function: deleteServicetypeConfirm |
1330 |
|
|
Author: Paul Bramscher |
1331 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1332 |
dpavlin |
1 |
*********************************************************** |
1333 |
|
|
Purpose: |
1334 |
|
|
Confirm prompt to delete the supplied service type id. |
1335 |
|
|
**********************************************************/ |
1336 |
dpavlin |
67 |
function deleteServicetypeConfirm($key_id){ |
1337 |
dpavlin |
1 |
|
1338 |
|
|
$servicetype_id = (int) $key_id; |
1339 |
dpavlin |
67 |
msgTableOpen(1, "Delete Service Type (ID# " . $servicetype_id . ")?"); |
1340 |
dpavlin |
1 |
|
1341 |
|
|
// Check to see if its possible |
1342 |
dpavlin |
67 |
$exists = existsRow("servicetype", "servicetype_id", $servicetype_id); |
1343 |
dpavlin |
1 |
if ($exists > 0){ |
1344 |
|
|
|
1345 |
|
|
// Lookup the descriptive title |
1346 |
dpavlin |
67 |
$servicetype = lookupField("servicetype", "servicetype_id", $servicetype_id, "servicetype"); |
1347 |
dpavlin |
1 |
printf("<b>Service Type:</b> %s<br><br>\n ", $servicetype); |
1348 |
dpavlin |
67 |
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 |
dpavlin |
1 |
|
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 |
dpavlin |
67 |
printf("</form>\n"); |
1360 |
dpavlin |
1 |
} |
1361 |
dpavlin |
67 |
else if ($exists < 1) printf ("Service Type not found. Operation cancelled.<br><br>\n"); |
1362 |
dpavlin |
1 |
|
1363 |
dpavlin |
67 |
msgTableClose(); |
1364 |
dpavlin |
1 |
} |
1365 |
|
|
|
1366 |
|
|
|
1367 |
|
|
/********************************************************** |
1368 |
|
|
Function: deleteServLoc |
1369 |
|
|
Author: Paul Bramscher |
1370 |
dpavlin |
67 |
Last Modified: 03.02.2004 |
1371 |
dpavlin |
1 |
*********************************************************** |
1372 |
|
|
Purpose: |
1373 |
|
|
Deletes service-location associations based on the supplied |
1374 |
|
|
location id (possibly multiple) and calls formService back |
1375 |
|
|
again. |
1376 |
|
|
**********************************************************/ |
1377 |
dpavlin |
67 |
function deleteServLoc($key_list_array, $service_id){ |
1378 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
xx_tryquery ($sql); |
1386 |
dpavlin |
1 |
} |
1387 |
|
|
// Call the service form back |
1388 |
dpavlin |
67 |
formService($service_id, 0, 0); |
1389 |
dpavlin |
1 |
} |
1390 |
|
|
|
1391 |
|
|
|
1392 |
|
|
/********************************************************** |
1393 |
|
|
Function: deleteServServtype |
1394 |
|
|
Author: Paul Bramscher |
1395 |
dpavlin |
67 |
Last Modified: 03.02.2004 |
1396 |
dpavlin |
1 |
*********************************************************** |
1397 |
|
|
Purpose: |
1398 |
|
|
Deletes service-servicetype associations based on the |
1399 |
|
|
supplied servicetype id (possibly multiple) and calls |
1400 |
|
|
formService back again. |
1401 |
|
|
**********************************************************/ |
1402 |
dpavlin |
67 |
function deleteServServtype($key_list_array, $service_id){ |
1403 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
xx_tryquery ($sql); |
1411 |
dpavlin |
1 |
} |
1412 |
|
|
// Call the service form back |
1413 |
dpavlin |
67 |
formService($service_id, 0, 0); |
1414 |
dpavlin |
1 |
} |
1415 |
|
|
|
1416 |
|
|
|
1417 |
|
|
/********************************************************** |
1418 |
|
|
Function: deleteStaff |
1419 |
|
|
Author: Paul Bramscher |
1420 |
dpavlin |
67 |
Last Modified: 03.15.2004 |
1421 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteStaff($delMessage, $staff_id){ |
1430 |
dpavlin |
1 |
|
1431 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Staff (ID# " . $staff_id . ")"); |
1432 |
|
|
printf("<b>Messages:</b><br>\n"); |
1433 |
dpavlin |
1 |
|
1434 |
dpavlin |
67 |
// Can't delete admin account (#2) or the '(N/A)' staff (#1) |
1435 |
|
|
if ($staff_id > 2) { |
1436 |
dpavlin |
1 |
|
1437 |
dpavlin |
67 |
// First delete all related rows in sub_staff |
1438 |
dpavlin |
1 |
$sql = "DELETE FROM sub_staff WHERE staff_id = " . $staff_id; |
1439 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("All subject-staff assignments for this staff person removed.<BR>\n"); |
1440 |
dpavlin |
1 |
|
1441 |
dpavlin |
67 |
// Delete from the course_personnel table |
1442 |
dpavlin |
1 |
$sql = "DELETE FROM course_personnel WHERE staff_id =" . $staff_id; |
1443 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this staff person from course personnel tables.<BR>\n"); |
1444 |
dpavlin |
1 |
|
1445 |
dpavlin |
67 |
// Delete all related rows in page_staff |
1446 |
dpavlin |
1 |
$sql = "DELETE FROM page_staff WHERE staff_id = " . $staff_id; |
1447 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("All page-staff assignments for this staff person removed.<BR>\n"); |
1448 |
dpavlin |
1 |
|
1449 |
dpavlin |
67 |
/******************************** |
1450 |
|
|
** Update affected CL/PS pages ** |
1451 |
|
|
********************************/ |
1452 |
dpavlin |
1 |
|
1453 |
|
|
// First, get the staff fields |
1454 |
|
|
$sql = "SELECT first_name, last_name FROM staff WHERE staff_id = " |
1455 |
|
|
. $staff_id; |
1456 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
1457 |
|
|
$row = xx_fetch_array ($rs, xx_ASSOC); |
1458 |
dpavlin |
1 |
$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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1478 |
dpavlin |
1 |
|
1479 |
dpavlin |
67 |
// Handle blank staff description elements |
1480 |
dpavlin |
1 |
$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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to blank PageScribe descriptions.<BR>\n"); |
1487 |
dpavlin |
1 |
|
1488 |
dpavlin |
67 |
/********************************** |
1489 |
|
|
** Update affected CL/PS buffers ** |
1490 |
|
|
**********************************/ |
1491 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1500 |
dpavlin |
1 |
|
1501 |
dpavlin |
67 |
// Handle blank staff description pastebuffer elements |
1502 |
dpavlin |
1 |
$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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to blank PageScribe descriptions.<BR>\n"); |
1509 |
dpavlin |
1 |
|
1510 |
dpavlin |
67 |
// Delete from the staff table |
1511 |
|
|
$sql = "DELETE FROM staff WHERE staff_id =" . $staff_id; |
1512 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this staff person successfully."); |
1513 |
dpavlin |
1 |
} |
1514 |
dpavlin |
67 |
else printf ("Cannot delete Staff ID's #1-2. Operation cancelled."); |
1515 |
dpavlin |
1 |
|
1516 |
dpavlin |
67 |
printf("<br><br>\n"); |
1517 |
|
|
msgTableClose(); |
1518 |
|
|
|
1519 |
dpavlin |
1 |
} // end function |
1520 |
|
|
|
1521 |
|
|
|
1522 |
|
|
/********************************************************** |
1523 |
|
|
Function: deleteStaffConfirm |
1524 |
|
|
Author: Paul Bramscher |
1525 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1526 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteStaffConfirm($staff_id){ |
1535 |
dpavlin |
1 |
|
1536 |
|
|
$staff_id = (int) $staff_id; |
1537 |
dpavlin |
67 |
msgTableOpen(1, "Delete Staff (ID# " . $staff_id . ")?"); |
1538 |
dpavlin |
1 |
|
1539 |
|
|
// Check to see if its possible |
1540 |
dpavlin |
67 |
$exists = existsRow("staff", "staff_id", $staff_id); |
1541 |
dpavlin |
1 |
if ($exists > 0){ |
1542 |
|
|
|
1543 |
|
|
// Lookup the first and last names |
1544 |
dpavlin |
67 |
$first_name = lookupField("staff", "staff_id", $staff_id, "first_name"); |
1545 |
|
|
$last_name = lookupField("staff", "staff_id", $staff_id, "last_name"); |
1546 |
dpavlin |
1 |
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 |
dpavlin |
67 |
printf("This will permanently remove this staffperson and his/her various assignments from the system.<BR><BR>\n"); |
1559 |
dpavlin |
1 |
|
1560 |
|
|
// Delete button |
1561 |
|
|
printf("<center>\n"); |
1562 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1563 |
|
|
printf("</center>\n"); |
1564 |
dpavlin |
67 |
printf("</form>\n"); |
1565 |
dpavlin |
1 |
} |
1566 |
dpavlin |
67 |
else if ($exists < 1) printf ("Staffperson not found. Operation cancelled.<br><br>\n"); |
1567 |
dpavlin |
1 |
|
1568 |
dpavlin |
67 |
msgTableClose(); |
1569 |
dpavlin |
1 |
} |
1570 |
|
|
|
1571 |
|
|
|
1572 |
|
|
/********************************************************** |
1573 |
|
|
Function: deleteStaffLibunit |
1574 |
|
|
Author: Paul Bramscher |
1575 |
dpavlin |
67 |
Last Modified: 03.03.2004 |
1576 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteStaffLibunit($key_list_array, $staff_id){ |
1584 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
xx_tryquery($sql); |
1593 |
dpavlin |
1 |
} |
1594 |
|
|
// Call the staff form back |
1595 |
dpavlin |
67 |
formStaff($staff_id); |
1596 |
dpavlin |
1 |
} |
1597 |
|
|
|
1598 |
|
|
|
1599 |
|
|
/********************************************************** |
1600 |
|
|
Function: deleteStaffSub |
1601 |
|
|
Author: Paul Bramscher |
1602 |
dpavlin |
67 |
Last Modified: 03.03.2004 |
1603 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteStaffSub($key_list_array, $staff_id){ |
1612 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
xx_tryquery($sql); |
1621 |
dpavlin |
1 |
} |
1622 |
|
|
// Call the staff form back |
1623 |
dpavlin |
67 |
formStaff($staff_id); |
1624 |
dpavlin |
1 |
} |
1625 |
|
|
|
1626 |
|
|
|
1627 |
|
|
/********************************************************** |
1628 |
|
|
Function: deleteStafftitle |
1629 |
|
|
Author: Paul Bramscher |
1630 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1631 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteStafftitle($stafftitle_id){ |
1637 |
dpavlin |
1 |
|
1638 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Staff Title (ID# " . $stafftitle_id . ")"); |
1639 |
|
|
printf("<b>Messages:</b><br>\n"); |
1640 |
dpavlin |
1 |
|
1641 |
|
|
if ($stafftitle_id > 1) { |
1642 |
dpavlin |
67 |
// First update all rows in staff to (N/A) |
1643 |
dpavlin |
1 |
$sql = "UPDATE staff SET stafftitle_id = 1 WHERE stafftitle_id = " . $stafftitle_id; |
1644 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully set affected staff titles to (N/A).<BR>\n"); |
1645 |
dpavlin |
1 |
|
1646 |
|
|
// Delete from the title table |
1647 |
dpavlin |
67 |
$sql = "DELETE FROM stafftitle WHERE stafftitle_id =" . $stafftitle_id; |
1648 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this staff title successfully."); |
1649 |
dpavlin |
1 |
|
1650 |
|
|
} |
1651 |
dpavlin |
67 |
else printf ("Cannot delete Staff Title ID# 1, it acts as a system placeholder."); |
1652 |
|
|
|
1653 |
|
|
printf("<br><br>\n"); |
1654 |
|
|
msgTableClose(); |
1655 |
dpavlin |
1 |
} |
1656 |
|
|
|
1657 |
|
|
|
1658 |
|
|
/********************************************************** |
1659 |
|
|
Function: deleteStafftitleConfirm |
1660 |
|
|
Author: Paul Bramscher |
1661 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1662 |
dpavlin |
1 |
*********************************************************** |
1663 |
|
|
Purpose: |
1664 |
|
|
Confirm prompt for deleting the supplied staff title id. |
1665 |
|
|
**********************************************************/ |
1666 |
dpavlin |
67 |
function deleteStafftitleConfirm($key_id){ |
1667 |
dpavlin |
1 |
|
1668 |
|
|
$stafftitle_id = (int) $key_id; |
1669 |
dpavlin |
67 |
msgTableOpen(1, "Delete Staff Title (ID# " . $stafftitle_id . ")?"); |
1670 |
dpavlin |
1 |
|
1671 |
|
|
// Check to see if its possible |
1672 |
dpavlin |
67 |
$exists = existsRow("stafftitle", "stafftitle_id", $stafftitle_id); |
1673 |
dpavlin |
1 |
if ($exists > 0){ |
1674 |
|
|
|
1675 |
|
|
// Lookup the descriptive title |
1676 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
|
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 |
dpavlin |
67 |
printf("<input type = \"Hidden\" name = \"stafftitle_id\" value = \"%d\" >\n", $stafftitle_id); |
1684 |
dpavlin |
1 |
printf("<center>\n"); |
1685 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1686 |
|
|
printf("</center>\n"); |
1687 |
dpavlin |
67 |
printf("</form>\n"); |
1688 |
dpavlin |
1 |
} |
1689 |
dpavlin |
67 |
else if ($exists < 1) printf ("Staff Title not found. Operation cancelled.<br><br>\n"); |
1690 |
dpavlin |
1 |
|
1691 |
dpavlin |
67 |
msgTableClose(); |
1692 |
dpavlin |
1 |
} |
1693 |
|
|
|
1694 |
|
|
|
1695 |
|
|
/********************************************************** |
1696 |
|
|
Function: deleteStyle |
1697 |
|
|
Author: Paul Bramscher |
1698 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1699 |
dpavlin |
1 |
*********************************************************** |
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 |
dpavlin |
67 |
function deleteStyle($style_id){ |
1707 |
dpavlin |
1 |
|
1708 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Style (ID# " . $style_id . ")"); |
1709 |
|
|
printf("<b>Messages:</b><br>\n"); |
1710 |
dpavlin |
1 |
|
1711 |
|
|
if ($style_id > 2) { |
1712 |
dpavlin |
67 |
// First update all affected rows in page to (N/A) |
1713 |
dpavlin |
1 |
$sql = "UPDATE page SET style_id = 1 WHERE style_id = " . $style_id; |
1714 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully set affected page styles to (N/A).<BR>\n"); |
1715 |
dpavlin |
1 |
|
1716 |
|
|
// Delete from the style table |
1717 |
dpavlin |
67 |
$sql = "DELETE FROM style WHERE style_id =" . $style_id; |
1718 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this style successfully."); |
1719 |
dpavlin |
1 |
|
1720 |
|
|
} |
1721 |
|
|
else { |
1722 |
dpavlin |
67 |
printf("Cannot delete Style ID's #1 and #2. #1 acts as a system placeholder, #2 "); |
1723 |
dpavlin |
1 |
printf("is the default style for new pages, but may be renamed or redefined as "); |
1724 |
dpavlin |
67 |
printf("needed."); |
1725 |
dpavlin |
1 |
} |
1726 |
|
|
|
1727 |
dpavlin |
67 |
printf("<br><br>\n"); |
1728 |
|
|
msgTableClose(); |
1729 |
dpavlin |
1 |
} |
1730 |
|
|
|
1731 |
|
|
|
1732 |
|
|
/********************************************************** |
1733 |
|
|
Function: deleteStyleConfirm |
1734 |
|
|
Author: Paul Bramscher |
1735 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
1736 |
dpavlin |
1 |
*********************************************************** |
1737 |
|
|
Purpose: |
1738 |
|
|
Confirm prompt for deleting the supplied style id |
1739 |
|
|
**********************************************************/ |
1740 |
dpavlin |
67 |
function deleteStyleConfirm($key_id){ |
1741 |
dpavlin |
1 |
|
1742 |
|
|
$style_id = (int) $key_id; |
1743 |
dpavlin |
67 |
msgTableOpen(1, "Delete Style (ID# " . $style_id . ")?"); |
1744 |
dpavlin |
1 |
|
1745 |
|
|
// Check to see if its possible |
1746 |
dpavlin |
67 |
$exists = existsRow("style", "style_id", $style_id); |
1747 |
dpavlin |
1 |
if ($exists > 0){ |
1748 |
|
|
|
1749 |
|
|
// Lookup the descriptive title |
1750 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
|
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 |
dpavlin |
67 |
printf("</form>\n"); |
1766 |
|
|
} |
1767 |
|
|
else if ($exists < 1) printf ("Style not found. Operation cancelled.<br><br>\n"); |
1768 |
|
|
|
1769 |
|
|
msgTableClose(); |
1770 |
|
|
} |
1771 |
dpavlin |
1 |
|
1772 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
xx_tryquery ($sql); |
1793 |
dpavlin |
1 |
} |
1794 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
|
1818 |
dpavlin |
67 |
// First delete all related rows in res_sub_infotype |
1819 |
|
|
$sql = "DELETE FROM res_sub_infotype WHERE subject_id = " . $subject_id; |
1820 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Resource-subject-information type associations removed.<BR>\n"); |
1821 |
dpavlin |
1 |
|
1822 |
dpavlin |
67 |
// Delete from the sub_loc table |
1823 |
|
|
$sql = "DELETE FROM sub_loc WHERE subject_id =" . $subject_id; |
1824 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Subject-location associations removed.<BR>\n"); |
1825 |
dpavlin |
67 |
|
1826 |
|
|
// Delete from the sub_mastersubject table |
1827 |
|
|
$sql = "DELETE FROM sub_mastersubject WHERE subject_id =" . $subject_id; |
1828 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Subject-mastersubject associations removed.<BR>\n"); |
1829 |
dpavlin |
67 |
|
1830 |
|
|
// Delete from the sub_staff table |
1831 |
|
|
$sql = "DELETE FROM sub_staff WHERE subject_id =" . $subject_id; |
1832 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Subject-staff assignments removed.<BR>\n"); |
1833 |
dpavlin |
67 |
|
1834 |
|
|
// Delete from the sub_coursesub table |
1835 |
|
|
$sql = "DELETE FROM sub_coursesub WHERE subject_id =" . $subject_id; |
1836 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Subject-Course Subject assignments removed.<BR>\n"); |
1837 |
dpavlin |
67 |
|
1838 |
|
|
// Delete from the sub_page table |
1839 |
|
|
$sql = "DELETE FROM sub_page WHERE subject_id =" . $subject_id; |
1840 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Subject-Page assignments removed.<BR>\n"); |
1841 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Subject-Other Subject assignments removed.<BR>\n"); |
1848 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
1857 |
|
|
$row = xx_fetch_array ($rs, xx_ASSOC); |
1858 |
dpavlin |
67 |
$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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.<BR>\n"); |
1878 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.<BR>\n"); |
1887 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).<BR>\n"); |
1900 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).<BR>\n"); |
1909 |
dpavlin |
67 |
|
1910 |
|
|
// Finally delete from the subject table |
1911 |
|
|
$sql = "DELETE FROM subject WHERE subject_id =" . $subject_id; |
1912 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully removed this subject from the system."); |
1913 |
dpavlin |
67 |
} |
1914 |
|
|
else printf ("Cannot delete Subject ID# 1, it acts as a system placeholder."); |
1915 |
|
|
|
1916 |
|
|
printf("<br><br>\n"); |
1917 |
|
|
msgTableClose(); |
1918 |
dpavlin |
1 |
} |
1919 |
|
|
|
1920 |
|
|
|
1921 |
dpavlin |
67 |
/********************************************************** |
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 |
dpavlin |
1 |
/********************************************************** |
1965 |
dpavlin |
67 |
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 |
dpavlin |
69 |
xx_tryquery($sql); |
1984 |
dpavlin |
67 |
} |
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 |
dpavlin |
69 |
xx_tryquery($sql); |
2010 |
dpavlin |
67 |
} |
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 |
dpavlin |
69 |
xx_tryquery($sql); |
2035 |
dpavlin |
67 |
} |
2036 |
|
|
// Call the subject form back |
2037 |
|
|
formSubject($subject_id); |
2038 |
|
|
} |
2039 |
|
|
|
2040 |
|
|
|
2041 |
|
|
/********************************************************** |
2042 |
dpavlin |
1 |
Function: deleteTerm |
2043 |
|
|
Author: Paul Bramscher |
2044 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
2045 |
dpavlin |
1 |
*********************************************************** |
2046 |
|
|
Purpose: |
2047 |
|
|
Deletes the supplied term id, and removes references in |
2048 |
|
|
the course table. |
2049 |
|
|
**********************************************************/ |
2050 |
dpavlin |
67 |
function deleteTerm($term_id){ |
2051 |
dpavlin |
1 |
|
2052 |
dpavlin |
67 |
msgTableOpen(1, "Deleting Term (ID# " . $term_id . ")"); |
2053 |
|
|
printf("<b>Messages:</b><br>\n"); |
2054 |
dpavlin |
1 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this term from affected course pages.<BR>\n"); |
2061 |
dpavlin |
1 |
|
2062 |
dpavlin |
67 |
// Delete from term table |
2063 |
|
|
$sql = "DELETE FROM term WHERE term_id =" . $term_id; |
2064 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed term successfully."); |
2065 |
dpavlin |
1 |
} |
2066 |
dpavlin |
67 |
else printf ("Cannot delete Term ID# 1, it acts as a system placeholder."); |
2067 |
dpavlin |
1 |
|
2068 |
dpavlin |
67 |
printf("<br><br>\n"); |
2069 |
|
|
msgTableClose(); |
2070 |
dpavlin |
1 |
} |
2071 |
|
|
|
2072 |
|
|
|
2073 |
|
|
/********************************************************** |
2074 |
|
|
Function: deleteTermConfirm |
2075 |
|
|
Author: Paul Bramscher |
2076 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
2077 |
dpavlin |
1 |
*********************************************************** |
2078 |
|
|
Purpose: |
2079 |
|
|
Confirm prompt for deleting the supplied term id. |
2080 |
|
|
**********************************************************/ |
2081 |
dpavlin |
67 |
function deleteTermConfirm($key_id){ |
2082 |
dpavlin |
1 |
|
2083 |
|
|
$term_id = (int) $key_id; |
2084 |
dpavlin |
67 |
msgTableOpen(1, "Delete Term (ID# " . $term_id . ")?"); |
2085 |
dpavlin |
1 |
|
2086 |
|
|
// Check to see if its possible |
2087 |
dpavlin |
67 |
$exists = existsRow("term", "term_id", $term_id); |
2088 |
dpavlin |
1 |
if ($exists > 0){ |
2089 |
|
|
|
2090 |
|
|
// Lookup the descriptive title |
2091 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
|
2095 |
|
|
// Form to draw the delete button |
2096 |
dpavlin |
67 |
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 |
dpavlin |
1 |
|
2109 |
dpavlin |
67 |
|
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Vendor purged from assignments to resources.<BR>\n"); |
2131 |
dpavlin |
67 |
|
2132 |
|
|
// Delete from the vendor table |
2133 |
|
|
$sql = "DELETE FROM vendor WHERE vendor_id =" . $vendor_id; |
2134 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Removed this vendor successfully."); |
2135 |
dpavlin |
67 |
|
2136 |
dpavlin |
1 |
} |
2137 |
dpavlin |
67 |
else printf ("Cannot delete Vendor ID# 1, it acts as a system placeholder."); |
2138 |
dpavlin |
1 |
|
2139 |
dpavlin |
67 |
printf("<br><br>\n"); |
2140 |
|
|
msgTableClose(); |
2141 |
|
|
} |
2142 |
dpavlin |
1 |
|
2143 |
dpavlin |
67 |
|
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 |
dpavlin |
1 |
} |
2179 |
dpavlin |
67 |
?> |