1 |
<?php |
<?php |
2 |
/********************************************************** |
/********************************************************** |
3 |
Function Library: public_controls.php |
Function Library: public_controls.php |
4 |
Original Author: Paul Bramscher <brams006@tc.umn.edu> |
Original Author: Paul Bramscher <brams006@umn.edu> |
5 |
Last Modified: 12.15.2003 |
Last Modified: 03.04.2004 |
6 |
*********************************************************** |
*********************************************************** |
7 |
Comments: |
Comments: |
8 |
Publicly accessible and executable functions. |
Publicly accessible and executable functions. |
18 |
dropDownFieldOmit |
dropDownFieldOmit |
19 |
dropDownFieldSelected |
dropDownFieldSelected |
20 |
existsRow |
existsRow |
|
locationList |
|
21 |
lookupField |
lookupField |
22 |
lookupStaff |
lookupStaff |
23 |
pageLoadStats |
pageLoadStats |
36 |
Purpose: |
Purpose: |
37 |
Output the course related information for a course page. |
Output the course related information for a course page. |
38 |
**********************************************************/ |
**********************************************************/ |
39 |
function displayCourseHeader($con, $page_id, $pagetitle_style) { |
function displayCourseHeader($page_id, $pagetitle_style) { |
40 |
|
|
41 |
// Retrieve current information |
// Retrieve current information |
42 |
$sql = "SELECT * |
$sql = "SELECT * |
49 |
WHERE |
WHERE |
50 |
page_id = " . $page_id; |
page_id = " . $page_id; |
51 |
|
|
52 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
53 |
$row = mysql_fetch_array ($rs); |
$row = mysql_fetch_array ($rs, MYSQL_ASSOC); |
54 |
|
|
55 |
$course_id = $row["course_id"]; |
$course_id = $row["course_id"]; |
56 |
$staff_id_created = $row["staff_id_created"]; |
$staff_id_created = $row["staff_id_created"]; |
127 |
/********************************************************** |
/********************************************************** |
128 |
Function: displayCoursePers |
Function: displayCoursePers |
129 |
Author: Paul Bramscher |
Author: Paul Bramscher |
130 |
Last Modified: 09.10.2003 |
Last Modified: 03.04.2004 |
131 |
*********************************************************** |
*********************************************************** |
132 |
Purpose: |
Purpose: |
133 |
Displays the personnel associated with the course, by |
Displays the personnel associated with the course, by |
134 |
looking up the course id based on the page id. |
looking up the course id based on the page id. |
135 |
**********************************************************/ |
**********************************************************/ |
136 |
function displayCoursePers($con, $page_id) { |
function displayCoursePers($page_id) { |
137 |
|
|
138 |
// Determine the course id |
// Determine the course id |
139 |
$course_id = lookupfield($con, "course", "page_id", $page_id, "course_id"); |
$course_id = lookupfield("course", "page_id", $page_id, "course_id"); |
140 |
|
|
141 |
// Retrieve current information |
// Retrieve current information |
142 |
$sql = "SELECT * |
$sql = "SELECT * |
149 |
WHERE |
WHERE |
150 |
course_id = " . $course_id . " ORDER BY personnel_id"; |
course_id = " . $course_id . " ORDER BY personnel_id"; |
151 |
|
|
152 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
153 |
|
|
154 |
// See how many in this record set |
// See how many in this record set |
155 |
$num_personnel = mysql_num_rows($rs); |
$num_personnel = mysql_num_rows($rs); |
161 |
printf("<b>Personnel:</b><br>\n"); |
printf("<b>Personnel:</b><br>\n"); |
162 |
|
|
163 |
|
|
164 |
while ($row = mysql_fetch_array ($rs)) { |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
165 |
|
|
166 |
// Initialize |
// Initialize |
167 |
$last_name = ""; |
$last_name = ""; |
219 |
|
|
220 |
|
|
221 |
/********************************************************** |
/********************************************************** |
222 |
Function: displayRelatedPages($con, $subject_id) |
Function: displayRelatedPages($subject_id) |
223 |
Author: Paul Bramscher |
Author: Paul Bramscher |
224 |
Last Modified: 06.17.2003 |
Last Modified: 03.04.2004 |
225 |
*********************************************************** |
*********************************************************** |
226 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
227 |
$subject_id Subject of the RQS page |
$subject_id Subject of the RQS page |
228 |
*********************************************************** |
*********************************************************** |
229 |
Outgoing: |
Outgoing: |
233 |
Displays any PageScribe pages associated with the supplied |
Displays any PageScribe pages associated with the supplied |
234 |
subject id. |
subject id. |
235 |
**********************************************************/ |
**********************************************************/ |
236 |
function displayRelatedPages($con, $subject_id){ |
function displayRelatedPages($subject_id){ |
237 |
$sql = "SELECT p.page_id, p.page_title |
$sql = "SELECT p.page_id, p.page_title |
238 |
FROM page p, sub_page sp |
FROM page p, sub_page sp |
239 |
WHERE sp.subject_id = " |
WHERE sp.subject_id = " |
240 |
. $subject_id |
. $subject_id |
241 |
. " AND sp.page_id = p.page_id ORDER BY p.page_title"; |
. " AND sp.page_id = p.page_id ORDER BY p.page_title"; |
242 |
|
|
243 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
244 |
while ($row = mysql_fetch_array ($rs)) { |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
245 |
$page_id = $row["page_id"]; |
$page_id = $row["page_id"]; |
246 |
$page_title = $row["page_title"]; |
$page_title = $row["page_title"]; |
247 |
|
|
254 |
|
|
255 |
|
|
256 |
/********************************************************** |
/********************************************************** |
257 |
Function: displayRelatedSubjects($con, $subject_id) |
Function: displayRelatedSubjects($subject_id) |
258 |
Author: Paul Bramscher |
Author: Paul Bramscher |
259 |
Last Modified: 11.05.2003 |
Last Modified: 03.04.2004 |
260 |
*********************************************************** |
*********************************************************** |
261 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
262 |
$subject_id Subject of the RQS page |
$subject_id Subject of the RQS page |
263 |
*********************************************************** |
*********************************************************** |
264 |
Outgoing: |
Outgoing: |
268 |
Displays any RQS pages associated with the supplied |
Displays any RQS pages associated with the supplied |
269 |
subject id. |
subject id. |
270 |
**********************************************************/ |
**********************************************************/ |
271 |
function displayRelatedSubjects($con, $subject_id){ |
function displayRelatedSubjects($subject_id){ |
272 |
|
|
273 |
$sql = "SELECT s.subject, so.othersub_id |
$sql = "SELECT s.subject, so.othersub_id |
274 |
FROM subject s, sub_othersub so |
FROM subject s, sub_othersub so |
276 |
. $subject_id |
. $subject_id |
277 |
. " AND so.othersub_id = s.subject_id ORDER BY s.subject"; |
. " AND so.othersub_id = s.subject_id ORDER BY s.subject"; |
278 |
|
|
279 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
280 |
while ($row = mysql_fetch_array ($rs)) { |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
281 |
$othersub_id = $row["othersub_id"]; |
$othersub_id = $row["othersub_id"]; |
282 |
$subject = $row["subject"]; |
$subject = $row["subject"]; |
283 |
|
|
292 |
/********************************************************** |
/********************************************************** |
293 |
Function: displayTOC |
Function: displayTOC |
294 |
Author: Paul Bramscher |
Author: Paul Bramscher |
295 |
Last Modified: 12.15.2003 |
Last Modified: 03.04.2004 |
296 |
*********************************************************** |
*********************************************************** |
297 |
Purpose: |
Purpose: |
298 |
Generates and displays a table of contents (TOC) for the |
Generates and displays a table of contents (TOC) for the |
303 |
two-column table of contents, split at the midpoint |
two-column table of contents, split at the midpoint |
304 |
(rounded up for odd numbers of root elements). |
(rounded up for odd numbers of root elements). |
305 |
**********************************************************/ |
**********************************************************/ |
306 |
function displayTOC($con, $page_id, $wrap_toc) { |
function displayTOC($page_id, $wrap_toc) { |
307 |
|
|
308 |
// Calculate number of elements |
// Calculate number of elements |
309 |
$sql = "SELECT COUNT(*) as num_elements FROM element WHERE indent_level < 1 AND page_id = " |
$sql = "SELECT COUNT(*) as num_elements FROM element WHERE indent_level < 1 AND page_id = " |
310 |
. $page_id; |
. $page_id; |
311 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
312 |
$row = mysql_fetch_array ($rs); |
$row = mysql_fetch_array ($rs); |
313 |
$num_elements = $row["num_elements"]; |
$num_elements = $row["num_elements"]; |
314 |
|
|
348 |
. $page_id |
. $page_id |
349 |
. " AND e.indent_level < 1 ORDER BY e.element_order"; |
. " AND e.indent_level < 1 ORDER BY e.element_order"; |
350 |
|
|
351 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
352 |
|
|
353 |
// Build a general ToC anchor |
// Build a general ToC anchor |
354 |
printf("<a name=\"toc\"></a>\n"); |
printf("<a name=\"toc\"></a>\n"); |
363 |
|
|
364 |
$row_num = 0; |
$row_num = 0; |
365 |
|
|
366 |
while ($row = mysql_fetch_array ($rs)) { |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
367 |
|
|
368 |
// Check for the midpoint |
// Check for the midpoint |
369 |
if ($row_num == $midpoint && $wrap_toc == 1) { |
if ($row_num == $midpoint && $wrap_toc == 1) { |
431 |
|
|
432 |
|
|
433 |
/********************************************************** |
/********************************************************** |
434 |
Function: dropDownCoursesubSelected($con, $limit, $preselected) |
Function: dropDownCoursesubSelected($limit, $preselected) |
435 |
Author: Paul Bramscher |
Author: Paul Bramscher |
436 |
Last Modified: 08.18.2003 |
Last Modified: 03.04.2004 |
437 |
*********************************************************** |
*********************************************************** |
438 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
439 |
$limit Initial limit to the result set |
$limit Initial limit to the result set |
440 |
$preselected Incoming course subject to preselect |
$preselected Incoming course subject to preselect |
441 |
*********************************************************** |
*********************************************************** |
448 |
which have associated and published CourseLib pages will |
which have associated and published CourseLib pages will |
449 |
appear in the drop down box. |
appear in the drop down box. |
450 |
**********************************************************/ |
**********************************************************/ |
451 |
function dropDownCoursesubSelected($con, $limit, $preselected){ |
function dropDownCoursesubSelected($limit, $preselected){ |
452 |
|
|
453 |
|
|
454 |
$sql = "SELECT DISTINCT s.coursesub |
$sql = "SELECT DISTINCT s.coursesub |
461 |
AND s.coursesub_id = c.coursesub_id " |
AND s.coursesub_id = c.coursesub_id " |
462 |
. " ORDER BY s.coursesub"; |
. " ORDER BY s.coursesub"; |
463 |
|
|
464 |
/* |
$rs = mysql_tryquery($sql); |
465 |
Use this SQL instead, if all distinct course designators, used or not, |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
|
would rather be displayed. |
|
|
|
|
|
|
|
|
$sql = "SELECT DISTINCT s.coursesub FROM coursesub s, course c" |
|
|
. $limit |
|
|
. " AND s.coursesub_id = c.coursesub_id " |
|
|
. " ORDER BY s.coursesub"; |
|
|
*/ |
|
|
|
|
|
|
|
|
$rs = mysql_query($sql, $con); |
|
|
while ($row = mysql_fetch_array ($rs)) { |
|
466 |
$coursesub = $row["coursesub"]; |
$coursesub = $row["coursesub"]; |
467 |
|
|
468 |
printf("<option value = \"%s\"", $coursesub); |
printf("<option value = \"%s\"", $coursesub); |
473 |
|
|
474 |
|
|
475 |
/********************************************************** |
/********************************************************** |
476 |
Function: dropDownFacultySelected($con, $limit, $preselected) |
Function: dropDownFacultySelected($limit, $preselected) |
477 |
Author: Paul Bramscher |
Author: Paul Bramscher |
478 |
Last Modified: 08.18.2003 |
Last Modified: 03.04.2004 |
479 |
*********************************************************** |
*********************************************************** |
480 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
481 |
$limit Any WHERE clause |
$limit Any WHERE clause |
482 |
$preselected Incoming faculty person to preselect |
$preselected Incoming faculty person to preselect |
483 |
*********************************************************** |
*********************************************************** |
490 |
(a) are currently teaching 1+ courselib courses and |
(a) are currently teaching 1+ courselib courses and |
491 |
(b) that course(s) is published. |
(b) that course(s) is published. |
492 |
**********************************************************/ |
**********************************************************/ |
493 |
function dropDownFacultySelected($con, $limit, $preselected){ |
function dropDownFacultySelected($limit, $preselected){ |
494 |
|
|
495 |
$sql = "SELECT DISTINCT |
$sql = "SELECT DISTINCT |
496 |
f.faculty_id, |
f.faculty_id, |
504 |
AND c.page_id = p.page_id |
AND c.page_id = p.page_id |
505 |
AND p.published = '1'" |
AND p.published = '1'" |
506 |
. " ORDER BY f.faculty_lastname, f.faculty_firstname"; |
. " ORDER BY f.faculty_lastname, f.faculty_firstname"; |
|
|
|
|
// printf("<!-- sql was: %s -->", $sql); |
|
|
|
|
|
/* |
|
|
Use this SQL instead, if all faculty, on published courselib pages or |
|
|
not, would rather be displayed. |
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM faculty " |
|
|
. $limit |
|
|
. " ORDER BY faculty_lastname, faculty_firstname"; |
|
|
*/ |
|
507 |
|
|
508 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
509 |
while ($row = mysql_fetch_array ($rs)) { |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
510 |
$faculty_id = $row["faculty_id"]; |
$faculty_id = $row["faculty_id"]; |
511 |
$faculty_lastname = $row["faculty_lastname"]; |
$faculty_lastname = $row["faculty_lastname"]; |
512 |
$faculty_firstname = $row["faculty_firstname"]; |
$faculty_firstname = $row["faculty_firstname"]; |
526 |
|
|
527 |
|
|
528 |
/********************************************************** |
/********************************************************** |
529 |
Function: dropDownFieldOmit($con, $table, $field_display, |
Function: dropDownFieldOmit($table, $field_display, |
530 |
$field_value, $where) |
$field_value, $where) |
531 |
Author: Paul Bramscher |
Author: Paul Bramscher |
532 |
Last Modified: 8.14.2002 |
Last Modified: 03.04.2004 |
533 |
*********************************************************** |
*********************************************************** |
534 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
535 |
$table Table in database to search |
$table Table in database to search |
536 |
$field_display Select displayed to user |
$field_display Select displayed to user |
537 |
$field_value Actual value of the HTML tag |
$field_value Actual value of the HTML tag |
546 |
Typically, $field_value is the primary key field. $where |
Typically, $field_value is the primary key field. $where |
547 |
can be used to filter out results. |
can be used to filter out results. |
548 |
**********************************************************/ |
**********************************************************/ |
549 |
function dropDownFieldOmit($con, $table, $field_display, |
function dropDownFieldOmit($table, $field_display, |
550 |
$field_value, $where){ |
$field_value, $where){ |
551 |
|
|
552 |
$sql = "SELECT " |
$sql = "SELECT " |
559 |
. $where |
. $where |
560 |
. " ORDER BY " |
. " ORDER BY " |
561 |
. $field_display; |
. $field_display; |
562 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
563 |
while ($row = mysql_fetch_array ($rs)) { |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
564 |
$field_display_item = $row[$field_display]; |
$field_display_item = $row[$field_display]; |
565 |
if (strlen($field_display_item) > 40) $field_display_item = substr($field_display_item, 0, 39) . "..."; |
if (strlen($field_display_item) > 40) $field_display_item = substr($field_display_item, 0, 39) . "..."; |
566 |
$field_value_item = $row[$field_value]; |
$field_value_item = $row[$field_value]; |
567 |
printf("<option value = \"" . $field_value_item |
printf("<option value = \"" . $field_value_item |
568 |
. "\" >" . $field_display_item . "</option>\n"); |
. "\" >" |
569 |
|
. $field_display_item |
570 |
|
. "</option>\n"); |
571 |
}; |
}; |
572 |
} |
} |
573 |
|
|
574 |
|
|
575 |
/********************************************************** |
/********************************************************** |
576 |
Function: dropDownFieldSelected($con, $table, $field_display, |
Function: dropDownFieldSelected($table, $field_display, |
577 |
$field_value, $limit, $preselected) |
$field_value, $limit, $preselected) |
578 |
Author: Paul Bramscher |
Author: Paul Bramscher |
579 |
Last Modified: 12.04.2002 |
Last Modified: 03.04.2004 |
580 |
*********************************************************** |
*********************************************************** |
581 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
582 |
$table Table in database to search |
$table Table in database to search |
583 |
$field_display Select displayed to user |
$field_display Select displayed to user |
584 |
$field_value Actual value of the HTML tag |
$field_value Actual value of the HTML tag |
595 |
parameter $preselected determines which (single) selection |
parameter $preselected determines which (single) selection |
596 |
is selected. |
is selected. |
597 |
**********************************************************/ |
**********************************************************/ |
598 |
function dropDownFieldSelected($con, $table, $field_display, |
function dropDownFieldSelected($table, $field_display, |
599 |
$field_value, $limit, $preselected){ |
$field_value, $limit, $preselected){ |
600 |
|
|
601 |
$sql = "SELECT " |
$sql = "SELECT " |
609 |
. " ORDER BY " |
. " ORDER BY " |
610 |
. $field_display; |
. $field_display; |
611 |
|
|
612 |
// Debugging |
$rs = mysql_tryquery($sql); |
613 |
//printf("sql was: %s<BR>", $sql); |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
|
|
|
|
$rs = mysql_query($sql, $con); |
|
|
while ($row = mysql_fetch_array ($rs)) { |
|
614 |
$field_display_item = $row[$field_display]; |
$field_display_item = $row[$field_display]; |
615 |
$field_value_item = $row[$field_value]; |
$field_value_item = $row[$field_value]; |
616 |
if (strlen($field_display_item) > 50) $field_display_item = substr($field_display_item, 0, 49) . "..."; |
if (strlen($field_display_item) > 50) $field_display_item = substr($field_display_item, 0, 49) . "..."; |
625 |
/********************************************************** |
/********************************************************** |
626 |
Function: existsRow |
Function: existsRow |
627 |
Author: Paul Bramscher |
Author: Paul Bramscher |
628 |
Last Modified: 12.09.2002 |
Last Modified: 03.04.2004 |
629 |
*********************************************************** |
*********************************************************** |
630 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
631 |
$table Table to search |
$table Table to search |
632 |
$key_field Field against which to search |
$key_field Field against which to search |
633 |
$key_id Limit for the where clause |
$key_id Limit for the where clause |
640 |
sure that a row entity exists matching the supplied key |
sure that a row entity exists matching the supplied key |
641 |
before going any further. |
before going any further. |
642 |
**********************************************************/ |
**********************************************************/ |
643 |
function existsRow($con, $table, $key_field, $limit_id){ |
function existsRow($table, $key_field, $limit_id){ |
644 |
// Cast as integer to avoid future problems |
// Cast as integer to avoid future problems |
645 |
$limit_id = (int) $limit_id; |
$limit_id = (int) $limit_id; |
646 |
|
|
654 |
. "=" |
. "=" |
655 |
. $limit_id; |
. $limit_id; |
656 |
|
|
657 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
658 |
$rowcount = mysql_num_rows($rs); |
$rowcount = mysql_num_rows($rs); |
659 |
if ($rowcount >= 1){ |
if ($rowcount >= 1){ |
660 |
$rowcount = 1; |
$rowcount = 1; |
666 |
|
|
667 |
|
|
668 |
/********************************************************** |
/********************************************************** |
669 |
Function: locationList($con, $resource_id) |
Function: lookupField($table, $key_field, $key_value, |
|
Author: Paul Bramscher |
|
|
Last Modified: 07.02.2002 |
|
|
*********************************************************** |
|
|
Incoming: |
|
|
$con Database connection string |
|
|
$resource_id Resource ID to check locations on |
|
|
*********************************************************** |
|
|
Outgoing: |
|
|
None |
|
|
*********************************************************** |
|
|
Purpose: |
|
|
Looks up location(s) for this resource |
|
|
**********************************************************/ |
|
|
function locationList($con, $resource_id){ |
|
|
|
|
|
// Initialize |
|
|
$locations = ""; |
|
|
$first = 1; |
|
|
|
|
|
$sql = "SELECT location FROM location l, res_loc rl WHERE rl.resource_id = " |
|
|
. $resource_id |
|
|
. " AND rl.location_id = l.location_id ORDER BY location"; |
|
|
|
|
|
$rs = mysql_query($sql, $con); |
|
|
while ($row = mysql_fetch_array ($rs)) { |
|
|
$location = $row["location"]; |
|
|
if ($first == 1) { |
|
|
$first = 0; |
|
|
$locations = $location; |
|
|
} |
|
|
else $locations .= "; " . $location; |
|
|
} |
|
|
|
|
|
return $locations; |
|
|
} |
|
|
|
|
|
|
|
|
/********************************************************** |
|
|
Function: lookupField($con, $table, $key_field, $key_value, |
|
670 |
$desc_field) |
$desc_field) |
671 |
Author: Paul Bramscher |
Author: Paul Bramscher |
672 |
Last Modified: 9.14.2000 |
Last Modified: 03.04.2004 |
673 |
*********************************************************** |
*********************************************************** |
674 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
675 |
$table Table in database to search |
$table Table in database to search |
676 |
$key_field Name of field on which to lookup |
$key_field Name of field on which to lookup |
677 |
$key_value Value to attempt lookup with |
$key_value Value to attempt lookup with |
684 |
Performs a lookup, typically on an ID field, to retrieve a |
Performs a lookup, typically on an ID field, to retrieve a |
685 |
user-friendly descriptive name to the page. |
user-friendly descriptive name to the page. |
686 |
**********************************************************/ |
**********************************************************/ |
687 |
function lookupField($con, $table, $key_field, $key_value, |
function lookupField($table, $key_field, $key_value, |
688 |
$desc_field){ |
$desc_field){ |
689 |
|
|
690 |
$sql = "SELECT " |
$sql = "SELECT " |
696 |
. "='" |
. "='" |
697 |
. $key_value |
. $key_value |
698 |
. "'"; |
. "'"; |
699 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
700 |
$row = mysql_fetch_array ($rs); |
$row = mysql_fetch_array ($rs, MYSQL_ASSOC); |
701 |
if (mysql_num_rows($rs) == 1) $result = $row[$desc_field]; |
if (mysql_num_rows($rs) == 1) $result = $row[$desc_field]; |
702 |
else $result = ""; |
else $result = ""; |
703 |
|
|
706 |
|
|
707 |
|
|
708 |
/********************************************************** |
/********************************************************** |
709 |
Function: lookupStaff($con, $staff_id) |
Function: lookupStaff($staff_id) |
710 |
Author: Paul Bramscher |
Author: Paul Bramscher |
711 |
Last Modified: 7.22.2002 |
Last Modified: 03.04.2004 |
712 |
*********************************************************** |
*********************************************************** |
713 |
Incoming: |
Incoming: |
|
$con Database connection string |
|
714 |
$staff_id Staff ID number to retrieve |
$staff_id Staff ID number to retrieve |
715 |
*********************************************************** |
*********************************************************** |
716 |
Outgoing: |
Outgoing: |
719 |
Purpose: |
Purpose: |
720 |
Performs a lookup on staff ID to retrieve name. |
Performs a lookup on staff ID to retrieve name. |
721 |
**********************************************************/ |
**********************************************************/ |
722 |
function lookupStaff($con, $staff_id){ |
function lookupStaff($staff_id){ |
723 |
|
|
724 |
$sql = "SELECT first_name, last_name FROM staff WHERE staff_id = " |
$sql = "SELECT first_name, last_name FROM staff WHERE staff_id = " |
725 |
. $staff_id; |
. $staff_id; |
726 |
$rs = mysql_query($sql, $con); |
$rs = mysql_tryquery($sql); |
727 |
$row = mysql_fetch_array ($rs); |
$row = mysql_fetch_array ($rs, MYSQL_ASSOC); |
728 |
$last_name = $row["last_name"]; |
$last_name = $row["last_name"]; |
729 |
$first_name = $row["first_name"]; |
$first_name = $row["first_name"]; |
730 |
|
|
740 |
/********************************************************** |
/********************************************************** |
741 |
Function: pageLoadStats |
Function: pageLoadStats |
742 |
Author: Paul Bramscher |
Author: Paul Bramscher |
743 |
Last Modified: 04.23.2003 |
Last Modified: 03.04.2004 |
744 |
*********************************************************** |
*********************************************************** |
745 |
Purpose: |
Purpose: |
746 |
Logs a statistical entry for a PageScribe/CourseLib page |
Logs a statistical entry for a PageScribe/CourseLib page |
751 |
that the database doesn't grow too large. Currently there |
that the database doesn't grow too large. Currently there |
752 |
exists no automatic mechanism to purge or archive stats. |
exists no automatic mechanism to purge or archive stats. |
753 |
**********************************************************/ |
**********************************************************/ |
754 |
function pageLoadStats($con, $page_id){ |
function pageLoadStats($page_id){ |
755 |
|
|
756 |
// Add a row for page usage |
// Add a row for page usage |
757 |
|
|
767 |
. ", now(), '" |
. ", now(), '" |
768 |
. $user_ip |
. $user_ip |
769 |
. "')"; |
. "')"; |
770 |
|
mysql_tryquery($sql); |
|
if (!mysql_query($sql, $con)){ |
|
|
sql_err($con); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} // bad write |
|
|
else { |
|
|
mysql_query("UNLOCK TABLES", $con); |
|
|
|
|
|
} // good write to the pagestats table |
|
771 |
|
|
772 |
} |
} |
773 |
|
|
801 |
/********************************************************** |
/********************************************************** |
802 |
Function: subLoadStats |
Function: subLoadStats |
803 |
Author: Paul Bramscher |
Author: Paul Bramscher |
804 |
Last Modified: 08.25.2003 |
Last Modified: 03.04.2004 |
805 |
*********************************************************** |
*********************************************************** |
806 |
Purpose: |
Purpose: |
807 |
Logs a statistical entry for a RQS page load. Subject id, |
Logs a statistical entry for a RQS page load. Subject id, |
811 |
No differentiation between them is made, only between |
No differentiation between them is made, only between |
812 |
subjects |
subjects |
813 |
**********************************************************/ |
**********************************************************/ |
814 |
function subLoadStats($con, $subject_id){ |
function subLoadStats($subject_id){ |
815 |
|
|
816 |
// Add a row for page usage |
// Add a row for page usage |
817 |
|
|
827 |
. ", now(), '" |
. ", now(), '" |
828 |
. $user_ip |
. $user_ip |
829 |
. "')"; |
. "')"; |
830 |
|
mysql_tryquery($sql); |
|
if (!mysql_query($sql, $con)){ |
|
|
sql_err($con); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} // bad write |
|
|
else { |
|
|
mysql_query("UNLOCK TABLES", $con); |
|
|
|
|
|
} // good write to the substats table |
|
831 |
|
|
832 |
} |
} |
833 |
|
|
871 |
return $outgoing; |
return $outgoing; |
872 |
|
|
873 |
} |
} |
874 |
?> |
?> |