/[libdata]/trunk/public_controls.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/public_controls.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 71 by dpavlin, Thu Mar 4 22:43:50 2004 UTC revision 72 by dpavlin, Thu Mar 18 20:33:37 2004 UTC
# Line 1  Line 1 
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.
# Line 18  dropDownFacultySelected Line 18  dropDownFacultySelected
18  dropDownFieldOmit  dropDownFieldOmit
19  dropDownFieldSelected  dropDownFieldSelected
20  existsRow  existsRow
 locationList  
21  lookupField  lookupField
22  lookupStaff  lookupStaff
23  pageLoadStats  pageLoadStats
# Line 37  Last Modified: 11.21.2003 Line 36  Last Modified: 11.21.2003
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 *
# Line 50  function displayCourseHeader($con, $page Line 49  function displayCourseHeader($con, $page
49                  WHERE                  WHERE
50                  page_id = " . $page_id;                  page_id = " . $page_id;
51                    
52          $rs = xx_query($sql, $con);          $rs = xx_tryquery($sql);
53          $row = xx_fetch_array ($rs);          $row = xx_fetch_array ($rs, xx_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"];
# Line 128  function displayCourseHeader($con, $page Line 127  function displayCourseHeader($con, $page
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 *
# Line 150  function displayCoursePers($con, $page_i Line 149  function displayCoursePers($con, $page_i
149                  WHERE                  WHERE
150                  course_id = " . $course_id . " ORDER BY personnel_id";                  course_id = " . $course_id . " ORDER BY personnel_id";
151                    
152          $rs = xx_query($sql, $con);          $rs = xx_tryquery($sql);
153                    
154          // See how many in this record set          // See how many in this record set
155          $num_personnel = xx_num_rows($rs);          $num_personnel = xx_num_rows($rs);
# Line 162  function displayCoursePers($con, $page_i Line 161  function displayCoursePers($con, $page_i
161                  printf("<b>Personnel:</b><br>\n");                  printf("<b>Personnel:</b><br>\n");
162    
163    
164                  while ($row = xx_fetch_array ($rs)) {                  while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
165    
166                          // Initialize                          // Initialize
167                          $last_name = "";                          $last_name = "";
# Line 220  function displayCoursePers($con, $page_i Line 219  function displayCoursePers($con, $page_i
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:
# Line 235  Purpose: Line 233  Purpose:
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 = xx_query($sql, $con);          $rs = xx_tryquery($sql);
244          while ($row = xx_fetch_array ($rs)) {          while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
245                  $page_id = $row["page_id"];                  $page_id = $row["page_id"];
246                  $page_title = $row["page_title"];                  $page_title = $row["page_title"];
247    
# Line 256  function displayRelatedPages($con, $subj Line 254  function displayRelatedPages($con, $subj
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:
# Line 271  Purpose: Line 268  Purpose:
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
# Line 279  function displayRelatedSubjects($con, $s Line 276  function displayRelatedSubjects($con, $s
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 = xx_query($sql, $con);          $rs = xx_tryquery($sql);
280          while ($row = xx_fetch_array ($rs)) {          while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
281                  $othersub_id = $row["othersub_id"];                  $othersub_id = $row["othersub_id"];
282                  $subject = $row["subject"];                      $subject = $row["subject"];    
283    
# Line 295  function displayRelatedSubjects($con, $s Line 292  function displayRelatedSubjects($con, $s
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
# Line 306  This function allows for the optional di Line 303  This function allows for the optional di
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 = xx_query($sql, $con);          $rs = xx_tryquery($sql);
312          $row = xx_fetch_array ($rs);          $row = xx_fetch_array ($rs);
313          $num_elements = $row["num_elements"];          $num_elements = $row["num_elements"];
314    
# Line 351  function displayTOC($con, $page_id, $wra Line 348  function displayTOC($con, $page_id, $wra
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 = xx_query($sql, $con);                  $rs = xx_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");
# Line 366  function displayTOC($con, $page_id, $wra Line 363  function displayTOC($con, $page_id, $wra
363                                    
364                  $row_num = 0;                  $row_num = 0;
365                                    
366                  while ($row = xx_fetch_array ($rs)) {                  while ($row = xx_fetch_array ($rs, xx_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) {
# Line 434  function displayTOC($con, $page_id, $wra Line 431  function displayTOC($con, $page_id, $wra
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  ***********************************************************  ***********************************************************
# Line 452  statements.  Note that only course subje Line 448  statements.  Note that only course subje
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
# Line 465  function dropDownCoursesubSelected($con, Line 461  function dropDownCoursesubSelected($con,
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 = xx_tryquery($sql);
465          Use this SQL instead, if all distinct course designators, used or not,          while ($row = xx_fetch_array ($rs, xx_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 = xx_query($sql, $con);  
         while ($row = xx_fetch_array ($rs)) {  
466                  $coursesub = $row["coursesub"];                  $coursesub = $row["coursesub"];
467                                    
468                  printf("<option value = \"%s\"", $coursesub);                  printf("<option value = \"%s\"", $coursesub);
# Line 489  function dropDownCoursesubSelected($con, Line 473  function dropDownCoursesubSelected($con,
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  ***********************************************************  ***********************************************************
# Line 507  statements.  The faculty are displayed o Line 490  statements.  The faculty are displayed o
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,
# Line 521  function dropDownFacultySelected($con, $ Line 504  function dropDownFacultySelected($con, $
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 = xx_query($sql, $con);          $rs = xx_tryquery($sql);
509          while ($row = xx_fetch_array ($rs)) {          while ($row = xx_fetch_array ($rs, xx_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"];
# Line 555  function dropDownFacultySelected($con, $ Line 526  function dropDownFacultySelected($con, $
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
# Line 576  options.  They are ordered by the $field Line 546  options.  They are ordered by the $field
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 "
# Line 589  function dropDownFieldOmit($con, $table, Line 559  function dropDownFieldOmit($con, $table,
559                  . $where                  . $where
560                  . " ORDER BY "                  . " ORDER BY "
561                  . $field_display;                  . $field_display;
562          $rs = xx_query($sql, $con);          $rs = xx_tryquery($sql);
563          while ($row = xx_fetch_array ($rs)) {          while ($row = xx_fetch_array ($rs, xx_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
# Line 624  Typically, $field_value is the primary k Line 595  Typically, $field_value is the primary k
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 "
# Line 638  function dropDownFieldSelected($con, $ta Line 609  function dropDownFieldSelected($con, $ta
609                  . " ORDER BY "                  . " ORDER BY "
610                  . $field_display;                  . $field_display;
611                    
612          // Debugging          $rs = xx_tryquery($sql);
613          //printf("sql was: %s<BR>", $sql);          while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
           
         $rs = xx_query($sql, $con);  
         while ($row = xx_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) . "...";
# Line 657  function dropDownFieldSelected($con, $ta Line 625  function dropDownFieldSelected($con, $ta
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
# Line 673  Useful in performing delete and other op Line 640  Useful in performing delete and other op
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                    
# Line 687  function existsRow($con, $table, $key_fi Line 654  function existsRow($con, $table, $key_fi
654                  . "="                  . "="
655                  . $limit_id;                  . $limit_id;
656    
657          $rs = xx_query($sql, $con);          $rs = xx_tryquery($sql);
658          $rowcount = xx_num_rows($rs);          $rowcount = xx_num_rows($rs);
659          if ($rowcount >= 1){          if ($rowcount >= 1){
660                  $rowcount = 1;                  $rowcount = 1;
# Line 699  function existsRow($con, $table, $key_fi Line 666  function existsRow($con, $table, $key_fi
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 = xx_query($sql, $con);  
         while ($row = xx_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
# Line 757  Purpose: Line 684  Purpose:
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 "
# Line 769  function lookupField($con, $table, $key_ Line 696  function lookupField($con, $table, $key_
696                  . "='"                  . "='"
697                  . $key_value                  . $key_value
698                  . "'";                  . "'";
699          $rs = xx_query($sql, $con);          $rs = xx_tryquery($sql);
700          $row = xx_fetch_array ($rs);          $row = xx_fetch_array ($rs, xx_ASSOC);
701          if (xx_num_rows($rs) == 1) $result = $row[$desc_field];          if (xx_num_rows($rs) == 1) $result = $row[$desc_field];
702          else $result = "";          else $result = "";
703                    
# Line 779  function lookupField($con, $table, $key_ Line 706  function lookupField($con, $table, $key_
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:
# Line 793  Staff name in {First Name} {Last Name} f Line 719  Staff name in {First Name} {Last Name} f
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 = xx_query($sql, $con);          $rs = xx_tryquery($sql);
727          $row = xx_fetch_array ($rs);          $row = xx_fetch_array ($rs, xx_ASSOC);
728          $last_name = $row["last_name"];          $last_name = $row["last_name"];
729          $first_name = $row["first_name"];          $first_name = $row["first_name"];
730                    
# Line 814  function lookupStaff($con, $staff_id){ Line 740  function lookupStaff($con, $staff_id){
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
# Line 825  and this function here.  However, care m Line 751  and this function here.  However, care m
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                    
# Line 841  function pageLoadStats($con, $page_id){ Line 767  function pageLoadStats($con, $page_id){
767                          . ", now(), '"                          . ", now(), '"
768                          . $user_ip                          . $user_ip
769                          . "')";                          . "')";
770            xx_tryquery($sql);
         if (!xx_query($sql, $con)){  
                 sql_err($con);  
                 xx_query ("UNLOCK TABLES", $con);  
                 bailout();  
         } // bad write  
         else {  
                 xx_query("UNLOCK TABLES", $con);  
   
         } // good write to the pagestats table  
771    
772  }  }
773    
# Line 884  function printAlphabet($separator_char, Line 801  function printAlphabet($separator_char,
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,
# Line 894  same subject are logged with this functi Line 811  same subject are logged with this functi
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                    
# Line 910  function subLoadStats($con, $subject_id) Line 827  function subLoadStats($con, $subject_id)
827                          . ", now(), '"                          . ", now(), '"
828                          . $user_ip                          . $user_ip
829                          . "')";                          . "')";
830            xx_tryquery($sql);
         if (!xx_query($sql, $con)){  
                 sql_err($con);  
                 xx_query ("UNLOCK TABLES", $con);  
                 bailout();  
         } // bad write  
         else {  
                 xx_query("UNLOCK TABLES", $con);  
   
         } // good write to the substats table  
831    
832  }  }
833    
# Line 963  function textSearchmySQL($incoming) { Line 871  function textSearchmySQL($incoming) {
871          return $outgoing;          return $outgoing;
872    
873  }  }
874  ?>  ?>

Legend:
Removed from v.71  
changed lines
  Added in v.72

  ViewVC Help
Powered by ViewVC 1.1.26