/[libdata]/branches/paul/admin/include/app_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 /branches/paul/admin/include/app_controls.php

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

revision 66 by dpavlin, Thu Jan 15 16:10:00 2004 UTC revision 67 by dpavlin, Thu Mar 18 19:24:54 2004 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /**********************************************************  /**********************************************************
3  Function Library: app_controls.php  Function Library: app_controls.php
4  Original Author: Paul Bramscher <brams006@tc.umn.edu>  Original Author: Paul Bramscher <brams006@umn.edu>
5  Last Modified: 09.29.2003  Last Modified: 03.15.2004
6  ***********************************************************  ***********************************************************
7  Comments:  Comments:
8  Functions here are generally related to drawing of HTML  Functions here are generally related to drawing of HTML
# Line 19  authPage Line 19  authPage
19  authResourceDelete  authResourceDelete
20  authResourceEdit  authResourceEdit
21  authSubject  authSubject
 commaList  
 displayKeys  
 displayRelatedPages  
22  dropDownAccountOmit  dropDownAccountOmit
23  dropDownAuthCourses  dropDownAuthCourses
24  dropDownAuthPages  dropDownAuthPages
# Line 44  dropDownStaffOmit Line 41  dropDownStaffOmit
41  dropDownStaffSelected  dropDownStaffSelected
42  existsResSub  existsResSub
43  existsResSubNA  existsResSubNA
44    existsResSubNOTNA
45  existsRow  existsRow
46  getNotIn  getNotIn
 locationList  
47  lookupFaculty  lookupFaculty
48  lookupField  lookupField
49  lookupStaff  lookupStaff
50  radioField  msgTableClose
51    msgTableOpen
52  recordCount  recordCount
53  selectCoursesub  selectCoursesub
54  selectFaculty  selectFaculty
# Line 104  function adminReturn($sess_access_level) Line 102  function adminReturn($sess_access_level)
102    
103    
104  /**********************************************************  /**********************************************************
105  Function: authPage($con, $page_id, $sess_access_level, $sess_staff_id)  Function: authPage($page_id, $sess_access_level, $sess_staff_id)
106  Author: Paul Bramscher  Author: Paul Bramscher
107  Last Modified: 01.15.2003  Last Modified: 03.02.2004
108  ***********************************************************  ***********************************************************
109  Incoming:  Incoming:
 $con                    Database connection string  
110  $page_id                Page to test authorization  $page_id                Page to test authorization
111  $sess_access_level      Access level of the current user  $sess_access_level      Access level of the current user
112                          session.                          session.
# Line 141  by the manager of the new unit and not y Line 138  by the manager of the new unit and not y
138  etc...  etc...
139    
140  **********************************************************/  **********************************************************/
141  function authPage($con, $page_id, $sess_access_level, $sess_staff_id){  function authPage($page_id, $sess_access_level, $sess_staff_id){
142    
143          /* Access Table Definitions          /* Access Table Definitions
144          +-----------+--------------+---------+          +-----------+--------------+---------+
# Line 180  function authPage($con, $page_id, $sess_ Line 177  function authPage($con, $page_id, $sess_
177          // User is a manager.  Must be page coordinator, co-maintainer, or manager of          // User is a manager.  Must be page coordinator, co-maintainer, or manager of
178          // the coordinator's unit.          // the coordinator's unit.
179          else if ($sess_access_level == 100) {          else if ($sess_access_level == 100) {
180            
                   
181                          // Determine libunit                          // Determine libunit
182                          $lu_sql = "SELECT libunit_id FROM libunit                          $lu_sql = "SELECT libunit_id FROM libunit
183                                  WHERE head_staff_id = "                                  WHERE head_staff_id = "
184                                  . $sess_staff_id;                                  . $sess_staff_id;
185                          $lu_rs = mysql_query($lu_sql, $con);                          $lu_rs = mysql_tryquery($lu_sql);
186                                                    
187                          $lu_string = "ls.libunit_id IN (";                          $lu_string = "ls.libunit_id IN (";
188                          $first_element = 0;                          $first_element = 0;
189                                                    
190                          // Concatenate the IN clause                          // Concatenate the IN clause
191                          while ($lu_row = mysql_fetch_array ($lu_rs)) {                          while ($lu_row = mysql_fetch_array ($lu_rs, MYSQL_ASSOC)) {
192                                  $libunit_id = $lu_row["libunit_id"];                                  $libunit_id = $lu_row["libunit_id"];
193                                  //printf("libunit id was: %d<BR><BR>", $libunit_id);                                                              //printf("libunit id was: %d<BR><BR>", $libunit_id);                            
194                    
# Line 239  function authPage($con, $page_id, $sess_ Line 235  function authPage($con, $page_id, $sess_
235          // Run the authorized page query if not DBA level          // Run the authorized page query if not DBA level
236          if ($sess_access_level >= 20 && $sess_access_level < 1000) {          if ($sess_access_level >= 20 && $sess_access_level < 1000) {
237    
238                  $rs = mysql_query($sql, $con);                  $rs = mysql_tryquery($sql);
239                  $row = mysql_fetch_array ($rs);                  $row = mysql_fetch_array ($rs, MYSQL_ASSOC);
240    
241                  // Collect the access information                  // Collect the access information
242                  $auth_page = $row["auth_page"];                  $auth_page = $row["auth_page"];
# Line 254  function authPage($con, $page_id, $sess_ Line 250  function authPage($con, $page_id, $sess_
250    
251    
252  /**********************************************************  /**********************************************************
253  Function: authResourceDelete($con, $resource_id, $sess_access_level,  Function: authResourceDelete($resource_id, $sess_access_level,
254          $sess_staff_account)          $sess_staff_account)
255  Author: Paul Bramscher  Author: Paul Bramscher
256  Last Modified: 08.26.2003  Last Modified: 03.02.2004
257  ***********************************************************  ***********************************************************
258  Incoming:  Incoming:
 $con                    Database connection string  
259  $resource_id            Resource to test authorization  $resource_id            Resource to test authorization
260  $sess_access_level      Access level of the current user  $sess_access_level      Access level of the current user
261                          session.                          session.
# Line 278  supplied resource.  The following rules Line 273  supplied resource.  The following rules
273  (2) Any staffperson with access greater than guest and less than  (2) Any staffperson with access greater than guest and less than
274  manager may delete only those resource s/he has created.  manager may delete only those resource s/he has created.
275  **********************************************************/  **********************************************************/
276  function authResourceDelete($con, $resource_id, $sess_access_level,  function authResourceDelete($resource_id, $sess_access_level,
277          $sess_staff_account) {          $sess_staff_account) {
278    
279          /* Access Table Definitions          /* Access Table Definitions
# Line 313  function authResourceDelete($con, $resou Line 308  function authResourceDelete($con, $resou
308                          . $sess_staff_account                          . $sess_staff_account
309                          . "'";                          . "'";
310                    
311                  $rs = mysql_query($sql, $con);                  $rs = mysql_tryquery($sql);
312                  $row = mysql_fetch_array ($rs);                  $row = mysql_fetch_array ($rs, MYSQL_ASSOC);
313    
314                  // Collect the access information                  // Collect the access information
315                  $auth_resource = $row["auth_resource"];                  $auth_resource = $row["auth_resource"];
# Line 332  function authResourceDelete($con, $resou Line 327  function authResourceDelete($con, $resou
327          uncomment the previous portion and delete this.          uncomment the previous portion and delete this.
328          Note: 08.21.2003 - PFB. Open editing of resources by any author is now verboten.          Note: 08.21.2003 - PFB. Open editing of resources by any author is now verboten.
329                    
330          // Author or higher access.  Great edit/delete access for everything.          // Author or higher access.  Grant edit/delete access for everything.
331          if ($sess_access_level >= "10" ) {          if ($sess_access_level >= "10" ) {
332                  $auth_resource = 1;                  $auth_resource = 1;
333          }          }
334          */          */
   
   
         // Every other access level.  No resources at all!  
         else {  
                 $auth_resource = 0;  
         }  
335                    
336          return $auth_resource;          return $auth_resource;
337    
# Line 350  function authResourceDelete($con, $resou Line 339  function authResourceDelete($con, $resou
339    
340    
341  /**********************************************************  /**********************************************************
342  Function: authResourceEdit($con, $resource_id, $sess_access_level,  Function: authResourceEdit($resource_id, $sess_access_level,
343          $sess_staff_account)          $sess_staff_account)
344  Author: Paul Bramscher  Author: Paul Bramscher
345  Last Modified: 08.26.2003  Last Modified: 03.10.2004
346  ***********************************************************  ***********************************************************
347  Incoming:  Incoming:
 $con                    Database connection string  
348  $resource_id            Resource to test authorization  $resource_id            Resource to test authorization
349  $sess_access_level      Access level of the current user  $sess_access_level      Access level of the current user
350                          session.                          session.
# Line 372  supplied resource.  The following rules Line 360  supplied resource.  The following rules
360    
361  (1) Authors and above may edit all resources  (1) Authors and above may edit all resources
362  **********************************************************/  **********************************************************/
363  function authResourceEdit($con, $resource_id, $sess_access_level,  function authResourceEdit($resource_id, $sess_access_level,
364          $sess_staff_account) {          $sess_staff_account) {
365    
366          /* Access Table Definitions          /* Access Table Definitions
# Line 408  function authResourceEdit($con, $resourc Line 396  function authResourceEdit($con, $resourc
396                          . $sess_staff_account                          . $sess_staff_account
397                          . "'";                          . "'";
398                                                    
399                  $rs = mysql_query($sql, $con);                  $rs = mysql_tryquery($sql);
400                  $row = mysql_fetch_array ($rs);                  $row = mysql_fetch_array ($rs, MYSQL_ASSOC);
401    
402                  // Collect the access information                  // Collect the access information
403                  $auth_resource = $row["auth_resource"];                  $auth_resource = $row["auth_resource"];
# Line 435  function authResourceEdit($con, $resourc Line 423  function authResourceEdit($con, $resourc
423          if ($sess_access_level >= 10 ) {          if ($sess_access_level >= 10 ) {
424                  $auth_resource = 1;                  $auth_resource = 1;
425          }          }
   
   
         // Every other access level.  No resources at all!  
         else {  
                 $auth_resource = 0;  
         }  
   
         // Testing  
         // printf("sql was: %s<BR>", $sql);  
         // printf("sess acl: %s<BR>", $sess_access_level);  
         // printf("sess_staff_account: %s<BR>", $sess_staff_account);  
         // printf("auth res: %s<br>", $auth_resource);  
426                    
427          return $auth_resource;          return $auth_resource;
428    
# Line 454  function authResourceEdit($con, $resourc Line 430  function authResourceEdit($con, $resourc
430    
431    
432  /**********************************************************  /**********************************************************
433  Function: authSubject($con, $sess_access_level, $sess_staff_id,  Function: authSubject($sess_access_level, $sess_staff_id,
434          $subject_id)          $subject_id)
435  Author: Paul Bramscher  Author: Paul Bramscher
436  Last Modified: 01.22.2003  Last Modified: 03.02.2004
437  ***********************************************************  ***********************************************************
438  Incoming:  Incoming:
 $con                    Database connection string  
439  $sess_access_level      Access level of the current user  $sess_access_level      Access level of the current user
440                          session.                          session.
441  $sess_staff_id          staff id of the current user  $sess_staff_id          staff id of the current user
# Line 482  which they are assigned. Line 457  which they are assigned.
457    
458    
459  **********************************************************/  **********************************************************/
460  function authSubject($con, $sess_access_level, $sess_staff_id,  function authSubject($sess_access_level, $sess_staff_id,
461          $subject_id){          $subject_id){
462    
463          /* Access Table Definitions          /* Access Table Definitions
# Line 524  function authSubject($con, $sess_access_ Line 499  function authSubject($con, $sess_access_
499                          $lu_sql = "SELECT libunit_id FROM libunit                          $lu_sql = "SELECT libunit_id FROM libunit
500                                  WHERE head_staff_id = "                                  WHERE head_staff_id = "
501                                  . $sess_staff_id;                                  . $sess_staff_id;
502                          $lu_rs = mysql_query($lu_sql, $con);                          $lu_rs = mysql_tryquery($lu_sql);
503                                                    
504                          $lu_string = "ls.libunit_id IN (";                          $lu_string = "ls.libunit_id IN (";
505                          $first_element = 0;                          $first_element = 0;
506                                                    
507                          // Concatenate the IN clause                          // Concatenate the IN clause
508                          while ($lu_row = mysql_fetch_array ($lu_rs)) {                          while ($lu_row = mysql_fetch_array ($lu_rs, MYSQL_ASSOC)) {
509                                  $libunit_id = $lu_row["libunit_id"];                                  $libunit_id = $lu_row["libunit_id"];
510                                  //printf("libunit id was: %d<BR><BR>", $libunit_id);                                                              //printf("libunit id was: %d<BR><BR>", $libunit_id);                            
511                    
# Line 573  function authSubject($con, $sess_access_ Line 548  function authSubject($con, $sess_access_
548                  $auth_subject = 0;                  $auth_subject = 0;
549          }          }
550    
         // Testing  
         // printf("sql was: %s<BR>", $sql);  
   
551          // Run the authorized subject query if not DBA level          // Run the authorized subject query if not DBA level
552          if ($sess_access_level >= 20 && $sess_access_level < 1000) {          if ($sess_access_level >= 20 && $sess_access_level < 1000) {
553    
554                  $rs = mysql_query($sql, $con);                  $rs = mysql_tryquery($sql);
555                  $row = mysql_fetch_array ($rs);                  $row = mysql_fetch_array ($rs, MYSQL_ASSOC);
556    
557                  // Collect the access information                  // Collect the access information
558                  $auth_subject = $row["auth_subject"];                  $auth_subject = $row["auth_subject"];
# Line 594  function authSubject($con, $sess_access_ Line 566  function authSubject($con, $sess_access_
566    
567    
568  /**********************************************************  /**********************************************************
569  Function: commaList($con, $displayField, $sql)  Function: dropDownAccountOmit($omit)
570  Author: Paul Bramscher  Author: Paul Bramscher
571  Last Modified: 07.02.2002  Last Modified: 03.10.2004
572  ***********************************************************  ***********************************************************
573  Incoming:  Incoming:
 $con                    Database connection string  
 $displayField           Field to display  
 $sql                    SQL to execute  
 ***********************************************************  
 Outgoing:  
 None  
 ***********************************************************  
 Purpose:  
 Performs a lookup similar to lookupField, but instead of  
 returning the descriptive value for an ID field, it returns  
 a comma-separated list of results.  
 **********************************************************/  
 function commaList($con, $displayField, $sql){  
         $rs = mysql_query($sql, $con);  
           
         $first = 1;  
         while ($row = mysql_fetch_array ($rs)) {  
                 $result = $row[$displayField];  
                 if ($first == 1) {  
                         $first = 0;  
                         printf("%s", $result);  
                 }  
                 else printf(", %s", $result);  
         }  
 }  
   
   
 /**********************************************************  
 Function: displayKeys($con, $table, $field_display,  
 $field_value, $limit)  
 Author: Paul Bramscher  
 Last Modified: 7.26.2001  
 ***********************************************************  
 Incoming:  
 $con                    Database connection string  
 $table                  Table in database to search  
 $field_display          Select displayed to user  
 $field_value            Actual value of the HTML tag  
 $limit                  Field to limit $field_display by  
 ***********************************************************  
 Outgoing:  
 None  
 ***********************************************************  
 Purpose:  
 Does a simple text dump to show descriptive values and  
 their associated primary keys in a small table.  If  
 $limit is defined, then limit the result set to display  
 only $field_display which matches a like cause.  
 **********************************************************/  
 function displayKeys($con, $table, $field_display,  
         $field_value, $limit){  
           
         // Build the sql  
         $sql = "SELECT " . $field_display . ", "  
                 . $field_value . " FROM " . $table;  
         if (strlen($limit) > 1){  
                 $sql .= " WHERE "  
                         . $field_display  
                         . " LIKE '%"  
                         . $limit  
                         . "%'";  
         }  
           
         // Order the display  
         $sql .= " ORDER BY " . $field_display;  
           
         $rs = mysql_query($sql, $con);  
   
         printf("<td><b>Description</b></td>");  
         printf("<td><b>Key</b></td></tr>");  
   
         while ($row = mysql_fetch_array ($rs)) {  
                 $field_display_item = $row[$field_display];  
                 $field_value_item = $row[$field_value];  
                 printf("<tr><td>"  
                         . $field_display_item  
                         . "</td><td>"  
                         . $field_value_item  
                         . "</td></tr>");  
         };  
 }  
   
   
 /**********************************************************  
 Function: displayRelatedPages($con, $subject_id)  
 Author: Paul Bramscher  
 Last Modified: 06.17.2003  
 ***********************************************************  
 Incoming:  
 $con                    Database connection string  
 $subject_id             Subject of the RQS page  
 ***********************************************************  
 Outgoing:  
 None  
 ***********************************************************  
 Purpose:  
 Displays any PageScribe pages associated with the supplied  
 subject id.  
 **********************************************************/  
 function displayRelatedPages($con, $subject_id){  
         $sql = "SELECT p.page_id, p.page_title  
                 FROM page p, sub_page sp  
                 WHERE sp.subject_id = "  
                         . $subject_id  
                         . " AND sp.page_id = p.page_id ORDER BY p.page_title";  
           
         $rs = mysql_query($sql, $con);  
         while ($row = mysql_fetch_array ($rs)) {  
                 $page_id = $row["page_id"];  
                 $page_title = $row["page_title"];  
   
                 // Pull out any HTML  
                 $page_title = strip_tags($page_title);  
                   
                 printf("<a href=\"page.phtml?page_id=%s\">%s</a><BR>\n", $page_id, $page_title);  
         };  
 }  
   
   
 /**********************************************************  
 Function: dropDownAccountOmit($con, $omit)  
 Author: Paul Bramscher  
 Last Modified: 04.01.2003  
 ***********************************************************  
 Incoming:  
 $con                    Database connection string  
574  $omit                   String of staff's to omit  $omit                   String of staff's to omit
575  ***********************************************************  ***********************************************************
576  Outgoing:  Outgoing:
# Line 738  it returns the staff_account.  This was Line 584  it returns the staff_account.  This was
584  which a relational tie with the staff table is not desirable  which a relational tie with the staff table is not desirable
585  after the value is inserted.  For example, historical statistics.  after the value is inserted.  For example, historical statistics.
586  **********************************************************/  **********************************************************/
587  function dropDownAccountOmit($con, $omit){  function dropDownAccountOmit($omit){
588          $sql = "SELECT * from staff " . $omit .          $sql = "SELECT * from staff "
589          " ORDER BY last_name, first_name";                  . $omit
590                    . " ORDER BY last_name, first_name";
591                    
592          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
593          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
594                  $last_name = $row["last_name"];                  $last_name = $row["last_name"];
595                  $first_name = $row["first_name"];                  $first_name = $row["first_name"];
596                  $staff_id = $row["staff_id"];                  $staff_id = $row["staff_id"];
# Line 752  function dropDownAccountOmit($con, $omit Line 599  function dropDownAccountOmit($con, $omit
599                  // Make it look more friendly                  // Make it look more friendly
600                  if ($staff_id == 1) $staff = "(N/A)";                  if ($staff_id == 1) $staff = "(N/A)";
601                  else $staff = $last_name . ", " . $first_name . " (" . $staff_account . ")";                  else $staff = $last_name . ", " . $first_name . " (" . $staff_account . ")";
602                  printf("<option value = \"" . $staff_account                  printf("<option value = \""
603                          . "\" >" . $staff . "</option>\n");                          . $staff_account
604                            . "\" >"
605                            . $staff
606                            . "</option>\n");
607          };          };
608  }  }
609    
610    
611  /**********************************************************  /**********************************************************
612  Function: dropDownAuthCourses($con, $sess_access_level, $sess_staff_id)  Function: dropDownAuthCourses($sess_access_level, $sess_staff_id)
613  Author: Paul Bramscher  Author: Paul Bramscher
614  Last Modified: 01.07.2003  Last Modified: 03.02.2004
615  ***********************************************************  ***********************************************************
616  Incoming:  Incoming:
 $con                    Database connection string  
617  $sess_access_level      Access level of the current user  $sess_access_level      Access level of the current user
618                          session.                          session.
619  $sess_staff_id          staff id of the current user  $sess_staff_id          staff id of the current user
# Line 799  accessed by the manager of the new unit Line 648  accessed by the manager of the new unit
648  etc...  etc...
649    
650  **********************************************************/  **********************************************************/
651  function dropDownAuthCourses($con, $sess_access_level, $sess_staff_id){  function dropDownAuthCourses($sess_access_level, $sess_staff_id){
652    
653          /* Access Table Definitions          /* Access Table Definitions
654          +-----------+--------------+---------+          +-----------+--------------+---------+
# Line 841  function dropDownAuthCourses($con, $sess Line 690  function dropDownAuthCourses($con, $sess
690                          $lu_sql = "SELECT libunit_id FROM libunit                          $lu_sql = "SELECT libunit_id FROM libunit
691                                  WHERE head_staff_id = "                                  WHERE head_staff_id = "
692                                  . $sess_staff_id;                                  . $sess_staff_id;
693                          $lu_rs = mysql_query($lu_sql, $con);                          $lu_rs = mysql_tryquery($lu_sql);
694                                                    
695                          $lu_string = "ls.libunit_id IN (";                          $lu_string = "ls.libunit_id IN (";
696                          $first_element = 0;                          $first_element = 0;
697                                                    
698                          // Concatenate the IN clause                          // Concatenate the IN clause
699                          while ($lu_row = mysql_fetch_array ($lu_rs)) {                          while ($lu_row = mysql_fetch_array ($lu_rs, MYSQL_ASSOC)) {
700                                  $libunit_id = $lu_row["libunit_id"];                                                              $libunit_id = $lu_row["libunit_id"];                            
701                    
702                                  if ($first_element == 0) {                                  if ($first_element == 0) {
# Line 882  function dropDownAuthCourses($con, $sess Line 731  function dropDownAuthCourses($con, $sess
731    
732                  // DBA.  Access everything.                  // DBA.  Access everything.
733                  case "1000" :                  case "1000" :
734                          dropDownCourses($con);                          dropDownCourses();
735                          break;                          break;
736    
737                  // Every other access level.  No pages at all!                  // Every other access level.  No pages at all!
# Line 894  function dropDownAuthCourses($con, $sess Line 743  function dropDownAuthCourses($con, $sess
743          // Run the authorized page query if not DBA level          // Run the authorized page query if not DBA level
744          if ($sess_access_level >= 20 && $sess_access_level < 1000) {          if ($sess_access_level >= 20 && $sess_access_level < 1000) {
745    
746                  $page_rs = mysql_query($page_sql, $con);                  $page_rs = mysql_tryquery($page_sql);
747    
748                  while ($page_row = mysql_fetch_array ($page_rs)) {                  while ($page_row = mysql_fetch_array ($page_rs, MYSQL_ASSOC)) {
749    
750                          // Collect the page information                          // Collect the page information
751                          $page_id = $page_row["page_id"];                          $page_id = $page_row["page_id"];
# Line 914  function dropDownAuthCourses($con, $sess Line 763  function dropDownAuthCourses($con, $sess
763    
764    
765  /**********************************************************  /**********************************************************
766  Function: dropDownAuthPages($con, $sess_access_level, $sess_staff_id)  Function: dropDownAuthPages($sess_access_level, $sess_staff_id)
767  Author: Paul Bramscher  Author: Paul Bramscher
768  Last Modified: 01.07.2003  Last Modified: 03.02.2004
769  ***********************************************************  ***********************************************************
770  Incoming:  Incoming:
 $con                    Database connection string  
771  $sess_access_level      Access level of the current user  $sess_access_level      Access level of the current user
772                          session.                          session.
773  $sess_staff_id          staff id of the current user  $sess_staff_id          staff id of the current user
# Line 950  by the manager of the new unit and not y Line 798  by the manager of the new unit and not y
798  etc...  etc...
799    
800  **********************************************************/  **********************************************************/
801  function dropDownAuthPages($con, $sess_access_level, $sess_staff_id){  function dropDownAuthPages($sess_access_level, $sess_staff_id){
802    
803          /* Access Table Definitions          /* Access Table Definitions
804          +-----------+--------------+---------+          +-----------+--------------+---------+
# Line 991  function dropDownAuthPages($con, $sess_a Line 839  function dropDownAuthPages($con, $sess_a
839                          $lu_sql = "SELECT libunit_id FROM libunit                          $lu_sql = "SELECT libunit_id FROM libunit
840                                  WHERE head_staff_id = "                                  WHERE head_staff_id = "
841                                  . $sess_staff_id;                                  . $sess_staff_id;
842                          $lu_rs = mysql_query($lu_sql, $con);                          $lu_rs = mysql_tryquery($lu_sql);
843                                                    
844                          $lu_string = "ls.libunit_id IN (";                          $lu_string = "ls.libunit_id IN (";
845                          $first_element = 0;                          $first_element = 0;
846                                                    
847                          // Concatenate the IN clause                          // Concatenate the IN clause
848                          while ($lu_row = mysql_fetch_array ($lu_rs)) {                          while ($lu_row = mysql_fetch_array ($lu_rs, MYSQL_ASSOC)) {
849                                  $libunit_id = $lu_row["libunit_id"];                                  $libunit_id = $lu_row["libunit_id"];
850                                  printf("libunit id was: %d<BR><BR>", $libunit_id);                                                                printf("libunit id was: %d<BR><BR>", $libunit_id);                              
851                    
# Line 1032  function dropDownAuthPages($con, $sess_a Line 880  function dropDownAuthPages($con, $sess_a
880    
881                  // DBA.  Access everything.                  // DBA.  Access everything.
882                  case "1000" :                  case "1000" :
883                          dropDownFieldOmit($con, "page", "page_title", "page_id", " WHERE pagetype_id = 2");                          dropDownFieldOmit("page", "page_title", "page_id", " WHERE pagetype_id = 2");
884                          break;                          break;
885    
886                  // Every other access level.  No pages at all!                  // Every other access level.  No pages at all!
# Line 1044  function dropDownAuthPages($con, $sess_a Line 892  function dropDownAuthPages($con, $sess_a
892          // Run the authorized page query if not DBA level          // Run the authorized page query if not DBA level
893          if ($sess_access_level >= 20 && $sess_access_level < 1000) {          if ($sess_access_level >= 20 && $sess_access_level < 1000) {
894    
895                  $page_rs = mysql_query($page_sql, $con);                  $page_rs = mysql_tryquery($page_sql);
896    
897                  while ($page_row = mysql_fetch_array ($page_rs)) {                  while ($page_row = mysql_fetch_array ($page_rs, MYSQL_ASSOC)) {
898    
899                          // Collect the page information                          // Collect the page information
900                          $page_id = $page_row["page_id"];                          $page_id = $page_row["page_id"];
# Line 1058  function dropDownAuthPages($con, $sess_a Line 906  function dropDownAuthPages($con, $sess_a
906                          printf("<option value=\"%d\">%s</option>\n", $page_id, $page_title);                          printf("<option value=\"%d\">%s</option>\n", $page_id, $page_title);
907                  }                  }
908    
   
         // printf("sql was: %s<BR>", $page_sql);  
   
909          }          }
910    
911  }  }
912    
913    
914  /**********************************************************  /**********************************************************
915  Function: dropDownAuthSubjects($con, $sess_access_level, $sess_staff_id)  Function: dropDownAuthSubjects($sess_access_level, $sess_staff_id)
916  Author: Paul Bramscher  Author: Paul Bramscher
917  Last Modified: 01.22.2003  Last Modified: 03.02.2004
918  ***********************************************************  ***********************************************************
919  Incoming:  Incoming:
 $con                    Database connection string  
920  $sess_access_level      Access level of the current user  $sess_access_level      Access level of the current user
921                          session.                          session.
922  $sess_staff_id          staff id of the current user  $sess_staff_id          staff id of the current user
# Line 1090  user has authorization to edit.  The fol Line 934  user has authorization to edit.  The fol
934  (3) Any staffperson can manage subjects to which s/he is assigned.  (3) Any staffperson can manage subjects to which s/he is assigned.
935    
936  **********************************************************/  **********************************************************/
937  function dropDownAuthSubjects($con, $sess_access_level, $sess_staff_id){  function dropDownAuthSubjects($sess_access_level, $sess_staff_id){
938    
939          /* Access Table Definitions          /* Access Table Definitions
940          +-----------+--------------+---------+          +-----------+--------------+---------+
# Line 1127  function dropDownAuthSubjects($con, $ses Line 971  function dropDownAuthSubjects($con, $ses
971                          $lu_sql = "SELECT libunit_id FROM libunit                          $lu_sql = "SELECT libunit_id FROM libunit
972                                  WHERE head_staff_id = "                                  WHERE head_staff_id = "
973                                  . $sess_staff_id;                                  . $sess_staff_id;
974                          $lu_rs = mysql_query($lu_sql, $con);                          $lu_rs = mysql_tryquery($lu_sql);
975                                                    
976                          $lu_string = "ls.libunit_id IN (";                          $lu_string = "ls.libunit_id IN (";
977                          $first_element = 0;                          $first_element = 0;
978                                                    
979                          // Concatenate the IN clause                          // Concatenate the IN clause
980                          while ($lu_row = mysql_fetch_array ($lu_rs)) {                          while ($lu_row = mysql_fetch_array ($lu_rs, MYSQL_ASSOC)) {
981                                  $libunit_id = $lu_row["libunit_id"];                                  $libunit_id = $lu_row["libunit_id"];
982                                  printf("libunit id was: %d<BR><BR>", $libunit_id);                                                                printf("libunit id was: %d<BR><BR>", $libunit_id);                              
983                    
# Line 1166  function dropDownAuthSubjects($con, $ses Line 1010  function dropDownAuthSubjects($con, $ses
1010    
1011                  // DBA.  Access everything.                  // DBA.  Access everything.
1012                  case "1000" :                  case "1000" :
1013                          dropDownFieldOmit($con, "subject", "subject", "subject_id", "WHERE SUBJECT_ID > 1");                          dropDownFieldOmit("subject", "subject", "subject_id", "WHERE SUBJECT_ID > 1");
1014                          break;                          break;
1015    
1016                  // Every other access level.  No pages at all!                  // Every other access level.  No pages at all!
# Line 1178  function dropDownAuthSubjects($con, $ses Line 1022  function dropDownAuthSubjects($con, $ses
1022          // Run the authorized page query if not DBA level          // Run the authorized page query if not DBA level
1023          if ($sess_access_level >= 20 && $sess_access_level < 1000) {          if ($sess_access_level >= 20 && $sess_access_level < 1000) {
1024    
1025                  $rs = mysql_query($sql, $con);                  $rs = mysql_tryquery($sql);
1026    
1027                  while ($row = mysql_fetch_array ($rs)) {                  while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1028    
1029                          // Collect the page information                          // Collect the page information
1030                          $subject_id = $row["subject_id"];                          $subject_id = $row["subject_id"];
# Line 1190  function dropDownAuthSubjects($con, $ses Line 1034  function dropDownAuthSubjects($con, $ses
1034                          printf("<option value=\"%d\">%s</option>\n", $subject_id, $subject);                          printf("<option value=\"%d\">%s</option>\n", $subject_id, $subject);
1035                  }                  }
1036    
   
         printf("sql was: %s<BR>", $sql);  
   
1037          }          }
1038    
1039  }  }
1040    
1041    
1042  /**********************************************************  /**********************************************************
1043  Function: dropDownCourses($con)  Function: dropDownCourses()
1044  Author: Paul Bramscher  Author: Paul Bramscher
1045  Last Modified: 11.26.2003  Last Modified: 03.10.2004
1046  ***********************************************************  ***********************************************************
1047  Incoming:  Incoming:
1048  $con                    Database connection string  None
1049  ***********************************************************  ***********************************************************
1050  Outgoing:  Outgoing:
1051  None  None
# Line 1213  Purpose: Line 1054  Purpose:
1054  Populates a drop-down box on an HTML form with courseScribe  Populates a drop-down box on an HTML form with courseScribe
1055  courses, listed by course name and designator.  courses, listed by course name and designator.
1056  **********************************************************/  **********************************************************/
1057  function dropDownCourses($con) {  function dropDownCourses() {
1058    
1059          $sql = "SELECT page_id, course_concat          $sql = "SELECT page_id, course_concat
1060                  FROM course                  FROM course
1061                  ORDER BY course_concat";                  ORDER BY course_concat";
1062                                    
1063          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1064          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1065                  $page_id = $row["page_id"];                  $page_id = $row["page_id"];
1066                  $course_concat = $row["course_concat"];                  $course_concat = $row["course_concat"];
1067    
1068                  if (strlen($course_concat) > 45) $course_concat = substr($course_concat, 0, 45) . "...";                  if (strlen($course_concat) > 45) $course_concat = substr($course_concat, 0, 45) . "...";
1069                                    
1070                  printf("<option value = \"" . $page_id                  printf("<option value = \""
1071                          . "\" >" . $course_concat . "</option>\n");                          . $page_id
1072                            . "\" >"
1073                            . $course_concat
1074                            . "</option>\n");
1075          };          };
1076  }  }
1077    
1078    
1079  /**********************************************************  /**********************************************************
1080  Function: dropDownCoursesubOmit($con, $omit)  Function: dropDownCoursesubOmit($omit)
1081  Author: Paul Bramscher  Author: Paul Bramscher
1082  Last Modified: 06.04.2003  Last Modified: 03.02.2004
1083  ***********************************************************  ***********************************************************
1084  Incoming:  Incoming:
 $con                    Database connection string  
1085  $omit                   String of coursesub's to omit  $omit                   String of coursesub's to omit
1086  ***********************************************************  ***********************************************************
1087  Outgoing:  Outgoing:
# Line 1248  Purpose: Line 1091  Purpose:
1091  Populates a drop-down box on an HTML form with select  Populates a drop-down box on an HTML form with select
1092  statements.  $omit limits output.  statements.  $omit limits output.
1093  **********************************************************/  **********************************************************/
1094  function dropDownCoursesubOmit($con, $omit){  function dropDownCoursesubOmit($omit){
1095    
1096          $sql = "SELECT coursesub, coursesub_descr, coursesub_id, cip_code FROM          $sql = "SELECT
1097                  coursesub "                  coursesub,
1098                    coursesub_descr,
1099                    coursesub_id,
1100                    cip_code
1101                    FROM coursesub "
1102                  . $omit                  . $omit
1103                  . " ORDER BY coursesub_descr";                  . " ORDER BY coursesub_descr";
1104                    
1105          // Fetch the values          // Fetch the values
1106          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1107          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1108                  $coursesub = $row["coursesub"];                  $coursesub = $row["coursesub"];
1109                  $coursesub_id = $row["coursesub_id"];                  $coursesub_id = $row["coursesub_id"];
1110                  $coursesub_descr = $row["coursesub_descr"];                  $coursesub_descr = $row["coursesub_descr"];
1111                  $cip_code = $row["cip_code"];                  $cip_code = $row["cip_code"];
1112                                    
1113                  // Limit length                  // Limit length
1114                  if (strlen($coursesub_descr) > 30) $coursesub_descr = substr($coursesub_descr, 0, 30) . "...";                  if (strlen($coursesub_descr) > 30)
1115                            $coursesub_descr = substr($coursesub_descr, 0, 30) . "...";
1116                                    
1117                  printf("<option value = \"%s\">%s | %s [%s]</option>", $coursesub_id, $coursesub, $coursesub_descr, $cip_code);                  printf("<option value = \"%s\">%s | %s [%s]</option>",
1118                            $coursesub_id, $coursesub, $coursesub_descr, $cip_code);
1119          }          }
1120  }  }
1121    
1122    
1123  /**********************************************************  /**********************************************************
1124  Function: dropDownCoursesubSelected($con, $limit, $preselected)  Function: dropDownCoursesubSelected($limit, $preselected)
1125  Author: Paul Bramscher  Author: Paul Bramscher
1126  Last Modified: 08.18.2003  Last Modified: 03.02.2004
1127  ***********************************************************  ***********************************************************
1128  Incoming:  Incoming:
 $con                    Database connection string  
1129  $limit                  Additional limit on the box  $limit                  Additional limit on the box
1130  $preselected            Pre-selected course subject  $preselected            Pre-selected course subject
1131  ***********************************************************  ***********************************************************
# Line 1288  Purpose: Line 1136  Purpose:
1136  Populates a drop-down box on an HTML form with select  Populates a drop-down box on an HTML form with select
1137  statements.  $limit limits output.  statements.  $limit limits output.
1138  **********************************************************/  **********************************************************/
1139  function dropDownCoursesubSelected($con, $limit, $preselected){  function dropDownCoursesubSelected($limit, $preselected){
1140    
1141          $sql = "SELECT          $sql = "SELECT
1142                  coursesub,                  coursesub,
# Line 1303  function dropDownCoursesubSelected($con, Line 1151  function dropDownCoursesubSelected($con,
1151          $sql .= " ORDER BY coursesub_descr";          $sql .= " ORDER BY coursesub_descr";
1152                    
1153          // Fetch the values          // Fetch the values
1154          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1155          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1156                  $coursesub = $row["coursesub"];                  $coursesub = $row["coursesub"];
1157                  $coursesub_id = $row["coursesub_id"];                  $coursesub_id = $row["coursesub_id"];
1158                  $coursesub_descr = $row["coursesub_descr"];                  $coursesub_descr = $row["coursesub_descr"];
1159                  $cip_code = $row["cip_code"];                  $cip_code = $row["cip_code"];
1160                                    
1161                  // Limit length                  // Limit length
1162                  if (strlen($coursesub_descr) > 25) $coursesub_descr = substr($coursesub_descr, 0, 30) . "...";                  if (strlen($coursesub_descr) > 25)
1163                            $coursesub_descr = substr($coursesub_descr, 0, 30) . "...";
1164    
1165                  printf("<option value = \"%d\"", $coursesub_id);                  printf("<option value = \"%d\"", $coursesub_id);
1166                  if ($coursesub_id == $preselected) printf(" selected ");                  if ($coursesub_id == $preselected) printf(" selected ");
# Line 1322  function dropDownCoursesubSelected($con, Line 1171  function dropDownCoursesubSelected($con,
1171    
1172    
1173  /**********************************************************  /**********************************************************
1174  Function: dropDownFaculty($con)  Function: dropDownFaculty()
1175  Author: Paul Bramscher  Author: Paul Bramscher
1176  Last Modified: 12.02.2002  Last Modified: 03.02.2004
1177  ***********************************************************  ***********************************************************
1178  Incoming:  Incoming:
1179  $con                    Database connection string  None
1180  ***********************************************************  ***********************************************************
1181  Outgoing:  Outgoing:
1182  None  None
# Line 1335  None Line 1184  None
1184  Purpose:  Purpose:
1185  Populates a drop-down box on an HTML form with select  Populates a drop-down box on an HTML form with select
1186  options of faculty members.  They are displayed and ordered  options of faculty members.  They are displayed and ordered
1187  in the following format: "last name, first name (x500id)".  in the following format: "last name, first name (staff account)".
1188  **********************************************************/  **********************************************************/
1189  function dropDownFaculty($con){  function dropDownFaculty(){
1190          // Build the SQL.          // Build the SQL.
1191          $sql = "SELECT *          $sql = "SELECT *
1192                  FROM faculty                  FROM faculty
1193                  ORDER BY faculty_lastname, faculty_firstname, faculty_account";                  ORDER BY faculty_lastname, faculty_firstname, faculty_account";
1194            $rs = mysql_tryquery($sql);
1195          $rs = mysql_query($sql, $con);          
1196          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1197                  $faculty_id = $row["faculty_id"];                  $faculty_id = $row["faculty_id"];
1198                  $faculty_lastname = $row["faculty_lastname"];                  $faculty_lastname = $row["faculty_lastname"];
1199                  $faculty_firstname = $row["faculty_firstname"];                  $faculty_firstname = $row["faculty_firstname"];
# Line 1357  function dropDownFaculty($con){ Line 1206  function dropDownFaculty($con){
1206                          if (strlen($faculty_account) > 0) $faculty .= " (" . $faculty_account . ")";                          if (strlen($faculty_account) > 0) $faculty .= " (" . $faculty_account . ")";
1207                  }                  }
1208                                    
1209                  printf("<option value = \"" . $faculty_id                  printf("<option value = \""
1210                          . "\" >" . $faculty . "</option>\n");                          . $faculty_id
1211                            . "\" >"
1212                            . $faculty
1213                            . "</option>\n");
1214          };          };
1215  }  }
1216    
1217    
1218  /**********************************************************  /**********************************************************
1219  Function: dropDownFacultyOmit($con, $omit)  Function: dropDownFacultyOmit($omit)
1220  Author: Paul Bramscher  Author: Paul Bramscher
1221  Last Modified: 12.12.2002  Last Modified: 03.10.2004
1222  ***********************************************************  ***********************************************************
1223  Incoming:  Incoming:
 $con                    Database connection string  
1224  $omit                   String of human's to omit  $omit                   String of human's to omit
1225  ***********************************************************  ***********************************************************
1226  Outgoing:  Outgoing:
# Line 1379  Purpose: Line 1230  Purpose:
1230  Populates a drop-down box on an HTML form with select  Populates a drop-down box on an HTML form with select
1231  statements.  $omit limits output.  statements.  $omit limits output.
1232  **********************************************************/  **********************************************************/
1233  function dropDownFacultyOmit($con, $omit){  function dropDownFacultyOmit($omit){
1234          $sql = "SELECT * FROM faculty "          $sql = "SELECT * FROM faculty "
1235                  . $omit                  . $omit
1236                  . " ORDER BY faculty_lastname, faculty_firstname";                  . " ORDER BY faculty_lastname, faculty_firstname";
1237            $rs = mysql_tryquery($sql);
1238                    
1239          $rs = mysql_query($sql, $con);          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
         while ($row = mysql_fetch_array ($rs)) {  
1240                  $faculty_id = $row["faculty_id"];                  $faculty_id = $row["faculty_id"];
1241                  $faculty_lastname = $row["faculty_lastname"];                  $faculty_lastname = $row["faculty_lastname"];
1242                  $faculty_firstname = $row["faculty_firstname"];                  $faculty_firstname = $row["faculty_firstname"];
# Line 1398  function dropDownFacultyOmit($con, $omit Line 1249  function dropDownFacultyOmit($con, $omit
1249                          if (strlen($faculty_account) > 0) $faculty .= " (" . $faculty_account . ")";                          if (strlen($faculty_account) > 0) $faculty .= " (" . $faculty_account . ")";
1250                  }                  }
1251                                    
1252                  printf("<option value = \"" . $faculty_id                  printf("<option value = \""
1253                          . "\" >" . $faculty . "</option>\n");                          . $faculty_id
1254                            . "\" >"
1255                            . $faculty
1256                            . "</option>\n");
1257          };          };
1258  }  }
1259    
1260    
1261  /**********************************************************  /**********************************************************
1262  Function: dropDownFacultySelected($con, $limit, $preselected)  Function: dropDownFacultySelected($limit, $preselected)
1263  Author: Paul Bramscher  Author: Paul Bramscher
1264  Last Modified: 12.12.2002  Last Modified: 03.02.2004
1265  ***********************************************************  ***********************************************************
1266  Incoming:  Incoming:
 $con                    Database connection string  
1267  $limit                  Any WHERE clause  $limit                  Any WHERE clause
1268  $preselected            Incoming faculty person to preselect  $preselected            Incoming faculty person to preselect
1269  ***********************************************************  ***********************************************************
# Line 1421  Purpose: Line 1274  Purpose:
1274  Populates a drop-down box on an HTML form with select  Populates a drop-down box on an HTML form with select
1275  statements.  $omit limits output.  statements.  $omit limits output.
1276  **********************************************************/  **********************************************************/
1277  function dropDownFacultySelected($con, $limit, $preselected){  function dropDownFacultySelected($limit, $preselected){
1278          $sql = "SELECT * FROM faculty "          $sql = "SELECT * FROM faculty "
1279                  . $limit                  . $limit
1280                  . " ORDER BY faculty_lastname, faculty_firstname";                  . " ORDER BY faculty_lastname, faculty_firstname";
1281            $rs = mysql_tryquery($sql);
1282                    
1283          $rs = mysql_query($sql, $con);          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
         while ($row = mysql_fetch_array ($rs)) {  
1284                  $faculty_id = $row["faculty_id"];                  $faculty_id = $row["faculty_id"];
1285                  $faculty_lastname = $row["faculty_lastname"];                  $faculty_lastname = $row["faculty_lastname"];
1286                  $faculty_firstname = $row["faculty_firstname"];                  $faculty_firstname = $row["faculty_firstname"];
# Line 1447  function dropDownFacultySelected($con, $ Line 1300  function dropDownFacultySelected($con, $
1300    
1301    
1302  /**********************************************************  /**********************************************************
1303  Function: dropDownField($con, $table, $field_display,  Function: dropDownField($table, $field_display,
1304  $field_value)  $field_value)
1305  Author: Paul Bramscher  Author: Paul Bramscher
1306  Last Modified: 7.26.2000  Last Modified: 03.10.2004
1307  ***********************************************************  ***********************************************************
1308  Incoming:  Incoming:
 $con                    Database connection string  
1309  $table                  Table in database to search  $table                  Table in database to search
1310  $field_display          Select displayed to user  $field_display          Select displayed to user
1311  $field_value            Actual value of the HTML tag  $field_value            Actual value of the HTML tag
# Line 1466  Populates a drop-down box on an HTML for Line 1318  Populates a drop-down box on an HTML for
1318  options.  They are ordered by the $field_display field.  options.  They are ordered by the $field_display field.
1319  Typically, $field_value is the primary key field.  Typically, $field_value is the primary key field.
1320  **********************************************************/  **********************************************************/
1321  function dropDownField($con, $table, $field_display, $field_value){  function dropDownField($table, $field_display, $field_value){
1322    
1323          $sql = "SELECT "          $sql = "SELECT "
1324                  . $field_display                  . $field_display
# Line 1476  function dropDownField($con, $table, $fi Line 1328  function dropDownField($con, $table, $fi
1328                  . $table                  . $table
1329                  . " ORDER BY "                  . " ORDER BY "
1330                  . $field_display;                  . $field_display;
1331            $rs = mysql_tryquery($sql);
1332          $rs = mysql_query($sql, $con);          
1333          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1334                  $field_display_item = $row[$field_display];                  $field_display_item = $row[$field_display];
1335                  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) . "...";
1336                  $field_value_item = $row[$field_value];                  $field_value_item = $row[$field_value];
1337                  printf("<option value = \"" . $field_value_item                  printf("<option value = \""
1338                          . "\" >" . $field_display_item . "</option>\n");                          . $field_value_item
1339                            . "\" >"
1340                            . $field_display_item
1341                            . "</option>\n");
1342          };          };
1343  }  }
1344    
1345    
1346  /**********************************************************  /**********************************************************
1347  Function: dropDownFieldOmit($con, $table, $field_display,  Function: dropDownFieldOmit($table, $field_display,
1348  $field_value, $where)  $field_value, $where)
1349  Author: Paul Bramscher  Author: Paul Bramscher
1350  Last Modified: 8.14.2002  Last Modified: 03.10.2004
1351  ***********************************************************  ***********************************************************
1352  Incoming:  Incoming:
 $con                    Database connection string  
1353  $table                  Table in database to search  $table                  Table in database to search
1354  $field_display          Select displayed to user  $field_display          Select displayed to user
1355  $field_value            Actual value of the HTML tag  $field_value            Actual value of the HTML tag
# Line 1510  options.  They are ordered by the $field Line 1364  options.  They are ordered by the $field
1364  Typically, $field_value is the primary key field.  $where  Typically, $field_value is the primary key field.  $where
1365  can be used to filter out results.  can be used to filter out results.
1366  **********************************************************/  **********************************************************/
1367  function dropDownFieldOmit($con, $table, $field_display,  function dropDownFieldOmit($table, $field_display,
1368          $field_value, $where){          $field_value, $where){
1369    
1370          $sql = "SELECT "          $sql = "SELECT "
# Line 1523  function dropDownFieldOmit($con, $table, Line 1377  function dropDownFieldOmit($con, $table,
1377                  . $where                  . $where
1378                  . " ORDER BY "                  . " ORDER BY "
1379                  . $field_display;                  . $field_display;
1380          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1381          while ($row = mysql_fetch_array ($rs)) {          
1382            while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1383                  $field_display_item = $row[$field_display];                  $field_display_item = $row[$field_display];
1384                  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) . "...";
1385                  $field_value_item = $row[$field_value];                  $field_value_item = $row[$field_value];
1386                  printf("<option value = \"" . $field_value_item                  printf("<option value = \""
1387                          . "\" >" . $field_display_item . "</option>\n");                          . $field_value_item
1388                            . "\" >"
1389                            . $field_display_item
1390                            . "</option>\n");
1391          };          };
1392  }  }
1393    
1394    
1395  /**********************************************************  /**********************************************************
1396  Function: dropDownFieldSelected($con, $table, $field_display,  Function: dropDownFieldSelected($table, $field_display,
1397  $field_value, $limit, $preselected)  $field_value, $limit, $preselected)
1398  Author: Paul Bramscher  Author: Paul Bramscher
1399  Last Modified: 12.04.2002  Last Modified: 03.02.2004
1400  ***********************************************************  ***********************************************************
1401  Incoming:  Incoming:
 $con                    Database connection string  
1402  $table                  Table in database to search  $table                  Table in database to search
1403  $field_display          Select displayed to user  $field_display          Select displayed to user
1404  $field_value            Actual value of the HTML tag  $field_value            Actual value of the HTML tag
# Line 1558  Typically, $field_value is the primary k Line 1415  Typically, $field_value is the primary k
1415  parameter $preselected determines which (single) selection  parameter $preselected determines which (single) selection
1416  is selected.  is selected.
1417  **********************************************************/  **********************************************************/
1418  function dropDownFieldSelected($con, $table, $field_display,  function dropDownFieldSelected($table, $field_display,
1419          $field_value, $limit, $preselected){          $field_value, $limit, $preselected){
1420    
1421          $sql = "SELECT "          $sql = "SELECT "
# Line 1571  function dropDownFieldSelected($con, $ta Line 1428  function dropDownFieldSelected($con, $ta
1428                  . $limit                  . $limit
1429                  . " ORDER BY "                  . " ORDER BY "
1430                  . $field_display;                  . $field_display;
1431            $rs = mysql_tryquery($sql);
1432                    
1433          // Debugging          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
         //printf("sql was: %s<BR>", $sql);  
           
         $rs = mysql_query($sql, $con);  
         while ($row = mysql_fetch_array ($rs)) {  
1434                  $field_display_item = $row[$field_display];                  $field_display_item = $row[$field_display];
1435                  $field_value_item = $row[$field_value];                  $field_value_item = $row[$field_value];
1436                  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 1589  function dropDownFieldSelected($con, $ta Line 1443  function dropDownFieldSelected($con, $ta
1443    
1444    
1445  /**********************************************************  /**********************************************************
1446  Function: dropDownInfotype($con, $infotype_id, $subject_id)  Function: dropDownInfotype($infotype_id, $subject_id)
1447  Author: Paul Bramscher  Author: Paul Bramscher
1448  Last Modified: 12.04.2002  Last Modified: 03.02.2004
1449  ***********************************************************  ***********************************************************
1450  Incoming:  Incoming:
 $con                    Database connection string  
1451  $subject_id             Subject on which to limit the list  $subject_id             Subject on which to limit the list
1452  ***********************************************************  ***********************************************************
1453  Outgoing:  Outgoing:
# Line 1605  Populates a drop-down box on an HTML for Line 1458  Populates a drop-down box on an HTML for
1458  options of information types including general and  options of information types including general and
1459  master subject-specific.  master subject-specific.
1460  **********************************************************/  **********************************************************/
1461  function dropDownInfotype($con, $infotype_id, $subject_id){  function dropDownInfotype($infotype_id, $subject_id){
1462    
1463          // Initialize          // Initialize
1464          $selected_infotype_id = $infotype_id;          $selected_infotype_id = $infotype_id;
# Line 1616  function dropDownInfotype($con, $infotyp Line 1469  function dropDownInfotype($con, $infotyp
1469          on subject.          on subject.
1470          */          */
1471                    
1472          $sql = "SELECT sm.mastersubject_id FROM sub_mastersubject sm WHERE sm.subject_id = "          $sql = "SELECT sm.mastersubject_id
1473                    FROM sub_mastersubject sm
1474                    WHERE sm.subject_id = "
1475                  . $subject_id;                  . $subject_id;
1476    
         // Debugging  
         //printf("sql was: %s<BR>", $sql);  
   
1477          // Build the string.  Start with the "(N/A)" and the "(ALL)" master subjects.          // Build the string.  Start with the "(N/A)" and the "(ALL)" master subjects.
1478          $masterstring = "(1, 2 ";          $masterstring = "(1, 2 ";
1479    
1480          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1481          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1482                  $mastersubject_id = $row["mastersubject_id"];                  $mastersubject_id = $row["mastersubject_id"];
1483                  $masterstring .= ", " . $mastersubject_id;                  $masterstring .= ", " . $mastersubject_id;
1484          }          }
# Line 1634  function dropDownInfotype($con, $infotyp Line 1486  function dropDownInfotype($con, $infotyp
1486    
1487          // Build the list of infotypes appropriate to all of the mastersubjects found          // Build the list of infotypes appropriate to all of the mastersubjects found
1488          $sql = "SELECT i.infotype, i.infotype_id, mi.masterinfotype          $sql = "SELECT i.infotype, i.infotype_id, mi.masterinfotype
1489          FROM infotype i, masterinfotype mi                  FROM infotype i, masterinfotype mi
1490          WHERE i.masterinfotype_id = mi.masterinfotype_id                  WHERE i.masterinfotype_id = mi.masterinfotype_id
1491          AND i.infotype_id > 0 and mi.masterinfotype_id > 0                  AND i.infotype_id > 0 and mi.masterinfotype_id > 0
1492          AND i.mastersubject_id IN " . $masterstring .                  AND i.mastersubject_id IN " . $masterstring .
1493          " ORDER BY mi.masterinfotype";                  " ORDER BY mi.masterinfotype";
1494          printf("sql was: %s<br>", $sql);          $rs = mysql_tryquery($sql);
1495            
1496          $rs = mysql_query($sql, $con);          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
         while ($row = mysql_fetch_array ($rs)) {  
1497                  $masterinfotype = $row["masterinfotype"];                  $masterinfotype = $row["masterinfotype"];
1498                  $infotype_id = $row["infotype_id"];                  $infotype_id = $row["infotype_id"];
1499                  $infotype = $row["infotype"];                  $infotype = $row["infotype"];
1500    
   
1501                  // Make it look more friendly                  // Make it look more friendly
1502                  $useroutput = $masterinfotype . " -> " . $infotype;                  $useroutput = $masterinfotype . " -> " . $infotype;
1503    
# Line 1659  function dropDownInfotype($con, $infotyp Line 1509  function dropDownInfotype($con, $infotyp
1509    
1510    
1511  /**********************************************************  /**********************************************************
1512  Function: dropDownPageStaff($con, $page_id)  Function: dropDownPageStaff($page_id)
1513  Author: Paul Bramscher  Author: Paul Bramscher
1514  Last Modified: 10.23.2002  Last Modified: 03.10.2004
1515  ***********************************************************  ***********************************************************
1516  Incoming:  Incoming:
 $con                    Database connection string  
1517  $page_id                PageScribe page involved  $page_id                PageScribe page involved
1518  ***********************************************************  ***********************************************************
1519  Outgoing:  Outgoing:
# Line 1677  in the following format: "last name, fir Line 1526  in the following format: "last name, fir
1526  The staff displayed are those associated as PageScribe  The staff displayed are those associated as PageScribe
1527  maintainers.  maintainers.
1528  **********************************************************/  **********************************************************/
1529  function dropDownPageStaff($con, $page_id){  function dropDownPageStaff($page_id){
1530    
1531          // Build the SQL.          // Build the SQL.
1532          $sql = "SELECT s.first_name, s.last_name, s.staff_id, s.staff_account          $sql = "SELECT s.first_name, s.last_name, s.staff_id, s.staff_account
# Line 1685  function dropDownPageStaff($con, $page_i Line 1534  function dropDownPageStaff($con, $page_i
1534                  WHERE ps.page_id = "                  WHERE ps.page_id = "
1535                  . $page_id                  . $page_id
1536                  . " AND s.staff_id > 1 AND ps.staff_id = s.staff_id ORDER BY last_name, first_name, staff_account";                  . " AND s.staff_id > 1 AND ps.staff_id = s.staff_id ORDER BY last_name, first_name, staff_account";
1537            $rs = mysql_tryquery($sql);
1538          $rs = mysql_query($sql, $con);          
1539          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1540                  $staff_id = $row["staff_id"];                  $staff_id = $row["staff_id"];
1541                  $last_name = $row["last_name"];                  $last_name = $row["last_name"];
1542                  $first_name = $row["first_name"];                  $first_name = $row["first_name"];
# Line 1695  function dropDownPageStaff($con, $page_i Line 1544  function dropDownPageStaff($con, $page_i
1544    
1545                  // Make it look more friendly                  // Make it look more friendly
1546                  $staff = $last_name . ", " . $first_name . " (" . $staff_account . ")";                  $staff = $last_name . ", " . $first_name . " (" . $staff_account . ")";
1547                  printf("<option value = \"" . $staff_id                  printf("<option value = \""
1548                          . "\" >" . $staff . "</option>\n");                          . $staff_id
1549                            . "\" >"
1550                            . $staff
1551                            . "</option>\n");
1552          };          };
1553  }  }
1554    
1555    
1556  /**********************************************************  /**********************************************************
1557  Function: dropDownPageSubject($con, $page_id)  Function: dropDownPageSubject($page_id)
1558  Author: Paul Bramscher  Author: Paul Bramscher
1559  Last Modified: 06.17.2003  Last Modified: 03.10.2004
1560  ***********************************************************  ***********************************************************
1561  Incoming:  Incoming:
 $con                    Database connection string  
1562  $page_id                PageScribe page involved  $page_id                PageScribe page involved
1563  ***********************************************************  ***********************************************************
1564  Outgoing:  Outgoing:
# Line 1717  Purpose: Line 1568  Purpose:
1568  Populates a drop-down box on an HTML form with select  Populates a drop-down box on an HTML form with select
1569  options of associated RQS subjects for the supplied page id.  options of associated RQS subjects for the supplied page id.
1570  **********************************************************/  **********************************************************/
1571  function dropDownPageSubject($con, $page_id){  function dropDownPageSubject($page_id){
1572    
1573          // Build the SQL.          // Build the SQL.
1574          $sql = "SELECT s.subject_id, s.subject          $sql = "SELECT s.subject_id, s.subject
# Line 1725  function dropDownPageSubject($con, $page Line 1576  function dropDownPageSubject($con, $page
1576                  WHERE ps.page_id = "                  WHERE ps.page_id = "
1577                  . $page_id                  . $page_id
1578                  . " AND s.subject_id > 1 AND ps.subject_id = s.subject_id ORDER BY s.subject";                  . " AND s.subject_id > 1 AND ps.subject_id = s.subject_id ORDER BY s.subject";
1579            $rs = mysql_tryquery($sql);
1580          $rs = mysql_query($sql, $con);          
1581          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1582                  $subject_id = $row["subject_id"];                  $subject_id = $row["subject_id"];
1583                  $subject = $row["subject"];                  $subject = $row["subject"];
1584    
1585                  printf("<option value = \"" . $subject_id                  printf("<option value = \""
1586                          . "\" >" . $subject . "</option>\n");                          . $subject_id
1587                            . "\" >"
1588                            . $subject
1589                            . "</option>\n");
1590          };          };
1591  }  }
1592    
1593    
1594  /**********************************************************  /**********************************************************
1595  Function: dropDownResource($con, $key_id, $letter, $masterinfotype_id, $feature_id)  Function: dropDownResource($key_id, $letter, $masterinfotype_id, $feature_id)
1596  Author: Paul Bramscher  Author: Paul Bramscher
1597  Last Modified: 05.28.2003  Last Modified: 03.02.2004
1598  ***********************************************************  ***********************************************************
1599  Incoming:  Incoming:
 $con                    Database connection string  
1600  $key_id                 "0" for a new resource, otherwise  $key_id                 "0" for a new resource, otherwise
1601                          indicates a pre-selected resource                          indicates a pre-selected resource
1602  $limit                  Starting with letter A-Z or freetext.  $limit                  Starting with letter A-Z or freetext.
# Line 1767  the query checks against all titles star Line 1620  the query checks against all titles star
1620  Otherwise it checks against all titles or annotations  Otherwise it checks against all titles or annotations
1621  containing that string.  containing that string.
1622  **********************************************************/  **********************************************************/
1623  function dropDownResource($con, $key_id, $limit, $masterinfotype_id, $feature_id){  function dropDownResource($key_id, $limit, $masterinfotype_id, $feature_id){
1624    
1625          // Clean up the limit string          // Clean up the limit string
1626          if (strlen($limit) > 0) $limit = textSearchmySQL($limit);          if (strlen($limit) > 0) $limit = textSearchmySQL($limit);
# Line 1795  function dropDownResource($con, $key_id, Line 1648  function dropDownResource($con, $key_id,
1648                    
1649          $sql .=" ORDER BY title, author, resource_id";          $sql .=" ORDER BY title, author, resource_id";
1650                    
1651          // Debugging          $rs = mysql_tryquery($sql);
1652          // printf("sql was: %s<BR>", $sql);          
1653                    while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
         $rs = mysql_query($sql, $con);  
         while ($row = mysql_fetch_array ($rs)) {  
1654                  $resource_id = $row["resource_id"];                  $resource_id = $row["resource_id"];
1655                  $title = $row["title"];                  $title = $row["title"];
1656                  //$author = $row["author"];                  //$author = $row["author"];
# Line 1824  function dropDownResource($con, $key_id, Line 1675  function dropDownResource($con, $key_id,
1675    
1676    
1677  /**********************************************************  /**********************************************************
1678  Function: dropDownServiceLimit($con, $servicetype_id)  Function: dropDownServiceLimit($servicetype_id)
1679  Author: Paul Bramscher  Author: Paul Bramscher
1680  Last Modified: 06.16.2003  Last Modified: 03.02.2004
1681  ***********************************************************  ***********************************************************
1682  Incoming:  Incoming:
 $con                    Database connection string  
1683  $servicetype_id         Service type to limit the picklist  $servicetype_id         Service type to limit the picklist
1684  ***********************************************************  ***********************************************************
1685  Outgoing:  Outgoing:
# Line 1840  Populates a drop-down box on an HTML for Line 1690  Populates a drop-down box on an HTML for
1690  options for library services, limited to a supplied service  options for library services, limited to a supplied service
1691  type id.  type id.
1692  **********************************************************/  **********************************************************/
1693  function dropDownServiceLimit($con, $servicetype_id){  function dropDownServiceLimit($servicetype_id){
1694    
1695          $sql = "SELECT DISTINCT s.service, s.service_id FROM service s          $sql = "SELECT DISTINCT s.service, s.service_id FROM service s
1696                  LEFT JOIN serv_servtype ss using (service_id)                  LEFT JOIN serv_servtype ss using (service_id)
1697                  LEFT JOIN servicetype v on ss.servicetype_id = v.servicetype_id";                  LEFT JOIN servicetype v on ss.servicetype_id = v.servicetype_id
1698                    WHERE s.service_id > 1";
1699                                    
1700                  if ($servicetype_id > 0) {                  if ($servicetype_id > 0) {
1701                          $sql .= " WHERE ss.servicetype_id = "                          $sql .= " AND ss.servicetype_id = "
1702                                  . $servicetype_id;                                  . $servicetype_id;
1703                  }                  }
1704                                    
1705                  $sql .= " ORDER BY s.service";                  $sql .= " ORDER BY s.service";
1706                    
1707          // Debugging          $rs = mysql_tryquery($sql);
         // printf("sql was: %s<BR>", $sql);  
1708                    
1709          $rs = mysql_query($sql, $con);          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
         while ($row = mysql_fetch_array ($rs)) {  
1710                  $service = $row["service"];                  $service = $row["service"];
1711                  $service_id = $row["service_id"];                  $service_id = $row["service_id"];
1712                  if (strlen($service) > 50) $service = substr($service, 0, 49) . "...";                  if (strlen($service) > 50) $service = substr($service, 0, 49) . "...";
# Line 1868  function dropDownServiceLimit($con, $ser Line 1717  function dropDownServiceLimit($con, $ser
1717    
1718    
1719  /**********************************************************  /**********************************************************
1720  Function: dropDownStaff($con)  Function: dropDownStaff()
1721  Author: Paul Bramscher  Author: Paul Bramscher
1722  Last Modified: 6.7.2001  Last Modified: 03.10.2004
1723  ***********************************************************  ***********************************************************
1724  Incoming:  Incoming:
1725  $con                    Database connection string  None
1726  ***********************************************************  ***********************************************************
1727  Outgoing:  Outgoing:
1728  None  None
# Line 1883  Populates a drop-down box on an HTML for Line 1732  Populates a drop-down box on an HTML for
1732  options of staff members.  They are displayed and ordered  options of staff members.  They are displayed and ordered
1733  in the following format: "last name, first name (x500id)".  in the following format: "last name, first name (x500id)".
1734  **********************************************************/  **********************************************************/
1735  function dropDownStaff($con){  function dropDownStaff(){
1736    
1737          // Build the SQL          // Build the SQL
1738          $sql = "SELECT *          $sql = "SELECT *
1739                  FROM staff                  FROM staff
1740                  ORDER BY last_name, first_name, staff_account";                  ORDER BY last_name, first_name, staff_account";
1741            $rs = mysql_tryquery($sql);
1742          $rs = mysql_query($sql, $con);          
1743          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1744                  $staff_id = $row["staff_id"];                  $staff_id = $row["staff_id"];
1745                  $last_name = $row["last_name"];                  $last_name = $row["last_name"];
1746                  $first_name = $row["first_name"];                  $first_name = $row["first_name"];
# Line 1900  function dropDownStaff($con){ Line 1749  function dropDownStaff($con){
1749                  // Make it look more friendly                  // Make it look more friendly
1750                  if ($staff_id == 1) $staff = "(N/A)";                  if ($staff_id == 1) $staff = "(N/A)";
1751                  else $staff = $last_name . ", " . $first_name . " (" . $staff_account . ")";                  else $staff = $last_name . ", " . $first_name . " (" . $staff_account . ")";
1752                  printf("<option value = \"" . $staff_id                  printf("<option value = \""
1753                          . "\" >" . $staff . "</option>\n");                          . $staff_id
1754                            . "\" >"
1755                            . $staff
1756                            . "</option>\n");
1757          };          };
1758  }  }
1759    
1760    
1761  /**********************************************************  /**********************************************************
1762  Function: dropDownStaffOmit($con, $omit)  Function: dropDownStaffOmit($omit)
1763  Author: Paul Bramscher  Author: Paul Bramscher
1764  Last Modified: 10.08.2002  Last Modified: 03.10.2004
1765  ***********************************************************  ***********************************************************
1766  Incoming:  Incoming:
 $con                    Database connection string  
1767  $omit                   String of staff's to omit  $omit                   String of staff's to omit
1768  ***********************************************************  ***********************************************************
1769  Outgoing:  Outgoing:
# Line 1922  Purpose: Line 1773  Purpose:
1773  Populates a drop-down box on an HTML form with select  Populates a drop-down box on an HTML form with select
1774  statements.  $omit limits output.  statements.  $omit limits output.
1775  **********************************************************/  **********************************************************/
1776  function dropDownStaffOmit($con, $omit){  function dropDownStaffOmit($omit){
1777    
1778          // Build the SQL          // Build the SQL
1779          $sql = "SELECT * from staff "          $sql = "SELECT * from staff "
1780                  . $omit                  . $omit
1781                  . " ORDER BY last_name, first_name";                  . " ORDER BY last_name, first_name";
1782            $rs = mysql_tryquery($sql);
1783                    
1784          $rs = mysql_query($sql, $con);          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
         while ($row = mysql_fetch_array ($rs)) {  
1785                  $last_name = $row["last_name"];                  $last_name = $row["last_name"];
1786                  $first_name = $row["first_name"];                  $first_name = $row["first_name"];
1787                  $staff_id = $row["staff_id"];                  $staff_id = $row["staff_id"];
# Line 1939  function dropDownStaffOmit($con, $omit){ Line 1790  function dropDownStaffOmit($con, $omit){
1790                  // Make it look more friendly                  // Make it look more friendly
1791                  if ($staff_id == 1) $staff = "(N/A)";                  if ($staff_id == 1) $staff = "(N/A)";
1792                  else $staff = $last_name . ", " . $first_name . " (" . $staff_account . ")";                  else $staff = $last_name . ", " . $first_name . " (" . $staff_account . ")";
1793                  printf("<option value = \"" . $staff_id                  printf("<option value = \""
1794                          . "\" >" . $staff . "</option>\n");                          . $staff_id
1795                            . "\" >"
1796                            . $staff
1797                            . "</option>\n");
1798          };          };
1799  }  }
1800    
1801    
1802  /**********************************************************  /**********************************************************
1803  Function: dropDownStaffSelected($con, $selected_id)  Function: dropDownStaffSelected($selected_id)
1804  Author: Paul Bramscher  Author: Paul Bramscher
1805  Last Modified: 6.12.2001  Last Modified: 03.10.2004
1806  ***********************************************************  ***********************************************************
1807  Incoming:  Incoming:
 $con                    Database connection string  
1808  $selected_id            Selected staff id  $selected_id            Selected staff id
1809  ***********************************************************  ***********************************************************
1810  Outgoing:  Outgoing:
# Line 1961  Purpose: Line 1814  Purpose:
1814  Populates a drop-down box on an HTML form with select  Populates a drop-down box on an HTML form with select
1815  statements.  Selected id represents the preselected staff.  statements.  Selected id represents the preselected staff.
1816  **********************************************************/  **********************************************************/
1817  function dropDownStaffSelected($con, $selected_id){  function dropDownStaffSelected($selected_id){
1818    
1819          // Build the SQL          // Build the SQL
1820          $sql = "SELECT * from staff WHERE staff_id > 1 ORDER BY last_name, first_name";          $sql = "SELECT * from staff WHERE staff_id > 1 ORDER BY last_name, first_name";
1821          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1822          while ($row = mysql_fetch_array ($rs)) {          
1823            while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1824                  $last_name = $row["last_name"];                  $last_name = $row["last_name"];
1825                  $first_name = $row["first_name"];                  $first_name = $row["first_name"];
1826                  $staff_id = $row["staff_id"];                  $staff_id = $row["staff_id"];
# Line 1980  function dropDownStaffSelected($con, $se Line 1834  function dropDownStaffSelected($con, $se
1834  /**********************************************************  /**********************************************************
1835  Function: existsFaculty  Function: existsFaculty
1836  Author: Paul Bramscher  Author: Paul Bramscher
1837  Last Modified: 06.24.2003  Last Modified: 03.02.2004
1838  ***********************************************************  ***********************************************************
1839  Incoming:  Incoming:
 $con                            Database connection string  
1840  $faculty_firstname              Faculty first name  $faculty_firstname              Faculty first name
1841  $faculty_lastname               Faculty last name  $faculty_lastname               Faculty last name
1842  ***********************************************************  ***********************************************************
# Line 1994  Purpose: Line 1847  Purpose:
1847  This function checks to see whether a match against the  This function checks to see whether a match against the
1848  supplied faculty first and last name already exists.  supplied faculty first and last name already exists.
1849  **********************************************************/  **********************************************************/
1850  function existsFaculty($con, $faculty_firstname, $faculty_lastname){  function existsFaculty($faculty_firstname, $faculty_lastname){
1851    
1852          // Build the sql          // Build the sql
1853          $faculty_firstname = textInmySQL($faculty_firstname);          $faculty_firstname = textInmySQL($faculty_firstname);
# Line 2007  function existsFaculty($con, $faculty_fi Line 1860  function existsFaculty($con, $faculty_fi
1860                  . "'";                  . "'";
1861    
1862          $faculty_id = 0;          $faculty_id = 0;
1863          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1864                    
1865          // Concatenate the NOT IN clause          // Concatenate the NOT IN clause
1866          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
1867                  if ($faculty_id == 0) $faculty_id = $row["faculty_id"];                  if ($faculty_id == 0) $faculty_id = $row["faculty_id"];
1868          }          }
1869    
# Line 2021  function existsFaculty($con, $faculty_fi Line 1874  function existsFaculty($con, $faculty_fi
1874  /**********************************************************  /**********************************************************
1875  Function: existsResSub  Function: existsResSub
1876  Author: Paul Bramscher  Author: Paul Bramscher
1877  Last Modified: 12.09.2002  Last Modified: 03.02.2004
1878  ***********************************************************  ***********************************************************
1879  Incoming:  Incoming:
 $con                            Database connection string  
1880  $resource_id                    Record ID  $resource_id                    Record ID
1881  $subject_id                     Subject ID  $subject_id                     Subject ID
1882  ***********************************************************  ***********************************************************
# Line 2035  Purpose: Line 1887  Purpose:
1887  This function checks to see whether a resource has already  This function checks to see whether a resource has already
1888  been attached to a given subject id.  been attached to a given subject id.
1889  **********************************************************/  **********************************************************/
1890  function existsResSub($con, $resource_id, $subject_id){  function existsResSub($resource_id, $subject_id){
1891    
1892          // Build the sql          // Build the sql
1893          $sql = "SELECT * FROM res_sub_infotype WHERE resource_id = "          $sql = "SELECT * FROM res_sub_infotype WHERE resource_id = "
# Line 2043  function existsResSub($con, $resource_id Line 1895  function existsResSub($con, $resource_id
1895                  . " AND subject_id = "                  . " AND subject_id = "
1896                  . $subject_id;                  . $subject_id;
1897    
1898          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1899          $rowcount = mysql_num_rows($rs);          $rowcount = mysql_num_rows($rs);
1900          if ($rowcount >= 1){          if ($rowcount >= 1){
1901                  $rowcount = 1;                  $rowcount = 1;
# Line 2057  function existsResSub($con, $resource_id Line 1909  function existsResSub($con, $resource_id
1909  /**********************************************************  /**********************************************************
1910  Function: existsResSubNA  Function: existsResSubNA
1911  Author: Paul Bramscher  Author: Paul Bramscher
1912  Last Modified: 05.27.2003  Last Modified: 03.02.2004
1913  ***********************************************************  ***********************************************************
1914  Incoming:  Incoming:
 $con                            Database connection string  
1915  $resource_id                    Record ID  $resource_id                    Record ID
1916  $subject_id                     Subject ID  $subject_id                     Subject ID
1917  ***********************************************************  ***********************************************************
# Line 2072  This function is similar to existsResSub Line 1923  This function is similar to existsResSub
1923  specifically to see whether the (N/A) type information type  specifically to see whether the (N/A) type information type
1924  is currently assigned to the resource-subject combination.  is currently assigned to the resource-subject combination.
1925  **********************************************************/  **********************************************************/
1926  function existsResSubNA($con, $resource_id, $subject_id){  function existsResSubNA($resource_id, $subject_id){
1927    
1928          // Build the sql          // Build the sql
1929          $sql = "SELECT * FROM res_sub_infotype WHERE resource_id = "          $sql = "SELECT * FROM res_sub_infotype WHERE resource_id = "
# Line 2081  function existsResSubNA($con, $resource_ Line 1932  function existsResSubNA($con, $resource_
1932                  . $subject_id                  . $subject_id
1933                  . " AND infotype_id = 1";                  . " AND infotype_id = 1";
1934    
1935          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
1936            $rowcount = mysql_num_rows($rs);
1937            if ($rowcount == 1){
1938                    $rowcount = 1;
1939            }
1940            else $rowcount = 0;
1941            
1942            return $rowcount;
1943    }
1944    
1945    
1946    /**********************************************************
1947    Function: existsResSubNOTNA
1948    Author: Paul Bramscher
1949    Last Modified: 03.02.2004
1950    ***********************************************************
1951    Incoming:
1952    $resource_id                    Record ID
1953    $subject_id                     Subject ID
1954    ***********************************************************
1955    Outgoing:
1956    "1" if an association already exists, "0" if not
1957    ***********************************************************
1958    Purpose:
1959    This function is similar to existsResSubNA, but it checks to
1960    see if the combination of resource/subject appears in the
1961    res_sub_infotype table under a heading other than N/A for
1962    the infotype.
1963    **********************************************************/
1964    function existsResSubNOTNA($resource_id, $subject_id){
1965    
1966            // Build the sql
1967            $sql = "SELECT * FROM res_sub_infotype WHERE resource_id = "
1968                    . $resource_id
1969                    . " AND subject_id = "
1970                    . $subject_id
1971                    . " AND infotype_id <> 1";
1972    
1973            $rs = mysql_tryquery($sql);
1974          $rowcount = mysql_num_rows($rs);          $rowcount = mysql_num_rows($rs);
1975          if ($rowcount == 1){          if ($rowcount == 1){
1976                  $rowcount = 1;                  $rowcount = 1;
# Line 2095  function existsResSubNA($con, $resource_ Line 1984  function existsResSubNA($con, $resource_
1984  /**********************************************************  /**********************************************************
1985  Function: existsRow  Function: existsRow
1986  Author: Paul Bramscher  Author: Paul Bramscher
1987  Last Modified: 12.09.2002  Last Modified: 03.02.2004
1988  ***********************************************************  ***********************************************************
1989  Incoming:  Incoming:
 $con                    Database connection string  
1990  $table                  Table to search  $table                  Table to search
1991  $key_field              Field against which to search  $key_field              Field against which to search
1992  $key_id                 Limit for the where clause  $key_id                 Limit for the where clause
# Line 2111  Useful in performing delete and other op Line 1999  Useful in performing delete and other op
1999  sure that a row entity exists matching the supplied key  sure that a row entity exists matching the supplied key
2000  before going any further.  before going any further.
2001  **********************************************************/  **********************************************************/
2002  function existsRow($con, $table, $key_field, $limit_id){  function existsRow($table, $key_field, $limit_id){
2003          // Cast as integer to avoid future problems          // Cast as integer to avoid future problems
2004          $limit_id = (int) $limit_id;          $limit_id = (int) $limit_id;
2005                    
# Line 2125  function existsRow($con, $table, $key_fi Line 2013  function existsRow($con, $table, $key_fi
2013                  . "="                  . "="
2014                  . $limit_id;                  . $limit_id;
2015    
2016          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2017          $rowcount = mysql_num_rows($rs);          $rowcount = mysql_num_rows($rs);
2018          if ($rowcount >= 1){          if ($rowcount >= 1){
2019                  $rowcount = 1;                  $rowcount = 1;
# Line 2139  function existsRow($con, $table, $key_fi Line 2027  function existsRow($con, $table, $key_fi
2027  /**********************************************************  /**********************************************************
2028  Function: getNotIn  Function: getNotIn
2029  Author: Paul Bramscher    Author: Paul Bramscher  
2030  Last Modified: 12.09.2002  Last Modified: 03.02.2004
2031  ***********************************************************  ***********************************************************
2032  Incoming:  Incoming:
 $con                    Database connection string  
2033  $in_field               Name of ID field to return  $in_field               Name of ID field to return
2034  $static_field           Name of the "other" ID field in the  $static_field           Name of the "other" ID field in the
2035                          bridging table                          bridging table
# Line 2166  selections.  The remaining (available) s Line 2053  selections.  The remaining (available) s
2053  exclude the current ones.  Thus, this function builds the  exclude the current ones.  Thus, this function builds the
2054  NOT IN portion of the SQL WHERE clause.  NOT IN portion of the SQL WHERE clause.
2055  **********************************************************/  **********************************************************/
2056  function getNotIn($con, $in_field, $static_field,  function getNotIn($in_field, $static_field,
2057          $static_value, $table) {          $static_value, $table) {
2058    
2059          // Initialze          // Initialze
# Line 2183  function getNotIn($con, $in_field, $stat Line 2070  function getNotIn($con, $in_field, $stat
2070                  . " = "                  . " = "
2071                  . $static_value;                  . $static_value;
2072                    
2073          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2074    
2075          // Concatenate the NOT IN clause          // Concatenate the NOT IN clause
2076          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
2077                  $in_element = $row[$in_field];                  $in_element = $row[$in_field];
2078    
2079                  if ($first_element == 0) {                  if ($first_element == 0) {
# Line 2208  function getNotIn($con, $in_field, $stat Line 2095  function getNotIn($con, $in_field, $stat
2095    
2096    
2097  /**********************************************************  /**********************************************************
2098  Function: locationList($con, $resource_id)  Function: lookupFaculty($faculty_id)
2099  Author: Paul Bramscher  Author: Paul Bramscher
2100  Last Modified: 07.02.2002  Last Modified: 03.02.2004
2101  ***********************************************************  ***********************************************************
2102  Incoming:  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: lookupFaculty($con, $faculty_id)  
 Author: Paul Bramscher  
 Last Modified: 12.03.2002  
 ***********************************************************  
 Incoming:  
 $con                    Database connection string  
2103  $faculty_id             Faculty ID number to retrieve  $faculty_id             Faculty ID number to retrieve
2104  ***********************************************************  ***********************************************************
2105  Outgoing:  Outgoing:
# Line 2261  Faculty name in {First Name} {Last Name} Line 2108  Faculty name in {First Name} {Last Name}
2108  Purpose:  Purpose:
2109  Performs a lookup on faculty ID to retrieve name.  Performs a lookup on faculty ID to retrieve name.
2110  **********************************************************/  **********************************************************/
2111  function lookupFaculty($con, $faculty_id){  function lookupFaculty($faculty_id){
2112    
2113          $sql = "SELECT faculty_firstname, faculty_lastname FROM faculty WHERE faculty_id = "          $sql = "SELECT faculty_firstname, faculty_lastname FROM faculty WHERE faculty_id = "
2114                  . $faculty_id;                  . $faculty_id;
2115          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2116          $row = mysql_fetch_array ($rs);          $row = mysql_fetch_array ($rs, MYSQL_ASSOC);
2117          $faculty_lastname = $row["faculty_lastname"];          $faculty_lastname = $row["faculty_lastname"];
2118          $faculty_firstname = $row["faculty_firstname"];          $faculty_firstname = $row["faculty_firstname"];
2119                    
2120          $faculty_name .= $faculty_firstname . " " . $faculty_lastname;          $faculty_name .= $faculty_firstname . " " . $faculty_lastname;
2121            
         // Debugging  
         //printf("sql was: %s<BR>", $sql);  
           
2122          return $faculty_name;          return $faculty_name;
2123  }  }
2124    
2125    
2126  /**********************************************************  /**********************************************************
2127  Function: lookupField($con, $table, $key_field, $key_value,  Function: lookupField($table, $key_field, $key_value,
2128  $desc_field)  $desc_field)
2129  Author: Paul Bramscher  Author: Paul Bramscher
2130  Last Modified: 9.14.2000  Last Modified: 03.02.2004
2131  ***********************************************************  ***********************************************************
2132  Incoming:  Incoming:
 $con                    Database connection string  
2133  $table                  Table in database to search  $table                  Table in database to search
2134  $key_field              Name of field on which to lookup  $key_field              Name of field on which to lookup
2135  $key_value              Value to attempt lookup with  $key_value              Value to attempt lookup with
# Line 2298  Purpose: Line 2142  Purpose:
2142  Performs a lookup, typically on an ID field, to retrieve a  Performs a lookup, typically on an ID field, to retrieve a
2143  user-friendly descriptive name to the page.  user-friendly descriptive name to the page.
2144  **********************************************************/  **********************************************************/
2145  function lookupField($con, $table, $key_field, $key_value,  function lookupField($table, $key_field, $key_value,
2146          $desc_field){          $desc_field){
2147                    
2148          $sql = "SELECT "          $sql = "SELECT "
# Line 2310  function lookupField($con, $table, $key_ Line 2154  function lookupField($con, $table, $key_
2154                  . "='"                  . "='"
2155                  . $key_value                  . $key_value
2156                  . "'";                  . "'";
2157          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2158          $row = mysql_fetch_array ($rs);          $row = mysql_fetch_array ($rs, MYSQL_ASSOC);
2159          if (mysql_num_rows($rs) == 1) $result = $row[$desc_field];          if (mysql_num_rows($rs) == 1) $result = $row[$desc_field];
2160          else $result = "";          else $result = "";
2161                    
# Line 2320  function lookupField($con, $table, $key_ Line 2164  function lookupField($con, $table, $key_
2164    
2165    
2166  /**********************************************************  /**********************************************************
2167  Function: lookupStaff($con, $staff_id)  Function: lookupStaff($staff_id)
2168  Author: Paul Bramscher  Author: Paul Bramscher
2169  Last Modified: 7.22.2002  Last Modified: 03.10.2004
2170  ***********************************************************  ***********************************************************
2171  Incoming:  Incoming:
 $con                    Database connection string  
2172  $staff_id               Staff ID number to retrieve  $staff_id               Staff ID number to retrieve
2173  ***********************************************************  ***********************************************************
2174  Outgoing:  Outgoing:
# Line 2334  Staff name in {First Name} {Last Name} f Line 2177  Staff name in {First Name} {Last Name} f
2177  Purpose:  Purpose:
2178  Performs a lookup on staff ID to retrieve name.  Performs a lookup on staff ID to retrieve name.
2179  **********************************************************/  **********************************************************/
2180  function lookupStaff($con, $staff_id){  function lookupStaff($staff_id){
2181    
2182          $sql = "SELECT first_name, last_name FROM staff WHERE staff_id = "          $sql = "SELECT first_name, last_name FROM staff WHERE staff_id = "
2183                  . $staff_id;                  . $staff_id;
2184          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2185          $row = mysql_fetch_array ($rs);          $row = mysql_fetch_array ($rs, MYSQL_ASSOC);
2186          $last_name = $row["last_name"];          $last_name = $row["last_name"];
2187          $first_name = $row["first_name"];          $first_name = $row["first_name"];
2188                    
2189          $staff_name .= $first_name . " " . $last_name;          $staff_name .= $first_name . " " . $last_name;
2190                    
         // Debugging  
         //printf("sql was: %s<BR>", $sql);  
           
2191          return $staff_name;          return $staff_name;
2192  }  }
2193    
2194    
2195  /**********************************************************  /**********************************************************
2196  Function: radioField($con, $table, $field_display,  Function: msgTableClose()
 $field_value, $position)  
2197  Author: Paul Bramscher  Author: Paul Bramscher
2198  Last Modified: 12.04.2002  Last Modified: 03.15.2004
2199  ***********************************************************  ***********************************************************
2200  Incoming:  Incoming:
2201  $con                    Database connection string  None
 $table                  Table in database to search  
 $field_display          Select displayed to user  
 $field_value            Actual value of the HTML tag  
 $position               Either "V" vertical or "H"  
                         horizontal to indicate display of  
                         radio buttons  
2202  ***********************************************************  ***********************************************************
2203  Outgoing:  Outgoing:
2204  None  None
2205  ***********************************************************  ***********************************************************
2206  Purpose:  Purpose:
2207  Populates radio boxes on an HTML form with values from a  Closes the message box table.
 table.  They are ordered by $field_display in either  
 horizontal or vertical fashion.  Each checkbox in the set  
 is named $field_display.  
2208  **********************************************************/  **********************************************************/
2209  function radioField($con, $table, $field_display,  function msgTableClose () {
2210  $field_value, $positon){          
2211            printf("</td></tr></table>\n");
2212            printf("</center>\n");
2213    
         $rd_sql = "SELECT "  
                 . $field_display  
                 . ", "  
                 . $field_value  
                 . " FROM "  
                 . $table  
                 . " ORDER BY "  
                 . $field_display;  
         $rd_rs = mysql_query($rd_sql, $con);  
         while ($rd_row = mysql_fetch_array ($rd_rs)) {  
                 $field_display_item = $rd_row[$field_display];  
                 $field_value_item = $rd_row[$field_value];  
                 printf("<input type='radio' name='"  
                         . $field_display  
                         . " value =\""  
                         . $field_value_item  
                         . "\" > "  
                         . $field_display_item  
                         . " ");  
                 if ($position =="V"){  
                         printf("<BR>\n");  
                 }  
         };  
2214  }  }
2215    
2216    
2217  /**********************************************************  /**********************************************************
2218  Function: recordCount($con, $table, $limit_field,  Function: msgTableOpen ($colspan, $header)
2219    Author: Paul Bramscher
2220    Last Modified: 03.15.2004
2221    ***********************************************************
2222    Incoming:
2223    $colspan                        Columns to span the first
2224                                    row.
2225    $header                         Message to appear in the
2226                                    first table header row.
2227    ***********************************************************
2228    Outgoing:
2229    None
2230    ***********************************************************
2231    Purpose:
2232    Starts the drawing of a message box table.
2233    **********************************************************/
2234    function msgTableOpen ($colspan, $header) {
2235            
2236            // Table
2237            printf("<center>\n");
2238            printf("<table width=\"50%%\" class=\"backLight\" border=\"1\" cellpadding=\"4\">\n");
2239            
2240            // Row header
2241            printf("<tr><td class=\"cellPlain\" colspan=\"%d\" >\n", $colspan);
2242            printf("%s", $header);
2243            printf("</td></tr>\n");
2244            
2245            // Initial cell
2246            printf("<tr><td>\n");
2247    }
2248    
2249    
2250    /**********************************************************
2251    Function: recordCount($table, $limit_field,
2252          $limit_where, $type)          $limit_where, $type)
2253  Author: Paul Bramscher  Author: Paul Bramscher
2254  Last Modified: 01.15.2004  Last Modified: 03.02.2004
2255  ***********************************************************  ***********************************************************
2256  Incoming:  Incoming:
 $con                    Database connection string  
2257  $table                  Table in database to query  $table                  Table in database to query
2258  $limit_field            Field to limit  $limit_field            Field to limit
2259  $limit_where            Criteria upon which to limit    $limit_where            Criteria upon which to limit  
# Line 2427  printf statement elsewhere "This operati Line 2268  printf statement elsewhere "This operati
2268  N record(s).  Do you wish to proceed?"  This function  N record(s).  Do you wish to proceed?"  This function
2269  returns a value for N.  returns a value for N.
2270  **********************************************************/  **********************************************************/
2271  function recordCount($con, $table, $limit_field,  function recordCount($table, $limit_field,
2272          $limit_where, $type) {          $limit_where, $type) {
2273                    
2274          // Guard against single quotes          // Guard against single quotes
# Line 2454  function recordCount($con, $table, $limi Line 2295  function recordCount($con, $table, $limi
2295          }          }
2296    
2297          // Open the query and take a row count          // Open the query and take a row count
2298          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2299          $count = mysql_num_rows($rs);          $count = mysql_num_rows($rs);
2300                    
2301          return $count;          return $count;
# Line 2462  function recordCount($con, $table, $limi Line 2303  function recordCount($con, $table, $limi
2303    
2304    
2305  /**********************************************************  /**********************************************************
2306  Function: selectCoursesub($con, $limit)  Function: selectCoursesub($limit)
2307  Author: Paul Bramscher  Author: Paul Bramscher
2308  Last Modified: 07.02.2003  Last Modified: 03.10.2004
2309  ***********************************************************  ***********************************************************
2310  Incoming:  Incoming:
 $con                    Database connection string  
2311  $limit                  String to limit the results by  $limit                  String to limit the results by
2312  ***********************************************************  ***********************************************************
2313  Outgoing:  Outgoing:
# Line 2477  Purpose: Line 2317  Purpose:
2317  Draws a table with all course subjects for basic  Draws a table with all course subjects for basic
2318  command add/edit/ delete selection.  command add/edit/ delete selection.
2319  **********************************************************/  **********************************************************/
2320  function selectCoursesub($con, $limit){  function selectCoursesub($limit){
2321    
2322          printf("<table width=\"90%%\" border = \"1\" cellpadding = \"2\" >");          printf("<table width=\"90%%\" border = \"1\" cellpadding = \"2\" >\n");
2323          printf("<tr>");          printf("<tr>\n");
2324          printf("<td class = \"cellPlain\">ID</td>");          printf("<td class = \"cellPlain\">ID</td>\n");
2325          printf("<td class = \"cellPlain\">Subject</td>");          printf("<td class = \"cellPlain\">Subject</td>\n");
2326          printf("<td class = \"cellPlain\">Subject Description</td>");          printf("<td class = \"cellPlain\">Subject Description</td>\n");
2327          printf("<td class = \"cellPlain\">Campus</td>");          printf("<td class = \"cellPlain\">Campus</td>\n");
2328          printf("<td class = \"cellPlain\">CIP Code</td>");          printf("<td class = \"cellPlain\">CIP Code</td>\n");
2329          printf("<td class = \"cellPlain\">Select</td>");          printf("<td class = \"cellPlain\">Select</td>\n");
2330          printf("</tr>");          printf("</tr>");
2331    
2332          // Build the sql          // Build the sql
# Line 2516  function selectCoursesub($con, $limit){ Line 2356  function selectCoursesub($con, $limit){
2356          // Order the display          // Order the display
2357          $sql .= " ORDER BY coursesub_descr";          $sql .= " ORDER BY coursesub_descr";
2358    
2359          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2360                    
2361          // Initialize row counter          // Initialize row counter
2362          $rowcount = 0;          $rowcount = 0;
2363                    
2364          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
2365                  $coursesub_id = $row["coursesub_id"];                  $coursesub_id = $row["coursesub_id"];
2366                  $coursesub = Trim($row["coursesub"]);                  $coursesub = Trim($row["coursesub"]);
2367                  $coursesub_descr = Trim($row["coursesub_descr"]);                  $coursesub_descr = Trim($row["coursesub_descr"]);
# Line 2534  function selectCoursesub($con, $limit){ Line 2374  function selectCoursesub($con, $limit){
2374                    
2375                  printf("<tr>");                  printf("<tr>");
2376    
2377                  printf("<td %s>%d</td>", $color, $coursesub_id);                  printf("<td %s>%d</td>\n", $color, $coursesub_id);
2378                  printf("<td %s>%s</td>", $color, $coursesub);                  printf("<td %s>%s</td>\n", $color, $coursesub);
2379                  printf("<td %s>%s</td>", $color, $coursesub_descr);                  printf("<td %s>%s</td>\n", $color, $coursesub_descr);
2380                  printf("<td %s>%s</td>", $color, $campus);                  printf("<td %s>%s</td>\n", $color, $campus);
2381                  printf("<td %s>%s</td>", $color, $cip_code);                  printf("<td %s>%s</td>\n", $color, $cip_code);
2382    
2383                  printf("<td %s>&nbsp;<input type = \"Radio\" name = \"coursesub_id\" value =\"%d\" >&nbsp;", $color, $coursesub_id);                  printf("<td %s>&nbsp;<input type = \"Radio\" name = \"coursesub_id\" value =\"%d\" >&nbsp;</td>\n", $color, $coursesub_id);
2384    
2385                  printf("</tr>");                  printf("</tr>\n");
2386                                    
2387                  $rowcount++;                  $rowcount++;
2388          };          };
2389          printf("</table>");          printf("</table>\n");
2390  }  }
2391    
2392    
2393  /**********************************************************  /**********************************************************
2394  Function: selectFaculty($con)  Function: selectFaculty()
2395  Author: Paul Bramscher  Author: Paul Bramscher
2396  Last Modified: 07.02.2002  Last Modified: 03.10.2004
2397  ***********************************************************  ***********************************************************
2398  Incoming:  Incoming:
2399  $con                    Database connection string  None
2400  ***********************************************************  ***********************************************************
2401  Outgoing:  Outgoing:
2402  None  None
# Line 2565  Purpose: Line 2405  Purpose:
2405  Draws a table with all faculty for basic command add/edit/  Draws a table with all faculty for basic command add/edit/
2406  delete selection.  delete selection.
2407  **********************************************************/  **********************************************************/
2408  function selectFaculty($con){  function selectFaculty(){
2409    
2410          printf("<table width=\"90%%\" border = \"1\" cellpadding = \"2\" >");          printf("<table width=\"90%%\" border = \"1\" cellpadding = \"2\" >\n");
2411          printf("<tr>");          printf("<tr>\n");
2412          printf("<td class = \"cellPlain\">ID</td>");          printf("<td class = \"cellPlain\">ID</td>\n");
2413          printf("<td class = \"cellPlain\">Faculty name</td>");          printf("<td class = \"cellPlain\">Faculty name</td>\n");
2414          printf("<td class = \"cellPlain\">Account</td>");          printf("<td class = \"cellPlain\">Account</td>\n");
2415          printf("<td class = \"cellPlain\">Email</td>");          printf("<td class = \"cellPlain\">Email</td>\n");
2416          printf("<td class = \"cellPlain\">Select</td>");          printf("<td class = \"cellPlain\">Select</td>\n");
2417          printf("</tr>");          printf("</tr>");
2418    
2419          // Build the sql          // Build the sql
# Line 2590  function selectFaculty($con){ Line 2430  function selectFaculty($con){
2430          // Order the display          // Order the display
2431          $sql .= " ORDER BY faculty_lastname, faculty_firstname";          $sql .= " ORDER BY faculty_lastname, faculty_firstname";
2432    
2433          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2434                    
2435          // Row counter          // Row counter
2436          $rowcount = 0;          $rowcount = 0;
2437                    
2438          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
2439                  $faculty_id = $row["faculty_id"];                  $faculty_id = $row["faculty_id"];
2440                  $faculty_firstname = Trim($row["faculty_firstname"]);                  $faculty_firstname = Trim($row["faculty_firstname"]);
2441                  $faculty_lastname = Trim($row["faculty_lastname"]);                  $faculty_lastname = Trim($row["faculty_lastname"]);
# Line 2612  function selectFaculty($con){ Line 2452  function selectFaculty($con){
2452                    
2453                  printf("<tr>");                  printf("<tr>");
2454    
2455                  printf("<td %s>%d</td>", $color, $faculty_id);                  printf("<td %s>%d</td>\n", $color, $faculty_id);
2456                  printf("<td %s>%s, %s</td>", $color, $faculty_lastname, $faculty_firstname);                  printf("<td %s>%s, %s</td>\n", $color, $faculty_lastname, $faculty_firstname);
2457                  printf("<td %s>%s</td>", $color, $faculty_account);                  printf("<td %s>%s</td>\n", $color, $faculty_account);
2458                  printf("<td %s>%s</td>", $color, $faculty_email);                  printf("<td %s>%s</td>\n", $color, $faculty_email);
2459    
2460                  printf("<td %s>&nbsp;<input type = \"Radio\" name = \"faculty_id\" value =\"%d\" >&nbsp;", $color, $faculty_id);                  printf("<td %s>&nbsp;<input type = \"Radio\" name = \"faculty_id\" value =\"%d\" >&nbsp;</td>\n", $color, $faculty_id);
2461    
2462                  printf("</tr>");                  printf("</tr>\n");
2463                                    
2464                  $rowcount++;                  $rowcount++;
2465          };          };
2466          printf("</table>");          printf("</table>\n");
2467  }  }
2468    
2469    
2470  /**********************************************************  /**********************************************************
2471  Function: selectKey($con, $display, $display_field,  Function: selectKey($display, $display_field,
2472  $key_field, $limit, $table)  $key_field, $limit, $table)
2473  Author: Paul Bramscher  Author: Paul Bramscher
2474  Last Modified: 06.25.2003  Last Modified: 03.10.2004
2475  ***********************************************************  ***********************************************************
2476  Incoming:  Incoming:
 $con                    Database connection string  
2477  $display                A form header to display to user  $display                A form header to display to user
2478  $display_field          Meaningful field in the table to display  $display_field          Meaningful field in the table to display
2479  $key_field              The table primary key (no composites)  $key_field              The table primary key (no composites)
# Line 2657  Note that the pick-list filters out the Line 2496  Note that the pick-list filters out the
2496  (N/A) rows which are present in many tables as system  (N/A) rows which are present in many tables as system
2497  placeholders.  placeholders.
2498  **********************************************************/  **********************************************************/
2499  function selectKey($con, $display, $display_field,  function selectKey($display, $display_field,
2500          $key_field, $limit, $table){          $key_field, $limit, $table){
2501    
2502          $sql = "SELECT "          $sql = "SELECT "
# Line 2688  function selectKey($con, $display, $disp Line 2527  function selectKey($con, $display, $disp
2527                  // Order the display                  // Order the display
2528                  $sql .= " ORDER BY " . $display_field;                  $sql .= " ORDER BY " . $display_field;
2529                    
2530                  $rs = mysql_query($sql, $con);                  $rs = mysql_tryquery($sql);
2531    
2532                  printf("<table width=\"60%%\" border = \"1\" >\n");                  printf("<table width=\"60%%\" border = \"1\" >\n");
2533                  printf("<tr><td class=\"cellPlain\">Description</td>\n");                  printf("<tr><td class=\"cellPlain\">Description</td>\n");
                 // printf("<td><b>Key</b></td>");  
2534                  printf("<td class=\"cellPlain\">Select</td></tr>\n");                  printf("<td class=\"cellPlain\">Select</td></tr>\n");
2535    
2536                  $rowcount = 0;                  $rowcount = 0;
2537    
2538                  while ($row = mysql_fetch_array ($rs)) {                  while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
2539                          $field_display_item = $row[$display_field];                          $field_display_item = $row[$display_field];
2540                          $field_value_item = (int) Trim($row[$key_field]);                          $field_value_item = (int) Trim($row[$key_field]);
2541                                                    
# Line 2711  function selectKey($con, $display, $disp Line 2549  function selectKey($con, $display, $disp
2549                          printf("<td %s><input type =\"Radio\" name =\"key_id\" value =\"%s\"></td>\n",                          printf("<td %s><input type =\"Radio\" name =\"key_id\" value =\"%s\"></td>\n",
2550                                  $color, $field_value_item);                                  $color, $field_value_item);
2551                          printf("</tr>\n");                          printf("</tr>\n");
                           
                         /*  
                         printf("<tr><td>"  
                                 . $field_display_item  
                                 . "</td><td>"  
                                 . "<input type = \"Radio\" name = \"key_id\" value =\""  
                                 . $field_value_item  
                                 . "\"></td></tr>\n");  
                         */  
2552                                                                    
2553                          $rowcount++;                                                      $rowcount++;                            
2554                  };                  };
# Line 2732  function selectKey($con, $display, $disp Line 2561  function selectKey($con, $display, $disp
2561    
2562    
2563  /**********************************************************  /**********************************************************
2564  Function: selectStaff($con)  Function: selectStaff()
2565  Author: Paul Bramscher  Author: Paul Bramscher
2566  Last Modified: 04.28.2003  Last Modified: 03.10.2004
2567  ***********************************************************  ***********************************************************
2568  Incoming:  Incoming:
2569  $con                    Database connection string  None
2570  ***********************************************************  ***********************************************************
2571  Outgoing:  Outgoing:
2572  None  None
# Line 2746  Purpose: Line 2575  Purpose:
2575  Draws a table with all staff for basic command add/edit/  Draws a table with all staff for basic command add/edit/
2576  delete selection.  delete selection.
2577  **********************************************************/  **********************************************************/
2578  function selectStaff($con){  function selectStaff(){
2579    
2580          printf("<table width=\"90%%\" border = \"1\" cellpadding = \"2\" >");          printf("<table width=\"90%%\" border = \"1\" cellpadding = \"2\" >\n");
2581          printf("<tr>");          printf("<tr>\n");
2582          printf("<td class = \"cellPlain\">ID</td>");          printf("<td class = \"cellPlain\">ID</td>\n");
2583          printf("<td class = \"cellPlain\">Staff name</td>");          printf("<td class = \"cellPlain\">Staff name</td>\n");
2584          printf("<td class = \"cellPlain\">Staff Account</td>");          printf("<td class = \"cellPlain\">Staff Account</td>\n");
2585          printf("<td class = \"cellPlain\">Local pwd?</td>");          printf("<td class = \"cellPlain\">Local pwd?</td>\n");
2586          printf("<td class = \"cellPlain\">Access</td>");          printf("<td class = \"cellPlain\">Access</td>\n");
2587          printf("<td class = \"cellPlain\">Level</td>");          printf("<td class = \"cellPlain\">Level</td>\n");      
2588          printf("<td class = \"cellPlain\">Last login</td>");          printf("<td class = \"cellPlain\">Last login</td>\n");
2589          printf("<td class = \"cellPlain\">Last ip</td>");          printf("<td class = \"cellPlain\">Last ip</td>\n");
2590          printf("<td class = \"cellPlain\">Select</td>");          printf("<td class = \"cellPlain\">Select</td>\n");
2591          printf("</tr>");          printf("</tr>");
2592    
2593          // Build the sql          // Build the sql
# Line 2779  function selectStaff($con){ Line 2608  function selectStaff($con){
2608          // Order the display          // Order the display
2609          $sql .= " ORDER BY last_name, first_name";          $sql .= " ORDER BY last_name, first_name";
2610    
2611          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2612                    
2613          $rowcount = 0;          $rowcount = 0;
2614                    
2615          while ($row = mysql_fetch_array ($rs)) {          while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
2616                  $first_name = Trim($row["first_name"]);                  $first_name = Trim($row["first_name"]);
2617                  $last_name = Trim($row["last_name"]);                  $last_name = Trim($row["last_name"]);
2618                  $staff_account = $row["staff_account"];                  $staff_account = $row["staff_account"];
# Line 2807  function selectStaff($con){ Line 2636  function selectStaff($con){
2636                    
2637                  printf("<tr>");                  printf("<tr>");
2638    
2639                  printf("<td %s>%d</td>", $color, $staff_id);                  printf("<td %s>%d</td>\n", $color, $staff_id);
2640                  printf("<td %s>%s, %s</td>", $color, $last_name, $first_name);                  printf("<td %s>%s, %s</td>\n", $color, $last_name, $first_name);
2641                  printf("<td %s>%s</td>", $color, $staff_account);                  printf("<td %s>%s</td>\n", $color, $staff_account);
2642                  printf("<td %s>%s</td>", $color, $local_pwd);                  printf("<td %s>%s</td>\n", $color, $local_pwd);
2643                  printf("<td %s>%s</td>", $color, $access);                  printf("<td %s>%s</td>\n", $color, $access);
2644                  printf("<td %s>%d</td>", $color, $access_level);                  printf("<td %s>%d</td>\n", $color, $access_level);
2645                  printf("<td %s>%s</td>", $color, $last_login);                  printf("<td %s>%s</td>\n", $color, $last_login);
2646                  printf("<td %s>%s</td>", $color, $last_ip);                  printf("<td %s>%s</td>\n", $color, $last_ip);
2647    
2648                  printf("<td %s>&nbsp;<input type = \"Radio\" name = \"staff_id\"                  printf("<td %s>&nbsp;<input type = \"Radio\" name = \"staff_id\"
2649                          value =\"%d\" >&nbsp;", $color, $staff_id);                          value =\"%d\" >&nbsp;</td>\n", $color, $staff_id);
2650    
2651                  printf("</tr>");                  printf("</tr>\n");
2652                                    
2653                  $rowcount++;                  $rowcount++;
2654          };          };
2655          printf("</table>");          printf("</table>\n");
2656  }  }
2657    
2658    
2659  /**********************************************************  /**********************************************************
2660  Function: statQuery($con, $sql)  Function: statQuery($sql)
2661  Author: Paul Bramscher  Author: Paul Bramscher
2662  Last Modified: 06.24.2003  Last Modified: 03.02.2004
2663  ***********************************************************  ***********************************************************
2664  Incoming:  Incoming:
 $con                    Database connection string  
2665  $sql                    A SQL statement to execute.  The  $sql                    A SQL statement to execute.  The
2666                          SELECT must have a COUNT(*) in it.                          SELECT must have a COUNT(*) in it.
2667                          The stat logic should be in WHERE.                          The stat logic should be in WHERE.
# Line 2849  column is $label explaining the purpose Line 2677  column is $label explaining the purpose
2677  the second column is the numerical figure of the $sql.  the second column is the numerical figure of the $sql.
2678  **********************************************************/  **********************************************************/
2679    
2680  function statQuery($con, $sql){  function statQuery($sql){
2681          $rs = mysql_query($sql, $con);          $rs = mysql_tryquery($sql);
2682          $row = mysql_fetch_array ($rs);          $row = mysql_fetch_array ($rs, MYSQL_ASSOC);
2683    
2684          // We should be getting only a single row.          // We should be getting only a single row.
2685          if (mysql_num_rows($rs) == 1) $result = $row["COUNT(*)"];          if (mysql_num_rows($rs) == 1) $result = $row["COUNT(*)"];
# Line 2925  function textSearchmySQL($incoming) { Line 2753  function textSearchmySQL($incoming) {
2753          return $outgoing;          return $outgoing;
2754    
2755  }  }
2756  ?>  ?>

Legend:
Removed from v.66  
changed lines
  Added in v.67

  ViewVC Help
Powered by ViewVC 1.1.26