/[libdata]/trunk/admin/include/assign.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

Annotation of /trunk/admin/include/assign.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (hide annotations)
Thu Mar 4 22:43:50 2004 UTC (20 years, 2 months ago) by dpavlin
File size: 18048 byte(s)
rename all mysql_ functions to xx_ so that wrapper can be used

1 dpavlin 1 <?php
2     /**********************************************************
3     Function Library: assign.php
4     Original Author: Paul Bramscher <brams006@tc.umn.edu>
5     Last Modified: 06.17.2003 by Paul Bramscher
6     ***********************************************************
7     Comments:
8     This library brings together all SQL assignment type
9     functions.
10     ***********************************************************
11     Table of Contents:
12    
13     Handling bridging tables
14     ========================
15     assignResFeature
16     assignResLoc
17     assignResMastersubject
18     assignServLoc
19     assignServServtype
20     assignSubCoursesub
21     assignSubLoc
22     assignSubMaster
23     assignSubStaff
24    
25    
26     assignLibunitStaff
27     assignStaffLibunit
28     assignStaffSub
29    
30    
31     **********************************************************/
32    
33    
34     /**********************************************************
35     Function: assignResFeature
36     Author: Paul Bramscher
37     Last Modified: 04.21.2003
38     ***********************************************************
39     Purpose:
40     Assigns features (possibly multiple) to a given resource
41     and calls formResource back again.
42     **********************************************************/
43     function assignResFeature($con, $feature_id_array, $resource_id) {
44    
45     // For all features in the array
46     for ($subscript = 0; $subscript < sizeof($feature_id_array); $subscript++ ) {
47    
48     // Check to make sure that the feature isn't already assigned
49     $sql = "SELECT * FROM res_feature WHERE resource_id = "
50     . $resource_id
51     . " AND feature_id = "
52     . $feature_id_array[$subscript];
53    
54 dpavlin 42 $rs = xx_query($sql);
55     if (xx_num_rows($rs) == 0) {
56 dpavlin 1
57     $sql = "INSERT INTO res_feature (resource_id, feature_id) VALUES ("
58     . $resource_id
59     . ", "
60     . $feature_id_array[$subscript]
61     . ")";
62    
63 dpavlin 42 if (!xx_query($sql, $con)){
64 dpavlin 1 sql_err($con);
65 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
66 dpavlin 1 bailout();
67     } // bad write
68     else {
69 dpavlin 42 xx_query("UNLOCK TABLES", $con);
70 dpavlin 1
71     } // good write of res_feature
72    
73     } // feature not already assigned
74    
75     } // array of feature id's
76    
77     // Call the resource form back
78     formResource($con, $resource_id, 0, 0, '');
79    
80     } // function
81    
82    
83     /**********************************************************
84     Function: assignResLoc
85     Author: Paul Bramscher
86     Last Modified: 04.21.2003
87     ***********************************************************
88     Purpose:
89     Assigns locations (possibly multiple) to a given resource
90     and calls formResource back again.
91     **********************************************************/
92     function assignResLoc($con, $location_id_array, $resource_id) {
93    
94     // For every location in the array
95     for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {
96    
97     // Check to make sure that the location isn't already assigned
98     $sql = "SELECT * FROM res_loc WHERE resource_id = "
99     . $resource_id
100     . " AND location_id = "
101     . $location_id_array[$subscript];
102    
103 dpavlin 42 $rs = xx_query($sql);
104     if (xx_num_rows($rs) == 0) {
105 dpavlin 1
106     $sql = "INSERT INTO res_loc (resource_id, location_id) VALUES ("
107     . $resource_id
108     . ", "
109     . $location_id_array[$subscript]
110     . ")";
111    
112 dpavlin 42 if (!xx_query($sql, $con)){
113 dpavlin 1 sql_err($con);
114 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
115 dpavlin 1 bailout();
116     } // bad write
117    
118     else {
119 dpavlin 42 xx_query("UNLOCK TABLES", $con);
120 dpavlin 1
121     } // good write of res_loc
122     } // location not already assigned
123    
124     } // array of location id's
125    
126     // Call the resource form back
127     formResource($con, $resource_id, 0, 0, '');
128    
129     } // function
130    
131    
132     /**********************************************************
133     Function: assignResMastersubject
134     Author: Paul Bramscher
135     Last Modified: 04.21.2003
136     ***********************************************************
137     Purpose:
138     Assigns master subjects (possibly multiple) to a given
139     resource and calls formResource back again.
140     **********************************************************/
141     function assignResMastersubject($con, $mastersubject_id_array, $resource_id) {
142    
143     // For every location in the array
144     for ($subscript = 0; $subscript < sizeof($mastersubject_id_array); $subscript++ ) {
145    
146     // Check to make sure that the masterinfotype isn't already assigned
147     $sql = "SELECT * FROM res_mastersubject WHERE resource_id = "
148     . $resource_id
149     . " AND mastersubject_id = "
150     . $mastersubject_id_array[$subscript];
151    
152 dpavlin 42 $rs = xx_query($sql);
153     if (xx_num_rows($rs) == 0) {
154 dpavlin 1
155     $sql = "INSERT INTO res_mastersubject (resource_id, mastersubject_id) VALUES ("
156     . $resource_id
157     . ", "
158     . $mastersubject_id_array[$subscript]
159     . ")";
160    
161 dpavlin 42 if (!xx_query($sql, $con)){
162 dpavlin 1 sql_err($con);
163 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
164 dpavlin 1 bailout();
165     } // bad write
166    
167     else {
168 dpavlin 42 xx_query("UNLOCK TABLES", $con);
169 dpavlin 1
170     } // good write of res_mastersubject
171     } // mastersubject not already assigned
172    
173     } // array of mastersubject id's
174    
175     // Call the resource form back
176     formResource($con, $resource_id, 0, 0, '');
177    
178     } // function
179    
180    
181     /**********************************************************
182     Function: assignServLoc
183     Author: Paul Bramscher
184     Last Modified: 04.21.2003
185     ***********************************************************
186     Purpose:
187     Assigns locations (possibly multiple) to a given service
188     and calls formService back again.
189     **********************************************************/
190     function assignServLoc($con, $location_id_array, $service_id) {
191    
192     // For every location, assign it to the selected service
193     for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {
194    
195     // Check to make sure that the location isn't already assigned
196     $sql = "SELECT * FROM serv_loc where service_id = "
197     . $service_id
198     . " AND location_id = "
199     . $location_id_array[$subscript];
200    
201 dpavlin 42 $rs = xx_query($sql);
202     if (xx_num_rows($rs) == 0) {
203 dpavlin 1
204     $sql = "INSERT INTO serv_loc (service_id, location_id) VALUES ("
205     . $service_id
206     . ", "
207     . $location_id_array[$subscript]
208     . ")";
209    
210 dpavlin 42 if (!xx_query($sql, $con)){
211 dpavlin 1 sql_err($con);
212 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
213 dpavlin 1 bailout();
214     } // bad write
215     else {
216 dpavlin 42 xx_query("UNLOCK TABLES", $con);
217 dpavlin 1
218     } // good write of serv_loc
219    
220     } // location not already assigned
221    
222     } // array of location id's
223    
224     // Call the service form back
225     formService($con, $service_id);
226    
227     } // function
228    
229    
230     /**********************************************************
231     Function: assignServServtype
232     Author: Paul Bramscher
233     Last Modified: 04.21.2003
234     ***********************************************************
235     Purpose:
236     Assigns service types (possibly multiple) to a given
237     service and calls formService back again.
238     **********************************************************/
239     function assignServServtype($con, $servicetype_id_array, $service_id) {
240    
241     // For every servicetype, assign it to the selected service
242     for ($subscript = 0; $subscript < sizeof($servicetype_id_array); $subscript++ ) {
243    
244     // Check to make sure that the servicetype isn't already assigned
245     $sql = "SELECT * FROM serv_servtype WHERE service_id = "
246     . $service_id
247     . " AND servicetype_id = "
248     . $servicetype_id_array[$subscript];
249    
250 dpavlin 42 $rs = xx_query($sql);
251     if (xx_num_rows($rs) == 0) {
252 dpavlin 1
253     $sql = "INSERT INTO serv_servtype (service_id, servicetype_id) VALUES ("
254     . $service_id
255     . ", "
256     . $servicetype_id_array[$subscript]
257     . ")";
258    
259 dpavlin 42 if (!xx_query($sql, $con)){
260 dpavlin 1 sql_err($con);
261 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
262 dpavlin 1 bailout();
263     } // bad write
264     else {
265 dpavlin 42 xx_query("UNLOCK TABLES", $con);
266 dpavlin 1
267     } // good write of serv_servtype
268    
269     } // servicetype not already assigned
270    
271     } // array of servicetype id's
272    
273     // Call the service form back
274     formService($con, $service_id);
275    
276     } // function
277    
278    
279     /**********************************************************
280     Function: assignSubCoursesub
281     Author: Paul Bramscher
282     Last Modified: 06.04.2003
283     ***********************************************************
284     Purpose:
285     Assigns course subjects (possibly multiple) to a given subject
286     and calls formSubject back again.
287     **********************************************************/
288     function assignSubCoursesub($con, $coursesub_id_array, $subject_id) {
289    
290     // For every coursesub, assign it to the selected subject
291     for ($subscript = 0; $subscript < sizeof($coursesub_id_array); $subscript++ ) {
292    
293     // Check to make sure that the coursesub isn't already assigned
294     $sql = "SELECT * FROM sub_coursesub WHERE subject_id = "
295     . $subject_id
296     . " AND coursesub_id = "
297     . $coursesub_id_array[$subscript];
298    
299 dpavlin 42 $rs = xx_query($sql);
300     if (xx_num_rows($rs) == 0) {
301 dpavlin 1
302     $sql = "INSERT INTO sub_coursesub (subject_id, coursesub_id) VALUES ("
303     . $subject_id
304     . ", "
305     . $coursesub_id_array[$subscript]
306     . ")";
307    
308 dpavlin 42 if (!xx_query($sql, $con)){
309 dpavlin 1 sql_err($con);
310 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
311 dpavlin 1 bailout();
312     } // bad write
313     else {
314 dpavlin 42 xx_query("UNLOCK TABLES", $con);
315 dpavlin 1
316     } // good write of sub_coursesub
317    
318     } // coursesub not already assigned
319    
320     } // array of coursesub id's
321    
322     // Call the subject form back
323     formSubject($con, $subject_id);
324    
325     } // function
326    
327    
328     /**********************************************************
329     Function: assignSubLoc
330     Author: Paul Bramscher
331     Last Modified: 04.21.2003
332     ***********************************************************
333     Purpose:
334     Assigns locations (possibly multiple) to a given subject
335     and calls formSubject back again.
336     **********************************************************/
337     function assignSubLoc($con, $location_id_array, $subject_id) {
338    
339     // For every location, assign it to the selected subject
340     for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {
341    
342     // Check to make sure that the location isn't already assigned
343     $sql = "SELECT * FROM sub_loc WHERE subject_id = "
344     . $subject_id
345     . " AND location_id = "
346     . $location_id_array[$subscript];
347    
348 dpavlin 42 $rs = xx_query($sql);
349     if (xx_num_rows($rs) == 0) {
350 dpavlin 1
351     $sql = "INSERT INTO sub_loc (subject_id, location_id) VALUES ("
352     . $subject_id
353     . ", "
354     . $location_id_array[$subscript]
355     . ")";
356    
357 dpavlin 42 if (!xx_query($sql, $con)){
358 dpavlin 1 sql_err($con);
359 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
360 dpavlin 1 bailout();
361     } // bad write
362     else {
363 dpavlin 42 xx_query("UNLOCK TABLES", $con);
364 dpavlin 1
365     } // good write of sub_loc
366    
367     } // location not already assigned
368    
369     } // array of location id's
370    
371     // Call the subject form back
372     formSubject($con, $subject_id);
373    
374     } // function
375    
376    
377     /**********************************************************
378     Function: assignSubMaster
379     Author: Paul Bramscher
380     Last Modified: 04.21.2003
381     ***********************************************************
382     Purpose:
383     Assigns master subjects (possibly multiple) to a given
384     subject and calls formSubject back again.
385     **********************************************************/
386     function assignSubMaster($con, $mastersubject_id_array, $subject_id) {
387    
388     // For every mastersubject, assign it to the selected subject
389     for ($subscript = 0; $subscript < sizeof($mastersubject_id_array); $subscript++ ) {
390    
391     // Check to make sure that the mastersubject isn't already assigned
392     $sql = "SELECT * FROM sub_mastersubject WHERE subject_id = "
393     . $subject_id
394     . " AND mastersubject_id = "
395     . $mastersubject_id_array[$subscript];
396    
397 dpavlin 42 $rs = xx_query($sql);
398     if (xx_num_rows($rs) == 0) {
399 dpavlin 1
400     $sql = "INSERT INTO sub_mastersubject (subject_id, mastersubject_id) VALUES ("
401     . $subject_id
402     . ", "
403     . $mastersubject_id_array[$subscript]
404     . ")";
405    
406 dpavlin 42 if (!xx_query($sql, $con)){
407 dpavlin 1 sql_err($con);
408 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
409 dpavlin 1 bailout();
410     } // bad write
411     else {
412 dpavlin 42 xx_query("UNLOCK TABLES", $con);
413 dpavlin 1
414     } // good write of sub_mastersubject
415    
416     } // location not already assigned
417    
418     } // array of mastersubject id's
419    
420     // Call the subject form back
421     formSubject($con, $subject_id);
422    
423     } // function
424    
425    
426     /**********************************************************
427     Function: assignSubStaff
428     Author: Paul Bramscher
429     Last Modified: 04.21.2003
430     ***********************************************************
431     Purpose:
432     Assigns staff specialists (possibly multiple) to a given
433     subject and calls formSubject back again.
434     **********************************************************/
435     function assignSubStaff($con, $staff_id_array, $subject_id) {
436    
437     // For every staff person selected
438     for ($subscript = 0; $subscript < sizeof($staff_id_array); $subscript++ ) {
439    
440     // Check to make sure that the specialist isn't already assigned
441     $sql = "SELECT * FROM sub_staff WHERE subject_id = "
442     . $subject_id
443     . " AND staff_id = "
444     . $staff_id_array[$subscript];
445    
446 dpavlin 42 $rs = xx_query($sql);
447     if (xx_num_rows($rs) == 0) {
448 dpavlin 1
449     $sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES ("
450     . $subject_id
451     . ", "
452     . $staff_id_array[$subscript]
453     . ")";
454    
455 dpavlin 42 //xx_query ("LOCK TABLE sub_staff WRITE", $con);
456     if (!xx_query($sql, $con)){
457 dpavlin 1 sql_err($con);
458 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
459 dpavlin 1 bailout();
460     } // bad write
461     else {
462 dpavlin 42 xx_query("UNLOCK TABLES", $con);
463 dpavlin 1 } // good write of sub_staff
464     }
465    
466     } // array of staff id's
467    
468     // Call the subject form back
469     formSubject($con, $subject_id);
470    
471     } // function
472    
473    
474    
475    
476    
477     /**********************************************************
478     Function: assignLibunitStaff
479     Author: Paul Bramscher
480     Last Modified: 04.29.2003
481     ***********************************************************
482     Purpose:
483     Assigns staff (possibly multiple) to a given library unit
484     and calls formLibunit back again.
485     **********************************************************/
486     function assignLibunitStaff($con, $staff_id_array, $libunit_id) {
487    
488     // This function assigns staff to a given library unit and calls the formLibunit to display again
489    
490     // For all staff in the array
491     for ($subscript = 0; $subscript < sizeof($staff_id_array); $subscript++ ) {
492    
493     // Check to make sure that the staff isn't already assigned
494     $sql = "SELECT * FROM libunit_staff WHERE libunit_id = " . $libunit_id .
495     " AND staff_id = " . $staff_id_array[$subscript];
496 dpavlin 42 $rs = xx_query($sql);
497     if (xx_num_rows($rs) == 0) {
498 dpavlin 1
499     $sql = "INSERT INTO libunit_staff (libunit_id, staff_id) VALUES ("
500     . $libunit_id
501     . ", "
502     . $staff_id_array[$subscript]
503     . ")";
504    
505 dpavlin 42 if (!xx_query($sql, $con)){
506 dpavlin 1 sql_err($con);
507 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
508 dpavlin 1 bailout();
509     } // bad write
510     else {
511 dpavlin 42 xx_query("UNLOCK TABLES", $con);
512 dpavlin 1
513     } // good write of libunit_staff
514    
515     } // staff not already assigned
516    
517     } // array of staff id's
518    
519     // Call the Libunit form back
520     formLibunit($con, $libunit_id);
521    
522     } // function
523    
524    
525     /**********************************************************
526     Function: assignStaffLibunit
527     Author: Paul Bramscher
528     Last Modified: 04.29.2003
529     ***********************************************************
530     Purpose:
531     Assigns library units (possibly multiple) to a given
532     staffperson and calls formStaff back again. This handles
533     the same bridging table as assignLibunitStaff, but from
534     the other side of the multiple pick list relationship.
535     **********************************************************/
536     function assignStaffLibunit($con, $libunit_id_array, $staff_id) {
537    
538     // This function assigns library units to a selected staff person
539     for ($subscript = 0; $subscript < sizeof($libunit_id_array); $subscript++ ) {
540    
541     // Check to make sure that the libunit isn't already assigned
542     $sql = "SELECT * FROM libunit_staff WHERE staff_id = "
543     . $staff_id
544     . " AND libunit_id = "
545     . $libunit_id_array[$subscript];
546    
547 dpavlin 42 $rs = xx_query($sql);
548     if (xx_num_rows($rs) == 0) {
549 dpavlin 1
550     $sql = "INSERT INTO libunit_staff (libunit_id, staff_id) VALUES ("
551     . $libunit_id_array[$subscript]
552     . ", "
553     . $staff_id
554     . ")";
555    
556 dpavlin 42 if (!xx_query($sql, $con)){
557 dpavlin 1 sql_err($con);
558 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
559 dpavlin 1 bailout();
560     } // bad write
561     else {
562 dpavlin 42 xx_query("UNLOCK TABLES", $con);
563 dpavlin 1
564     } // good write of libunit_staff
565    
566     } // assignment didn't already exist
567    
568     } // array of libunit id's
569    
570     // Call the staff form back
571     formStaff($con, $staff_id);
572    
573     } // function
574    
575    
576     /**********************************************************
577     Function: assignStaffSub
578     Author: Paul Bramscher
579     Last Modified: 04.29.2003
580     ***********************************************************
581     Purpose:
582     Assigns subjects (possibly multiple) to a given staffperson
583     and calls formStaff back again.
584     **********************************************************/
585     function assignStaffSub($con, $staff_id, $subject_id_array) {
586    
587     // This function assigns subjects to a selected staff person
588     for ($subscript = 0; $subscript < sizeof($subject_id_array); $subscript++ ) {
589    
590     // Check to make sure that the subject isn't already assigned
591     $sql = "SELECT * FROM sub_staff WHERE staff_id = "
592     . $staff_id
593     . " AND subject_id = "
594     . $subject_id_array[$subscript];
595    
596 dpavlin 42 $rs = xx_query($sql);
597     if (xx_num_rows($rs) == 0) {
598 dpavlin 1
599     $sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES ("
600     . $subject_id_array[$subscript]
601     . ", "
602     . $staff_id
603     . ")";
604    
605 dpavlin 42 if (!xx_query($sql, $con)){
606 dpavlin 1 sql_err($con);
607 dpavlin 42 xx_query ("UNLOCK TABLES", $con);
608 dpavlin 1 bailout();
609     } // bad write
610     else {
611 dpavlin 42 xx_query("UNLOCK TABLES", $con);
612 dpavlin 1
613     } // good write of sub_staff
614    
615     } // assignment didn't already exist
616    
617     } // array of subject id's
618    
619     // Call the staff form back
620     formStaff($con, $staff_id);
621    
622     } // function
623     ?>

  ViewVC Help
Powered by ViewVC 1.1.26