1 |
dpavlin |
18 |
<?php |
2 |
|
|
/********************************************************** |
3 |
|
|
Function Library: scribe_application.php |
4 |
|
|
Original Author: Paul Bramscher <brams006@tc.umn.edu> |
5 |
|
|
Last Modified: 01.27.2004 |
6 |
|
|
*********************************************************** |
7 |
|
|
Comments: |
8 |
|
|
This library brings together all of the SQL actions in |
9 |
|
|
the CLPS system. Note that it occasionally relies |
10 |
|
|
on app_controls.php and other libraries as well, but these |
11 |
|
|
are specific to CLPS. |
12 |
|
|
*********************************************************** |
13 |
|
|
assignPageStaff |
14 |
|
|
assignStaffCoordinator |
15 |
|
|
copyPasteElement |
16 |
|
|
deleteCopyBuffer |
17 |
|
|
deleteCoursePers |
18 |
|
|
deleteElement |
19 |
|
|
deletePage |
20 |
|
|
deletePageConfirm |
21 |
|
|
deletePageStaff |
22 |
|
|
displayCourseHeader |
23 |
|
|
displayCoursePers |
24 |
|
|
displayTOC |
25 |
|
|
elementDecrease |
26 |
|
|
elementDown |
27 |
|
|
elementIncrease |
28 |
|
|
elementMultiFormat |
29 |
|
|
elementSize |
30 |
|
|
elementUp |
31 |
|
|
getMaxIndent |
32 |
|
|
insertCoursePers |
33 |
|
|
insertScribeLabel |
34 |
|
|
insertScribeLocation |
35 |
|
|
insertScribeResource |
36 |
|
|
insertScribeRQS |
37 |
|
|
insertScribeRQSLink |
38 |
|
|
insertScribeService |
39 |
|
|
insertScribeStaff |
40 |
|
|
pageLoadStats |
41 |
|
|
pageTemplate |
42 |
|
|
pageTemplateConfirm |
43 |
|
|
parentIs |
44 |
|
|
parentProbe |
45 |
|
|
pasteElement |
46 |
|
|
populateGenArray |
47 |
|
|
scribePublish |
48 |
|
|
scribeUnpublish |
49 |
|
|
|
50 |
|
|
--- |
51 |
|
|
Deprecated: |
52 |
|
|
siblingElderProbe |
53 |
|
|
siblingYoungerProbe |
54 |
|
|
--- |
55 |
|
|
|
56 |
|
|
|
57 |
|
|
sibProbeElder |
58 |
|
|
sibProbeYounger |
59 |
|
|
toggleTOCDisplay |
60 |
|
|
toggleTOCWrap |
61 |
|
|
toggleURLDisplay |
62 |
|
|
toggleUpDisplay |
63 |
|
|
toggleUpText |
64 |
|
|
updatePageDebug |
65 |
|
|
updatePageHeader |
66 |
|
|
updatePageTitleStyle |
67 |
|
|
updateScribeCourse |
68 |
|
|
updateScribeCourseConcat |
69 |
|
|
updateScribeElement |
70 |
|
|
updateScribeHeader |
71 |
|
|
updateScribeStyle |
72 |
|
|
updateScribeUpdate |
73 |
|
|
youngerProbe |
74 |
|
|
**********************************************************/ |
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
/********************************************************** |
79 |
|
|
Function: assignPageStaff |
80 |
|
|
Author: Paul Bramscher |
81 |
|
|
Last Modified: 04.23.2003 |
82 |
|
|
*********************************************************** |
83 |
|
|
Purpose: |
84 |
|
|
Assigns staffpersons (possibly multiple) to a given page |
85 |
|
|
and calls the page edit mode back again. |
86 |
|
|
**********************************************************/ |
87 |
|
|
function assignPageStaff($con, $page_id, $staff_id_array) { |
88 |
|
|
|
89 |
|
|
// For all staff in the array |
90 |
|
|
for ($subscript = 0; $subscript < sizeof($staff_id_array); $subscript++ ) { |
91 |
|
|
|
92 |
|
|
// Check to make sure that the staff isn't already assigned |
93 |
|
|
$sql = "SELECT * FROM page_staff where page_id = " . $page_id . |
94 |
|
|
" AND staff_id = " . $staff_id_array[$subscript]; |
95 |
|
|
$rs = mysql_query($sql); |
96 |
|
|
if (mysql_num_rows($rs) == 0) { |
97 |
|
|
|
98 |
|
|
$sql = "INSERT INTO page_staff (page_id, staff_id) VALUES (" |
99 |
|
|
. $page_id |
100 |
|
|
. ", " |
101 |
|
|
. $staff_id_array[$subscript] |
102 |
|
|
. ")"; |
103 |
|
|
|
104 |
|
|
if (!mysql_query($sql, $con)){ |
105 |
|
|
sql_err($con); |
106 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
107 |
|
|
bailout(); |
108 |
|
|
} // bad write |
109 |
|
|
else { |
110 |
|
|
mysql_query("UNLOCK TABLES", $con); |
111 |
|
|
|
112 |
|
|
} // good write of staff |
113 |
|
|
|
114 |
|
|
} // staff not already assigned |
115 |
|
|
|
116 |
|
|
} // array of staff id's |
117 |
|
|
|
118 |
|
|
// Call the PageScribe back |
119 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "&cmd=pagestaff"); |
120 |
|
|
|
121 |
|
|
} // function |
122 |
|
|
|
123 |
|
|
|
124 |
|
|
/********************************************************** |
125 |
|
|
Function: assignStaffCoordinator |
126 |
|
|
Author: Paul Bramscher |
127 |
|
|
Last Modified: 04.22.2003 |
128 |
|
|
*********************************************************** |
129 |
|
|
Purpose: |
130 |
|
|
Assigns a single staff coordinator to a given page and |
131 |
|
|
calls the page edit mode back again. |
132 |
|
|
**********************************************************/ |
133 |
|
|
function assignStaffCoordinator($con, $page_id, $staff_coordinator) { |
134 |
|
|
|
135 |
|
|
$sql = "UPDATE page SET staff_coordinator = " |
136 |
|
|
. $staff_coordinator |
137 |
|
|
. " WHERE page_id = " |
138 |
|
|
. $page_id; |
139 |
|
|
|
140 |
|
|
if (!mysql_query ($sql, $con)){ |
141 |
|
|
sql_err($sql); |
142 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
143 |
|
|
bailout(); |
144 |
|
|
} |
145 |
|
|
else { // Success call the page back |
146 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
147 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
148 |
|
|
} |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
|
152 |
|
|
/********************************************************** |
153 |
|
|
Function: copyPasteElement |
154 |
|
|
Author: Paul Bramscher |
155 |
|
|
Last Modified: 06.11.2003 |
156 |
|
|
*********************************************************** |
157 |
|
|
Purpose: |
158 |
|
|
Copies the supplied element id and descendants (if picked) |
159 |
|
|
and inserts them into the user's copy/paste buffer. Any |
160 |
|
|
previously copied data is replaced. |
161 |
|
|
**********************************************************/ |
162 |
|
|
function copyPasteElement($con, $page_id, $place_array_HTML, $copysingle, $sess_staff_id){ |
163 |
|
|
|
164 |
|
|
// Split by comma separated values |
165 |
|
|
$place_array = split(",", $place_array_HTML); |
166 |
|
|
|
167 |
|
|
// Break apart place array |
168 |
|
|
$element_id = $place_array[0]; |
169 |
|
|
$element_order = $place_array[1]; |
170 |
|
|
$indent_level = $place_array[2]; |
171 |
|
|
$parent_id = $place_array[3]; |
172 |
|
|
$position = $place_array[4]; |
173 |
|
|
|
174 |
|
|
// First, we delete any previously cut elements from the pastebuffer table |
175 |
|
|
$sql = "DELETE FROM pastebuffer WHERE paste_staff_id = " |
176 |
|
|
. $sess_staff_id; |
177 |
|
|
|
178 |
|
|
//printf("sql was: %s<BR>\n", $sql); |
179 |
|
|
|
180 |
|
|
|
181 |
|
|
if (!mysql_query($sql, $con)){ |
182 |
|
|
sql_err($con); |
183 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
184 |
|
|
$success = 0; |
185 |
|
|
bailout(); |
186 |
|
|
} |
187 |
|
|
else { |
188 |
|
|
mysql_query("UNLOCK TABLES", $con); |
189 |
|
|
|
190 |
|
|
} |
191 |
|
|
|
192 |
|
|
// Element is a parent, and user is copying that element only. |
193 |
|
|
if ($copysingle == 1) { |
194 |
|
|
$end_element_order = $element_order; |
195 |
|
|
|
196 |
|
|
} |
197 |
|
|
|
198 |
|
|
// Copy parent and all descendants. Determine the block of affected rows |
199 |
|
|
else { |
200 |
|
|
|
201 |
|
|
// End order flags |
202 |
|
|
$end_found = 0; |
203 |
|
|
$end_element_order = $element_order; |
204 |
|
|
$last_element_order = $element_order; |
205 |
|
|
|
206 |
|
|
$sql = "SELECT element_id, indent_level, element_order FROM element where page_id = " |
207 |
|
|
. $page_id |
208 |
|
|
. " AND element_order > " |
209 |
|
|
. $element_order |
210 |
|
|
. " ORDER BY element_order"; |
211 |
|
|
$rs = mysql_query($sql, $con); |
212 |
|
|
|
213 |
|
|
// Check for indent level |
214 |
|
|
while (($row = mysql_fetch_array ($rs)) && ($end_found == 0)) { |
215 |
|
|
|
216 |
|
|
$probe_element_id = $row["element_id"]; |
217 |
|
|
$probe_indent_level = $row["indent_level"]; |
218 |
|
|
$probe_element_order = $row["element_order"]; |
219 |
|
|
|
220 |
|
|
if ($probe_indent_level <= $indent_level) { |
221 |
|
|
$end_element_order = $last_element_order; |
222 |
|
|
$end_found = 1; |
223 |
|
|
} |
224 |
|
|
else $end_element_order = $probe_element_order; |
225 |
|
|
$last_element_order = $probe_element_order; |
226 |
|
|
//printf("probed element: %d<BR>", $probe_element_id); |
227 |
|
|
//printf("probed indent: %d<BR>", $probe_indent_level); |
228 |
|
|
|
229 |
|
|
} // end of affected elements to copy |
230 |
|
|
|
231 |
|
|
} // determine last descendant to copy |
232 |
|
|
|
233 |
|
|
/* |
234 |
|
|
Select the block of affected elements and insert them into the pastebuffer table |
235 |
|
|
*/ |
236 |
|
|
$sql = "INSERT INTO pastebuffer ( |
237 |
|
|
paste_staff_id, |
238 |
|
|
parent_id, |
239 |
|
|
resource_id, |
240 |
|
|
location_id, |
241 |
|
|
service_id, |
242 |
|
|
staff_id, |
243 |
|
|
subject_id, |
244 |
|
|
indent_level, |
245 |
|
|
label, |
246 |
|
|
label_url, |
247 |
|
|
element_descr, |
248 |
|
|
element_size, |
249 |
|
|
element_order) |
250 |
|
|
SELECT |
251 |
|
|
staff.staff_id AS paste_staff_id, |
252 |
|
|
parent_id, |
253 |
|
|
resource_id, |
254 |
|
|
location_id, |
255 |
|
|
service_id, |
256 |
|
|
element.staff_id, |
257 |
|
|
subject_id, |
258 |
|
|
indent_level, |
259 |
|
|
label, |
260 |
|
|
label_url, |
261 |
|
|
element_descr, |
262 |
|
|
element_size, |
263 |
|
|
element_order |
264 |
|
|
FROM element, staff |
265 |
|
|
WHERE staff.staff_id = " |
266 |
|
|
. $sess_staff_id |
267 |
|
|
. " AND page_id = " |
268 |
|
|
. $page_id |
269 |
|
|
. " AND element_order >=" |
270 |
|
|
. $element_order |
271 |
|
|
. " AND element_order <=" |
272 |
|
|
. $end_element_order |
273 |
|
|
. " ORDER BY element_order"; |
274 |
|
|
|
275 |
|
|
if (!mysql_query($sql, $con)){ |
276 |
|
|
sql_err($con); |
277 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
278 |
|
|
$success = 0; |
279 |
|
|
bailout(); |
280 |
|
|
} |
281 |
|
|
else { |
282 |
|
|
mysql_query("UNLOCK TABLES", $con); |
283 |
|
|
|
284 |
|
|
} |
285 |
|
|
|
286 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
287 |
|
|
|
288 |
|
|
} // end function |
289 |
|
|
|
290 |
|
|
|
291 |
|
|
/********************************************************** |
292 |
|
|
Function: deleteCopyBuffer |
293 |
|
|
Author: Paul Bramscher |
294 |
|
|
Last Modified: 04.22.2003 |
295 |
|
|
*********************************************************** |
296 |
|
|
Purpose: |
297 |
|
|
Clears the user's copy/paste buffer. |
298 |
|
|
**********************************************************/ |
299 |
|
|
function deleteCopyBuffer($con, $page_id, $paste_staff_id){ |
300 |
|
|
|
301 |
|
|
$sql = "DELETE from pastebuffer WHERE paste_staff_id = " |
302 |
|
|
. $paste_staff_id; |
303 |
|
|
|
304 |
|
|
if (!mysql_query ($sql, $con)){ |
305 |
|
|
sql_err($sql); |
306 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
307 |
|
|
bailout(); |
308 |
|
|
} |
309 |
|
|
else { |
310 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
311 |
|
|
} |
312 |
|
|
|
313 |
|
|
header("Location: scribe.phtml?page_id=". $page_id); |
314 |
|
|
} |
315 |
|
|
|
316 |
|
|
|
317 |
|
|
/********************************************************** |
318 |
|
|
Function: deleteCoursePers |
319 |
|
|
Author: Paul Bramscher |
320 |
|
|
Last Modified: 12.02.2002 |
321 |
|
|
*********************************************************** |
322 |
|
|
Purpose: |
323 |
|
|
Deletes the supplied personnel id from the course. |
324 |
|
|
**********************************************************/ |
325 |
|
|
function deleteCoursePers($con, $course_id, $page_id, $personnel_id){ |
326 |
|
|
|
327 |
|
|
// Build the sql. |
328 |
|
|
$sql = "DELETE from course_personnel WHERE personnel_id = " |
329 |
|
|
. $personnel_id |
330 |
|
|
. " AND course_id = " |
331 |
|
|
. $course_id; |
332 |
|
|
|
333 |
|
|
if (!mysql_query ($sql, $con)){ |
334 |
|
|
sql_err($sql); |
335 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
336 |
|
|
bailout(); |
337 |
|
|
} |
338 |
|
|
else { |
339 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
340 |
|
|
} |
341 |
|
|
|
342 |
|
|
header("Location: scribe.phtml?page_id=". $page_id); |
343 |
|
|
} |
344 |
|
|
|
345 |
|
|
|
346 |
|
|
|
347 |
|
|
/********************************************************** |
348 |
|
|
Function: deleteElement |
349 |
|
|
Author: Paul Bramscher |
350 |
|
|
Last Modified: 04.24.2003 |
351 |
|
|
*********************************************************** |
352 |
|
|
Purpose: |
353 |
|
|
Deletes the supplied element id. Depending on user selection, |
354 |
|
|
all descendants are also deleted, or else promoted to the |
355 |
|
|
generation of the deleted parent. |
356 |
|
|
|
357 |
|
|
This function also deletes references to the affected element, |
358 |
|
|
and any removed descendants, from the libstats statistics |
359 |
|
|
table. |
360 |
|
|
**********************************************************/ |
361 |
|
|
function deleteElement($con, $page_id, $place_array_HTML, $promote){ |
362 |
|
|
|
363 |
|
|
// Split by comma separated values |
364 |
|
|
$place_array = split(",", $place_array_HTML); |
365 |
|
|
|
366 |
|
|
// Break apart place array |
367 |
|
|
$element_id = $place_array[0]; |
368 |
|
|
$element_order = $place_array[1]; |
369 |
|
|
$indent_level = $place_array[2]; |
370 |
|
|
$parent_id = $place_array[3]; |
371 |
|
|
$position = $place_array[4]; |
372 |
|
|
|
373 |
|
|
|
374 |
|
|
/* Incoming promote parameters |
375 |
|
|
0: no children |
376 |
|
|
1: children present, promote them |
377 |
|
|
2: children present, delete them |
378 |
|
|
*/ |
379 |
|
|
|
380 |
|
|
|
381 |
|
|
/******************************************************** |
382 |
|
|
** Item is singular, no children. Simple delete case. ** |
383 |
|
|
********************************************************/ |
384 |
|
|
|
385 |
|
|
if ($promote == 0) { |
386 |
|
|
|
387 |
|
|
// Success flag |
388 |
|
|
$success = 1; |
389 |
|
|
|
390 |
|
|
// First delete the element |
391 |
|
|
$sql = "DELETE from element WHERE page_id = " |
392 |
|
|
. $page_id |
393 |
|
|
. " AND element_id = " |
394 |
|
|
. $element_id; |
395 |
|
|
if (!mysql_query($sql, $con)){ |
396 |
|
|
sql_err($con); |
397 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
398 |
|
|
$success = 0; |
399 |
|
|
bailout(); |
400 |
|
|
} |
401 |
|
|
else { |
402 |
|
|
mysql_query("UNLOCK TABLES", $con); |
403 |
|
|
|
404 |
|
|
} |
405 |
|
|
|
406 |
|
|
// Next, update the order of the remainders |
407 |
|
|
if ($success == 1) { |
408 |
|
|
|
409 |
|
|
$sql = "UPDATE element SET element_order = element_order - 1 WHERE page_id = " |
410 |
|
|
. $page_id |
411 |
|
|
. " AND element_order > " |
412 |
|
|
. $element_order; |
413 |
|
|
|
414 |
|
|
// Make the change |
415 |
|
|
if (!mysql_query($sql, $con)){ |
416 |
|
|
sql_err($con); |
417 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
418 |
|
|
bailout(); |
419 |
|
|
} |
420 |
|
|
else { |
421 |
|
|
mysql_query("UNLOCK TABLES", $con); |
422 |
|
|
|
423 |
|
|
} // end reordering |
424 |
|
|
|
425 |
|
|
} // end safety check for reordering |
426 |
|
|
|
427 |
|
|
// Last, delete the element reference from the stats database |
428 |
|
|
if ($success == 1) { |
429 |
|
|
$sql = "DELETE from libstats.elementstats WHERE page_id = " |
430 |
|
|
. $page_id |
431 |
|
|
. " AND element_id = " |
432 |
|
|
. $element_id; |
433 |
|
|
if (!mysql_query($sql, $con)){ |
434 |
|
|
sql_err($con); |
435 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
436 |
|
|
$success = 0; |
437 |
|
|
bailout(); |
438 |
|
|
} |
439 |
|
|
else { |
440 |
|
|
mysql_query("UNLOCK TABLES", $con); |
441 |
|
|
|
442 |
|
|
// Done, return to page |
443 |
|
|
if ($position > 2) $new_pos = $position - 1; |
444 |
|
|
else $new_pos = 1; |
445 |
|
|
header("Location: scribe.phtml?page_id=". $page_id . "#p" . $new_pos); |
446 |
|
|
|
447 |
|
|
} |
448 |
|
|
} // end removal from stats database |
449 |
|
|
|
450 |
|
|
} // end simple delete |
451 |
|
|
|
452 |
|
|
|
453 |
|
|
/************************************* |
454 |
|
|
** Delete element, promote children ** |
455 |
|
|
*************************************/ |
456 |
|
|
|
457 |
|
|
else if ($promote == 1) { |
458 |
|
|
|
459 |
|
|
// Success flag |
460 |
|
|
$success = 1; |
461 |
|
|
|
462 |
|
|
// Intialize first descendant indent level to proper value |
463 |
|
|
$desc_indent_level = $indent_level + 1; |
464 |
|
|
|
465 |
|
|
/* |
466 |
|
|
First, we need to march through the records, starting at the |
467 |
|
|
first child. We need to decrease all indent levels by one. When |
468 |
|
|
we arrive at an indent level equal to the parent's, it is a sibling |
469 |
|
|
(of the parent) and we stop. |
470 |
|
|
*/ |
471 |
|
|
|
472 |
|
|
$sql = "SELECT element_id, parent_id, indent_level, element_order FROM element WHERE page_id = " |
473 |
|
|
. $page_id |
474 |
|
|
. " AND element_order > " |
475 |
|
|
. $element_order |
476 |
|
|
. " ORDER BY element_order"; |
477 |
|
|
$rs = mysql_query($sql, $con); |
478 |
|
|
|
479 |
|
|
// Check for and promote all descendants |
480 |
|
|
while (($row = mysql_fetch_array ($rs)) && ($desc_indent_level > $indent_level)) { |
481 |
|
|
$desc_element_id = $row["element_id"]; |
482 |
|
|
$desc_parent_id = $row["parent_id"]; |
483 |
|
|
$desc_indent_level = $row["indent_level"]; |
484 |
|
|
|
485 |
|
|
// We've found a descendant, alter the indent level |
486 |
|
|
if ($desc_indent_level > $indent_level) { |
487 |
|
|
$promote_sql = "UPDATE element SET indent_level = indent_level - 1 WHERE page_id = " |
488 |
|
|
. $page_id |
489 |
|
|
. " AND element_id = " |
490 |
|
|
. $desc_element_id; |
491 |
|
|
|
492 |
|
|
if (!mysql_query($promote_sql, $con)){ |
493 |
|
|
sql_err($con); |
494 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
495 |
|
|
$success = 0; |
496 |
|
|
bailout(); |
497 |
|
|
} |
498 |
|
|
else { |
499 |
|
|
mysql_query("UNLOCK TABLES", $con); |
500 |
|
|
|
501 |
|
|
} // end of a descendant promote |
502 |
|
|
|
503 |
|
|
} // end of check for one descendant |
504 |
|
|
|
505 |
|
|
|
506 |
|
|
/* |
507 |
|
|
Reset the parent ID on the immediate first-generation children. |
508 |
|
|
Note that at this point they have the same indent level as their |
509 |
|
|
parent in the database, but differ here in PHP. |
510 |
|
|
*/ |
511 |
|
|
|
512 |
|
|
if ($desc_indent_level == $indent_level + 1) { |
513 |
|
|
|
514 |
|
|
$newparent_sql = "UPDATE element SET parent_id = " |
515 |
|
|
. $parent_id |
516 |
|
|
. " WHERE page_id = " |
517 |
|
|
. $page_id |
518 |
|
|
. " AND element_id = " |
519 |
|
|
. $desc_element_id; |
520 |
|
|
if (!mysql_query($newparent_sql, $con)){ |
521 |
|
|
sql_err($con); |
522 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
523 |
|
|
$success = 0; |
524 |
|
|
bailout(); |
525 |
|
|
} |
526 |
|
|
else { |
527 |
|
|
mysql_query("UNLOCK TABLES", $con); |
528 |
|
|
|
529 |
|
|
} // end of a first-generation parent reassignment |
530 |
|
|
|
531 |
|
|
} // end check for first generation children |
532 |
|
|
|
533 |
|
|
} // end check for all descendants |
534 |
|
|
|
535 |
|
|
// Next, delete the parent |
536 |
|
|
if ($success == 1) { |
537 |
|
|
$parent_sql = "DELETE FROM element WHERE element_id = " |
538 |
|
|
. $element_id; |
539 |
|
|
if (!mysql_query($parent_sql, $con)){ |
540 |
|
|
sql_err($con); |
541 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
542 |
|
|
bailout(); |
543 |
|
|
$success = 0; |
544 |
|
|
} |
545 |
|
|
else { |
546 |
|
|
mysql_query("UNLOCK TABLES", $con); |
547 |
|
|
|
548 |
|
|
// Increment the deleted counter to include the parent |
549 |
|
|
$num_desc++; |
550 |
|
|
|
551 |
|
|
} // end of parent delete |
552 |
|
|
|
553 |
|
|
} // end of safety check for parent delete |
554 |
|
|
|
555 |
|
|
// Next, update the order of the remainders |
556 |
|
|
if ($success == 1) { |
557 |
|
|
$order_sql = "UPDATE element SET element_order = element_order - 1 WHERE page_id = " |
558 |
|
|
. $page_id |
559 |
|
|
. " AND element_order > " |
560 |
|
|
. $element_order; |
561 |
|
|
if (!mysql_query($order_sql, $con)){ |
562 |
|
|
sql_err($con); |
563 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
564 |
|
|
bailout(); |
565 |
|
|
$success = 0; |
566 |
|
|
} |
567 |
|
|
else { |
568 |
|
|
mysql_query("UNLOCK TABLES", $con); |
569 |
|
|
|
570 |
|
|
} // end reordering |
571 |
|
|
|
572 |
|
|
} // end of safety check for reordering |
573 |
|
|
|
574 |
|
|
|
575 |
|
|
// Last, delete the (parent) element reference from the stats database |
576 |
|
|
if ($success == 1) { |
577 |
|
|
$sql = "DELETE from libstats.elementstats WHERE page_id = " |
578 |
|
|
. $page_id |
579 |
|
|
. " AND element_id = " |
580 |
|
|
. $element_id; |
581 |
|
|
if (!mysql_query($sql, $con)){ |
582 |
|
|
sql_err($con); |
583 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
584 |
|
|
$success = 0; |
585 |
|
|
bailout(); |
586 |
|
|
} |
587 |
|
|
else { |
588 |
|
|
mysql_query("UNLOCK TABLES", $con); |
589 |
|
|
|
590 |
|
|
// Done, return to page |
591 |
|
|
if ($position > 2) $new_pos = $position - 1; |
592 |
|
|
else $new_pos = 1; |
593 |
|
|
header("Location: scribe.phtml?page_id=". $page_id . "#p" . $new_pos); |
594 |
|
|
|
595 |
|
|
} |
596 |
|
|
|
597 |
|
|
} // end removal from stats database |
598 |
|
|
|
599 |
|
|
|
600 |
|
|
} // end delete and promote |
601 |
|
|
|
602 |
|
|
|
603 |
|
|
/******************************** |
604 |
|
|
** Delete element and children ** |
605 |
|
|
********************************/ |
606 |
|
|
|
607 |
|
|
|
608 |
|
|
else if ($promote == 2) { |
609 |
|
|
|
610 |
|
|
// Success flag |
611 |
|
|
$success = 1; |
612 |
|
|
|
613 |
|
|
// Intialize first descendant indent level to proper value |
614 |
|
|
$desc_indent_level = $indent_level + 1; |
615 |
|
|
$num_desc = 0; |
616 |
|
|
|
617 |
|
|
/* First, we need to march through the records, starting at the |
618 |
|
|
first child, and purge any with an indent level equal to or |
619 |
|
|
greater than the first child. When we reach an indent level |
620 |
|
|
equal to the parent, we are now dealing with a sibling (of |
621 |
|
|
the parent) and stop. It may possible to do this recursively, |
622 |
|
|
but it might involve more SQL's and probably represent less |
623 |
|
|
clear logic. |
624 |
|
|
*/ |
625 |
|
|
|
626 |
|
|
$sql = "SELECT element_id, parent_id, indent_level, element_order FROM element WHERE page_id = " |
627 |
|
|
. $page_id |
628 |
|
|
. " AND element_order > " |
629 |
|
|
. $element_order |
630 |
|
|
. " ORDER BY element_order"; |
631 |
|
|
$rs = mysql_query($sql, $con); |
632 |
|
|
|
633 |
|
|
// Check for and delete all descendants |
634 |
|
|
while (($row = mysql_fetch_array ($rs)) && ($desc_indent_level > $indent_level)) { |
635 |
|
|
$desc_element_id = $row["element_id"]; |
636 |
|
|
$desc_parent_id = $row["parent_id"]; |
637 |
|
|
$desc_indent_level = $row["indent_level"]; |
638 |
|
|
|
639 |
|
|
// We've found a descendant, delete it |
640 |
|
|
if ($desc_indent_level > $indent_level) { |
641 |
|
|
$delete_sql = "DELETE FROM element WHERE element_id = " |
642 |
|
|
. $desc_element_id; |
643 |
|
|
if (!mysql_query($delete_sql, $con)){ |
644 |
|
|
sql_err($con); |
645 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
646 |
|
|
bailout(); |
647 |
|
|
$success = 0; |
648 |
|
|
} |
649 |
|
|
else { |
650 |
|
|
mysql_query("UNLOCK TABLES", $con); |
651 |
|
|
|
652 |
|
|
// Increment the deleted descendant counter |
653 |
|
|
$num_desc++; |
654 |
|
|
} // end of a descendant delete |
655 |
|
|
|
656 |
|
|
} // end of check for one descendant |
657 |
|
|
|
658 |
|
|
|
659 |
|
|
// Delete this (descendant) element reference from the stats database |
660 |
|
|
if ($success == 1) { |
661 |
|
|
$sql = "DELETE from libstats.elementstats WHERE page_id = " |
662 |
|
|
. $page_id |
663 |
|
|
. " AND element_id = " |
664 |
|
|
. $desc_element_id; |
665 |
|
|
if (!mysql_query($sql, $con)){ |
666 |
|
|
sql_err($con); |
667 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
668 |
|
|
$success = 0; |
669 |
|
|
bailout(); |
670 |
|
|
} |
671 |
|
|
else { |
672 |
|
|
mysql_query("UNLOCK TABLES", $con); |
673 |
|
|
|
674 |
|
|
} |
675 |
|
|
} // end removal from stats database |
676 |
|
|
|
677 |
|
|
} // end check for all descendants |
678 |
|
|
|
679 |
|
|
// Delete the parent itself |
680 |
|
|
if ($success == 1) { |
681 |
|
|
$parent_sql = "DELETE FROM element WHERE element_id = " |
682 |
|
|
. $element_id; |
683 |
|
|
if (!mysql_query($parent_sql, $con)){ |
684 |
|
|
sql_err($con); |
685 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
686 |
|
|
bailout(); |
687 |
|
|
$success = 0; |
688 |
|
|
} |
689 |
|
|
else { |
690 |
|
|
mysql_query("UNLOCK TABLES", $con); |
691 |
|
|
|
692 |
|
|
// Increment the deleted counter to include the parent |
693 |
|
|
$num_desc++; |
694 |
|
|
|
695 |
|
|
} // end of parent delete |
696 |
|
|
|
697 |
|
|
} // end of safety check for parent delete |
698 |
|
|
|
699 |
|
|
// Next, update the order of the remainders |
700 |
|
|
if ($success == 1) { |
701 |
|
|
$order_sql = "UPDATE element SET element_order = element_order - " |
702 |
|
|
. $num_desc |
703 |
|
|
. " WHERE page_id = " |
704 |
|
|
. $page_id |
705 |
|
|
. " AND element_order > " |
706 |
|
|
. $element_order; |
707 |
|
|
if (!mysql_query($order_sql, $con)){ |
708 |
|
|
sql_err($con); |
709 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
710 |
|
|
bailout(); |
711 |
|
|
$success = 0; |
712 |
|
|
} |
713 |
|
|
else { |
714 |
|
|
mysql_query("UNLOCK TABLES", $con); |
715 |
|
|
|
716 |
|
|
} // end reordering |
717 |
|
|
|
718 |
|
|
} // end of safety check for reordering |
719 |
|
|
|
720 |
|
|
|
721 |
|
|
// Last, delete the (parent) element reference from the stats database |
722 |
|
|
if ($success == 1) { |
723 |
|
|
$sql = "DELETE from libstats.elementstats WHERE page_id = " |
724 |
|
|
. $page_id |
725 |
|
|
. " AND element_id = " |
726 |
|
|
. $element_id; |
727 |
|
|
|
728 |
|
|
if (!mysql_query($sql, $con)){ |
729 |
|
|
sql_err($con); |
730 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
731 |
|
|
$success = 0; |
732 |
|
|
bailout(); |
733 |
|
|
} |
734 |
|
|
else { |
735 |
|
|
mysql_query("UNLOCK TABLES", $con); |
736 |
|
|
|
737 |
|
|
// Done, return to page |
738 |
|
|
if ($position > 2) $new_pos = $position - 1; |
739 |
|
|
else $new_pos = 1; |
740 |
|
|
header("Location: scribe.phtml?page_id=". $page_id . "#p" . $new_pos); |
741 |
|
|
|
742 |
|
|
} |
743 |
|
|
|
744 |
|
|
} // end removal from stats database |
745 |
|
|
|
746 |
|
|
} // end delete parent and children |
747 |
|
|
|
748 |
|
|
} // end function |
749 |
|
|
|
750 |
|
|
|
751 |
|
|
/********************************************************** |
752 |
|
|
Function: deletePage |
753 |
|
|
Author: Paul Bramscher |
754 |
|
|
Last Modified: 06.17.2003 |
755 |
|
|
*********************************************************** |
756 |
|
|
Purpose: |
757 |
|
|
Deletes the supplied page id. In doing so, elements, |
758 |
|
|
assigned page staff, course information, assigned course |
759 |
|
|
personnel, and the page itself are deleted. |
760 |
|
|
|
761 |
|
|
This function also deletes any references to the supplied |
762 |
|
|
page id in the libstats database, including element-level |
763 |
|
|
and overall page statistics. |
764 |
|
|
**********************************************************/ |
765 |
|
|
function deletePage($con, $page_id){ |
766 |
|
|
|
767 |
|
|
// Load globals |
768 |
|
|
include("global_vars.php"); |
769 |
|
|
|
770 |
|
|
// Include the page header |
771 |
|
|
include ($GLOBAL_ADMIN_INC."scribe_header.phtml"); |
772 |
|
|
|
773 |
|
|
// HTML headers |
774 |
|
|
printf("<html>\n"); |
775 |
|
|
printf("<head>\n"); |
776 |
|
|
printf("<title>PageScribe: Deleting page...</title>\n"); |
777 |
|
|
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS); |
778 |
|
|
printf("</head>"); |
779 |
|
|
|
780 |
|
|
|
781 |
|
|
// Draw form heading |
782 |
|
|
printf("<center><h3>Deleting Page...</h3>\n"); |
783 |
|
|
|
784 |
|
|
// Table |
785 |
|
|
printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">\n"); |
786 |
|
|
printf("<tr><td><br>\n"); |
787 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
788 |
|
|
|
789 |
|
|
|
790 |
|
|
// Purge all |
791 |
|
|
if ($page_id > 0) { |
792 |
|
|
|
793 |
|
|
// Error flag |
794 |
|
|
$success = 1; |
795 |
|
|
|
796 |
|
|
// Initialize |
797 |
|
|
$course_id = 0; |
798 |
|
|
|
799 |
|
|
// First identify whether this is a CourseLib page. If so, collect the course id. |
800 |
|
|
$sql = "SELECT course_id FROM course WHERE page_id = " |
801 |
|
|
. $page_id; |
802 |
|
|
|
803 |
|
|
$rs = mysql_query($sql, $con); |
804 |
|
|
$row = mysql_fetch_array ($rs); |
805 |
|
|
|
806 |
|
|
// Collect the access information |
807 |
|
|
$course_id = $row["course_id"]; |
808 |
|
|
|
809 |
|
|
// Delete all elements first |
810 |
|
|
$sql = "DELETE from element WHERE page_id =" . $page_id; |
811 |
|
|
|
812 |
|
|
if (!mysql_query ($sql, $con)){ |
813 |
|
|
$success = 0; |
814 |
|
|
sql_err($sql); |
815 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
816 |
|
|
bailout(); |
817 |
|
|
} |
818 |
|
|
else { |
819 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
820 |
|
|
printf("Removed this page's elements.<BR>\n"); |
821 |
|
|
} |
822 |
|
|
|
823 |
|
|
// Delete course information, if any |
824 |
|
|
if ($success == 1) { |
825 |
|
|
|
826 |
|
|
$sql = "DELETE from course WHERE page_id =" . $page_id; |
827 |
|
|
|
828 |
|
|
if (!mysql_query ($sql, $con)){ |
829 |
|
|
$success = 0; |
830 |
|
|
sql_err($sql); |
831 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
832 |
|
|
bailout(); |
833 |
|
|
} |
834 |
|
|
else { |
835 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
836 |
|
|
printf("Removed course information (if any).<BR>\n"); |
837 |
|
|
} |
838 |
|
|
} |
839 |
|
|
|
840 |
|
|
// Delete assigned course personnel, if any |
841 |
|
|
if ($success == 1 && $course_id > 0) { |
842 |
|
|
|
843 |
|
|
$sql = "DELETE from course_personnel WHERE course_id =" . $course_id; |
844 |
|
|
|
845 |
|
|
if (!mysql_query ($sql, $con)){ |
846 |
|
|
$success = 0; |
847 |
|
|
sql_err($sql); |
848 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
849 |
|
|
bailout(); |
850 |
|
|
} |
851 |
|
|
else { |
852 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
853 |
|
|
printf("Removed assigned course personnel (if any).<BR>\n"); |
854 |
|
|
} |
855 |
|
|
} |
856 |
|
|
|
857 |
|
|
// Delete assigned staff, if any |
858 |
|
|
if ($success == 1) { |
859 |
|
|
|
860 |
|
|
$sql = "DELETE from page_staff WHERE page_id =" . $page_id; |
861 |
|
|
|
862 |
|
|
if (!mysql_query ($sql, $con)){ |
863 |
|
|
$success = 0; |
864 |
|
|
sql_err($sql); |
865 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
866 |
|
|
bailout(); |
867 |
|
|
} |
868 |
|
|
else { |
869 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
870 |
|
|
printf("Removed assigned staff (if any).<BR>\n"); |
871 |
|
|
} |
872 |
|
|
} |
873 |
|
|
|
874 |
|
|
// Delete assigned subjects, if any |
875 |
|
|
if ($success == 1) { |
876 |
|
|
|
877 |
|
|
$sql = "DELETE from sub_page WHERE page_id =" . $page_id; |
878 |
|
|
|
879 |
|
|
if (!mysql_query ($sql, $con)){ |
880 |
|
|
$success = 0; |
881 |
|
|
sql_err($sql); |
882 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
883 |
|
|
bailout(); |
884 |
|
|
} |
885 |
|
|
else { |
886 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
887 |
|
|
printf("Removed assigned subjects (if any).<BR>\n"); |
888 |
|
|
} |
889 |
|
|
} |
890 |
|
|
|
891 |
|
|
// Delete element statistics, if any |
892 |
|
|
if ($success == 1) { |
893 |
|
|
|
894 |
|
|
$sql = "DELETE from libstats.elementstats WHERE page_id =" . $page_id; |
895 |
|
|
|
896 |
|
|
if (!mysql_query ($sql, $con)){ |
897 |
|
|
$success = 0; |
898 |
|
|
sql_err($sql); |
899 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
900 |
|
|
bailout(); |
901 |
|
|
} |
902 |
|
|
else { |
903 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
904 |
|
|
printf("Removed page's element statistics (if any).<BR>\n"); |
905 |
|
|
} |
906 |
|
|
} |
907 |
|
|
|
908 |
|
|
// Delete page overall statistics, if any |
909 |
|
|
if ($success == 1) { |
910 |
|
|
|
911 |
|
|
$sql = "DELETE from libstats.pagestats WHERE page_id =" . $page_id; |
912 |
|
|
|
913 |
|
|
if (!mysql_query ($sql, $con)){ |
914 |
|
|
$success = 0; |
915 |
|
|
sql_err($sql); |
916 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
917 |
|
|
bailout(); |
918 |
|
|
} |
919 |
|
|
else { |
920 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
921 |
|
|
printf("Removed page's overall statistics (if any).<BR>\n"); |
922 |
|
|
} |
923 |
|
|
} |
924 |
|
|
|
925 |
|
|
// Delete the page information |
926 |
|
|
if ($success == 1) { |
927 |
|
|
|
928 |
|
|
$sql = "DELETE from page WHERE page_id =" . $page_id; |
929 |
|
|
|
930 |
|
|
if (!mysql_query ($sql, $con)){ |
931 |
|
|
sql_err($sql); |
932 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
933 |
|
|
bailout(); |
934 |
|
|
} |
935 |
|
|
else { |
936 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
937 |
|
|
printf("Removed page successfully.<BR><BR>\n"); |
938 |
|
|
} |
939 |
|
|
} |
940 |
|
|
|
941 |
|
|
} |
942 |
|
|
else printf("Scribe page not found.<br><br>\n"); |
943 |
|
|
|
944 |
|
|
printf("</td></tr></table>\n"); |
945 |
|
|
|
946 |
|
|
|
947 |
|
|
// Link to return to admin console |
948 |
|
|
adminReturn(""); |
949 |
|
|
|
950 |
|
|
printf("</center>\n"); |
951 |
|
|
|
952 |
|
|
// Include the footer |
953 |
|
|
include ($GLOBAL_ADMIN_INC."scribe_footer.phtml"); |
954 |
|
|
} |
955 |
|
|
|
956 |
|
|
|
957 |
|
|
/********************************************************** |
958 |
|
|
Function: deletePageConfirm |
959 |
|
|
Author: Paul Bramscher |
960 |
|
|
Last Modified: 05.01.2003 |
961 |
|
|
*********************************************************** |
962 |
|
|
Purpose: |
963 |
|
|
Confirm prompt to delete the supplied page id. |
964 |
|
|
**********************************************************/ |
965 |
|
|
function deletePageConfirm($con, $page_id){ |
966 |
|
|
|
967 |
|
|
// Load globals |
968 |
|
|
include ("global_vars.php"); |
969 |
|
|
|
970 |
|
|
// Make sure we have a valid integer type |
971 |
|
|
$page_id = (int) $page_id; |
972 |
|
|
|
973 |
|
|
// Include the page header |
974 |
|
|
include ($GLOBAL_ADMIN_INC."scribe_header.phtml"); |
975 |
|
|
|
976 |
|
|
// HTML junk |
977 |
|
|
printf("<html>\n"); |
978 |
|
|
printf("<head>\n"); |
979 |
|
|
printf("<title>PageScribe: Delete Page?</title>\n"); |
980 |
|
|
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS); |
981 |
|
|
printf("</head>"); |
982 |
|
|
|
983 |
|
|
// Draw page heading |
984 |
|
|
printf("<center><h3>Delete Page?</h3>"); |
985 |
|
|
|
986 |
|
|
// Check to see if its possible |
987 |
|
|
$exists = existsRow($con, "page", "page_id", $page_id); |
988 |
|
|
if ($exists > 0){ |
989 |
|
|
|
990 |
|
|
// Table |
991 |
|
|
printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">"); |
992 |
|
|
printf("<tr><td>"); |
993 |
|
|
|
994 |
|
|
// Lookup the title & author |
995 |
|
|
$page_title = lookupField($con, "page", "page_id", $page_id, "page_title"); |
996 |
|
|
printf("<BR><strong>Page Title:</strong> %s<br>\n ", $page_title); |
997 |
|
|
|
998 |
|
|
// Form to draw the delete button |
999 |
|
|
printf("<form method = \"POST\" action = \"scribe_transaction.phtml\" >\n"); |
1000 |
|
|
printf("<input type = \"Hidden\" name = \"transaction\" value = \"deletePage\" >\n"); |
1001 |
|
|
printf("<input type = \"Hidden\" name = \"page_id\" value = \"%d\" >\n", $page_id); |
1002 |
|
|
printf("This will <b>permanently</b> remove the page and its various assignments from the system<BR><BR>\n"); |
1003 |
|
|
printf("<center>\n"); |
1004 |
|
|
|
1005 |
|
|
// Interior table |
1006 |
|
|
printf("<table border=\"0\">\n"); |
1007 |
|
|
|
1008 |
|
|
printf("<tr><td>\n"); |
1009 |
|
|
printf("<input type =\"Submit\" value=\"Delete!\">\n"); |
1010 |
|
|
printf("</center>\n"); |
1011 |
|
|
printf("</form>\n"); |
1012 |
|
|
printf("</td>\n"); |
1013 |
|
|
|
1014 |
|
|
// Cancel button |
1015 |
|
|
printf("<td>\n"); |
1016 |
|
|
printf("<form method=\"POST\" action=\"scribe.phtml?page_id=%d\">\n", $page_id); |
1017 |
|
|
printf("<input type=\"hidden\" name=\"cmd\" value=\"\">\n"); |
1018 |
|
|
printf("<input type=\"submit\" value=\"Cancel\">\n"); |
1019 |
|
|
printf("</form>\n"); |
1020 |
|
|
printf("</td></tr>\n"); |
1021 |
|
|
|
1022 |
|
|
// Close interior table |
1023 |
|
|
printf("</table>\n"); |
1024 |
|
|
|
1025 |
|
|
// Close table |
1026 |
|
|
printf("</td></tr></table>\n"); |
1027 |
|
|
} |
1028 |
|
|
|
1029 |
|
|
// Failed for whatever reason |
1030 |
|
|
else if ($exists < 1) printf ("Page not found. Operation cancelled.<br>\n"); |
1031 |
|
|
|
1032 |
|
|
|
1033 |
|
|
// Link to return to admin console |
1034 |
|
|
adminReturn(""); |
1035 |
|
|
|
1036 |
|
|
|
1037 |
|
|
printf("</center>"); |
1038 |
|
|
|
1039 |
|
|
// Include the footer |
1040 |
|
|
include ($GLOBAL_ADMIN_INC."scribe_footer.phtml"); |
1041 |
|
|
} |
1042 |
|
|
|
1043 |
|
|
|
1044 |
|
|
/********************************************************** |
1045 |
|
|
Function: deletePageStaff |
1046 |
|
|
Author: Paul Bramscher |
1047 |
|
|
Last Modified: 04.22.2003 |
1048 |
|
|
*********************************************************** |
1049 |
|
|
Purpose: |
1050 |
|
|
Delete a staffperson (possibly multiple) associated with |
1051 |
|
|
the supplied page id. |
1052 |
|
|
**********************************************************/ |
1053 |
|
|
function deletePageStaff($con, $page_id, $staff_list_array){ |
1054 |
|
|
|
1055 |
|
|
for ($element = 0; $element < sizeof($staff_list_array); $element++) { |
1056 |
|
|
$sql = "DELETE FROM page_staff where page_id = " . $page_id . |
1057 |
|
|
" AND staff_id = " . $staff_list_array[$element]; |
1058 |
|
|
|
1059 |
|
|
// Failed |
1060 |
|
|
if (!mysql_query ($sql, $con)){ |
1061 |
|
|
sql_err($sql); |
1062 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1063 |
|
|
bailout(); |
1064 |
|
|
} |
1065 |
|
|
|
1066 |
|
|
// Succeeded |
1067 |
|
|
else { |
1068 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1069 |
|
|
} |
1070 |
|
|
} |
1071 |
|
|
|
1072 |
|
|
// Call the PageScribe page back |
1073 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "&cmd=pagestaff"); |
1074 |
|
|
} |
1075 |
|
|
|
1076 |
|
|
|
1077 |
|
|
/********************************************************** |
1078 |
|
|
Function: displayCourseHeader |
1079 |
|
|
Author: Paul Bramscher |
1080 |
|
|
Last Modified: 04.24.2003 |
1081 |
|
|
*********************************************************** |
1082 |
|
|
Purpose: |
1083 |
|
|
Output the course related information for a course page. |
1084 |
|
|
**********************************************************/ |
1085 |
|
|
function displayCourseHeader($con, $page_id, $page_title) { |
1086 |
|
|
|
1087 |
|
|
// Retrieve current information |
1088 |
|
|
$sql = "SELECT * |
1089 |
|
|
FROM |
1090 |
|
|
course c |
1091 |
|
|
LEFT JOIN term t using (term_id) |
1092 |
|
|
LEFT JOIN campus p on c.campus_id = p.campus_id |
1093 |
|
|
LEFT JOIN coursesub s on c.coursesub_id = s.coursesub_id |
1094 |
|
|
|
1095 |
|
|
WHERE |
1096 |
|
|
page_id = " . $page_id; |
1097 |
|
|
|
1098 |
|
|
$rs = mysql_query($sql, $con); |
1099 |
|
|
$row = mysql_fetch_array ($rs); |
1100 |
|
|
|
1101 |
|
|
$course_id = $row["course_id"]; |
1102 |
|
|
$staff_id_created = $row["staff_id_created"]; |
1103 |
|
|
$staff_id_edited = $row["staff_id_edited"]; |
1104 |
|
|
$coursesub_id = $row["coursesub_id"]; |
1105 |
|
|
$coursesub = $row["coursesub"]; |
1106 |
|
|
$course_num = $row["course_num"]; |
1107 |
|
|
$course_section = $row["course_section"]; |
1108 |
|
|
$course_concat = $row["course_concat"]; |
1109 |
|
|
$term_id = $row["term_id"]; |
1110 |
|
|
$term = $row["term"]; |
1111 |
|
|
$course_year = $row["course_year"]; |
1112 |
|
|
$campus_id = $row["campus_id"]; |
1113 |
|
|
$campus = $row["campus"]; |
1114 |
|
|
$courseheader = $row["courseheader"]; |
1115 |
|
|
$introheader1 = $row["introheader1"]; |
1116 |
|
|
$intromessage1 = $row["intromessage1"]; |
1117 |
|
|
$introheader2 = $row["introheader2"]; |
1118 |
|
|
$intromessage2 = $row["intromessage2"]; |
1119 |
|
|
|
1120 |
|
|
// Course Header |
1121 |
|
|
if (strlen($courseheader) > 1) printf("%s<BR>\n", $courseheader); |
1122 |
|
|
|
1123 |
|
|
// Start the span class |
1124 |
|
|
printf("<span class=\"S2\">"); |
1125 |
|
|
|
1126 |
|
|
// Display concatenated course title |
1127 |
|
|
printf("%s", $course_concat); |
1128 |
|
|
|
1129 |
|
|
// Close the span |
1130 |
|
|
printf("</span><BR><BR>\n"); |
1131 |
|
|
|
1132 |
|
|
// Display course term |
1133 |
|
|
if (strlen($term) > 1 && $term_id > 1) printf("%s", $term); |
1134 |
|
|
|
1135 |
|
|
// Display Comma |
1136 |
|
|
if (strlen($term) > 1 && strlen($course_year) > 1) printf(", "); |
1137 |
|
|
|
1138 |
|
|
// Display course year |
1139 |
|
|
if (strlen($course_year) > 1) printf("%s", $course_year); |
1140 |
|
|
|
1141 |
|
|
printf("<BR>"); |
1142 |
|
|
|
1143 |
|
|
// Campus |
1144 |
|
|
if (strlen($campus) > 0 && $campus_id > 1) printf("%s<BR>\n", $campus); |
1145 |
|
|
|
1146 |
|
|
// Intro header1 |
1147 |
|
|
if (strlen($introheader1) > 0) { |
1148 |
|
|
printf("<center><b>\n"); |
1149 |
|
|
printf("%s", $introheader1); |
1150 |
|
|
printf("</b></center><br>\n"); |
1151 |
|
|
|
1152 |
|
|
} |
1153 |
|
|
|
1154 |
|
|
// Intro Message1 |
1155 |
|
|
if (strlen($intromessage1) > 0) { |
1156 |
|
|
printf("%s", $intromessage1); |
1157 |
|
|
printf("<br>\n"); |
1158 |
|
|
} |
1159 |
|
|
|
1160 |
|
|
// Intro header2 |
1161 |
|
|
if (strlen($introheader2) > 0) { |
1162 |
|
|
printf("<center><b>\n"); |
1163 |
|
|
printf("%s", $introheader2); |
1164 |
|
|
printf("</b></center><br>\n"); |
1165 |
|
|
|
1166 |
|
|
} |
1167 |
|
|
|
1168 |
|
|
// Intro Message2 |
1169 |
|
|
if (strlen($intromessage2) > 0) { |
1170 |
|
|
printf("%s", $intromessage2); |
1171 |
|
|
printf("<br>\n"); |
1172 |
|
|
} |
1173 |
|
|
|
1174 |
|
|
} |
1175 |
|
|
|
1176 |
|
|
|
1177 |
|
|
/********************************************************** |
1178 |
|
|
Function: displayCoursePers |
1179 |
|
|
Author: Paul Bramscher |
1180 |
|
|
Last Modified: 04.22.2003 |
1181 |
|
|
*********************************************************** |
1182 |
|
|
Purpose: |
1183 |
|
|
Displays the personnel associated with the course, by |
1184 |
|
|
looking up the course id based on the page id. |
1185 |
|
|
**********************************************************/ |
1186 |
|
|
function displayCoursePers($con, $page_id) { |
1187 |
|
|
|
1188 |
|
|
// Determine the course id |
1189 |
|
|
$course_id = lookupfield($con, "course", "page_id", $page_id, "course_id"); |
1190 |
|
|
|
1191 |
|
|
// Retrieve current information |
1192 |
|
|
$sql = "SELECT * |
1193 |
|
|
FROM |
1194 |
|
|
course_personnel cp |
1195 |
|
|
LEFT JOIN staff s using (staff_id) |
1196 |
|
|
LEFT JOIN stafftitle st on cp.stafftitle_id = st.stafftitle_id |
1197 |
|
|
LEFT JOIN faculty f on cp.faculty_id = f.faculty_id |
1198 |
|
|
|
1199 |
|
|
WHERE |
1200 |
|
|
course_id = " . $course_id . " ORDER BY personnel_id"; |
1201 |
|
|
|
1202 |
|
|
$rs = mysql_query($sql, $con); |
1203 |
|
|
|
1204 |
|
|
// See how many in this record set |
1205 |
|
|
$num_personnel = mysql_num_rows($rs); |
1206 |
|
|
|
1207 |
|
|
if ($num_personnel > 0) { |
1208 |
|
|
|
1209 |
|
|
// Display course personnel |
1210 |
|
|
printf("<BR>\n"); |
1211 |
|
|
printf("<b>Personnel:</b><br>\n"); |
1212 |
|
|
|
1213 |
|
|
|
1214 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
1215 |
|
|
|
1216 |
|
|
// Initialize |
1217 |
|
|
$last_name = ""; |
1218 |
|
|
$first_name = ""; |
1219 |
|
|
$x500 = ""; |
1220 |
|
|
$email = ""; |
1221 |
|
|
$stafftitle = ""; |
1222 |
|
|
|
1223 |
|
|
// Fetch the general stuff |
1224 |
|
|
$personnel_id = $row["personnel_id"]; |
1225 |
|
|
$staff_id = $row["staff_id"]; |
1226 |
|
|
$faculty_id = $row["faculty_id"]; |
1227 |
|
|
$stafftitle = $row["stafftitle"]; |
1228 |
|
|
$stafftitle_id = $row["stafftitle_id"]; |
1229 |
|
|
|
1230 |
|
|
// Row is staff. (Not 0, NULL, 1=N/A). |
1231 |
|
|
if ($staff_id > 1) { |
1232 |
|
|
|
1233 |
|
|
// Gather the staff table fields |
1234 |
|
|
$last_name = $row["last_name"]; |
1235 |
|
|
$first_name = $row["first_name"]; |
1236 |
|
|
$x500 = $row["staff_account"]; |
1237 |
|
|
$email = $x500 . "@umn.edu"; |
1238 |
|
|
|
1239 |
|
|
} |
1240 |
|
|
|
1241 |
|
|
// Row is faculty (Not 0, NULL, 1=N/A). |
1242 |
|
|
else if ($faculty_id > 1) { |
1243 |
|
|
|
1244 |
|
|
// Gather the faculty table fields |
1245 |
|
|
$last_name = $row["faculty_lastname"]; |
1246 |
|
|
$first_name = $row["faculty_firstname"]; |
1247 |
|
|
$x500 = $row["faculty_account"]; |
1248 |
|
|
$email = $row["faculty_email"]; |
1249 |
|
|
|
1250 |
|
|
} |
1251 |
|
|
|
1252 |
|
|
// Row is "other", use the freetext fields |
1253 |
|
|
else { |
1254 |
|
|
|
1255 |
|
|
// Gather the catch-all fields |
1256 |
|
|
$last_name = $row["pers_lastname"]; |
1257 |
|
|
$first_name = $row["pers_firstname"]; |
1258 |
|
|
$x500 = $row["pers_account"]; |
1259 |
|
|
$email = $row["pers_email"]; |
1260 |
|
|
} |
1261 |
|
|
|
1262 |
|
|
|
1263 |
|
|
// Display the data |
1264 |
|
|
if ($stafftitle_id > 1) printf("%s: ", $stafftitle); |
1265 |
|
|
printf("%s %s <a href=\"mailto:%s\">%s</a><br>\n", |
1266 |
|
|
$first_name, $last_name, $email, $email); |
1267 |
|
|
|
1268 |
|
|
} // all course_personnel rows |
1269 |
|
|
|
1270 |
|
|
} // if there were any persons attached to this course |
1271 |
|
|
|
1272 |
|
|
} |
1273 |
|
|
|
1274 |
|
|
|
1275 |
|
|
/********************************************************** |
1276 |
|
|
Function: displayTOC |
1277 |
|
|
Author: Paul Bramscher |
1278 |
|
|
Last Modified: 12.15.2003 |
1279 |
|
|
*********************************************************** |
1280 |
|
|
Purpose: |
1281 |
|
|
Generates and displays a table of contents (TOC) for the |
1282 |
|
|
supplied page id. This is done dynamically, and uses |
1283 |
|
|
root-level elements on the given page. |
1284 |
|
|
|
1285 |
|
|
This function allows for the optional display of a |
1286 |
|
|
two-column table of contents, split at the midpoint |
1287 |
|
|
(rounded up for odd numbers of root elements). |
1288 |
|
|
**********************************************************/ |
1289 |
|
|
function displayTOC($con, $page_id, $wrap_toc) { |
1290 |
|
|
|
1291 |
|
|
// Calculate number of elements |
1292 |
|
|
$sql = "SELECT COUNT(*) as num_elements FROM element WHERE indent_level < 1 AND page_id = " |
1293 |
|
|
. $page_id; |
1294 |
|
|
$rs = mysql_query($sql, $con); |
1295 |
|
|
$row = mysql_fetch_array ($rs); |
1296 |
|
|
$num_elements = $row["num_elements"]; |
1297 |
|
|
|
1298 |
|
|
// Calculate midpoint element |
1299 |
|
|
if ($num_elements > 0) $midpoint = ceil($num_elements / 2); |
1300 |
|
|
else $midpoint = 0; |
1301 |
|
|
|
1302 |
|
|
if ($num_elements > 0) { |
1303 |
|
|
|
1304 |
|
|
// Retrieve all elements on that page |
1305 |
|
|
$sql = "SELECT |
1306 |
|
|
e.element_id, |
1307 |
|
|
e.label, |
1308 |
|
|
r.resource_id, |
1309 |
|
|
r.title, |
1310 |
|
|
l.location_id, |
1311 |
|
|
l.location, |
1312 |
|
|
v.service_id, |
1313 |
|
|
v.service, |
1314 |
|
|
s.staff_id, |
1315 |
|
|
s.last_name, |
1316 |
|
|
s.first_name, |
1317 |
|
|
b.subject_id, |
1318 |
|
|
b.subject |
1319 |
|
|
|
1320 |
|
|
FROM |
1321 |
|
|
page p |
1322 |
|
|
LEFT JOIN element e using (page_id) |
1323 |
|
|
LEFT JOIN resource r on e.resource_id = r.resource_id |
1324 |
|
|
LEFT JOIN location l on e.location_id = l.location_id |
1325 |
|
|
LEFT JOIN service v on e.service_id = v.service_id |
1326 |
|
|
LEFT JOIN staff s on e.staff_id = s.staff_id |
1327 |
|
|
LEFT JOIN subject b on e.subject_id = b.subject_id |
1328 |
|
|
|
1329 |
|
|
WHERE |
1330 |
|
|
p.page_id = " |
1331 |
|
|
. $page_id |
1332 |
|
|
. " AND e.indent_level < 1 ORDER BY e.element_order"; |
1333 |
|
|
|
1334 |
|
|
$rs = mysql_query($sql, $con); |
1335 |
|
|
|
1336 |
|
|
// Build a general ToC anchor |
1337 |
|
|
printf("<a name=\"toc\"></a>\n"); |
1338 |
|
|
printf("<b>Table of Contents:</b><br>\n"); |
1339 |
|
|
printf("<table>\n"); |
1340 |
|
|
|
1341 |
|
|
// Build the (single) row |
1342 |
|
|
printf("<tr>\n"); |
1343 |
|
|
|
1344 |
|
|
// Populate the left cell |
1345 |
|
|
printf("<td valign=\"top\"><ul>\n"); |
1346 |
|
|
|
1347 |
|
|
$row_num = 0; |
1348 |
|
|
|
1349 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
1350 |
|
|
|
1351 |
|
|
// Check for the midpoint |
1352 |
|
|
if ($wrap_toc == 1) |
1353 |
|
|
if ($row_num == $midpoint) { |
1354 |
|
|
|
1355 |
|
|
// Close the ul tag & table cell |
1356 |
|
|
printf("</ul>\n"); |
1357 |
|
|
printf("</td>\n"); |
1358 |
|
|
|
1359 |
|
|
// Start a new one |
1360 |
|
|
printf("<td valign=\"top\">\n"); |
1361 |
|
|
printf("<ul>\n"); |
1362 |
|
|
|
1363 |
|
|
} |
1364 |
|
|
|
1365 |
|
|
// General |
1366 |
|
|
$element_id = $row["element_id"]; |
1367 |
|
|
|
1368 |
|
|
// Resource |
1369 |
|
|
$resource_id = $row["resource_id"]; |
1370 |
|
|
$title = $row["title"]; |
1371 |
|
|
|
1372 |
|
|
// Label/unique |
1373 |
|
|
$label = $row["label"]; |
1374 |
|
|
|
1375 |
|
|
// Location |
1376 |
|
|
$location_id = $row["location_id"]; |
1377 |
|
|
$location = $row["location"]; |
1378 |
|
|
|
1379 |
|
|
// Service |
1380 |
|
|
$service_id = $row["service_id"]; |
1381 |
|
|
$service = $row["service"]; |
1382 |
|
|
|
1383 |
|
|
// Staff |
1384 |
|
|
$staff_id = $row["staff_id"]; |
1385 |
|
|
$last_name = $row["last_name"]; |
1386 |
|
|
$first_name = $row["first_name"]; |
1387 |
|
|
|
1388 |
|
|
// Subject |
1389 |
|
|
$subject_id = $row["subject_id"]; |
1390 |
|
|
$subject = $row["subject"]; |
1391 |
|
|
|
1392 |
|
|
// Determine what sort of element it is |
1393 |
|
|
$toc_label = ""; |
1394 |
|
|
if ($resource_id > 0) $toc_label = $title; |
1395 |
|
|
else if (strlen($label) > 0) $toc_label = $label; |
1396 |
|
|
else if ($location_id > 0) $toc_label = $location; |
1397 |
|
|
else if ($service_id > 0) $toc_label = $service; |
1398 |
|
|
else if ($staff_id > 0) $toc_label = $first_name . " " . $last_name; |
1399 |
|
|
else if ($subject_id > 0) $toc_label = $subject; |
1400 |
|
|
|
1401 |
|
|
// Last-minute error check |
1402 |
|
|
if (strlen($toc_label) > 0) printf("<li><a href=\"#toc%d\">%s</a></li>\n", $element_id, $toc_label); |
1403 |
|
|
|
1404 |
|
|
$row_num++; |
1405 |
|
|
|
1406 |
|
|
} // end elements |
1407 |
|
|
|
1408 |
|
|
// Close things |
1409 |
|
|
printf("</ul>\n"); |
1410 |
|
|
printf("</td></tr></table><br>\n"); |
1411 |
|
|
|
1412 |
|
|
|
1413 |
|
|
} // at least one item on this page |
1414 |
|
|
} |
1415 |
|
|
|
1416 |
|
|
|
1417 |
|
|
/********************************************************** |
1418 |
|
|
Function: elementDecrease |
1419 |
|
|
Author: Paul Bramscher |
1420 |
|
|
Last Modified: 10.29.2002 |
1421 |
|
|
*********************************************************** |
1422 |
|
|
Incoming: |
1423 |
|
|
$con Database connection string |
1424 |
|
|
$element_id Element to perform decrease on |
1425 |
|
|
$page_id Page the element is location on |
1426 |
|
|
$position Position on the page |
1427 |
|
|
*********************************************************** |
1428 |
|
|
Outgoing: |
1429 |
|
|
None |
1430 |
|
|
*********************************************************** |
1431 |
|
|
Purpose: |
1432 |
|
|
Decreases the output size of the element. Note that the |
1433 |
|
|
HTML <H> tag operates in reverse, with H1 typically being |
1434 |
|
|
larger than H5. So this increase effectively increases the |
1435 |
|
|
numerical value of the tag. |
1436 |
|
|
|
1437 |
|
|
If the user shrinks below 5, set it equal to zero, which |
1438 |
|
|
means that the <H> tag will be unused by the system. |
1439 |
|
|
|
1440 |
|
|
NOTE: This has been deprecated with the elementSize() |
1441 |
|
|
function. It is not currently being used. |
1442 |
|
|
**********************************************************/ |
1443 |
|
|
function elementDecrease($con, $element_id, $page_id, $position){ |
1444 |
|
|
|
1445 |
|
|
// Get current element size |
1446 |
|
|
$sql = "SELECT element_size FROM element WHERE element_id = " |
1447 |
|
|
. $element_id |
1448 |
|
|
. " AND page_id = " |
1449 |
|
|
. $page_id; |
1450 |
|
|
$rs = mysql_query($sql, $con); |
1451 |
|
|
$row = mysql_fetch_array ($rs); |
1452 |
|
|
$element_size = $row["element_size"]; |
1453 |
|
|
|
1454 |
|
|
// Default to <H5> if nothing specified |
1455 |
|
|
if ($element_size < 1) $element_size = 5; |
1456 |
|
|
|
1457 |
|
|
// Original was less than 5. Note that we don't shrink smaller than 5. |
1458 |
|
|
else if ($element_size < 5) $element_size++; |
1459 |
|
|
|
1460 |
|
|
// Else get rid of the size value altogether |
1461 |
|
|
else if ($element_size == 5) $element_size = 0; |
1462 |
|
|
|
1463 |
|
|
$sql = "UPDATE element SET element_size = " |
1464 |
|
|
. $element_size |
1465 |
|
|
. " WHERE page_id = " |
1466 |
|
|
. $page_id |
1467 |
|
|
. " AND element_id = " |
1468 |
|
|
. $element_id; |
1469 |
|
|
|
1470 |
|
|
if (!mysql_query ($sql, $con)){ |
1471 |
|
|
sql_err($sql); |
1472 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1473 |
|
|
bailout(); |
1474 |
|
|
} |
1475 |
|
|
else { // Success call the page back |
1476 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1477 |
|
|
|
1478 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
1479 |
|
|
} |
1480 |
|
|
|
1481 |
|
|
} |
1482 |
|
|
|
1483 |
|
|
|
1484 |
|
|
/********************************************************** |
1485 |
|
|
Function: elementDown |
1486 |
|
|
Author: Paul Bramscher |
1487 |
|
|
Last Modified: 09.24.2002 |
1488 |
|
|
*********************************************************** |
1489 |
|
|
Incoming: |
1490 |
|
|
$con Database connection string |
1491 |
|
|
$element_id Element to move down |
1492 |
|
|
$page_id Page the element is location on |
1493 |
|
|
$position Position on the page |
1494 |
|
|
*********************************************************** |
1495 |
|
|
Outgoing: |
1496 |
|
|
None |
1497 |
|
|
*********************************************************** |
1498 |
|
|
Purpose: |
1499 |
|
|
Moves a selected element (and any descendants) down to the |
1500 |
|
|
position of the next youngest sibling. The sibling (and |
1501 |
|
|
any of its descendants are moved up). The main challenge in |
1502 |
|
|
the algorithm is the final shuffling phase since it's not |
1503 |
|
|
possible move affected elements down, and then move the |
1504 |
|
|
other affected elements up -- since they are selected by |
1505 |
|
|
their order and duplicate positions will be created this |
1506 |
|
|
way. Therefore, they are moved and written individually |
1507 |
|
|
within the same recordset. One alternative would be to |
1508 |
|
|
assign the "down set" temporary orders, over the current |
1509 |
|
|
maximum, move the "up set" up, then re-assign the "down set" |
1510 |
|
|
to its position. With the next iteration, perhaps... |
1511 |
|
|
**********************************************************/ |
1512 |
|
|
|
1513 |
|
|
function elementDown($con, $element_id, $page_id, $position) { |
1514 |
|
|
|
1515 |
|
|
// Get information about the element to move down |
1516 |
|
|
$sql = "SELECT indent_level, parent_id, element_order FROM element WHERE page_id = " |
1517 |
|
|
. $page_id |
1518 |
|
|
. " AND element_id = " |
1519 |
|
|
. $element_id; |
1520 |
|
|
$rs = mysql_query($sql, $con); |
1521 |
|
|
$row = mysql_fetch_array ($rs); |
1522 |
|
|
$down_indent_level = $row["indent_level"]; |
1523 |
|
|
$down_element_order = $row["element_order"]; |
1524 |
|
|
|
1525 |
|
|
// Identify information about the element to move up |
1526 |
|
|
$sql = "SELECT element_id, element_order, indent_level FROM element WHERE page_id = " |
1527 |
|
|
. $page_id |
1528 |
|
|
. " AND indent_level = " |
1529 |
|
|
. $down_indent_level |
1530 |
|
|
. " AND element_order > " |
1531 |
|
|
. $down_element_order |
1532 |
|
|
. " ORDER BY element_order"; |
1533 |
|
|
|
1534 |
|
|
$rs = mysql_query($sql, $con); |
1535 |
|
|
$row = mysql_fetch_array ($rs); |
1536 |
|
|
$up_element_id = $row["element_id"]; |
1537 |
|
|
$up_element_order = $row["element_order"]; |
1538 |
|
|
|
1539 |
|
|
/* |
1540 |
|
|
Determine number of affected children to move down. Note that we count the |
1541 |
|
|
number of elements from the starting position with an indent level of greater |
1542 |
|
|
than the starting indent level (they are descendents) up to the position of the |
1543 |
|
|
first younger sibling. Then we add the element itself. |
1544 |
|
|
*/ |
1545 |
|
|
|
1546 |
|
|
$sql = "SELECT COUNT(*) as down_num FROM element WHERE page_id = " |
1547 |
|
|
. $page_id |
1548 |
|
|
. " AND element_order > " |
1549 |
|
|
. $down_element_order |
1550 |
|
|
. " AND indent_level > " |
1551 |
|
|
. $down_indent_level |
1552 |
|
|
. " AND element_order < " |
1553 |
|
|
. $up_element_order; |
1554 |
|
|
|
1555 |
|
|
$rs = mysql_query($sql, $con); |
1556 |
|
|
$row = mysql_fetch_array ($rs); |
1557 |
|
|
$down_num = $row["down_num"]; |
1558 |
|
|
|
1559 |
|
|
// Add the element itself |
1560 |
|
|
$down_num++; |
1561 |
|
|
|
1562 |
|
|
/* |
1563 |
|
|
Determine number of elements which will be moved up. Note that we need to |
1564 |
|
|
probe until we hit the next sibling or older generation element. |
1565 |
|
|
*/ |
1566 |
|
|
|
1567 |
|
|
$sql = "SELECT element_id, indent_level, element_order FROM element WHERE page_id = " |
1568 |
|
|
. $page_id |
1569 |
|
|
. " AND element_order > " |
1570 |
|
|
. $up_element_order |
1571 |
|
|
. " ORDER BY element_order"; |
1572 |
|
|
|
1573 |
|
|
$rs = mysql_query($sql, $con); |
1574 |
|
|
|
1575 |
|
|
// Flag to determine the end of this element's lineage |
1576 |
|
|
$lineage = 1; |
1577 |
|
|
|
1578 |
|
|
/* |
1579 |
|
|
Initialize the last affected element to be the next sibling. It may be overwritten |
1580 |
|
|
the sibling's last descendant (if any). |
1581 |
|
|
*/ |
1582 |
|
|
|
1583 |
|
|
$stop_element_order = $up_element_order; |
1584 |
|
|
$stop_element_id = $up_element_id; |
1585 |
|
|
|
1586 |
|
|
// Number of descendants |
1587 |
|
|
$up_num = 0; |
1588 |
|
|
|
1589 |
|
|
/* |
1590 |
|
|
March through the list looking for all descendants. Take note of the last |
1591 |
|
|
descendant affected by a move. |
1592 |
|
|
*/ |
1593 |
|
|
|
1594 |
|
|
while (($row = mysql_fetch_array ($rs)) && $lineage == 1) { |
1595 |
|
|
$desc_element_id = $row["element_id"]; |
1596 |
|
|
$desc_indent_level = $row["indent_level"]; |
1597 |
|
|
$desc_element_order = $row["element_order"]; |
1598 |
|
|
|
1599 |
|
|
if ($desc_indent_level > $down_indent_level) { |
1600 |
|
|
$up_num++; |
1601 |
|
|
$stop_element_id = $desc_element_id; |
1602 |
|
|
$stop_element_order = $desc_element_order; |
1603 |
|
|
} |
1604 |
|
|
else { |
1605 |
|
|
$lineage = 0; |
1606 |
|
|
} |
1607 |
|
|
} |
1608 |
|
|
|
1609 |
|
|
// Add the younger sibling itself |
1610 |
|
|
$up_num++; |
1611 |
|
|
|
1612 |
|
|
// Flag to determine whether to move down (1) or up (0) |
1613 |
|
|
$move_down = 1; |
1614 |
|
|
|
1615 |
|
|
// Begin the update process. Create a recordset of all affected elements. |
1616 |
|
|
$sql = "SELECT element_id, indent_level, element_order FROM element WHERE page_id = " |
1617 |
|
|
. $page_id |
1618 |
|
|
. " AND element_order >= " |
1619 |
|
|
. $down_element_order |
1620 |
|
|
. " AND element_order <= " |
1621 |
|
|
. $stop_element_order |
1622 |
|
|
. " ORDER BY element_order"; |
1623 |
|
|
$rs = mysql_query($sql, $con); |
1624 |
|
|
|
1625 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
1626 |
|
|
$mod_element_id = $row["element_id"]; |
1627 |
|
|
$mod_indent_level = $row["indent_level"]; |
1628 |
|
|
$mod_element_order = $row["element_order"]; |
1629 |
|
|
|
1630 |
|
|
/* |
1631 |
|
|
When we've moved the selected elements down, we switch operations and move |
1632 |
|
|
the others up. |
1633 |
|
|
*/ |
1634 |
|
|
|
1635 |
|
|
if ($mod_element_id == $up_element_id) $move_down = 0; |
1636 |
|
|
|
1637 |
|
|
if ($move_down == 1) { |
1638 |
|
|
$new_order = $mod_element_order + $up_num; |
1639 |
|
|
//printf("move element %d down %d spaces -- %d<BR>", $mod_element_id, $up_num, $new_order); |
1640 |
|
|
} |
1641 |
|
|
else { |
1642 |
|
|
$new_order = $mod_element_order - $down_num; |
1643 |
|
|
//printf("move element %d up %d spaces -- %d<BR>", $mod_element_id, $down_num, $new_order); |
1644 |
|
|
} |
1645 |
|
|
|
1646 |
|
|
$mod_sql = "UPDATE element SET element_order = " |
1647 |
|
|
. $new_order |
1648 |
|
|
. " WHERE page_id = " |
1649 |
|
|
. $page_id |
1650 |
|
|
. " AND element_id = " |
1651 |
|
|
. $mod_element_id; |
1652 |
|
|
if (!mysql_query ($mod_sql, $con)){ |
1653 |
|
|
sql_err($sql); |
1654 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1655 |
|
|
bailout(); |
1656 |
|
|
} |
1657 |
|
|
else { // Success |
1658 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1659 |
|
|
} // moved an element up or down |
1660 |
|
|
|
1661 |
|
|
} // all affected elements |
1662 |
|
|
|
1663 |
|
|
/* |
1664 |
|
|
Note: This part is somewhat a kludge. It typically comes out close, |
1665 |
|
|
but not exact due to the latest scribe engine. Should do some more |
1666 |
|
|
refinement here. |
1667 |
|
|
|
1668 |
|
|
Position is calculated by N + 2(N - 1) where N = element position. |
1669 |
|
|
We also need to add (3X - 1) of the downset, where X is the number of |
1670 |
|
|
children moved up. |
1671 |
|
|
*/ |
1672 |
|
|
|
1673 |
|
|
// Position is calculated by N + 2(N - 1) where N = element position. |
1674 |
|
|
// We also need to add the number of elements Z * 3. |
1675 |
|
|
$position = $position + (3 * $up_num); |
1676 |
|
|
|
1677 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
1678 |
|
|
|
1679 |
|
|
} |
1680 |
|
|
|
1681 |
|
|
|
1682 |
|
|
/********************************************************** |
1683 |
|
|
Function: elementIncrease |
1684 |
|
|
Author: Paul Bramscher |
1685 |
|
|
Last Modified: 09.12.2002 |
1686 |
|
|
*********************************************************** |
1687 |
|
|
Incoming: |
1688 |
|
|
$con Database connection string |
1689 |
|
|
$element_id Element to perform decrease on |
1690 |
|
|
$page_id Page the element is location on |
1691 |
|
|
$position Position on the page |
1692 |
|
|
*********************************************************** |
1693 |
|
|
Outgoing: |
1694 |
|
|
None |
1695 |
|
|
*********************************************************** |
1696 |
|
|
Purpose: |
1697 |
|
|
Increases the output size of the element. Note that the |
1698 |
|
|
HTML <H> tag operates in reverse, with H1 typically being |
1699 |
|
|
larger than H5. So this increase effectively decreases the |
1700 |
|
|
numerical value of the tag. |
1701 |
|
|
|
1702 |
|
|
NOTE: This has been deprecated with the elementSize() |
1703 |
|
|
function. It is not currently being used. |
1704 |
|
|
**********************************************************/ |
1705 |
|
|
function elementIncrease($con, $element_id, $page_id, $position){ |
1706 |
|
|
|
1707 |
|
|
// Get current element size |
1708 |
|
|
$sql = "SELECT element_size FROM element WHERE element_id = " |
1709 |
|
|
. $element_id |
1710 |
|
|
. " AND page_id = " |
1711 |
|
|
. $page_id; |
1712 |
|
|
$rs = mysql_query($sql, $con); |
1713 |
|
|
$row = mysql_fetch_array ($rs); |
1714 |
|
|
$element_size = $row["element_size"]; |
1715 |
|
|
|
1716 |
|
|
// Default to <H5> if nothing specified |
1717 |
|
|
if ($element_size < 1) $element_size = 5; |
1718 |
|
|
|
1719 |
|
|
// Original was larger than 1. Note that we don't shrink smaller than 1. |
1720 |
|
|
else if ($element_size > 1) $element_size--; |
1721 |
|
|
|
1722 |
|
|
$sql = "UPDATE element SET element_size = " |
1723 |
|
|
. $element_size |
1724 |
|
|
. " WHERE page_id = " |
1725 |
|
|
. $page_id |
1726 |
|
|
. " AND element_id = " |
1727 |
|
|
. $element_id; |
1728 |
|
|
|
1729 |
|
|
if (!mysql_query ($sql, $con)){ |
1730 |
|
|
sql_err($sql); |
1731 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1732 |
|
|
bailout(); |
1733 |
|
|
} |
1734 |
|
|
else { // Success call the page back |
1735 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1736 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
1737 |
|
|
} |
1738 |
|
|
|
1739 |
|
|
} |
1740 |
|
|
|
1741 |
|
|
|
1742 |
|
|
/********************************************************** |
1743 |
|
|
Function: elementMultiFormat |
1744 |
|
|
Author: Paul Bramscher |
1745 |
|
|
Last Modified: 06.25.2003 |
1746 |
|
|
*********************************************************** |
1747 |
|
|
Incoming: |
1748 |
|
|
$con Database connection string |
1749 |
|
|
$auto_font_style Corresponds to 0-5 CSS style styles |
1750 |
|
|
$auto_indent_level Indent level upon which to apply |
1751 |
|
|
the changes. |
1752 |
|
|
$page_id Affected CourseLib/PageScribe page |
1753 |
|
|
*********************************************************** |
1754 |
|
|
Outgoing: |
1755 |
|
|
None |
1756 |
|
|
*********************************************************** |
1757 |
|
|
Purpose: |
1758 |
|
|
Performs a sweep-style format, changing all elements at a |
1759 |
|
|
particular indent level to the selected size on the |
1760 |
|
|
supplied page id. |
1761 |
|
|
**********************************************************/ |
1762 |
|
|
function elementMultiFormat($con, $auto_element_size, $auto_indent_level, $page_id){ |
1763 |
|
|
|
1764 |
|
|
// Build the SQL |
1765 |
|
|
$sql = "UPDATE element SET element_size = " |
1766 |
|
|
. $auto_element_size |
1767 |
|
|
. " WHERE page_id = " |
1768 |
|
|
. $page_id |
1769 |
|
|
. " AND indent_level = " |
1770 |
|
|
. $auto_indent_level; |
1771 |
|
|
|
1772 |
|
|
if (!mysql_query ($sql, $con)){ |
1773 |
|
|
sql_err($sql); |
1774 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1775 |
|
|
bailout(); |
1776 |
|
|
} |
1777 |
|
|
else { // Success call the page back |
1778 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1779 |
|
|
|
1780 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
1781 |
|
|
} |
1782 |
|
|
|
1783 |
|
|
} |
1784 |
|
|
|
1785 |
|
|
|
1786 |
|
|
/********************************************************** |
1787 |
|
|
Function: elementSize |
1788 |
|
|
Author: Paul Bramscher |
1789 |
|
|
Last Modified: 02.18.2003 |
1790 |
|
|
*********************************************************** |
1791 |
|
|
Incoming: |
1792 |
|
|
$con Database connection string |
1793 |
|
|
$element_id Element to perform decrease on |
1794 |
|
|
$page_id Page the element is location on |
1795 |
|
|
$position Position on the page |
1796 |
|
|
$size Value 1-5 of the element size to |
1797 |
|
|
utilize. |
1798 |
|
|
*********************************************************** |
1799 |
|
|
Outgoing: |
1800 |
|
|
None |
1801 |
|
|
*********************************************************** |
1802 |
|
|
Purpose: |
1803 |
|
|
Changes the size code for the specified element. Values |
1804 |
|
|
less than 1 are treated as 0, greater than 5 is treated as |
1805 |
|
|
5. This function is meant to deprecate the elementIncrease() |
1806 |
|
|
and elementDecrease() pair of functions. |
1807 |
|
|
**********************************************************/ |
1808 |
|
|
function elementSize($con, $element_id, $page_id, $position, $size){ |
1809 |
|
|
|
1810 |
|
|
// Error trap |
1811 |
|
|
if ($size < 1) $size = 0; |
1812 |
|
|
if ($size > 5) $size = 5; |
1813 |
|
|
|
1814 |
|
|
$sql = "UPDATE element SET element_size = " |
1815 |
|
|
. $size |
1816 |
|
|
. " WHERE page_id = " |
1817 |
|
|
. $page_id |
1818 |
|
|
. " AND element_id = " |
1819 |
|
|
. $element_id; |
1820 |
|
|
|
1821 |
|
|
if (!mysql_query ($sql, $con)){ |
1822 |
|
|
sql_err($sql); |
1823 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1824 |
|
|
bailout(); |
1825 |
|
|
} |
1826 |
|
|
else { // Success call the page back |
1827 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1828 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
1829 |
|
|
} |
1830 |
|
|
|
1831 |
|
|
} |
1832 |
|
|
|
1833 |
|
|
|
1834 |
|
|
/********************************************************** |
1835 |
|
|
Function: elementUp |
1836 |
|
|
Author: Paul Bramscher |
1837 |
|
|
Last Modified: 09.24.2002 |
1838 |
|
|
*********************************************************** |
1839 |
|
|
Incoming: |
1840 |
|
|
$con Database connection string |
1841 |
|
|
$element_id Element to move up |
1842 |
|
|
$page_id Page the element is location on |
1843 |
|
|
$position Position on the page |
1844 |
|
|
*********************************************************** |
1845 |
|
|
Outgoing: |
1846 |
|
|
None |
1847 |
|
|
*********************************************************** |
1848 |
|
|
Purpose: |
1849 |
|
|
Similar to elementDown, but differs since the user-selected |
1850 |
|
|
element is the "up set" rather than the "down set". See |
1851 |
|
|
comments under elementDown for further information. |
1852 |
|
|
**********************************************************/ |
1853 |
|
|
function elementUp($con, $element_id, $page_id, $position) { |
1854 |
|
|
|
1855 |
|
|
// Get information about the element to move up |
1856 |
|
|
$sql = "SELECT indent_level, parent_id, element_order FROM element WHERE page_id = " |
1857 |
|
|
. $page_id |
1858 |
|
|
. " AND element_id = " |
1859 |
|
|
. $element_id; |
1860 |
|
|
$rs = mysql_query($sql, $con); |
1861 |
|
|
$row = mysql_fetch_array ($rs); |
1862 |
|
|
$up_indent_level = $row["indent_level"]; |
1863 |
|
|
$up_element_order = $row["element_order"]; |
1864 |
|
|
|
1865 |
|
|
// Identify information about the element which will move down |
1866 |
|
|
$sql = "SELECT element_id, element_order, indent_level FROM element WHERE page_id = " |
1867 |
|
|
. $page_id |
1868 |
|
|
. " AND indent_level = " |
1869 |
|
|
. $up_indent_level |
1870 |
|
|
. " AND element_order < " |
1871 |
|
|
. $up_element_order |
1872 |
|
|
. " ORDER BY element_order DESC"; |
1873 |
|
|
|
1874 |
|
|
$rs = mysql_query($sql, $con); |
1875 |
|
|
$row = mysql_fetch_array ($rs); |
1876 |
|
|
$down_element_id = $row["element_id"]; |
1877 |
|
|
$down_element_order = $row["element_order"]; |
1878 |
|
|
|
1879 |
|
|
/* |
1880 |
|
|
Determine number of affected children to move down. Note that we count the |
1881 |
|
|
number of elements from the starting position with an indent level of greater |
1882 |
|
|
than the starting indent level (they are descendents) up to the position of the |
1883 |
|
|
first younger sibling. Then we add the element itself. |
1884 |
|
|
*/ |
1885 |
|
|
|
1886 |
|
|
$sql = "SELECT COUNT(*) as down_num FROM element WHERE page_id = " |
1887 |
|
|
. $page_id |
1888 |
|
|
. " AND element_order > " |
1889 |
|
|
. $down_element_order |
1890 |
|
|
. " AND indent_level > " |
1891 |
|
|
. $up_indent_level |
1892 |
|
|
. " AND element_order < " |
1893 |
|
|
. $up_element_order; |
1894 |
|
|
|
1895 |
|
|
$rs = mysql_query($sql, $con); |
1896 |
|
|
$row = mysql_fetch_array ($rs); |
1897 |
|
|
$down_num = $row["down_num"]; |
1898 |
|
|
|
1899 |
|
|
// Add the element itself |
1900 |
|
|
$down_num++; |
1901 |
|
|
|
1902 |
|
|
/* |
1903 |
|
|
Determine number of elements which will be moved up. Note that we need to |
1904 |
|
|
probe until we hit the next sibling or older generation element. |
1905 |
|
|
*/ |
1906 |
|
|
|
1907 |
|
|
$sql = "SELECT element_id, indent_level, element_order FROM element WHERE page_id = " |
1908 |
|
|
. $page_id |
1909 |
|
|
. " AND element_order > " |
1910 |
|
|
. $up_element_order |
1911 |
|
|
. " ORDER BY element_order"; |
1912 |
|
|
|
1913 |
|
|
$rs = mysql_query($sql, $con); |
1914 |
|
|
|
1915 |
|
|
// Flag to determine the end of this element's lineage |
1916 |
|
|
$lineage = 1; |
1917 |
|
|
|
1918 |
|
|
/* |
1919 |
|
|
Initialize the last affected element to be the next sibling. It may be overwritten |
1920 |
|
|
the sibling's last descendant (if any). |
1921 |
|
|
*/ |
1922 |
|
|
|
1923 |
|
|
$stop_element_order = $up_element_order; |
1924 |
|
|
$stop_element_id = $up_element_id; |
1925 |
|
|
|
1926 |
|
|
// Number of descendants |
1927 |
|
|
$up_num = 0; |
1928 |
|
|
|
1929 |
|
|
/* |
1930 |
|
|
March through the list looking for all descendants. Take note of the last |
1931 |
|
|
descendant affected by a move. |
1932 |
|
|
*/ |
1933 |
|
|
|
1934 |
|
|
while (($row = mysql_fetch_array ($rs)) && $lineage == 1) { |
1935 |
|
|
$desc_element_id = $row["element_id"]; |
1936 |
|
|
$desc_indent_level = $row["indent_level"]; |
1937 |
|
|
$desc_element_order = $row["element_order"]; |
1938 |
|
|
|
1939 |
|
|
if ($desc_indent_level > $up_indent_level) { |
1940 |
|
|
$up_num++; |
1941 |
|
|
$stop_element_id = $desc_element_id; |
1942 |
|
|
$stop_element_order = $desc_element_order; |
1943 |
|
|
} |
1944 |
|
|
else { |
1945 |
|
|
$lineage = 0; |
1946 |
|
|
} |
1947 |
|
|
} |
1948 |
|
|
|
1949 |
|
|
// Add the younger sibling itself |
1950 |
|
|
$up_num++; |
1951 |
|
|
|
1952 |
|
|
// Flag to determine whether to move down (1) or up (0) |
1953 |
|
|
$move_down = 1; |
1954 |
|
|
|
1955 |
|
|
// Begin the update process. Create a recordset of all affected elements. |
1956 |
|
|
$sql = "SELECT element_id, indent_level, element_order FROM element WHERE page_id = " |
1957 |
|
|
. $page_id |
1958 |
|
|
. " AND element_order >= " |
1959 |
|
|
. $down_element_order |
1960 |
|
|
. " AND element_order <= " |
1961 |
|
|
. $stop_element_order |
1962 |
|
|
. " ORDER BY element_order"; |
1963 |
|
|
$rs = mysql_query($sql, $con); |
1964 |
|
|
|
1965 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
1966 |
|
|
$mod_element_id = $row["element_id"]; |
1967 |
|
|
$mod_indent_level = $row["indent_level"]; |
1968 |
|
|
$mod_element_order = $row["element_order"]; |
1969 |
|
|
|
1970 |
|
|
/* |
1971 |
|
|
When we've moved the selected elements down, we switch operations and move |
1972 |
|
|
the others up. |
1973 |
|
|
*/ |
1974 |
|
|
|
1975 |
|
|
if ($mod_element_id == $element_id) $move_down = 0; |
1976 |
|
|
|
1977 |
|
|
if ($move_down == 1) { |
1978 |
|
|
$new_order = $mod_element_order + $up_num; |
1979 |
|
|
//printf("move element %d down %d spaces -- %d<BR>", $mod_element_id, $up_num, $new_order); |
1980 |
|
|
} |
1981 |
|
|
else { |
1982 |
|
|
$new_order = $mod_element_order - $down_num; |
1983 |
|
|
//printf("move element %d up %d spaces -- %d<BR>", $mod_element_id, $down_num, $new_order); |
1984 |
|
|
} |
1985 |
|
|
|
1986 |
|
|
$mod_sql = "UPDATE element SET element_order = " |
1987 |
|
|
. $new_order |
1988 |
|
|
. " WHERE page_id = " |
1989 |
|
|
. $page_id |
1990 |
|
|
. " AND element_id = " |
1991 |
|
|
. $mod_element_id; |
1992 |
|
|
|
1993 |
|
|
if (!mysql_query ($mod_sql, $con)){ |
1994 |
|
|
sql_err($sql); |
1995 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1996 |
|
|
bailout(); |
1997 |
|
|
} |
1998 |
|
|
else { // Success |
1999 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2000 |
|
|
} // moved an element up or down |
2001 |
|
|
|
2002 |
|
|
|
2003 |
|
|
} // all affected elements |
2004 |
|
|
|
2005 |
|
|
// Position is calculated by N + 2(N - 1) where N = element position. |
2006 |
|
|
$position = $down_element_order + (2 * $down_element_order - 1); |
2007 |
|
|
|
2008 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
2009 |
|
|
|
2010 |
|
|
} |
2011 |
|
|
|
2012 |
|
|
|
2013 |
|
|
/********************************************************** |
2014 |
|
|
Function: getMaxIndent |
2015 |
|
|
Author: Paul Bramscher |
2016 |
|
|
Last Modified: 06.25.2003 |
2017 |
|
|
*********************************************************** |
2018 |
|
|
Purpose: |
2019 |
|
|
Return the maximum indent level for the supplied page id. |
2020 |
|
|
**********************************************************/ |
2021 |
|
|
function getMaxIndent($con, $page_id){ |
2022 |
|
|
|
2023 |
|
|
// Initialize |
2024 |
|
|
$max_indent = 0; |
2025 |
|
|
|
2026 |
|
|
// Build the query |
2027 |
|
|
$sql = "SELECT MAX(indent_level) AS max_indent FROM element WHERE page_id = " |
2028 |
|
|
. $page_id; |
2029 |
|
|
|
2030 |
|
|
$rs = mysql_query($sql, $con); |
2031 |
|
|
$row = mysql_fetch_array ($rs); |
2032 |
|
|
$max_indent = $row["max_indent"]; |
2033 |
|
|
|
2034 |
|
|
return $max_indent; |
2035 |
|
|
} |
2036 |
|
|
|
2037 |
|
|
|
2038 |
|
|
/********************************************************** |
2039 |
|
|
Function: insertCoursePers |
2040 |
|
|
Author: Paul Bramscher |
2041 |
|
|
Last Modified: 06.24.2003 |
2042 |
|
|
*********************************************************** |
2043 |
|
|
Purpose: |
2044 |
|
|
Associates the incoming personnel information with the |
2045 |
|
|
supplied course id. Note that the incoming may be one of |
2046 |
|
|
three types of personnel: a library staff person, a faculty |
2047 |
|
|
member (existing or newly created on the fly), or a |
2048 |
|
|
non-indexed TA. |
2049 |
|
|
**********************************************************/ |
2050 |
|
|
function insertCoursePers($con, $course_id, $faculty_id, |
2051 |
|
|
$page_id, $pers_email, $pers_firstname, $pers_lastname, |
2052 |
|
|
$pers_type, $pers_account, $staff_id, $stafftitle_id){ |
2053 |
|
|
|
2054 |
|
|
// Error flag |
2055 |
|
|
$err_code = 0; |
2056 |
|
|
|
2057 |
|
|
// Incoming was library staff |
2058 |
|
|
if ($staff_id > 1) { |
2059 |
|
|
$sql = "INSERT INTO course_personnel (course_id, stafftitle_id, staff_id) VALUES (" |
2060 |
|
|
. $course_id |
2061 |
|
|
. ", " |
2062 |
|
|
. $stafftitle_id |
2063 |
|
|
. ", " |
2064 |
|
|
. $staff_id |
2065 |
|
|
. ")"; |
2066 |
|
|
|
2067 |
|
|
} |
2068 |
|
|
|
2069 |
|
|
// Incoming was faculty |
2070 |
|
|
else if ($faculty_id > 1) { |
2071 |
|
|
$sql = "INSERT INTO course_personnel (course_id, stafftitle_id, faculty_id) VALUES (" |
2072 |
|
|
. $course_id |
2073 |
|
|
. ", " |
2074 |
|
|
. $stafftitle_id |
2075 |
|
|
. ", " |
2076 |
|
|
. $faculty_id |
2077 |
|
|
. ")"; |
2078 |
|
|
|
2079 |
|
|
} |
2080 |
|
|
|
2081 |
|
|
// Incoming was a new faculty member |
2082 |
|
|
else if (strlen($pers_lastname) > 0 && $pers_type == "faculty") { |
2083 |
|
|
|
2084 |
|
|
// Check for uniqueness |
2085 |
|
|
$faculty_name_display = $pers_firstname . " " . $pers_lastname; |
2086 |
|
|
$exists_id = existsFaculty($con, $pers_firstname, $pers_lastname); |
2087 |
|
|
|
2088 |
|
|
if ($exists_id > 0) { |
2089 |
|
|
$err_code = 1; |
2090 |
|
|
$err_msg = "Failed. '" . $faculty_name_display . "' already exists in the Faculty table. Faculty firstname + lastname must be unique."; |
2091 |
|
|
} |
2092 |
|
|
|
2093 |
|
|
// So long as there are no errors |
2094 |
|
|
if ($err_code < 1) { |
2095 |
|
|
|
2096 |
|
|
// Clean up strings |
2097 |
|
|
if (strlen($pers_lastname) > 0) $pers_lastname = textInmySQL($pers_lastname); |
2098 |
|
|
if (strlen($pers_firstname) > 0) $pers_firstname = textInmySQL($pers_firstname); |
2099 |
|
|
if (strlen($pers_email) > 0) $pers_email = textInmySQL($pers_email); |
2100 |
|
|
if (strlen($pers_account) > 0) $pers_account = textInmySQL($pers_account); |
2101 |
|
|
|
2102 |
|
|
// Insert into the faculty table |
2103 |
|
|
$sql = "INSERT INTO faculty (faculty_lastname, faculty_firstname, faculty_account, faculty_email) VALUES ('" |
2104 |
|
|
. $pers_lastname |
2105 |
|
|
. "', '" |
2106 |
|
|
. $pers_firstname |
2107 |
|
|
. "', '" |
2108 |
|
|
. $pers_account |
2109 |
|
|
. "', '" |
2110 |
|
|
. $pers_email |
2111 |
|
|
. "')"; |
2112 |
|
|
|
2113 |
|
|
mysql_query ("LOCK TABLE faculty WRITE", $con); |
2114 |
|
|
if (!mysql_query($sql, $con)){ |
2115 |
|
|
sql_err($con); |
2116 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2117 |
|
|
bailout(); |
2118 |
|
|
} |
2119 |
|
|
else { |
2120 |
|
|
$new_faculty_id = mysql_insert_id($con); |
2121 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2122 |
|
|
} |
2123 |
|
|
|
2124 |
|
|
// Now, build the SQL for the insert into course_personnel |
2125 |
|
|
$sql = "INSERT INTO course_personnel (course_id, stafftitle_id, faculty_id) VALUES (" |
2126 |
|
|
. $course_id |
2127 |
|
|
. ", " |
2128 |
|
|
. $stafftitle_id |
2129 |
|
|
. ", " |
2130 |
|
|
. $new_faculty_id |
2131 |
|
|
. ")"; |
2132 |
|
|
|
2133 |
|
|
} |
2134 |
|
|
} |
2135 |
|
|
|
2136 |
|
|
// Incoming was a lowly TA or "other". Don't index these, plop them into the course_personnel table |
2137 |
|
|
else if (strlen($pers_lastname) > 0 && $pers_type == "other") { |
2138 |
|
|
|
2139 |
|
|
// Clean up strings |
2140 |
|
|
if (strlen($pers_lastname) > 0) $pers_lastname = textInmySQL($pers_lastname); |
2141 |
|
|
if (strlen($pers_firstname) > 0) $pers_firstname = textInmySQL($pers_firstname); |
2142 |
|
|
if (strlen($pers_email) > 0) $pers_email = textInmySQL($pers_email); |
2143 |
|
|
if (strlen($pers_account) > 0) $pers_account = textInmySQL($pers_account); |
2144 |
|
|
|
2145 |
|
|
$sql = "INSERT INTO course_personnel (course_id, stafftitle_id, pers_lastname, pers_firstname, pers_account, pers_email) VALUES (" |
2146 |
|
|
. $course_id |
2147 |
|
|
. ", " |
2148 |
|
|
. $stafftitle_id |
2149 |
|
|
. ", '" |
2150 |
|
|
. $pers_lastname |
2151 |
|
|
. "', '" |
2152 |
|
|
. $pers_firstname |
2153 |
|
|
. "', '" |
2154 |
|
|
. $pers_account |
2155 |
|
|
. "', '" |
2156 |
|
|
. $pers_email |
2157 |
|
|
. "')"; |
2158 |
|
|
} |
2159 |
|
|
|
2160 |
|
|
// Must have at least a last name. Send them back to the page. |
2161 |
|
|
else header("Location: scribe.phtml?page_id=" . $page_id); |
2162 |
|
|
|
2163 |
|
|
|
2164 |
|
|
// Proceed if there are no error messages |
2165 |
|
|
if ($err_code == 0) { |
2166 |
|
|
|
2167 |
|
|
// Failed |
2168 |
|
|
if (!mysql_query ($sql, $con)){ |
2169 |
|
|
sql_err($sql); |
2170 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2171 |
|
|
bailout(); |
2172 |
|
|
} |
2173 |
|
|
|
2174 |
|
|
// Succeeded |
2175 |
|
|
else { |
2176 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2177 |
|
|
} |
2178 |
|
|
|
2179 |
|
|
// Done. Call the PageScribe page back |
2180 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#coursePers"); |
2181 |
|
|
|
2182 |
|
|
} |
2183 |
|
|
|
2184 |
|
|
else { |
2185 |
|
|
|
2186 |
|
|
// Page header |
2187 |
|
|
require_once ($GLOBAL_ADMIN_INC."scribe_header.phtml"); |
2188 |
|
|
|
2189 |
|
|
printf("<center><h3>Adding Course Personnel...</h3>"); |
2190 |
|
|
|
2191 |
|
|
// Table |
2192 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
2193 |
|
|
printf("<tr><td><br>\n"); |
2194 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
2195 |
|
|
printf("%s", $err_msg); |
2196 |
|
|
printf("<BR><BR>\n"); |
2197 |
|
|
printf("</td></tr></table>\n"); |
2198 |
|
|
printf("</center>\n"); |
2199 |
|
|
|
2200 |
|
|
// Page footer |
2201 |
|
|
require_once ($GLOBAL_ADMIN_INC."scribe_footer.phtml"); |
2202 |
|
|
|
2203 |
|
|
} |
2204 |
|
|
|
2205 |
|
|
} |
2206 |
|
|
|
2207 |
|
|
|
2208 |
|
|
/********************************************************** |
2209 |
|
|
Function: insertScribeLabel |
2210 |
|
|
Author: Paul Bramscher |
2211 |
|
|
Last Modified: 07.03.2003 |
2212 |
|
|
*********************************************************** |
2213 |
|
|
Purpose: |
2214 |
|
|
Inserts a "label" or free-text type PageScribe element onto |
2215 |
|
|
a PageScribe page. |
2216 |
|
|
**********************************************************/ |
2217 |
|
|
function insertScribeLabel($con, $element_descr, $label, $label_url, $place_array_HTML, $page_id){ |
2218 |
|
|
|
2219 |
|
|
// Clean up strings |
2220 |
|
|
$element_descr = textInmySQL($element_descr); |
2221 |
|
|
$label = textInmySQL($label); |
2222 |
|
|
|
2223 |
|
|
// Problem flag |
2224 |
|
|
$problem = 0; |
2225 |
|
|
|
2226 |
|
|
// Protect against blank label |
2227 |
|
|
if (strlen($label) < 1) { |
2228 |
|
|
$problem = 1; |
2229 |
|
|
} |
2230 |
|
|
|
2231 |
|
|
// No problems |
2232 |
|
|
if ($problem == 0) { |
2233 |
|
|
|
2234 |
|
|
// Error check |
2235 |
|
|
if ($label_url == "http://") $label_url = ""; |
2236 |
|
|
|
2237 |
|
|
// Split by comma separated values |
2238 |
|
|
$place_array = split(",", $place_array_HTML); |
2239 |
|
|
|
2240 |
|
|
// Break apart place array |
2241 |
|
|
$prev_element_id = $place_array[0]; |
2242 |
|
|
$prev_element_order = $place_array[1]; |
2243 |
|
|
$prev_indent_level = $place_array[2]; |
2244 |
|
|
// $parent_id = $place_array[3]; |
2245 |
|
|
$position = $place_array[4]; |
2246 |
|
|
|
2247 |
|
|
// First probe for the new parent_id |
2248 |
|
|
$parent_id = parentProbe($con, $page_id, $prev_element_order, $prev_indent_level); |
2249 |
|
|
|
2250 |
|
|
// Next, bump all of the following items down by one |
2251 |
|
|
$sql = "UPDATE element SET element_order = element_order + 1 WHERE page_id = " |
2252 |
|
|
. $page_id . " AND element_order >= " . $prev_element_order; |
2253 |
|
|
|
2254 |
|
|
// Make the change |
2255 |
|
|
if (!mysql_query($sql, $con)){ |
2256 |
|
|
sql_err($con); |
2257 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2258 |
|
|
bailout(); |
2259 |
|
|
} |
2260 |
|
|
else { |
2261 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2262 |
|
|
} |
2263 |
|
|
|
2264 |
|
|
|
2265 |
|
|
// Next insert the new label |
2266 |
|
|
$sql = "INSERT INTO element (page_id, label, label_url, element_descr, element_order, indent_level,parent_id) VALUES (" |
2267 |
|
|
. $page_id . ", '" |
2268 |
|
|
. $label . "', '" |
2269 |
|
|
. $label_url . "', '" |
2270 |
|
|
. $element_descr . "', " |
2271 |
|
|
. $prev_element_order . ", " |
2272 |
|
|
. $prev_indent_level . ", " |
2273 |
|
|
. $parent_id . ")"; |
2274 |
|
|
|
2275 |
|
|
if (!mysql_query ($sql, $con)){ |
2276 |
|
|
sql_err($sql); |
2277 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2278 |
|
|
bailout(); |
2279 |
|
|
} |
2280 |
|
|
else { |
2281 |
|
|
// Success |
2282 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2283 |
|
|
} |
2284 |
|
|
} |
2285 |
|
|
|
2286 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
2287 |
|
|
} |
2288 |
|
|
|
2289 |
|
|
|
2290 |
|
|
/********************************************************** |
2291 |
|
|
Function: insertScribeLocation |
2292 |
|
|
Author: Paul Bramscher |
2293 |
|
|
Last Modified: 07.03.2003 |
2294 |
|
|
*********************************************************** |
2295 |
|
|
Purpose: |
2296 |
|
|
Inserts location type element onto a PageScribe page. |
2297 |
|
|
**********************************************************/ |
2298 |
|
|
function insertScribeLocation($con, $location_id, $place_array_HTML, $page_id){ |
2299 |
|
|
|
2300 |
|
|
// Error checking |
2301 |
|
|
if ($location_id > 0) { |
2302 |
|
|
|
2303 |
|
|
// Split by comma separated values |
2304 |
|
|
$place_array = split(",", $place_array_HTML); |
2305 |
|
|
|
2306 |
|
|
// Break apart place array |
2307 |
|
|
$prev_element_id = $place_array[0]; |
2308 |
|
|
$prev_element_order = $place_array[1]; |
2309 |
|
|
$prev_indent_level = $place_array[2]; |
2310 |
|
|
// $parent_id = $place_array[3]; |
2311 |
|
|
$position = $place_array[4]; |
2312 |
|
|
|
2313 |
|
|
// First probe for the new parent_id |
2314 |
|
|
$parent_id = parentProbe($con, $page_id, $prev_element_order, $prev_indent_level); |
2315 |
|
|
|
2316 |
|
|
// Next, bump all of the following items down by one |
2317 |
|
|
$sql = "UPDATE element SET element_order = element_order + 1 WHERE page_id = " |
2318 |
|
|
. $page_id . " AND element_order >= " . $prev_element_order; |
2319 |
|
|
|
2320 |
|
|
// Make the change |
2321 |
|
|
if (!mysql_query($sql, $con)){ |
2322 |
|
|
sql_err($con); |
2323 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2324 |
|
|
bailout(); |
2325 |
|
|
} |
2326 |
|
|
else { |
2327 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2328 |
|
|
} |
2329 |
|
|
|
2330 |
|
|
// Next insert the new location |
2331 |
|
|
$sql = "INSERT INTO element (page_id, location_id, element_order, indent_level,parent_id) VALUES (" |
2332 |
|
|
. $page_id . ", " |
2333 |
|
|
. $location_id . ", " |
2334 |
|
|
. $prev_element_order . ", " |
2335 |
|
|
. $prev_indent_level . ", " |
2336 |
|
|
. $parent_id . ")"; |
2337 |
|
|
if (!mysql_query ($sql, $con)){ |
2338 |
|
|
sql_err($sql); |
2339 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2340 |
|
|
bailout(); |
2341 |
|
|
} |
2342 |
|
|
else { |
2343 |
|
|
// Success |
2344 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2345 |
|
|
} |
2346 |
|
|
|
2347 |
|
|
} |
2348 |
|
|
|
2349 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
2350 |
|
|
} |
2351 |
|
|
|
2352 |
|
|
|
2353 |
|
|
/********************************************************** |
2354 |
|
|
Function: insertScribeResource |
2355 |
|
|
Author: Paul Bramscher |
2356 |
|
|
Last Modified: 07.03.2003 |
2357 |
|
|
*********************************************************** |
2358 |
|
|
Purpose: |
2359 |
|
|
Inserts a resource type element onto a PageScribe page. |
2360 |
|
|
**********************************************************/ |
2361 |
|
|
function insertScribeResource($con, $place_array_HTML, $resource_id, $page_id){ |
2362 |
|
|
|
2363 |
|
|
// Error checking |
2364 |
|
|
if ($resource_id > 0) { |
2365 |
|
|
|
2366 |
|
|
// Split by comma separated values |
2367 |
|
|
$place_array = split(",", $place_array_HTML); |
2368 |
|
|
|
2369 |
|
|
// Break apart place array |
2370 |
|
|
$prev_element_id = $place_array[0]; |
2371 |
|
|
$prev_element_order = $place_array[1]; |
2372 |
|
|
$prev_indent_level = $place_array[2]; |
2373 |
|
|
// $parent_id = $place_array[3]; |
2374 |
|
|
$position = $place_array[4]; |
2375 |
|
|
|
2376 |
|
|
// First probe for the new parent_id |
2377 |
|
|
$parent_id = parentProbe($con, $page_id, $prev_element_order, $prev_indent_level); |
2378 |
|
|
|
2379 |
|
|
// Next, bump all of the following items down by one |
2380 |
|
|
$sql = "UPDATE element SET element_order = element_order + 1 WHERE page_id = " |
2381 |
|
|
. $page_id . " AND element_order >= " . $prev_element_order; |
2382 |
|
|
|
2383 |
|
|
// Make the change |
2384 |
|
|
if (!mysql_query($sql, $con)){ |
2385 |
|
|
sql_err($con); |
2386 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2387 |
|
|
bailout(); |
2388 |
|
|
} |
2389 |
|
|
else { |
2390 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2391 |
|
|
} |
2392 |
|
|
|
2393 |
|
|
// Next insert the new resource |
2394 |
|
|
$sql = "INSERT INTO element (page_id, resource_id, element_order, indent_level,parent_id) VALUES (" |
2395 |
|
|
. $page_id . ", " |
2396 |
|
|
. $resource_id . ", " |
2397 |
|
|
. $prev_element_order . ", " |
2398 |
|
|
. $prev_indent_level . ", " |
2399 |
|
|
. $parent_id . ")"; |
2400 |
|
|
if (!mysql_query ($sql, $con)){ |
2401 |
|
|
sql_err($sql); |
2402 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2403 |
|
|
bailout(); |
2404 |
|
|
} |
2405 |
|
|
else { |
2406 |
|
|
// Success |
2407 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2408 |
|
|
} |
2409 |
|
|
|
2410 |
|
|
} |
2411 |
|
|
|
2412 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
2413 |
|
|
} |
2414 |
|
|
|
2415 |
|
|
|
2416 |
|
|
/********************************************************** |
2417 |
|
|
Function: insertScribeRQS |
2418 |
|
|
Author: Paul Bramscher |
2419 |
|
|
Last Modified: 07.03.2003 |
2420 |
|
|
*********************************************************** |
2421 |
|
|
Purpose: |
2422 |
|
|
This function performs the "RQS harvest". For the supplied |
2423 |
|
|
subject id, collect all of the resources and insert them |
2424 |
|
|
as elements onto a PageScribe page. |
2425 |
|
|
**********************************************************/ |
2426 |
|
|
function insertScribeRQS($con, $place_array_HTML, $subject_id, $page_id){ |
2427 |
|
|
|
2428 |
|
|
// Error checking |
2429 |
|
|
if ($subject_id > 0) { |
2430 |
|
|
|
2431 |
|
|
// Split by comma separated values |
2432 |
|
|
$place_array = split(",", $place_array_HTML); |
2433 |
|
|
|
2434 |
|
|
// Break apart place array |
2435 |
|
|
$prev_element_id = $place_array[0]; |
2436 |
|
|
$prev_element_order = $place_array[1]; |
2437 |
|
|
$prev_indent_level = $place_array[2]; |
2438 |
|
|
// $parent_id = $place_array[3]; |
2439 |
|
|
$position = $place_array[4]; |
2440 |
|
|
|
2441 |
|
|
// First probe for the new parent_id |
2442 |
|
|
$parent_id = parentProbe($con, $page_id, $prev_element_order, $prev_indent_level); |
2443 |
|
|
|
2444 |
|
|
// Identify the number of new elements to add |
2445 |
|
|
$sql = "SELECT COUNT(*) as num_rqs from res_sub_infotype WHERE subject_id = " . $subject_id; |
2446 |
|
|
$rs = mysql_query($sql, $con); |
2447 |
|
|
$row = mysql_fetch_array ($rs); |
2448 |
|
|
|
2449 |
|
|
// Pull out the possible display values |
2450 |
|
|
$num_rqs = $row["num_rqs"]; |
2451 |
|
|
|
2452 |
|
|
// Continue if num_rqs > 0. If the RQS+ page was empty, skip all of this. |
2453 |
|
|
if ($num_rqs > 0) { |
2454 |
|
|
|
2455 |
|
|
// Next, bump all of the following items down by the number of incoming |
2456 |
|
|
$sql = "UPDATE element SET element_order = element_order + " |
2457 |
|
|
. $num_rqs |
2458 |
|
|
. " WHERE page_id = " |
2459 |
|
|
. $page_id . " AND element_order >= " . $prev_element_order; |
2460 |
|
|
|
2461 |
|
|
// Make the change |
2462 |
|
|
if (!mysql_query($sql, $con)){ |
2463 |
|
|
sql_err($con); |
2464 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2465 |
|
|
bailout(); |
2466 |
|
|
} |
2467 |
|
|
else { |
2468 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2469 |
|
|
} |
2470 |
|
|
|
2471 |
|
|
// Cycle through the resources |
2472 |
|
|
$sql = "SELECT rsi.resource_id, r.title |
2473 |
|
|
FROM res_sub_infotype rsi |
2474 |
|
|
LEFT JOIN resource r using (resource_id) |
2475 |
|
|
WHERE subject_id = " . $subject_id . |
2476 |
|
|
" ORDER BY r.title"; |
2477 |
|
|
|
2478 |
|
|
$rs = mysql_query($sql, $con); |
2479 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
2480 |
|
|
|
2481 |
|
|
// Fetch resource |
2482 |
|
|
$resource_id = $row["resource_id"]; |
2483 |
|
|
|
2484 |
|
|
// Next insert the culled resource |
2485 |
|
|
$i_sql = "INSERT INTO element (page_id, resource_id, element_order, indent_level,parent_id) VALUES (" |
2486 |
|
|
. $page_id . ", " |
2487 |
|
|
. $resource_id . ", " |
2488 |
|
|
. $prev_element_order . ", " |
2489 |
|
|
. $prev_indent_level . ", " |
2490 |
|
|
. $parent_id . ")"; |
2491 |
|
|
if (!mysql_query ($i_sql, $con)){ |
2492 |
|
|
sql_err($sql); |
2493 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2494 |
|
|
bailout(); |
2495 |
|
|
} |
2496 |
|
|
else { |
2497 |
|
|
// Success |
2498 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2499 |
|
|
} // successful import |
2500 |
|
|
|
2501 |
|
|
// Increment element order |
2502 |
|
|
$prev_element_order++; |
2503 |
|
|
|
2504 |
|
|
} // for all resources on RQS page |
2505 |
|
|
|
2506 |
|
|
} // rqs+ page was not empty |
2507 |
|
|
|
2508 |
|
|
} |
2509 |
|
|
|
2510 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
2511 |
|
|
|
2512 |
|
|
} |
2513 |
|
|
|
2514 |
|
|
|
2515 |
|
|
/********************************************************** |
2516 |
|
|
Function: insertScribeRQSLink |
2517 |
|
|
Author: Paul Bramscher |
2518 |
|
|
Last Modified: 07.03.2003 |
2519 |
|
|
*********************************************************** |
2520 |
|
|
Purpose: |
2521 |
|
|
Inserts an RQS subject page element onto a PageScribe page. |
2522 |
|
|
**********************************************************/ |
2523 |
|
|
function insertScribeRQSLink($con, $place_array_HTML, $subject_id, $page_id){ |
2524 |
|
|
|
2525 |
|
|
// Error checking |
2526 |
|
|
if ($subject_id > 0) { |
2527 |
|
|
|
2528 |
|
|
// Split by comma separated values |
2529 |
|
|
$place_array = split(",", $place_array_HTML); |
2530 |
|
|
|
2531 |
|
|
// Break apart place array |
2532 |
|
|
$prev_element_id = $place_array[0]; |
2533 |
|
|
$prev_element_order = $place_array[1]; |
2534 |
|
|
$prev_indent_level = $place_array[2]; |
2535 |
|
|
// $parent_id = $place_array[3]; |
2536 |
|
|
$position = $place_array[4]; |
2537 |
|
|
|
2538 |
|
|
// First probe for the new parent_id |
2539 |
|
|
$parent_id = parentProbe($con, $page_id, $prev_element_order, $prev_indent_level); |
2540 |
|
|
|
2541 |
|
|
// Next, bump all of the following items down by one |
2542 |
|
|
$sql = "UPDATE element SET element_order = element_order + 1 WHERE page_id = " |
2543 |
|
|
. $page_id . " AND element_order >= " . $prev_element_order; |
2544 |
|
|
|
2545 |
|
|
// Make the change |
2546 |
|
|
if (!mysql_query($sql, $con)){ |
2547 |
|
|
sql_err($con); |
2548 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2549 |
|
|
bailout(); |
2550 |
|
|
} |
2551 |
|
|
else { |
2552 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2553 |
|
|
} |
2554 |
|
|
|
2555 |
|
|
// Next insert the new resource |
2556 |
|
|
$sql = "INSERT INTO element (page_id, subject_id, element_order, indent_level,parent_id) VALUES (" |
2557 |
|
|
. $page_id . ", " |
2558 |
|
|
. $subject_id . ", " |
2559 |
|
|
. $prev_element_order . ", " |
2560 |
|
|
. $prev_indent_level . ", " |
2561 |
|
|
. $parent_id . ")"; |
2562 |
|
|
if (!mysql_query ($sql, $con)){ |
2563 |
|
|
sql_err($sql); |
2564 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2565 |
|
|
bailout(); |
2566 |
|
|
} |
2567 |
|
|
else { |
2568 |
|
|
// Success |
2569 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2570 |
|
|
} |
2571 |
|
|
|
2572 |
|
|
} |
2573 |
|
|
|
2574 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
2575 |
|
|
} |
2576 |
|
|
|
2577 |
|
|
|
2578 |
|
|
/********************************************************** |
2579 |
|
|
Function: insertScribeService |
2580 |
|
|
Author: Paul Bramscher |
2581 |
|
|
Last Modified: 07.03.2003 |
2582 |
|
|
*********************************************************** |
2583 |
|
|
Purpose: |
2584 |
|
|
Inserts a service type element onto a PageScribe page. |
2585 |
|
|
**********************************************************/ |
2586 |
|
|
function insertScribeService($con, $place_array_HTML, $page_id, $service_id){ |
2587 |
|
|
|
2588 |
|
|
// Error checking |
2589 |
|
|
if ($service_id > 0) { |
2590 |
|
|
|
2591 |
|
|
// Split by comma separated values |
2592 |
|
|
$place_array = split(",", $place_array_HTML); |
2593 |
|
|
|
2594 |
|
|
// Break apart place array |
2595 |
|
|
$prev_element_id = $place_array[0]; |
2596 |
|
|
$prev_element_order = $place_array[1]; |
2597 |
|
|
$prev_indent_level = $place_array[2]; |
2598 |
|
|
// $parent_id = $place_array[3]; |
2599 |
|
|
$position = $place_array[4]; |
2600 |
|
|
|
2601 |
|
|
// First probe for the new parent_id |
2602 |
|
|
$parent_id = parentProbe($con, $page_id, $prev_element_order, $prev_indent_level); |
2603 |
|
|
|
2604 |
|
|
// Next, bump all of the following items down by one |
2605 |
|
|
$sql = "UPDATE element SET element_order = element_order + 1 WHERE page_id = " |
2606 |
|
|
. $page_id . " AND element_order >= " . $prev_element_order; |
2607 |
|
|
|
2608 |
|
|
// Make the change |
2609 |
|
|
if (!mysql_query($sql, $con)){ |
2610 |
|
|
sql_err($con); |
2611 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2612 |
|
|
bailout(); |
2613 |
|
|
} |
2614 |
|
|
else { |
2615 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2616 |
|
|
} |
2617 |
|
|
|
2618 |
|
|
// Next insert the new service |
2619 |
|
|
$sql = "INSERT INTO element (page_id, service_id, element_order, indent_level,parent_id) VALUES (" |
2620 |
|
|
. $page_id . ", " |
2621 |
|
|
. $service_id . ", " |
2622 |
|
|
. $prev_element_order . ", " |
2623 |
|
|
. $prev_indent_level . ", " |
2624 |
|
|
. $parent_id . ")"; |
2625 |
|
|
if (!mysql_query ($sql, $con)){ |
2626 |
|
|
sql_err($sql); |
2627 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2628 |
|
|
bailout(); |
2629 |
|
|
} |
2630 |
|
|
else { |
2631 |
|
|
// Success |
2632 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2633 |
|
|
} |
2634 |
|
|
|
2635 |
|
|
} |
2636 |
|
|
|
2637 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
2638 |
|
|
} |
2639 |
|
|
|
2640 |
|
|
|
2641 |
|
|
/********************************************************** |
2642 |
|
|
Function: insertScribeStaff |
2643 |
|
|
Author: Paul Bramscher |
2644 |
|
|
Last Modified: 04.22.2003 |
2645 |
|
|
*********************************************************** |
2646 |
|
|
Purpose: |
2647 |
|
|
Inserts a staffperson as an element on a PageScribe page. |
2648 |
|
|
**********************************************************/ |
2649 |
|
|
function insertScribeStaff($con, $place_array_HTML, $staff_id, $page_id){ |
2650 |
|
|
|
2651 |
|
|
// Split by comma separated values |
2652 |
|
|
$place_array = split(",", $place_array_HTML); |
2653 |
|
|
|
2654 |
|
|
// Break apart place array |
2655 |
|
|
$prev_element_id = $place_array[0]; |
2656 |
|
|
$prev_element_order = $place_array[1]; |
2657 |
|
|
$prev_indent_level = $place_array[2]; |
2658 |
|
|
// $parent_id = $place_array[3]; |
2659 |
|
|
$position = $place_array[4]; |
2660 |
|
|
|
2661 |
|
|
// First probe for the new parent_id |
2662 |
|
|
$parent_id = parentProbe($con, $page_id, $prev_element_order, $prev_indent_level); |
2663 |
|
|
|
2664 |
|
|
// Next, bump all of the following items down by one |
2665 |
|
|
$sql = "UPDATE element SET element_order = element_order + 1 WHERE page_id = " |
2666 |
|
|
. $page_id . " AND element_order >= " . $prev_element_order; |
2667 |
|
|
|
2668 |
|
|
// Make the change |
2669 |
|
|
if (!mysql_query($sql, $con)){ |
2670 |
|
|
sql_err($con); |
2671 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2672 |
|
|
bailout(); |
2673 |
|
|
} |
2674 |
|
|
else { |
2675 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2676 |
|
|
} |
2677 |
|
|
|
2678 |
|
|
// Next insert the new staff |
2679 |
|
|
$sql = "INSERT INTO element (page_id, staff_id, element_order, indent_level,parent_id) VALUES (" |
2680 |
|
|
. $page_id . ", " |
2681 |
|
|
. $staff_id . ", " |
2682 |
|
|
. $prev_element_order . ", " |
2683 |
|
|
. $prev_indent_level . ", " |
2684 |
|
|
. $parent_id . ")"; |
2685 |
|
|
if (!mysql_query ($sql, $con)){ |
2686 |
|
|
sql_err($sql); |
2687 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2688 |
|
|
bailout(); |
2689 |
|
|
} |
2690 |
|
|
else { |
2691 |
|
|
// Success |
2692 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2693 |
|
|
} |
2694 |
|
|
|
2695 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
2696 |
|
|
} |
2697 |
|
|
|
2698 |
|
|
|
2699 |
|
|
/********************************************************** |
2700 |
|
|
Function: pageLoadStats |
2701 |
|
|
Author: Paul Bramscher |
2702 |
|
|
Last Modified: 04.23.2003 |
2703 |
|
|
*********************************************************** |
2704 |
|
|
Purpose: |
2705 |
|
|
Logs a statistical entry for a PageScribe/CourseLib page |
2706 |
|
|
load. Page id, date, and IP address are currently logged. |
2707 |
|
|
It would be relatively trivial to add other fields, |
2708 |
|
|
such as browser type, refer URL, etc. both to the database |
2709 |
|
|
and this function here. However, care must be taken so |
2710 |
|
|
that the database doesn't grow too large. Currently there |
2711 |
|
|
exists no automatic mechanism to purge or archive stats. |
2712 |
|
|
**********************************************************/ |
2713 |
|
|
function pageLoadStats($con, $page_id){ |
2714 |
|
|
|
2715 |
|
|
// Add a row for page usage |
2716 |
|
|
|
2717 |
|
|
// Fetch user ip |
2718 |
|
|
$user_ip = $GLOBALS["REMOTE_ADDR"]; |
2719 |
|
|
|
2720 |
|
|
// Do the stat stuff here |
2721 |
|
|
$sql = "INSERT INTO libstats.pagestats ( |
2722 |
|
|
page_id, |
2723 |
|
|
visit_date, |
2724 |
|
|
user_ip) VALUES (" |
2725 |
|
|
. $page_id |
2726 |
|
|
. ", now(), '" |
2727 |
|
|
. $user_ip |
2728 |
|
|
. "')"; |
2729 |
|
|
|
2730 |
|
|
if (!mysql_query($sql, $con)){ |
2731 |
|
|
sql_err($con); |
2732 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2733 |
|
|
bailout(); |
2734 |
|
|
} // bad write |
2735 |
|
|
else { |
2736 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2737 |
|
|
|
2738 |
|
|
} // good write to the pagestats table |
2739 |
|
|
|
2740 |
|
|
} |
2741 |
|
|
|
2742 |
|
|
|
2743 |
|
|
/********************************************************** |
2744 |
|
|
Function: pageTemplate |
2745 |
|
|
Author: Paul Bramscher |
2746 |
|
|
Last Modified: 12.15.2003 |
2747 |
|
|
*********************************************************** |
2748 |
|
|
Purpose: |
2749 |
|
|
Performs the clone or copy page functionality. Note that |
2750 |
|
|
the new title is "Copy of:" prefixed to the previous page |
2751 |
|
|
title. Also, not all parameters are copied. Specifically, |
2752 |
|
|
those relating to permissions must be set independently. |
2753 |
|
|
|
2754 |
|
|
This function could probably be cleaned up for efficiency. |
2755 |
|
|
The biggest challenge is in handling the parent-child |
2756 |
|
|
relationships on the new page. While the abstract structure |
2757 |
|
|
remains the same, the pointers to specific element id's |
2758 |
|
|
on the new page are all new and must be calculated on the |
2759 |
|
|
fly. |
2760 |
|
|
**********************************************************/ |
2761 |
|
|
function pageTemplate($con, $page_id, $sess_staff_id, $sess_staff_account){ |
2762 |
|
|
|
2763 |
|
|
// First copy the page elements |
2764 |
|
|
$sql = "SELECT * FROM page WHERE page_id = " |
2765 |
|
|
. $page_id; |
2766 |
|
|
$rs = mysql_query($sql, $con); |
2767 |
|
|
$row = mysql_fetch_array ($rs); |
2768 |
|
|
|
2769 |
|
|
// Fetch results |
2770 |
|
|
$style_id = $row["style_id"]; |
2771 |
|
|
$pagetype_id = $row["pagetype_id"]; |
2772 |
|
|
$page_title = $row["page_title"]; |
2773 |
|
|
$pagetitle_style = $row["pagetitle_style"]; |
2774 |
|
|
$display_toc = $row["display_toc"]; |
2775 |
|
|
$wrap_toc = $row["wrap_toc"]; |
2776 |
|
|
$display_up = $row["display_up"]; |
2777 |
|
|
$up_text = $row["up_text"]; |
2778 |
|
|
|
2779 |
|
|
// Handle possible nulls |
2780 |
|
|
if ($display_toc < 1) $display_toc = "NULL"; |
2781 |
|
|
if ($wrap_toc < 1) $wrap_toc = "NULL"; |
2782 |
|
|
if ($display_up < 1) $display_up = "NULL"; |
2783 |
|
|
if ($pagetitle_style < 1) $pagetitle_style = "NULL"; |
2784 |
|
|
|
2785 |
|
|
// Clean up strings |
2786 |
|
|
$page_title = textInmySQL($page_title); |
2787 |
|
|
if (strlen($up_text) > 0) $up_text = textInmySQL($up_text); |
2788 |
|
|
|
2789 |
|
|
// Create new page insert statement |
2790 |
|
|
|
2791 |
|
|
|
2792 |
|
|
$sql = "INSERT INTO page |
2793 |
|
|
(date_created, |
2794 |
|
|
account_created, |
2795 |
|
|
staff_coordinator, |
2796 |
|
|
style_id, |
2797 |
|
|
pagetype_id, |
2798 |
|
|
page_title, |
2799 |
|
|
pagetitle_style, |
2800 |
|
|
display_toc, |
2801 |
|
|
wrap_toc, |
2802 |
|
|
display_up, |
2803 |
|
|
up_text) |
2804 |
|
|
VALUES ( |
2805 |
|
|
now(), '" |
2806 |
|
|
. $sess_staff_account |
2807 |
|
|
. "', " |
2808 |
|
|
. $sess_staff_id |
2809 |
|
|
. ", " |
2810 |
|
|
. $style_id |
2811 |
|
|
. ", " |
2812 |
|
|
. $pagetype_id |
2813 |
|
|
. ", 'Copy of: " |
2814 |
|
|
. $page_title |
2815 |
|
|
. "', " |
2816 |
|
|
. $pagetitle_style |
2817 |
|
|
. ", " |
2818 |
|
|
. $display_toc |
2819 |
|
|
. ", " |
2820 |
|
|
. $wrap_toc |
2821 |
|
|
. ", " |
2822 |
|
|
. $display_up |
2823 |
|
|
. ", '" |
2824 |
|
|
. $up_text |
2825 |
|
|
. "')"; |
2826 |
|
|
|
2827 |
|
|
//printf("sql was: %s", $sql); |
2828 |
|
|
|
2829 |
|
|
mysql_query ("LOCK TABLE page WRITE", $con); |
2830 |
|
|
if (!mysql_query($sql, $con)){ |
2831 |
|
|
sql_err($con); |
2832 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2833 |
|
|
bailout(); |
2834 |
|
|
} |
2835 |
|
|
else { |
2836 |
|
|
$new_page_id = mysql_insert_id($con); |
2837 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2838 |
|
|
} |
2839 |
|
|
|
2840 |
|
|
|
2841 |
|
|
// If a new stub was created, and this happens to be a course page, get the course id. |
2842 |
|
|
if ($new_page_id > 0 && $pagetype_id == 3) { |
2843 |
|
|
$course_id = lookupfield($con, "course", "page_id", $page_id, "course_id"); |
2844 |
|
|
} |
2845 |
|
|
|
2846 |
|
|
|
2847 |
|
|
if ($course_id > 0 && $new_page_id > 0) { |
2848 |
|
|
|
2849 |
|
|
|
2850 |
|
|
// Copy the course elements |
2851 |
|
|
$sql = "SELECT * FROM course WHERE page_id = " |
2852 |
|
|
. $page_id; |
2853 |
|
|
$rs = mysql_query($sql, $con); |
2854 |
|
|
$row = mysql_fetch_array ($rs); |
2855 |
|
|
|
2856 |
|
|
// Fetch results |
2857 |
|
|
$coursesub_id = $row["coursesub_id"]; |
2858 |
|
|
$course_num = $row["course_num"]; |
2859 |
|
|
$course_section = $row["course_section"]; |
2860 |
|
|
$course_concat = $row["course_concat"]; |
2861 |
|
|
$term_id = $row["term_id"]; |
2862 |
|
|
$course_year = $row["course_year"]; |
2863 |
|
|
$campus_id = $row["campus_id"]; |
2864 |
|
|
$courseheader = $row["courseheader"]; |
2865 |
|
|
$introheader1 = $row["introheader1"]; |
2866 |
|
|
$intromessage1 = $row["intromessage1"]; |
2867 |
|
|
$introheader2 = $row["introheader2"]; |
2868 |
|
|
$intromessage2 = $row["intromessage2"]; |
2869 |
|
|
|
2870 |
|
|
// Cleanup |
2871 |
|
|
$course_num = textInmySQL($course_num); |
2872 |
|
|
$course_section = textInmySQL($course_section); |
2873 |
|
|
$course_concat = textInmySQL($course_concat); |
2874 |
|
|
$course_year = textInmySQL($course_year); |
2875 |
|
|
$courseheader = textInmySQL($courseheader); |
2876 |
|
|
$introheader1 = textInmySQL($introheader1); |
2877 |
|
|
$intromessage1 = textInmySQL($intromessage1); |
2878 |
|
|
$introheader2 = textInmySQL($introheader2); |
2879 |
|
|
$intromessage2 = textInmySQL($intromessage2); |
2880 |
|
|
|
2881 |
|
|
// Cleanup for null or numeric values |
2882 |
|
|
if ($coursesub_id < 1) $coursesub_id = 0; |
2883 |
|
|
if ($term_id < 1) $term_id = 0; |
2884 |
|
|
if ($campus_id < 1) $campus_id = 0; |
2885 |
|
|
|
2886 |
|
|
|
2887 |
|
|
// Create new course insert statement |
2888 |
|
|
|
2889 |
|
|
|
2890 |
|
|
$sql = "INSERT INTO course |
2891 |
|
|
(page_id, |
2892 |
|
|
coursesub_id, |
2893 |
|
|
course_num, |
2894 |
|
|
course_section, |
2895 |
|
|
course_concat, |
2896 |
|
|
term_id, |
2897 |
|
|
course_year, |
2898 |
|
|
campus_id, |
2899 |
|
|
courseheader, |
2900 |
|
|
introheader1, |
2901 |
|
|
intromessage1, |
2902 |
|
|
introheader2, |
2903 |
|
|
intromessage2) |
2904 |
|
|
VALUES ( " . |
2905 |
|
|
$new_page_id . ", " . |
2906 |
|
|
$coursesub_id . ", '" . |
2907 |
|
|
$course_num . "', '" . |
2908 |
|
|
$course_section . "', 'Copy: " . |
2909 |
|
|
$course_concat . "'," . |
2910 |
|
|
$term_id . ", '" . |
2911 |
|
|
$course_year . "', " . |
2912 |
|
|
$campus_id . ", '" . |
2913 |
|
|
$courseheader . "', '" . |
2914 |
|
|
$introheader1 . "', '" . |
2915 |
|
|
$intromessage1 . "', '" . |
2916 |
|
|
$introheader2 . "', '" . |
2917 |
|
|
$intromessage2 . "')"; |
2918 |
|
|
|
2919 |
|
|
if (!mysql_query($sql, $con)){ |
2920 |
|
|
sql_err($con); |
2921 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
2922 |
|
|
bailout(); |
2923 |
|
|
} |
2924 |
|
|
else { |
2925 |
|
|
mysql_query("UNLOCK TABLES", $con); |
2926 |
|
|
} |
2927 |
|
|
} // was a CourseScribe type page |
2928 |
|
|
|
2929 |
|
|
|
2930 |
|
|
// Next, copy all elements |
2931 |
|
|
|
2932 |
|
|
|
2933 |
|
|
// This is not the most efficient method, but it works for now. |
2934 |
|
|
|
2935 |
|
|
|
2936 |
|
|
$sql = "SELECT * FROM element WHERE page_id = " |
2937 |
|
|
. $page_id |
2938 |
|
|
. " ORDER BY element_id"; |
2939 |
|
|
|
2940 |
|
|
$rs = mysql_query($sql, $con); |
2941 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
2942 |
|
|
|
2943 |
|
|
// Fetch previous values |
2944 |
|
|
$element_id = $row["element_id"]; |
2945 |
|
|
$parent_id = $row["parent_id"]; |
2946 |
|
|
$resource_id = $row["resource_id"]; |
2947 |
|
|
$location_id = $row["location_id"]; |
2948 |
|
|
$service_id = $row["service_id"]; |
2949 |
|
|
$staff_id = $row["staff_id"]; |
2950 |
|
|
$subject_id = $row["subject_id"]; |
2951 |
|
|
$label = $row["label"]; |
2952 |
|
|
$label_url = $row["label_url"]; |
2953 |
|
|
$element_descr = $row["element_descr"]; |
2954 |
|
|
$element_size = $row["element_size"]; |
2955 |
|
|
$element_order = $row["element_order"]; |
2956 |
|
|
$indent_level = $row["indent_level"]; |
2957 |
|
|
|
2958 |
|
|
// Cleanup for null or numeric values |
2959 |
|
|
if ($parent_id < 1) $parent_id = 0; |
2960 |
|
|
if ($resource_id < 1) $resource_id = "NULL"; |
2961 |
|
|
if ($location_id < 1) $location_id = "NULL"; |
2962 |
|
|
if ($service_id < 1) $service_id = "NULL"; |
2963 |
|
|
if ($staff_id < 1 ) $staff_id = "NULL"; |
2964 |
|
|
if ($subject_id < 1 ) $subject_id = "NULL"; |
2965 |
|
|
if ($element_size < 1) $element_size = "NULL"; |
2966 |
|
|
if ($indent_level < 1) $indent_level = 0; |
2967 |
|
|
|
2968 |
|
|
// Cleanup for text values |
2969 |
|
|
if (strlen($label) > 0) $label = textInmySQL($label); |
2970 |
|
|
if (strlen($label_url) > 0) $label_url = textInmySQL($label_url); |
2971 |
|
|
if (strlen($element_descr) > 0) $element_descr = textInmySQL($element_descr); |
2972 |
|
|
|
2973 |
|
|
// Calculate the new parent if needed |
2974 |
|
|
if ($parent_id > 0) $parent_id = parentProbe($con, $new_page_id, $element_order, $indent_level); |
2975 |
|
|
|
2976 |
|
|
// Insert the element onto the new page |
2977 |
|
|
$clone_sql = "INSERT INTO element ( |
2978 |
|
|
page_id, |
2979 |
|
|
parent_id, |
2980 |
|
|
resource_id, |
2981 |
|
|
location_id, |
2982 |
|
|
service_id, |
2983 |
|
|
staff_id, |
2984 |
|
|
subject_id, |
2985 |
|
|
label, |
2986 |
|
|
label_url, |
2987 |
|
|
element_descr, |
2988 |
|
|
element_size, |
2989 |
|
|
element_order, |
2990 |
|
|
indent_level) |
2991 |
|
|
VALUES (" . |
2992 |
|
|
$new_page_id . ", " . |
2993 |
|
|
$parent_id . ", " . |
2994 |
|
|
$resource_id . ", " . |
2995 |
|
|
$location_id . ", " . |
2996 |
|
|
$service_id . ", " . |
2997 |
|
|
$staff_id . ", " . |
2998 |
|
|
$subject_id . ", '" . |
2999 |
|
|
$label . "', '" . |
3000 |
|
|
$label_url . "', '" . |
3001 |
|
|
$element_descr . "', " . |
3002 |
|
|
$element_size . ", " . |
3003 |
|
|
$element_order . ", " . |
3004 |
|
|
$indent_level . ")"; |
3005 |
|
|
|
3006 |
|
|
// Execute the query |
3007 |
|
|
if (!mysql_query($clone_sql, $con)){ |
3008 |
|
|
sql_err($con); |
3009 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3010 |
|
|
bailout(); |
3011 |
|
|
} |
3012 |
|
|
else { |
3013 |
|
|
mysql_query("UNLOCK TABLES", $con); |
3014 |
|
|
} |
3015 |
|
|
|
3016 |
|
|
} |
3017 |
|
|
|
3018 |
|
|
header("Location: scribe.phtml?page_id=" . $new_page_id); |
3019 |
|
|
|
3020 |
|
|
} |
3021 |
|
|
|
3022 |
|
|
|
3023 |
|
|
/********************************************************** |
3024 |
|
|
Function: pageTemplateConfirm |
3025 |
|
|
Author: Paul Bramscher |
3026 |
|
|
Last Modified: 11.07.2003 |
3027 |
|
|
*********************************************************** |
3028 |
|
|
Purpose: |
3029 |
|
|
Prompts the author that he/she is about to template a |
3030 |
|
|
page. |
3031 |
|
|
**********************************************************/ |
3032 |
|
|
function pageTemplateConfirm($con, $page_id, $sess_staff_id, $sess_staff_account){ |
3033 |
|
|
|
3034 |
|
|
// Load globals |
3035 |
|
|
include("global_vars.php"); |
3036 |
|
|
|
3037 |
|
|
// Include the page header |
3038 |
|
|
include ($GLOBAL_ADMIN_INC."scribe_header.phtml"); |
3039 |
|
|
|
3040 |
|
|
// HTML headers |
3041 |
|
|
printf("<html>\n"); |
3042 |
|
|
printf("<head>\n"); |
3043 |
|
|
printf("<title>%s: Confirm Clone & Load</title>\n", $GLOBAL_SYS_NAME); |
3044 |
|
|
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS); |
3045 |
|
|
printf("</head>"); |
3046 |
|
|
|
3047 |
|
|
// Table |
3048 |
|
|
printf("<center>\n"); |
3049 |
|
|
printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">\n"); |
3050 |
|
|
printf("<tr><td class=\"cellPlain\">\n"); |
3051 |
|
|
printf("Confirm Clone & Load"); |
3052 |
|
|
printf("</td></tr>\n"); |
3053 |
|
|
printf("<tr><td><br>\n"); |
3054 |
|
|
|
3055 |
|
|
// Collect information |
3056 |
|
|
$sql = "SELECT |
3057 |
|
|
p.page_title, |
3058 |
|
|
s.first_name, |
3059 |
|
|
s.last_name, |
3060 |
|
|
s.staff_email |
3061 |
|
|
FROM |
3062 |
|
|
page p, |
3063 |
|
|
staff s |
3064 |
|
|
WHERE |
3065 |
|
|
p.page_id = " |
3066 |
|
|
. $page_id |
3067 |
|
|
. " AND p.staff_coordinator = s.staff_id"; |
3068 |
|
|
|
3069 |
|
|
$rs = mysql_query($sql, $con); |
3070 |
|
|
$row = mysql_fetch_array ($rs); |
3071 |
|
|
|
3072 |
|
|
$page_title = strip_tags($row["page_title"]); |
3073 |
|
|
$first_name = $row["first_name"]; |
3074 |
|
|
$last_name = $row["last_name"]; |
3075 |
|
|
$staff_email = $row["staff_email"]; |
3076 |
|
|
$staff_name = $first_name . " " . $last_name; |
3077 |
|
|
|
3078 |
|
|
printf("<b>Page Title: </b>%s<br>", $page_title); |
3079 |
|
|
printf("<b>Coordinator: </b>%s <a href=\"mailto:%s\">%s</a><br><br>", $staff_name, $staff_email, $staff_email); |
3080 |
|
|
|
3081 |
|
|
printf("Before cloning this page, please consider seeking permission from and/or giving "); |
3082 |
|
|
printf("attribution to the page author(s) of the original work.<br><br>\n"); |
3083 |
|
|
|
3084 |
|
|
// Button to continue |
3085 |
|
|
printf("<form method=\"POST\" action=\"scribe_transaction.phtml\">\n"); |
3086 |
|
|
printf("<input type=\"hidden\" name =\"transaction\" value = \"pageTemplate\">\n"); |
3087 |
|
|
printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id); |
3088 |
|
|
printf("<input type=\"hidden\" name =\"sess_staff_account\" value = \"%d\">\n", $sess_staff_account); |
3089 |
|
|
printf("<input type=\"hidden\" name =\"sess_staff_id\" value = \"%d\">\n", $sess_staff_id); |
3090 |
|
|
printf("<center><input type=\"submit\" value=\"Continue\"></center>\n"); |
3091 |
|
|
printf("</td></tr></table>\n"); |
3092 |
|
|
|
3093 |
|
|
// Link to return to admin console |
3094 |
|
|
adminReturn(""); |
3095 |
|
|
|
3096 |
|
|
printf("</center>\n"); |
3097 |
|
|
|
3098 |
|
|
// Include the footer |
3099 |
|
|
include ($GLOBAL_ADMIN_INC."scribe_footer.phtml"); |
3100 |
|
|
} |
3101 |
|
|
|
3102 |
|
|
|
3103 |
|
|
/********************************************************** |
3104 |
|
|
Function: parentIs |
3105 |
|
|
Author: Paul Bramscher |
3106 |
|
|
Last Modified: 04.23.2003 |
3107 |
|
|
*********************************************************** |
3108 |
|
|
Purpose: |
3109 |
|
|
Tests the supplied element to determine whether it has any |
3110 |
|
|
children. |
3111 |
|
|
**********************************************************/ |
3112 |
|
|
function parentIs($con, $element_id, $page_id){ |
3113 |
|
|
|
3114 |
|
|
// First initialize the number of children |
3115 |
|
|
$num_children = 0; |
3116 |
|
|
|
3117 |
|
|
$sql = "SELECT COUNT(*) AS num_children FROM element where page_id = " |
3118 |
|
|
. $page_id |
3119 |
|
|
. " AND parent_id = " |
3120 |
|
|
. $element_id; |
3121 |
|
|
$rs = mysql_query($sql, $con); |
3122 |
|
|
$row = mysql_fetch_array ($rs); |
3123 |
|
|
$num_children = $row["num_children"]; |
3124 |
|
|
|
3125 |
|
|
return $num_children; |
3126 |
|
|
} |
3127 |
|
|
|
3128 |
|
|
|
3129 |
|
|
/********************************************************** |
3130 |
|
|
Function: parentProbe |
3131 |
|
|
Author: Paul Bramscher |
3132 |
|
|
Last Modified: 11.20.2003 |
3133 |
|
|
*********************************************************** |
3134 |
|
|
Purpose: |
3135 |
|
|
Probes for a parent (if not a root-level element) of the |
3136 |
|
|
supplied element order. For example, what is the parent |
3137 |
|
|
of the Nth element on page M? The parent is calculated by |
3138 |
|
|
looking for the first previous element with an indent |
3139 |
|
|
(generation) level of precisely one less. |
3140 |
|
|
**********************************************************/ |
3141 |
|
|
function parentProbe($con, $page_id, $prev_element_order, $prev_indent_level){ |
3142 |
|
|
|
3143 |
|
|
// If the item's indent level is 0, it is its own parent. Return 0. |
3144 |
|
|
if ($prev_indent_level < 1) $parent_id = 0; |
3145 |
|
|
|
3146 |
|
|
// Otherwise, probe for the parent |
3147 |
|
|
else { |
3148 |
|
|
|
3149 |
|
|
/* Build the SQL. We know that the parent must appear earlier in the |
3150 |
|
|
list, so we limit the SQL to same or previous elements for efficiency. */ |
3151 |
|
|
|
3152 |
|
|
$sql = "SELECT * FROM element WHERE page_id = " |
3153 |
|
|
. $page_id |
3154 |
|
|
. " AND element_order < " |
3155 |
|
|
. $prev_element_order |
3156 |
|
|
. " ORDER BY element_order DESC"; |
3157 |
|
|
|
3158 |
|
|
// Found parent tag |
3159 |
|
|
$found = 0; |
3160 |
|
|
|
3161 |
|
|
$rs = mysql_query($sql, $con); |
3162 |
|
|
while (($row = mysql_fetch_array ($rs)) && $found == 0) { |
3163 |
|
|
|
3164 |
|
|
/* Cycle through the list, looking for the first item with an indent |
3165 |
|
|
of less. */ |
3166 |
|
|
$element_id = $row["element_id"]; |
3167 |
|
|
$indent_level = $row["indent_level"]; |
3168 |
|
|
|
3169 |
|
|
// Probe for parent. |
3170 |
|
|
if ($indent_level == ($prev_indent_level - 1)) { |
3171 |
|
|
$parent_id = $element_id; |
3172 |
|
|
$found = 1; |
3173 |
|
|
} |
3174 |
|
|
|
3175 |
|
|
} |
3176 |
|
|
} |
3177 |
|
|
|
3178 |
|
|
// Just in case there was a problem probing |
3179 |
|
|
if ($parent_id < 1) $parent_id = 0; |
3180 |
|
|
|
3181 |
|
|
return $parent_id; |
3182 |
|
|
} |
3183 |
|
|
|
3184 |
|
|
|
3185 |
|
|
/********************************************************** |
3186 |
|
|
Function: pasteElement |
3187 |
|
|
Author: Paul Bramscher |
3188 |
|
|
Last Modified: 04.23.2003 |
3189 |
|
|
*********************************************************** |
3190 |
|
|
Purpose: |
3191 |
|
|
Copies the user's copy/paste buffer onto the supplied |
3192 |
|
|
PageScribe/CourseScribe page at the specified position. |
3193 |
|
|
This sort of logic required a fair amount of coffee to |
3194 |
|
|
work out. |
3195 |
|
|
**********************************************************/ |
3196 |
|
|
function pasteElement($con, $element_order, $indent_level, $page_id, $position, $sess_staff_id) { |
3197 |
|
|
|
3198 |
|
|
// Debug mode: 0=off, 1=on. |
3199 |
|
|
$debug = 0; |
3200 |
|
|
|
3201 |
|
|
if ($debug == 1) { |
3202 |
|
|
printf("<BR><BR><h3>This will eventually paste your elements... Close, but not quite bug-free.</h3><BR>\n"); |
3203 |
|
|
printf("On page id: %d<BR>\n", $page_id); |
3204 |
|
|
printf("It will go in order #%d<BR>\n", $element_order); |
3205 |
|
|
printf("Afterwards you'll return to pos: %d<BR>\n", $position); |
3206 |
|
|
} |
3207 |
|
|
|
3208 |
|
|
|
3209 |
|
|
// First determine number of elements in buffer |
3210 |
|
|
$sql = "SELECT COUNT(*) as buffer_size FROM pastebuffer WHERE paste_staff_id = " |
3211 |
|
|
. $sess_staff_id |
3212 |
|
|
. " ORDER BY element_order"; |
3213 |
|
|
$rs = mysql_query($sql, $con); |
3214 |
|
|
$row = mysql_fetch_array ($rs); |
3215 |
|
|
$buffer_size = $row["buffer_size"]; |
3216 |
|
|
|
3217 |
|
|
if ($debug == 1) printf("Number of elements in buffer: %s<BR>\n", $buffer_size); |
3218 |
|
|
|
3219 |
|
|
|
3220 |
|
|
// Determine parent ID of first pasted element |
3221 |
|
|
$sql = "SELECT element_id from element WHERE page_id = " |
3222 |
|
|
. $page_id |
3223 |
|
|
. " AND element_order = " |
3224 |
|
|
. $element_order; |
3225 |
|
|
$rs = mysql_query($sql, $con); |
3226 |
|
|
$row = mysql_fetch_array ($rs); |
3227 |
|
|
$adjust_parent_id = $row["element_id"]; |
3228 |
|
|
|
3229 |
|
|
if ($debug == 1) printf("Parent of first element will be: %d<BR>", $adjust_parent_id); |
3230 |
|
|
|
3231 |
|
|
|
3232 |
|
|
// Next bump down all elements after the affected element |
3233 |
|
|
$sql = "UPDATE element set element_order = element_order + " |
3234 |
|
|
. $buffer_size |
3235 |
|
|
. " WHERE page_id = " |
3236 |
|
|
. $page_id |
3237 |
|
|
. " AND element_order >= " |
3238 |
|
|
. $element_order; |
3239 |
|
|
|
3240 |
|
|
if ($debug == 1) printf("bump down sql was: %s<BR>", $sql); |
3241 |
|
|
|
3242 |
|
|
|
3243 |
|
|
if (!mysql_query($sql, $con)){ |
3244 |
|
|
sql_err($con); |
3245 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3246 |
|
|
bailout(); |
3247 |
|
|
} |
3248 |
|
|
else { |
3249 |
|
|
mysql_query("UNLOCK TABLES", $con); |
3250 |
|
|
} |
3251 |
|
|
|
3252 |
|
|
// Select from the paste buffer |
3253 |
|
|
$sql = "SELECT * FROM pastebuffer WHERE paste_staff_id = " |
3254 |
|
|
. $sess_staff_id |
3255 |
|
|
. " ORDER BY element_order"; |
3256 |
|
|
$rs = mysql_query($sql, $con); |
3257 |
|
|
|
3258 |
|
|
// row count |
3259 |
|
|
$row_num = 0; |
3260 |
|
|
|
3261 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
3262 |
|
|
|
3263 |
|
|
// Load copy-paste buffer elements |
3264 |
|
|
$copy_indent_level = $row["indent_level"]; |
3265 |
|
|
$copy_parent_id = $row["parent_id"]; |
3266 |
|
|
$copy_resource_id = $row["resource_id"]; |
3267 |
|
|
$copy_location_id = $row["location_id"]; |
3268 |
|
|
$copy_service_id = $row["service_id"]; |
3269 |
|
|
$copy_staff_id = $row["staff_id"]; |
3270 |
|
|
$copy_subject_id = $row["subject_id"]; |
3271 |
|
|
$copy_label = $row["label"]; |
3272 |
|
|
$copy_label_url = $row["label_url"]; |
3273 |
|
|
$copy_element_descr = $row["element_descr"]; |
3274 |
|
|
$copy_element_size = $row["element_size"]; |
3275 |
|
|
$copy_element_order = $row["element_order"]; |
3276 |
|
|
|
3277 |
|
|
// Initialize as necessary -- all values must be set |
3278 |
|
|
if ($copy_indent_level <1) $copy_indent_level = 0; |
3279 |
|
|
if ($copy_parent_id < 1) $copy_parent_id = 0; |
3280 |
|
|
if ($copy_resource_id < 1) $copy_resource_id = "NULL"; |
3281 |
|
|
if ($copy_location_id < 1) $copy_location_id = "NULL"; |
3282 |
|
|
if ($copy_service_id < 1) $copy_service_id = "NULL"; |
3283 |
|
|
if ($copy_subject_id < 1) $copy_subject_id = "NULL"; |
3284 |
|
|
if ($copy_staff_id < 1) $copy_staff_id = "NULL"; |
3285 |
|
|
if ($copy_element_size < 1) $copy_element_size = "NULL"; |
3286 |
|
|
if ($copy_element_order < 1) $copy_element_order = 1; |
3287 |
|
|
|
3288 |
|
|
// Clean up text type entries for insertion |
3289 |
|
|
$copy_label = textInmySQL($copy_label); |
3290 |
|
|
$copy_label_url = textInmySQL($copy_label_url); |
3291 |
|
|
$copy_element_descr = textInmySQL($copy_element_descr); |
3292 |
|
|
|
3293 |
|
|
// Determine the New W0rld 0rder |
3294 |
|
|
$adjust_element_order = $element_order + $row_num; |
3295 |
|
|
|
3296 |
|
|
/* |
3297 |
|
|
Determine relative indent level. If this is the first item, |
3298 |
|
|
it will adopt the same indent level as the incoming indent level. |
3299 |
|
|
Everything else will be relative to it. |
3300 |
|
|
*/ |
3301 |
|
|
|
3302 |
|
|
if ($row_num == 0) { |
3303 |
|
|
$adjust_indent_level = $indent_level; |
3304 |
|
|
} |
3305 |
|
|
|
3306 |
|
|
// The copied item is a child |
3307 |
|
|
else if ($copy_indent_level > $last_copy_indent_level) $adjust_indent_level = $last_adjust_indent_level + 1; |
3308 |
|
|
|
3309 |
|
|
// The copied item was older |
3310 |
|
|
else if ($copy_indent_level < $last_copy_indent_level) $adjust_indent_level = $last_adjust_indent_level - 1; |
3311 |
|
|
|
3312 |
|
|
// Else the copied item was a sibling of the last inserted item |
3313 |
|
|
else $adjust_indent_level = $last_adjust_indent_level; |
3314 |
|
|
|
3315 |
|
|
// Determine parent for all but the first item |
3316 |
|
|
$adjust_parent_id = parentProbe($con, $page_id, $adjust_element_order, $adjust_indent_level); |
3317 |
|
|
|
3318 |
|
|
// Debugging |
3319 |
|
|
if ($debug == 1) { |
3320 |
|
|
printf("new position start indent:<BR>"); |
3321 |
|
|
printf("last copy indent: %d, ", $last_copy_indent_level); |
3322 |
|
|
printf("this copy indent: %d<BR>", $copy_indent_level); |
3323 |
|
|
printf("last adjust indent: %d, ", $last_adjust_indent_level); |
3324 |
|
|
printf("this adjust indent: %d<br>", $adjust_indent_level); |
3325 |
|
|
|
3326 |
|
|
} |
3327 |
|
|
|
3328 |
|
|
// Build the paste SQL |
3329 |
|
|
$p_sql = "INSERT INTO element ( |
3330 |
|
|
page_id, |
3331 |
|
|
indent_level, |
3332 |
|
|
parent_id, |
3333 |
|
|
resource_id, |
3334 |
|
|
location_id, |
3335 |
|
|
service_id, |
3336 |
|
|
staff_id, |
3337 |
|
|
subject_id, |
3338 |
|
|
label, |
3339 |
|
|
label_url, |
3340 |
|
|
element_descr, |
3341 |
|
|
element_size, |
3342 |
|
|
element_order) VALUES (" |
3343 |
|
|
. $page_id |
3344 |
|
|
. ", " |
3345 |
|
|
. $adjust_indent_level |
3346 |
|
|
. ", " |
3347 |
|
|
. $adjust_parent_id |
3348 |
|
|
. ", " |
3349 |
|
|
. $copy_resource_id |
3350 |
|
|
. ", " |
3351 |
|
|
. $copy_location_id |
3352 |
|
|
. ", " |
3353 |
|
|
. $copy_service_id |
3354 |
|
|
. ", " |
3355 |
|
|
. $copy_staff_id |
3356 |
|
|
. ", " |
3357 |
|
|
. $copy_subject_id |
3358 |
|
|
. ", '" |
3359 |
|
|
. $copy_label |
3360 |
|
|
. "', '" |
3361 |
|
|
. $copy_label_url |
3362 |
|
|
. "', '" |
3363 |
|
|
. $copy_element_descr |
3364 |
|
|
. "', " |
3365 |
|
|
. $copy_element_size |
3366 |
|
|
. ", " |
3367 |
|
|
. $adjust_element_order |
3368 |
|
|
. ")"; |
3369 |
|
|
|
3370 |
|
|
// Debugging |
3371 |
|
|
if ($debug == 1) printf("insert sql was: %s<BR>\n", $p_sql); |
3372 |
|
|
|
3373 |
|
|
// Perform the write |
3374 |
|
|
mysql_query ("LOCK TABLE element WRITE", $con); |
3375 |
|
|
if (!mysql_query($p_sql, $con)){ |
3376 |
|
|
sql_err($con); |
3377 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3378 |
|
|
bailout(); |
3379 |
|
|
} |
3380 |
|
|
else { |
3381 |
|
|
$paste_element_id = mysql_insert_id($con); |
3382 |
|
|
mysql_query("UNLOCK TABLES", $con); |
3383 |
|
|
} |
3384 |
|
|
|
3385 |
|
|
// Debugging |
3386 |
|
|
if ($debug == 1) { |
3387 |
|
|
printf("insert sql was: %s<BR>\n", $p_sql); |
3388 |
|
|
printf("<b>inserted id was: %d</b><Br>\n", $paste_element_id); |
3389 |
|
|
printf("<b>adjust parent was: %d</b><Br>\n", $adjust_parent_id); |
3390 |
|
|
printf("<b>adjust order was: %d</b><Br><BR>\n", $adjust_element_order); |
3391 |
|
|
} |
3392 |
|
|
|
3393 |
|
|
// Track some variables |
3394 |
|
|
$last_copy_indent_level = $copy_indent_level; |
3395 |
|
|
$last_adjust_indent_level = $adjust_indent_level; |
3396 |
|
|
$row_num++; |
3397 |
|
|
|
3398 |
|
|
} // Done pasting all elements |
3399 |
|
|
|
3400 |
|
|
if ($debug == 0) header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
3401 |
|
|
} |
3402 |
|
|
|
3403 |
|
|
|
3404 |
|
|
/********************************************************** |
3405 |
|
|
Function: populateGenArray |
3406 |
|
|
Author: Paul Bramscher |
3407 |
|
|
Last Modified: 06.30.2003 |
3408 |
|
|
*********************************************************** |
3409 |
|
|
Purpose: |
3410 |
|
|
Builds an array from 0 (unused empty placeholder) to N, |
3411 |
|
|
where N is the number of elements on the page, ordered by |
3412 |
|
|
the element order. Each element in the array holds the |
3413 |
|
|
indent level (generation) of the page element. The array |
3414 |
|
|
is created outside the function. This function modifies |
3415 |
|
|
and returns it. |
3416 |
|
|
**********************************************************/ |
3417 |
|
|
function populateGenArray($con, &$genArray, $page_id) { |
3418 |
|
|
|
3419 |
|
|
// Initialize the 0th (unused) array element |
3420 |
|
|
$genArray[0] = 0; |
3421 |
|
|
|
3422 |
|
|
// Load the page element structure into the array |
3423 |
|
|
$sql = "SELECT element_order, indent_level |
3424 |
|
|
FROM element |
3425 |
|
|
WHERE page_id = " |
3426 |
|
|
. $page_id |
3427 |
|
|
. " ORDER BY element_order"; |
3428 |
|
|
|
3429 |
|
|
$rs = mysql_query($sql, $con); |
3430 |
|
|
|
3431 |
|
|
// Start populating generation array subscript [1] |
3432 |
|
|
$rowcount = 1; |
3433 |
|
|
|
3434 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
3435 |
|
|
|
3436 |
|
|
// Fetch values |
3437 |
|
|
$element_order = $row["element_order"]; |
3438 |
|
|
$indent_level = $row["indent_level"]; |
3439 |
|
|
|
3440 |
|
|
// Just in case |
3441 |
|
|
if ($indent_level < 0) $indent_level = 0; |
3442 |
|
|
if ($element_order < 0) $element_order = 0; |
3443 |
|
|
|
3444 |
|
|
array_push($genArray, $indent_level); |
3445 |
|
|
|
3446 |
|
|
$rowcount++; |
3447 |
|
|
} |
3448 |
|
|
|
3449 |
|
|
return $genArray; |
3450 |
|
|
} |
3451 |
|
|
|
3452 |
|
|
|
3453 |
|
|
/********************************************************** |
3454 |
|
|
Function: scribePublish |
3455 |
|
|
Author: Paul Bramscher |
3456 |
|
|
Last Modified: 04.23.2003 |
3457 |
|
|
*********************************************************** |
3458 |
|
|
Purpose: |
3459 |
|
|
Performs the PageScribe/CourseLib page publish functionality. |
3460 |
|
|
Note that in addition to flipping the published field in the |
3461 |
|
|
page table to 1 (TRUE), it also opens a socket to the dynamic |
3462 |
|
|
URL for the page, sucks down all page source in 4k blocks, |
3463 |
|
|
then concatenates them into the pageHTML field in the page |
3464 |
|
|
table. This creates a static snapshot of the page, which |
3465 |
|
|
requires only a single SQL to dump the entire output of the |
3466 |
|
|
page. Use that URL (displayed on the scribe.phtml authoring |
3467 |
|
|
page for published pages) if there are concerns about page load |
3468 |
|
|
performance issues with the fully dynamic version. |
3469 |
|
|
**********************************************************/ |
3470 |
|
|
function scribePublish($con, $page_id) { |
3471 |
|
|
|
3472 |
|
|
|
3473 |
|
|
/* |
3474 |
|
|
First determine whether the current page is (a) a courselib page and |
3475 |
|
|
(b) is missing a course subject/department. If so, this page cannot |
3476 |
|
|
be published. |
3477 |
|
|
*/ |
3478 |
|
|
|
3479 |
|
|
// Initialize |
3480 |
|
|
$coursesub_id = 0; |
3481 |
|
|
$pagetype_id = 0; |
3482 |
|
|
|
3483 |
|
|
// Build the SQL |
3484 |
|
|
$sql = "SELECT |
3485 |
|
|
c.coursesub_id, |
3486 |
|
|
p.pagetype_id |
3487 |
|
|
FROM course c, page p |
3488 |
|
|
WHERE p.page_id = " |
3489 |
|
|
. $page_id |
3490 |
|
|
. " AND p.page_id = c.page_id"; |
3491 |
|
|
|
3492 |
|
|
// printf("sql was: %s", $sql); |
3493 |
|
|
|
3494 |
|
|
$rs = mysql_query($sql, $con); |
3495 |
|
|
$row = mysql_fetch_array ($rs); |
3496 |
|
|
$coursesub_id = $row["coursesub_id"]; |
3497 |
|
|
$pagetype_id = $row["pagetype_id"]; |
3498 |
|
|
|
3499 |
|
|
// This was a courselib page missing a course/department subject |
3500 |
|
|
// Note that coursesub_id of 1 = N/A, so we don't want this value either. |
3501 |
|
|
if ($coursesub_id < 2 && $pagetype_id == 3) { |
3502 |
|
|
|
3503 |
|
|
// Load globals |
3504 |
|
|
include("global_vars.php"); |
3505 |
|
|
|
3506 |
|
|
// Include the page header |
3507 |
|
|
include ($GLOBAL_ADMIN_INC."scribe_header.phtml"); |
3508 |
|
|
|
3509 |
|
|
// HTML headers |
3510 |
|
|
printf("<html>\n"); |
3511 |
|
|
printf("<head>\n"); |
3512 |
|
|
printf("<title>%s: Missing Information</title>\n", $GLOBAL_SYS_NAME); |
3513 |
|
|
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS); |
3514 |
|
|
printf("</head>"); |
3515 |
|
|
|
3516 |
|
|
// Draw form heading |
3517 |
|
|
printf("<center><h3>%s: Missing Information</h3>\n", $GLOBAL_SYS_NAME); |
3518 |
|
|
|
3519 |
|
|
// Table |
3520 |
|
|
printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">\n"); |
3521 |
|
|
printf("<tr><td><br>\n"); |
3522 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
3523 |
|
|
printf("CourseLib pages may not be published without a course designator. "); |
3524 |
|
|
printf("This is a required field -- please go back and select a course designator. "); |
3525 |
|
|
printf("If one does not apply, this should probably be a PageScribe page instead.<BR><BR>\n"); |
3526 |
|
|
|
3527 |
|
|
printf("</td></tr></table>\n"); |
3528 |
|
|
|
3529 |
|
|
|
3530 |
|
|
// Link to return to admin console |
3531 |
|
|
adminReturn(""); |
3532 |
|
|
|
3533 |
|
|
printf("</center>\n"); |
3534 |
|
|
|
3535 |
|
|
// Include the footer |
3536 |
|
|
include ($GLOBAL_ADMIN_INC."scribe_footer.phtml"); |
3537 |
|
|
} |
3538 |
|
|
|
3539 |
|
|
// Page may be published |
3540 |
|
|
else { |
3541 |
|
|
|
3542 |
|
|
/* |
3543 |
|
|
Uncomment this portion if the static page functionality is desired. |
3544 |
|
|
PFB: 06-23-2003 |
3545 |
|
|
|
3546 |
|
|
// Load globals |
3547 |
|
|
include ("global_vars.php"); |
3548 |
|
|
|
3549 |
|
|
// Test URL to snapshot |
3550 |
|
|
$page_loc = $GLOBAL_SCRIBE_URL . "page.phtml?page_id=" . $page_id; |
3551 |
|
|
|
3552 |
|
|
// Clear out existing published information |
3553 |
|
|
// This is important, also, to get rid of a NULL value before performing a CONCAT below. |
3554 |
|
|
$sql = "UPDATE page set pageHTML = '' WHERE page_id = " . $page_id; |
3555 |
|
|
|
3556 |
|
|
if (!mysql_query($sql, $con)){ |
3557 |
|
|
sql_err($con); |
3558 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3559 |
|
|
bailout(); |
3560 |
|
|
} // bad write |
3561 |
|
|
else { |
3562 |
|
|
mysql_query("UNLOCK TABLES", $con); |
3563 |
|
|
} |
3564 |
|
|
|
3565 |
|
|
// Open the filepointer for a screen dump |
3566 |
|
|
$fp = fopen ($page_loc, "r"); |
3567 |
|
|
|
3568 |
|
|
// Open failed |
3569 |
|
|
if (!$fp) { |
3570 |
|
|
echo "$errstr ($errno)<br>\n"; |
3571 |
|
|
} |
3572 |
|
|
// Continue as long as there's data |
3573 |
|
|
else { |
3574 |
|
|
fputs ($fp, "GET / HTTP/1.0\r\nHost: %s\r\n\r\n", $page_loc); |
3575 |
|
|
while (!feof($fp)) { |
3576 |
|
|
|
3577 |
|
|
// Fetch the stream |
3578 |
|
|
$iostream = fgets ($fp,4096); |
3579 |
|
|
|
3580 |
|
|
// Replace single quotes with two single quotes |
3581 |
|
|
$iostream_fix = ereg_replace("'","''",$iostream); |
3582 |
|
|
|
3583 |
|
|
// Concatenate the stream into the pageHTML field |
3584 |
|
|
$sql = "UPDATE page set pageHTML = CONCAT(pageHTML,'" . $iostream_fix . "') WHERE page_id = " . $page_id; |
3585 |
|
|
|
3586 |
|
|
if (!mysql_query($sql, $con)){ |
3587 |
|
|
sql_err($con); |
3588 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3589 |
|
|
printf("sql was: %s<BR>", $sql); |
3590 |
|
|
bailout(); |
3591 |
|
|
} // bad write |
3592 |
|
|
else { |
3593 |
|
|
mysql_query("UNLOCK TABLES", $con); |
3594 |
|
|
} // good write |
3595 |
|
|
} |
3596 |
|
|
|
3597 |
|
|
// Close up the open file pointer |
3598 |
|
|
fclose ($fp); |
3599 |
|
|
|
3600 |
|
|
// Set published flag to 1 |
3601 |
|
|
$sql = "UPDATE page set published = '1' WHERE page_id = " . $page_id; |
3602 |
|
|
|
3603 |
|
|
if (!mysql_query($sql, $con)){ |
3604 |
|
|
sql_err($con); |
3605 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3606 |
|
|
bailout(); |
3607 |
|
|
} // bad write |
3608 |
|
|
else { |
3609 |
|
|
mysql_query("UNLOCK TABLES", $con); |
3610 |
|
|
|
3611 |
|
|
} // good write |
3612 |
|
|
|
3613 |
|
|
} // end open file pointer |
3614 |
|
|
|
3615 |
|
|
end of comment-out */ |
3616 |
|
|
|
3617 |
|
|
/********************************************************************* |
3618 |
|
|
** Comment out this portion if static page functionality is desired ** |
3619 |
|
|
*********************************************************************/ |
3620 |
|
|
|
3621 |
|
|
// Set published flag to 1 |
3622 |
|
|
$sql = "UPDATE page set published = '1' WHERE page_id = " . $page_id; |
3623 |
|
|
|
3624 |
|
|
if (!mysql_query($sql, $con)){ |
3625 |
|
|
sql_err($con); |
3626 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3627 |
|
|
bailout(); |
3628 |
|
|
} // bad write |
3629 |
|
|
else { |
3630 |
|
|
mysql_query("UNLOCK TABLES", $con); |
3631 |
|
|
|
3632 |
|
|
} // good write |
3633 |
|
|
|
3634 |
|
|
/*********************** |
3635 |
|
|
** End of comment-out ** |
3636 |
|
|
***********************/ |
3637 |
|
|
|
3638 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
3639 |
|
|
|
3640 |
|
|
} |
3641 |
|
|
|
3642 |
|
|
} // end function |
3643 |
|
|
|
3644 |
|
|
|
3645 |
|
|
/********************************************************** |
3646 |
|
|
Function: scribeUnpublish |
3647 |
|
|
Author: Paul Bramscher |
3648 |
|
|
Last Modified: 04.23.2003 |
3649 |
|
|
*********************************************************** |
3650 |
|
|
Purpose: |
3651 |
|
|
Unpublishes the supplied page id. Note that we set both |
3652 |
|
|
the pageHTML to NULL and flip the published flag back to |
3653 |
|
|
0 (FALSE). |
3654 |
|
|
**********************************************************/ |
3655 |
|
|
function scribeUnpublish($con, $page_id) { |
3656 |
|
|
|
3657 |
|
|
// Build the SQL |
3658 |
|
|
$sql = "UPDATE page SET pageHTML = NULL, published = '0' WHERE page_id =" . $page_id; |
3659 |
|
|
|
3660 |
|
|
if (!mysql_query ($sql, $con)){ |
3661 |
|
|
sql_err($sql); |
3662 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3663 |
|
|
bailout(); |
3664 |
|
|
} |
3665 |
|
|
else { |
3666 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3667 |
|
|
} |
3668 |
|
|
|
3669 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
3670 |
|
|
} |
3671 |
|
|
|
3672 |
|
|
|
3673 |
|
|
/********************************************************** |
3674 |
|
|
Function: siblingElderProbe |
3675 |
|
|
Author: Paul Bramscher |
3676 |
|
|
Last Modified: 04.23.2003 |
3677 |
|
|
*********************************************************** |
3678 |
|
|
Purpose: |
3679 |
|
|
Tests the supplied element to see whether it has an elder |
3680 |
|
|
sibling. If so, then this element (and descendants) may |
3681 |
|
|
be moved up a position and the up arrow becomes available |
3682 |
|
|
on the PageScribe/CourseLib authoring page. |
3683 |
|
|
**********************************************************/ |
3684 |
|
|
function siblingElderProbe($con, $page_id, $place_array){ |
3685 |
|
|
|
3686 |
|
|
// Break apart place array |
3687 |
|
|
$prev_element_id = $place_array[0]; |
3688 |
|
|
$prev_element_order = $place_array[1]; |
3689 |
|
|
$prev_indent_level = $place_array[2]; |
3690 |
|
|
$prev_parent_id = $place_array[3]; |
3691 |
|
|
$prev_position = $place_array[4]; |
3692 |
|
|
|
3693 |
|
|
// Error checking |
3694 |
|
|
if ($prev_indent_level < 1) $prev_indent_level = 0; |
3695 |
|
|
if ($prev_parent_id < 1) $prev_parent_id = 0; |
3696 |
|
|
if ($prev_element_order < 1) $prev_element_order = 0; |
3697 |
|
|
|
3698 |
|
|
// ID of elder sibling |
3699 |
|
|
$element_id = 0; |
3700 |
|
|
|
3701 |
|
|
$sql = "SELECT element_id, element_order FROM element WHERE page_id = " |
3702 |
|
|
. $page_id |
3703 |
|
|
. " AND indent_level = " |
3704 |
|
|
. $prev_indent_level |
3705 |
|
|
. " AND parent_id = " |
3706 |
|
|
. $prev_parent_id |
3707 |
|
|
. " AND element_order < " |
3708 |
|
|
. $prev_element_order |
3709 |
|
|
. " ORDER BY element_order DESC LIMIT 1"; |
3710 |
|
|
|
3711 |
|
|
$rs = mysql_query($sql, $con); |
3712 |
|
|
$row = mysql_fetch_array ($rs); |
3713 |
|
|
$element_id = $row["element_id"]; |
3714 |
|
|
|
3715 |
|
|
return $element_id; |
3716 |
|
|
} |
3717 |
|
|
|
3718 |
|
|
|
3719 |
|
|
/********************************************************** |
3720 |
|
|
Function: siblingYoungerProbe |
3721 |
|
|
Author: Paul Bramscher |
3722 |
|
|
Last Modified: 04.23.2003 |
3723 |
|
|
*********************************************************** |
3724 |
|
|
Purpose: |
3725 |
|
|
Tests the supplied element to see whether it has a younger |
3726 |
|
|
sibling. If so, then this element (and descendants) may |
3727 |
|
|
be moved down a position and the down arrow becomes available |
3728 |
|
|
on the PageScribe/CourseLib authoring page. |
3729 |
|
|
**********************************************************/ |
3730 |
|
|
function siblingYoungerProbe($con, $page_id, $place_array){ |
3731 |
|
|
|
3732 |
|
|
// Break apart place array |
3733 |
|
|
$prev_element_id = $place_array[0]; |
3734 |
|
|
$prev_element_order = $place_array[1]; |
3735 |
|
|
$prev_indent_level = $place_array[2]; |
3736 |
|
|
$prev_parent_id = $place_array[3]; |
3737 |
|
|
$prev_position = $place_array[4]; |
3738 |
|
|
|
3739 |
|
|
// Error checking |
3740 |
|
|
if ($prev_indent_level < 1) $prev_indent_level = 0; |
3741 |
|
|
if ($prev_parent_id < 1) $prev_parent_id = 0; |
3742 |
|
|
if ($prev_element_order < 1) $prev_element_order = 0; |
3743 |
|
|
|
3744 |
|
|
// Younger sibling ID |
3745 |
|
|
$element_id = 0; |
3746 |
|
|
|
3747 |
|
|
$sql = "SELECT element_id, element_order FROM element WHERE page_id = " |
3748 |
|
|
. $page_id |
3749 |
|
|
. " AND indent_level = " |
3750 |
|
|
. $prev_indent_level |
3751 |
|
|
. " AND parent_id = " |
3752 |
|
|
. $prev_parent_id |
3753 |
|
|
. " AND element_order > " |
3754 |
|
|
. $prev_element_order |
3755 |
|
|
. " ORDER BY element_order LIMIT 1"; |
3756 |
|
|
|
3757 |
|
|
$rs = mysql_query($sql, $con); |
3758 |
|
|
$row = mysql_fetch_array ($rs); |
3759 |
|
|
$element_id = $row["element_id"]; |
3760 |
|
|
|
3761 |
|
|
return $element_id; |
3762 |
|
|
|
3763 |
|
|
} |
3764 |
|
|
|
3765 |
|
|
|
3766 |
|
|
/********************************************************** |
3767 |
|
|
Function: sibProbeElder |
3768 |
|
|
Author: Paul Bramscher |
3769 |
|
|
Last Modified: 06.30.2003 |
3770 |
|
|
*********************************************************** |
3771 |
|
|
Purpose: |
3772 |
|
|
Probes the generational array for an elder sibling. If |
3773 |
|
|
found, the function returns TRUE (1). Note that there is |
3774 |
|
|
an optimizing exit condition, namely that if the probed |
3775 |
|
|
element's indent level is less than the current indent |
3776 |
|
|
level, we've already reached a parent and thus quit |
3777 |
|
|
probing early. |
3778 |
|
|
**********************************************************/ |
3779 |
|
|
function sibProbeElder($genArray, $page_id, $place_array){ |
3780 |
|
|
|
3781 |
|
|
// Break apart place array |
3782 |
|
|
$element_id = $place_array[0]; |
3783 |
|
|
$element_order = $place_array[1]; |
3784 |
|
|
$indent_level = $place_array[2]; |
3785 |
|
|
//$parent_id = $place_array[3]; |
3786 |
|
|
//$position = $place_array[4]; |
3787 |
|
|
|
3788 |
|
|
// Initialize finding an elder sibling to FALSE |
3789 |
|
|
$elder = 0; |
3790 |
|
|
|
3791 |
|
|
if ($element_order > 1) { |
3792 |
|
|
|
3793 |
|
|
// Initialize more things |
3794 |
|
|
$probe = $element_order - 1; |
3795 |
|
|
$continue = 1; |
3796 |
|
|
|
3797 |
|
|
while ($elder == 0 && $continue == 1 && $probe >= 1) { |
3798 |
|
|
|
3799 |
|
|
if ($genArray[$probe] == $indent_level) $elder = 1; |
3800 |
|
|
else if ($genArray[$probe] < $indent_level) $continue = 0; |
3801 |
|
|
|
3802 |
|
|
$probe--; |
3803 |
|
|
} |
3804 |
|
|
} |
3805 |
|
|
|
3806 |
|
|
return $elder; |
3807 |
|
|
} |
3808 |
|
|
|
3809 |
|
|
|
3810 |
|
|
/********************************************************** |
3811 |
|
|
Function: sibProbeYounger |
3812 |
|
|
Author: Paul Bramscher |
3813 |
|
|
Last Modified: 06.30.2003 |
3814 |
|
|
*********************************************************** |
3815 |
|
|
Purpose: |
3816 |
|
|
Probes the generational array for a younger sibling. If |
3817 |
|
|
found, the function returns TRUE (1). Note that there is |
3818 |
|
|
an optimizing exit condition, namely that if the probed |
3819 |
|
|
element's indent level is less than the current indent |
3820 |
|
|
level, we've already reached a parent (of a separate nuclear |
3821 |
|
|
family) and thus quit probing early. |
3822 |
|
|
**********************************************************/ |
3823 |
|
|
function sibProbeYounger($genArray, $page_id, $place_array){ |
3824 |
|
|
|
3825 |
|
|
// Break apart place array |
3826 |
|
|
$element_id = $place_array[0]; |
3827 |
|
|
$element_order = $place_array[1]; |
3828 |
|
|
$indent_level = $place_array[2]; |
3829 |
|
|
//$parent_id = $place_array[3]; |
3830 |
|
|
//$position = $place_array[4]; |
3831 |
|
|
|
3832 |
|
|
// Initialize finding a younger sibling to FALSE |
3833 |
|
|
$younger = 0; |
3834 |
|
|
|
3835 |
|
|
if ($element_order < sizeof($genArray)) { |
3836 |
|
|
|
3837 |
|
|
// Initialize more things |
3838 |
|
|
$probe = $element_order + 1; |
3839 |
|
|
$continue = 1; |
3840 |
|
|
|
3841 |
|
|
while ($younger == 0 && $continue == 1 && $probe <= sizeof($genArray)) { |
3842 |
|
|
|
3843 |
|
|
if ($genArray[$probe] == $indent_level) $younger = 1; |
3844 |
|
|
else if ($genArray[$probe] < $indent_level) $continue = 0; |
3845 |
|
|
|
3846 |
|
|
$probe++; |
3847 |
|
|
} |
3848 |
|
|
} |
3849 |
|
|
|
3850 |
|
|
return $younger; |
3851 |
|
|
} |
3852 |
|
|
|
3853 |
|
|
|
3854 |
|
|
/********************************************************** |
3855 |
|
|
Function: toggleTOCDisplay |
3856 |
|
|
Author: Paul Bramscher |
3857 |
|
|
Last Modified: 04.24.2003 |
3858 |
|
|
*********************************************************** |
3859 |
|
|
Purpose: |
3860 |
|
|
Flips the flag to 1 (TRUE) or 0 (FALSE) for the display |
3861 |
|
|
of the PageScribe/CourseLib table of contents. This |
3862 |
|
|
ToC is autogenerated and includes the root elements on the |
3863 |
|
|
page. |
3864 |
|
|
**********************************************************/ |
3865 |
|
|
function toggleTOCDisplay($con, $display_toc, $page_id) { |
3866 |
|
|
|
3867 |
|
|
$sql = "UPDATE page SET display_toc = " |
3868 |
|
|
. $display_toc |
3869 |
|
|
. " WHERE page_id = " |
3870 |
|
|
. $page_id; |
3871 |
|
|
|
3872 |
|
|
// Failed |
3873 |
|
|
if (!mysql_query ($sql, $con)){ |
3874 |
|
|
sql_err($sql); |
3875 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3876 |
|
|
bailout(); |
3877 |
|
|
} |
3878 |
|
|
|
3879 |
|
|
// Succeeded |
3880 |
|
|
else { |
3881 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3882 |
|
|
} |
3883 |
|
|
|
3884 |
|
|
// Call the PageScribe page back |
3885 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
3886 |
|
|
} |
3887 |
|
|
|
3888 |
|
|
|
3889 |
|
|
/********************************************************** |
3890 |
|
|
Function: toggleTOCWrap |
3891 |
|
|
Author: Paul Bramscher |
3892 |
|
|
Last Modified: 12.15.2003 |
3893 |
|
|
*********************************************************** |
3894 |
|
|
Purpose: |
3895 |
|
|
Flips the flag to 1 (TRUE) or 0 (FALSE) for the wrapping |
3896 |
|
|
of the PageScribe/CourseLib table of contents. This |
3897 |
|
|
ToC is autogenerated and includes the root elements on the |
3898 |
|
|
page. The wrap results in a two-column view of the ToC. |
3899 |
|
|
**********************************************************/ |
3900 |
|
|
function toggleTOCWrap($con, $page_id, $wrap_toc) { |
3901 |
|
|
|
3902 |
|
|
$sql = "UPDATE page SET wrap_toc = " |
3903 |
|
|
. $wrap_toc |
3904 |
|
|
. " WHERE page_id = " |
3905 |
|
|
. $page_id; |
3906 |
|
|
|
3907 |
|
|
// Failed |
3908 |
|
|
if (!mysql_query ($sql, $con)){ |
3909 |
|
|
sql_err($sql); |
3910 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3911 |
|
|
bailout(); |
3912 |
|
|
} |
3913 |
|
|
|
3914 |
|
|
// Succeeded |
3915 |
|
|
else { |
3916 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3917 |
|
|
} |
3918 |
|
|
|
3919 |
|
|
// Call the PageScribe page back |
3920 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
3921 |
|
|
} |
3922 |
|
|
|
3923 |
|
|
|
3924 |
|
|
/********************************************************** |
3925 |
|
|
Function: toggleUpDisplay |
3926 |
|
|
Author: Paul Bramscher |
3927 |
|
|
Last Modified: 04.24.2003 |
3928 |
|
|
*********************************************************** |
3929 |
|
|
Purpose: |
3930 |
|
|
Toggles the display of the [return to top] text on the |
3931 |
|
|
supplied page id before each new root element. If there |
3932 |
|
|
is currently no value in the up_text field (i.e. the user |
3933 |
|
|
has never saved anything previously), then this function |
3934 |
|
|
will also insert a preliminary value as passed from the |
3935 |
|
|
default string setting on the scribe authoring page. |
3936 |
|
|
**********************************************************/ |
3937 |
|
|
function toggleUpDisplay($con, $display_up, $page_id, $up_text) { |
3938 |
|
|
|
3939 |
|
|
// Collect some data on the current up text |
3940 |
|
|
$current_up_text = lookupField($con, "page", "page_id", $page_id, "up_text"); |
3941 |
|
|
|
3942 |
|
|
// Toggle the flag to TRUE or FALSE |
3943 |
|
|
$sql = "UPDATE page SET display_up = " |
3944 |
|
|
. $display_up |
3945 |
|
|
. " WHERE page_id = " |
3946 |
|
|
. $page_id; |
3947 |
|
|
|
3948 |
|
|
// Failed |
3949 |
|
|
if (!mysql_query ($sql, $con)){ |
3950 |
|
|
sql_err($sql); |
3951 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3952 |
|
|
bailout(); |
3953 |
|
|
} |
3954 |
|
|
|
3955 |
|
|
// Succeeded |
3956 |
|
|
else { |
3957 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3958 |
|
|
} |
3959 |
|
|
|
3960 |
|
|
/* If the current up_text is blank, and the user has |
3961 |
|
|
toggled ON, then insert the default wording. */ |
3962 |
|
|
if ($display_up == 1 && strlen($current_up_text) < 1) { |
3963 |
|
|
$sql = "UPDATE page SET up_text = '" |
3964 |
|
|
. $up_text |
3965 |
|
|
. "' WHERE page_id = " |
3966 |
|
|
. $page_id; |
3967 |
|
|
|
3968 |
|
|
// Failed |
3969 |
|
|
if (!mysql_query ($sql, $con)){ |
3970 |
|
|
sql_err($sql); |
3971 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3972 |
|
|
bailout(); |
3973 |
|
|
} |
3974 |
|
|
|
3975 |
|
|
// Succeeded |
3976 |
|
|
else { |
3977 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
3978 |
|
|
} |
3979 |
|
|
} |
3980 |
|
|
|
3981 |
|
|
// Call the PageScribe page back |
3982 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
3983 |
|
|
} |
3984 |
|
|
|
3985 |
|
|
|
3986 |
|
|
/********************************************************** |
3987 |
|
|
Function: toggleUpText |
3988 |
|
|
Author: Paul Bramscher |
3989 |
|
|
Last Modified: 04.24.2003 |
3990 |
|
|
*********************************************************** |
3991 |
|
|
Purpose: |
3992 |
|
|
Changes the [return to top] text for the supplied page id, |
3993 |
|
|
on a given page id before each new root element. |
3994 |
|
|
**********************************************************/ |
3995 |
|
|
function toggleUpText($con, $page_id, $up_text) { |
3996 |
|
|
|
3997 |
|
|
// Clean the string |
3998 |
|
|
$up_text = textInmySQL($up_text); |
3999 |
|
|
|
4000 |
|
|
// Make the change |
4001 |
|
|
$sql = "UPDATE page SET up_text = '" |
4002 |
|
|
. $up_text |
4003 |
|
|
. "' WHERE page_id = " |
4004 |
|
|
. $page_id; |
4005 |
|
|
|
4006 |
|
|
// Failed |
4007 |
|
|
if (!mysql_query ($sql, $con)){ |
4008 |
|
|
sql_err($sql); |
4009 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4010 |
|
|
bailout(); |
4011 |
|
|
} |
4012 |
|
|
|
4013 |
|
|
// Succeeded |
4014 |
|
|
else { |
4015 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4016 |
|
|
} |
4017 |
|
|
|
4018 |
|
|
// Call the PageScribe page back |
4019 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
4020 |
|
|
} |
4021 |
|
|
|
4022 |
|
|
|
4023 |
|
|
/********************************************************** |
4024 |
|
|
Function: toggleURLDisplay |
4025 |
|
|
Author: Paul Bramscher |
4026 |
|
|
Last Modified: 04.24.2003 |
4027 |
|
|
*********************************************************** |
4028 |
|
|
Purpose: |
4029 |
|
|
This function updates the display_urls field in the |
4030 |
|
|
page table. When set to 1 (TRUE), URL's are diplayed |
4031 |
|
|
during the PageScribe edit mode. |
4032 |
|
|
|
4033 |
|
|
Previously, we used this flag to create pages for which the |
4034 |
|
|
URL's ought to be displayed or surpressed to the user |
4035 |
|
|
(not merely the page author). However, with the creation |
4036 |
|
|
of the "printer friendly version" of a page, which |
4037 |
|
|
automatically displays URL's, the utility here is lessened. |
4038 |
|
|
Still, it might be useful for an author to see his/her |
4039 |
|
|
URL's in edit mode for a quick visual inspection without |
4040 |
|
|
having to resort to the user interface. |
4041 |
|
|
**********************************************************/ |
4042 |
|
|
function toggleURLDisplay($con, $display_urls, $page_id) { |
4043 |
|
|
|
4044 |
|
|
// Build the SQL |
4045 |
|
|
$sql = "UPDATE page SET display_urls = " |
4046 |
|
|
. $display_urls |
4047 |
|
|
. " WHERE page_id = " |
4048 |
|
|
. $page_id; |
4049 |
|
|
|
4050 |
|
|
// Failed |
4051 |
|
|
if (!mysql_query ($sql, $con)){ |
4052 |
|
|
sql_err($sql); |
4053 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4054 |
|
|
bailout(); |
4055 |
|
|
} |
4056 |
|
|
|
4057 |
|
|
// Succeeded |
4058 |
|
|
else { |
4059 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4060 |
|
|
} |
4061 |
|
|
|
4062 |
|
|
// Call the PageScribe page back |
4063 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
4064 |
|
|
} |
4065 |
|
|
|
4066 |
|
|
/********************************************************** |
4067 |
|
|
Function: updatePageDebug |
4068 |
|
|
Author: Paul Bramscher |
4069 |
|
|
Last Modified: 04.24.2003 |
4070 |
|
|
*********************************************************** |
4071 |
|
|
Purpose: |
4072 |
|
|
Updates the flag for page debug to 1 (TRUE) or 0 (FALSE). |
4073 |
|
|
**********************************************************/ |
4074 |
|
|
function updatePageDebug($con, $page_debug, $page_id) { |
4075 |
|
|
|
4076 |
|
|
$sql = "UPDATE page SET page_debug = " |
4077 |
|
|
. $page_debug |
4078 |
|
|
. " WHERE page_id = " |
4079 |
|
|
. $page_id; |
4080 |
|
|
|
4081 |
|
|
// Failed |
4082 |
|
|
if (!mysql_query ($sql, $con)){ |
4083 |
|
|
sql_err($sql); |
4084 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4085 |
|
|
bailout(); |
4086 |
|
|
} |
4087 |
|
|
|
4088 |
|
|
// Succeeded |
4089 |
|
|
else { |
4090 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4091 |
|
|
} |
4092 |
|
|
|
4093 |
|
|
// Call the PageScribe page back |
4094 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
4095 |
|
|
} |
4096 |
|
|
|
4097 |
|
|
|
4098 |
|
|
/********************************************************** |
4099 |
|
|
Function: updatePageHeader |
4100 |
|
|
Author: Paul Bramscher |
4101 |
|
|
Last Modified: 01.27.2004 |
4102 |
|
|
*********************************************************** |
4103 |
|
|
Purpose: |
4104 |
|
|
Updates the supplie page id's pageheader |
4105 |
|
|
**********************************************************/ |
4106 |
|
|
function updatePageHeader($con, $page_id, $pageheader) { |
4107 |
|
|
|
4108 |
|
|
// Clean up |
4109 |
|
|
if (strlen($pageheader) > 0) $pageheader = textInmySQL($pageheader); |
4110 |
|
|
|
4111 |
|
|
$sql = "UPDATE page SET pageheader = '" |
4112 |
|
|
. $pageheader |
4113 |
|
|
. "' WHERE page_id = " |
4114 |
|
|
. $page_id; |
4115 |
|
|
|
4116 |
|
|
// Failed |
4117 |
|
|
if (!mysql_query ($sql, $con)){ |
4118 |
|
|
sql_err($sql); |
4119 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4120 |
|
|
bailout(); |
4121 |
|
|
} |
4122 |
|
|
|
4123 |
|
|
// Succeeded |
4124 |
|
|
else { |
4125 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4126 |
|
|
} |
4127 |
|
|
|
4128 |
|
|
// Call the PageScribe page back |
4129 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
4130 |
|
|
} |
4131 |
|
|
|
4132 |
|
|
|
4133 |
|
|
/********************************************************** |
4134 |
|
|
Function: updatePageTitleStyle |
4135 |
|
|
Author: Paul Bramscher |
4136 |
|
|
Last Modified: 11.21.2003 |
4137 |
|
|
*********************************************************** |
4138 |
|
|
Purpose: |
4139 |
|
|
Updates the style class for the supplied page_id |
4140 |
|
|
**********************************************************/ |
4141 |
|
|
function updatePageTitleStyle($con, $page_id, $pagetitle_style) { |
4142 |
|
|
|
4143 |
|
|
$sql = "UPDATE page SET pagetitle_style = " |
4144 |
|
|
. $pagetitle_style |
4145 |
|
|
. " WHERE page_id = " |
4146 |
|
|
. $page_id; |
4147 |
|
|
|
4148 |
|
|
// Failed |
4149 |
|
|
if (!mysql_query ($sql, $con)){ |
4150 |
|
|
sql_err($sql); |
4151 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4152 |
|
|
bailout(); |
4153 |
|
|
} |
4154 |
|
|
|
4155 |
|
|
// Succeeded |
4156 |
|
|
else { |
4157 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4158 |
|
|
} |
4159 |
|
|
|
4160 |
|
|
// Call the PageScribe page back |
4161 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
4162 |
|
|
} |
4163 |
|
|
|
4164 |
|
|
|
4165 |
|
|
/********************************************************** |
4166 |
|
|
Function: updateScribeCourse |
4167 |
|
|
Author: Paul Bramscher |
4168 |
|
|
Last Modified: 06.25.2003 |
4169 |
|
|
*********************************************************** |
4170 |
|
|
Purpose: |
4171 |
|
|
Updates the supplied field and value for the course id. |
4172 |
|
|
The concatenated course title is also updated, in case |
4173 |
|
|
there were modifications which affect the title |
4174 |
|
|
(subject, designator, or section). |
4175 |
|
|
**********************************************************/ |
4176 |
|
|
function updateScribeCourse($con, $course_id, $field_name, $field_value, $page_id) { |
4177 |
|
|
|
4178 |
|
|
// Clean up for entry |
4179 |
|
|
if (strlen($field_value) > 0) $field_value = textInmySQL($field_value); |
4180 |
|
|
|
4181 |
|
|
// Determine whether this is an existing course or a new one |
4182 |
|
|
if ($course_id > 0) { |
4183 |
|
|
|
4184 |
|
|
// Build the SQL. Key on both course_id and page_id for safety sake. |
4185 |
|
|
$sql = "UPDATE course SET " |
4186 |
|
|
. $field_name |
4187 |
|
|
. " = '" |
4188 |
|
|
. $field_value |
4189 |
|
|
. "' WHERE course_id = " |
4190 |
|
|
. $course_id |
4191 |
|
|
. " AND page_id = " |
4192 |
|
|
. $page_id; |
4193 |
|
|
|
4194 |
|
|
if (!mysql_query ($sql, $con)){ |
4195 |
|
|
sql_err($sql); |
4196 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4197 |
|
|
bailout(); |
4198 |
|
|
} |
4199 |
|
|
else { |
4200 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4201 |
|
|
} |
4202 |
|
|
|
4203 |
|
|
|
4204 |
|
|
} |
4205 |
|
|
|
4206 |
|
|
// New course |
4207 |
|
|
else { |
4208 |
|
|
$sql = "INSERT INTO course ('" |
4209 |
|
|
. $field_name |
4210 |
|
|
. "', page_id) VALUES ('" |
4211 |
|
|
. $field_value |
4212 |
|
|
. "', " |
4213 |
|
|
. $page_id |
4214 |
|
|
. ")"; |
4215 |
|
|
|
4216 |
|
|
// Write the new row to the database |
4217 |
|
|
mysql_query ("LOCK TABLE course WRITE", $con); |
4218 |
|
|
if (!mysql_query($sql, $con)){ |
4219 |
|
|
sql_err($con); |
4220 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4221 |
|
|
bailout(); |
4222 |
|
|
} |
4223 |
|
|
else { |
4224 |
|
|
$course_id = mysql_insert_id($con); |
4225 |
|
|
mysql_query("UNLOCK TABLES", $con); |
4226 |
|
|
} |
4227 |
|
|
|
4228 |
|
|
} |
4229 |
|
|
updateScribeCourseConcat($con, $course_id, $page_id); |
4230 |
|
|
} |
4231 |
|
|
|
4232 |
|
|
/********************************************************** |
4233 |
|
|
Function: updateScribeCourseConcat |
4234 |
|
|
Author: Paul Bramscher |
4235 |
|
|
Last Modified: 04.24.2003 |
4236 |
|
|
*********************************************************** |
4237 |
|
|
Purpose: |
4238 |
|
|
This function updates a CourseLib course title of the |
4239 |
|
|
supplied page id and course id. This course title is a |
4240 |
|
|
concatenation of the course subject + designator + |
4241 |
|
|
section (if provided). This was done because there was a |
4242 |
|
|
problem in sorting multiple fields with our version of |
4243 |
|
|
mySQL. We needed to present a completely ordered list of |
4244 |
|
|
courses -- not merely by course subject. |
4245 |
|
|
**********************************************************/ |
4246 |
|
|
function updateScribeCourseConcat($con, $course_id, $page_id) { |
4247 |
|
|
|
4248 |
|
|
// Fetch course related information |
4249 |
|
|
$sql = "SELECT |
4250 |
|
|
p.page_title, |
4251 |
|
|
c.course_num, |
4252 |
|
|
c.course_section, |
4253 |
|
|
s.coursesub_id, |
4254 |
|
|
s.coursesub |
4255 |
|
|
FROM |
4256 |
|
|
course c |
4257 |
|
|
LEFT JOIN page p using (page_id) |
4258 |
|
|
LEFT JOIN coursesub s on c.coursesub_id = s.coursesub_id |
4259 |
|
|
|
4260 |
|
|
WHERE |
4261 |
|
|
course_id = " . $course_id; |
4262 |
|
|
|
4263 |
|
|
$rs = mysql_query($sql, $con); |
4264 |
|
|
$row = mysql_fetch_array ($rs); |
4265 |
|
|
|
4266 |
|
|
$page_title = $row["page_title"]; |
4267 |
|
|
$coursesub_id = $row["coursesub_id"]; |
4268 |
|
|
$coursesub = $row["coursesub"]; |
4269 |
|
|
$course_num = $row["course_num"]; |
4270 |
|
|
$course_section = $row["course_section"]; |
4271 |
|
|
|
4272 |
|
|
// Initialize |
4273 |
|
|
$course_concat = ""; |
4274 |
|
|
|
4275 |
|
|
// So long as the course subject is not N/A |
4276 |
|
|
// if ($coursesub_id > 1) $course_concat = $coursesub . " "; |
4277 |
|
|
if ($coursesub_id > 1) $course_concat = $coursesub; |
4278 |
|
|
|
4279 |
|
|
//if (strlen($course_num) > 1) $course_concat = $course_concat . $course_num . " "; |
4280 |
|
|
//$course_concat = $course_concat . $page_title . " "; |
4281 |
|
|
|
4282 |
|
|
if (strlen($course_num) > 1) $course_concat = $course_concat . " " . $course_num . ": "; |
4283 |
|
|
else $course_concat = $course_concat . " "; |
4284 |
|
|
$course_concat = $course_concat . $page_title . " "; |
4285 |
|
|
|
4286 |
|
|
if (strlen($course_section) > 1) $course_concat = $course_concat . $course_section . " "; |
4287 |
|
|
|
4288 |
|
|
// Clean up |
4289 |
|
|
$course_concat = textInmySQL($course_concat); |
4290 |
|
|
|
4291 |
|
|
// Update the concatenated title into the course table |
4292 |
|
|
$sql = "UPDATE course SET course_concat = '" |
4293 |
|
|
. $course_concat |
4294 |
|
|
. "' WHERE course_id = " |
4295 |
|
|
. $course_id; |
4296 |
|
|
|
4297 |
|
|
if (!mysql_query ($sql, $con)){ |
4298 |
|
|
sql_err($sql); |
4299 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4300 |
|
|
bailout(); |
4301 |
|
|
} |
4302 |
|
|
else { |
4303 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4304 |
|
|
} |
4305 |
|
|
|
4306 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
4307 |
|
|
|
4308 |
|
|
} |
4309 |
|
|
|
4310 |
|
|
/********************************************************** |
4311 |
|
|
Function: updateScribeElement |
4312 |
|
|
Author: Paul Bramscher |
4313 |
|
|
Last Modified: 07.01.2003 |
4314 |
|
|
*********************************************************** |
4315 |
|
|
Purpose: |
4316 |
|
|
Updates a PageScribe element. This function handles the |
4317 |
|
|
updating of text or label type elements, their url's and |
4318 |
|
|
descriptions -- as well as customized descriptions for |
4319 |
|
|
any other element type. |
4320 |
|
|
**********************************************************/ |
4321 |
|
|
function updateScribeElement($con, $element_descr, |
4322 |
|
|
$element_id, $label, $label_flag, $label_url, $page_id, $position) { |
4323 |
|
|
|
4324 |
|
|
// Problem flagging |
4325 |
|
|
$problem = 0; |
4326 |
|
|
|
4327 |
|
|
// Clean up strings |
4328 |
|
|
if (strlen($element_descr) > 0) $element_descr = textInmySQL($element_descr); |
4329 |
|
|
if (strlen($label) > 0) $label = textInmySQL($label); |
4330 |
|
|
if (strlen($label_url) > 0) $label_url = textInmySQL($label_url); |
4331 |
|
|
|
4332 |
|
|
// Protection against no url supplied |
4333 |
|
|
if ($label_url == "http://") $label_url = ""; |
4334 |
|
|
|
4335 |
|
|
/* |
4336 |
|
|
Protection against a blank label. If this element type is a label, some text |
4337 |
|
|
must be supplied. |
4338 |
|
|
*/ |
4339 |
|
|
|
4340 |
|
|
if ($label_flag == 1 && strlen($label) < 1) { |
4341 |
|
|
$problem = 1; |
4342 |
|
|
printf("Error. You must provide a text label if you wish it to be on the page.<br>\n"); |
4343 |
|
|
} |
4344 |
|
|
|
4345 |
|
|
|
4346 |
|
|
// If no problems |
4347 |
|
|
if ($problem == 0) { |
4348 |
|
|
|
4349 |
|
|
/* |
4350 |
|
|
First handle text-label type elements. It is assumed they |
4351 |
|
|
are all non-default descriptions. |
4352 |
|
|
*/ |
4353 |
|
|
|
4354 |
|
|
if ($label_flag == 1) { |
4355 |
|
|
// Build the SQL |
4356 |
|
|
$sql = "UPDATE element SET element_descr = '" |
4357 |
|
|
. $element_descr |
4358 |
|
|
. "', label = '" |
4359 |
|
|
. $label |
4360 |
|
|
. "', label_url = '" |
4361 |
|
|
. $label_url |
4362 |
|
|
. "' WHERE page_id =" |
4363 |
|
|
. $page_id |
4364 |
|
|
. " AND element_id = " |
4365 |
|
|
. $element_id; |
4366 |
|
|
|
4367 |
|
|
if (!mysql_query ($sql, $con)){ |
4368 |
|
|
sql_err($sql); |
4369 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4370 |
|
|
bailout(); |
4371 |
|
|
} |
4372 |
|
|
else { |
4373 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4374 |
|
|
} |
4375 |
|
|
|
4376 |
|
|
|
4377 |
|
|
} |
4378 |
|
|
|
4379 |
|
|
/* |
4380 |
|
|
This is a non- text-label element, and the user changed the default description. |
4381 |
|
|
*/ |
4382 |
|
|
|
4383 |
|
|
else if ($label_flag == 0 && strlen($element_descr) > 0) { |
4384 |
|
|
|
4385 |
|
|
// Build the SQL |
4386 |
|
|
$sql = "UPDATE element SET element_descr = '" |
4387 |
|
|
. $element_descr |
4388 |
|
|
. "' WHERE page_id =" |
4389 |
|
|
. $page_id |
4390 |
|
|
. " AND element_id = " |
4391 |
|
|
. $element_id; |
4392 |
|
|
|
4393 |
|
|
if (!mysql_query ($sql, $con)){ |
4394 |
|
|
sql_err($sql); |
4395 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4396 |
|
|
bailout(); |
4397 |
|
|
} |
4398 |
|
|
else { |
4399 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4400 |
|
|
} |
4401 |
|
|
|
4402 |
|
|
} |
4403 |
|
|
|
4404 |
|
|
/* |
4405 |
|
|
This is a non- text-label element. The user cleared everything out. |
4406 |
|
|
Dump the unique description. By doing this, the page-rendering interfaces |
4407 |
|
|
will revert to the default description for the element. |
4408 |
|
|
*/ |
4409 |
|
|
|
4410 |
|
|
else if ($label_flag == 0 && strlen($element_descr) == 0) { |
4411 |
|
|
|
4412 |
|
|
// Build the SQL |
4413 |
|
|
$sql = "UPDATE element SET element_descr = NULL WHERE page_id = " |
4414 |
|
|
. $page_id |
4415 |
|
|
. " AND element_id = " |
4416 |
|
|
. $element_id; |
4417 |
|
|
|
4418 |
|
|
if (!mysql_query ($sql, $con)){ |
4419 |
|
|
sql_err($sql); |
4420 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4421 |
|
|
bailout(); |
4422 |
|
|
} |
4423 |
|
|
else { |
4424 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4425 |
|
|
} |
4426 |
|
|
|
4427 |
|
|
} |
4428 |
|
|
|
4429 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id . "#p" . $position); |
4430 |
|
|
|
4431 |
|
|
} // no problems |
4432 |
|
|
|
4433 |
|
|
} |
4434 |
|
|
|
4435 |
|
|
|
4436 |
|
|
/********************************************************** |
4437 |
|
|
Function: updateScribeHeader |
4438 |
|
|
Author: Paul Bramscher |
4439 |
|
|
Last Modified: 04.24.2003 |
4440 |
|
|
*********************************************************** |
4441 |
|
|
Purpose: |
4442 |
|
|
Updates the page title for the supplied page id. |
4443 |
|
|
**********************************************************/ |
4444 |
|
|
function updateScribeHeader($con, $course_id, $page_id, $page_title, $pagetype_id) { |
4445 |
|
|
|
4446 |
|
|
// Clean up strings |
4447 |
|
|
$page_title = textInmySQL($page_title); |
4448 |
|
|
|
4449 |
|
|
// Build the SQL |
4450 |
|
|
$sql = "UPDATE page SET page_title = '" |
4451 |
|
|
. $page_title |
4452 |
|
|
. "' WHERE page_id =" |
4453 |
|
|
. $page_id; |
4454 |
|
|
|
4455 |
|
|
if (!mysql_query ($sql, $con)){ |
4456 |
|
|
sql_err($sql); |
4457 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4458 |
|
|
bailout(); |
4459 |
|
|
} |
4460 |
|
|
else { |
4461 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4462 |
|
|
} |
4463 |
|
|
|
4464 |
|
|
// Update the concatenated course title if this is a course page |
4465 |
|
|
if ($pagetype_id == 3) updateScribeCourseConcat($con, $course_id, $page_id); |
4466 |
|
|
|
4467 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
4468 |
|
|
|
4469 |
|
|
} |
4470 |
|
|
|
4471 |
|
|
|
4472 |
|
|
/********************************************************** |
4473 |
|
|
Function: updateScribeStyle |
4474 |
|
|
Author: Paul Bramscher |
4475 |
|
|
Last Modified: 04.24.2003 |
4476 |
|
|
*********************************************************** |
4477 |
|
|
Purpose: |
4478 |
|
|
Changes the style definition for the supplied page id. |
4479 |
|
|
**********************************************************/ |
4480 |
|
|
function updateScribeStyle($con, $page_id, $style_id) { |
4481 |
|
|
|
4482 |
|
|
// Build the SQL |
4483 |
|
|
$sql = "UPDATE page SET style_id = " |
4484 |
|
|
. $style_id |
4485 |
|
|
. " WHERE page_id =" |
4486 |
|
|
. $page_id; |
4487 |
|
|
|
4488 |
|
|
if (!mysql_query ($sql, $con)){ |
4489 |
|
|
sql_err($sql); |
4490 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4491 |
|
|
bailout(); |
4492 |
|
|
} |
4493 |
|
|
else { |
4494 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4495 |
|
|
} |
4496 |
|
|
|
4497 |
|
|
header("Location: scribe.phtml?page_id=" . $page_id); |
4498 |
|
|
} |
4499 |
|
|
|
4500 |
|
|
|
4501 |
|
|
/********************************************************** |
4502 |
|
|
Function: updateScribeUpdate |
4503 |
|
|
Author: Paul Bramscher |
4504 |
|
|
Last Modified: 04.24.2003 |
4505 |
|
|
*********************************************************** |
4506 |
|
|
Purpose: |
4507 |
|
|
Modifies the PageScribe/CourseLib page "last updated" |
4508 |
|
|
field. |
4509 |
|
|
**********************************************************/ |
4510 |
|
|
function updateScribeUpdate($con, $page_id, $sess_staff_account) { |
4511 |
|
|
|
4512 |
|
|
$sql = "UPDATE page SET date_modified = now(), account_modified ='" |
4513 |
|
|
. $sess_staff_account |
4514 |
|
|
. "' WHERE page_id = " |
4515 |
|
|
. $page_id; |
4516 |
|
|
|
4517 |
|
|
// Failed |
4518 |
|
|
if (!mysql_query ($sql, $con)){ |
4519 |
|
|
sql_err($sql); |
4520 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4521 |
|
|
bailout(); |
4522 |
|
|
} |
4523 |
|
|
|
4524 |
|
|
// Succeeded |
4525 |
|
|
else { |
4526 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
4527 |
|
|
} |
4528 |
|
|
} |
4529 |
|
|
|
4530 |
|
|
|
4531 |
|
|
/********************************************************** |
4532 |
|
|
Function: youngerProbe |
4533 |
|
|
Author: Paul Bramscher |
4534 |
|
|
Last Modified: 10.29.2002 |
4535 |
|
|
*********************************************************** |
4536 |
|
|
Incoming: |
4537 |
|
|
$page_id ID of the page involved |
4538 |
|
|
$place_array Variables related to the last element |
4539 |
|
|
displayed. |
4540 |
|
|
$rs Record set with cursor position. |
4541 |
|
|
*********************************************************** |
4542 |
|
|
Outgoing: |
4543 |
|
|
$younger Returns 0 if next element is not |
4544 |
|
|
younger, 1 if it is. |
4545 |
|
|
*********************************************************** |
4546 |
|
|
Purpose: |
4547 |
|
|
Starts out with the cursor pointing at the next element in |
4548 |
|
|
the recordset. Examines the value of its indent level and |
4549 |
|
|
determines whether it is older or younger than the previous |
4550 |
|
|
element. If younger, it returns a 1. If not, returns a 0. |
4551 |
|
|
|
4552 |
|
|
Note that we need some range checking. $element_order |
4553 |
|
|
represents the order 1 to N of the elements on a page, |
4554 |
|
|
whereas the cursor sits at positions 0 to (N - 1). Thus, |
4555 |
|
|
we need to make sure we never check beyond the limit of |
4556 |
|
|
the number of rows. After the check, we need to move the |
4557 |
|
|
cursor back to $element_order - 1. This would correspond to |
4558 |
|
|
the cursor row it was originally sitting at coming into the |
4559 |
|
|
function. |
4560 |
|
|
**********************************************************/ |
4561 |
|
|
function youngerProbe($page_id, $place_array, $rs){ |
4562 |
|
|
|
4563 |
|
|
// Break apart place array |
4564 |
|
|
$element_id = $place_array[0]; |
4565 |
|
|
$element_order = $place_array[1]; |
4566 |
|
|
$indent_level = $place_array[2]; |
4567 |
|
|
//$parent_id = $place_array[3]; |
4568 |
|
|
//$position = $place_array[4]; |
4569 |
|
|
|
4570 |
|
|
// Younger found |
4571 |
|
|
$younger = 0; |
4572 |
|
|
|
4573 |
|
|
if ($element_order <= mysql_num_rows($rs)) { |
4574 |
|
|
|
4575 |
|
|
$row = mysql_fetch_array ($rs); |
4576 |
|
|
$probe_indent_level = $row["indent_level"]; |
4577 |
|
|
$probe_element_id = $row["element_id"]; |
4578 |
|
|
|
4579 |
|
|
/* |
4580 |
|
|
printf("<BR>this element: %d, this indent: %d<BR>", $element_id, $indent_level); |
4581 |
|
|
printf("probed element: %d, probed indent: %d<BR>", $probe_element_id, $probe_indent_level); |
4582 |
|
|
printf("order was: %d<br>", $element_order); |
4583 |
|
|
*/ |
4584 |
|
|
|
4585 |
|
|
if ($probe_indent_level > $indent_level) $younger = 1; |
4586 |
|
|
if ($element_order <= mysql_num_rows($rs)) mysql_data_seek($rs, $element_order - 1); |
4587 |
|
|
|
4588 |
|
|
} |
4589 |
|
|
|
4590 |
|
|
return $younger; |
4591 |
|
|
|
4592 |
|
|
} |
4593 |
|
|
?> |