1 |
dpavlin |
1 |
<?php |
2 |
|
|
/********************************************************** |
3 |
|
|
Function Library: insert.php |
4 |
|
|
Original Author: Paul Bramscher <brams006@tc.umn.edu> |
5 |
|
|
Last Modified: 09.30.2003 by Paul Bramscher |
6 |
|
|
*********************************************************** |
7 |
|
|
Comments: |
8 |
|
|
This library brings together all SQL insert functions for |
9 |
|
|
LibData general setup tables. Those pertaining to |
10 |
|
|
CLPS and RQS are located in scribe_application.php and |
11 |
|
|
subject_builder.php respectively. |
12 |
|
|
*********************************************************** |
13 |
|
|
Table of Contents: |
14 |
|
|
|
15 |
|
|
insertCoursesub |
16 |
|
|
insertFaculty |
17 |
|
|
insertFeature |
18 |
|
|
insertInfotype |
19 |
|
|
insertLibunit |
20 |
|
|
insertLocation |
21 |
|
|
insertResource |
22 |
|
|
insertService |
23 |
|
|
insertSingleField |
24 |
|
|
insertStaff |
25 |
|
|
insertStyle |
26 |
|
|
insertSubject |
27 |
|
|
|
28 |
|
|
|
29 |
|
|
**********************************************************/ |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/********************************************************** |
33 |
|
|
Function: insertCoursesub |
34 |
|
|
Author: Paul Bramscher |
35 |
|
|
Last Modified: 06.03.2003 |
36 |
|
|
*********************************************************** |
37 |
|
|
Purpose: |
38 |
|
|
Inserts a course subject. |
39 |
|
|
**********************************************************/ |
40 |
|
|
function insertCoursesub($con, $campus_id, $cip_code, $coursesub, $coursesub_descr) { |
41 |
|
|
|
42 |
|
|
// Error flag |
43 |
|
|
$err_code = 0; |
44 |
|
|
|
45 |
|
|
// Need for display/uniqueness |
46 |
|
|
$coursesub_display = $coursesub; |
47 |
|
|
$coursesub_search = textSearchmySQL($coursesub); |
48 |
|
|
|
49 |
|
|
// Check to see if already exists |
50 |
|
|
$exists = recordCount($con, "coursesub", "coursesub", $coursesub_search, "A"); |
51 |
|
|
if ($exists > 0) { |
52 |
|
|
$err_code = 1; |
53 |
|
|
$err_msg = "Failed. '" . $coursesub_display . "' already exists in the course subject table."; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
// Check for blank entry |
57 |
|
|
if ($coursesub == "") { |
58 |
|
|
$err_code = 2; |
59 |
|
|
$err_msg = "Failed. Cannot enter a blank course subject."; |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
printf("<center><h3>Adding Course Subject...</h3>"); |
63 |
|
|
|
64 |
|
|
// Table |
65 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
66 |
|
|
printf("<tr><td><br>"); |
67 |
|
|
printf("<strong>Messages:</strong><br>"); |
68 |
|
|
|
69 |
|
|
// Add only if this coursesub doesn't already exist, and something was supplied |
70 |
|
|
if ($err_code == 0) { |
71 |
|
|
|
72 |
|
|
// Clean up strings |
73 |
|
|
if (strlen($coursesub) > 0) $coursesub = textInmySQL($coursesub); |
74 |
|
|
if (strlen($coursesub_descr) > 0) $coursesub_descr = textInmySQL($coursesub_descr); |
75 |
|
|
if (strlen($cip_code) > 0) $cip_code = textInmySQL($cip_code); |
76 |
|
|
|
77 |
|
|
// Set up SQL |
78 |
|
|
$sql = "INSERT INTO coursesub (coursesub, coursesub_descr, cip_code, campus_id) VALUES ('" |
79 |
|
|
. $coursesub |
80 |
|
|
. "', '" |
81 |
|
|
. $coursesub_descr |
82 |
|
|
. "', '" |
83 |
|
|
. $cip_code |
84 |
|
|
. "', " |
85 |
|
|
. $campus_id |
86 |
|
|
. ")"; |
87 |
|
|
|
88 |
|
|
// Write the new row to the database |
89 |
|
|
if (!mysql_query($sql, $con)){ |
90 |
|
|
sql_err($con); |
91 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
92 |
|
|
bailout(); |
93 |
|
|
} |
94 |
|
|
else { |
95 |
|
|
printf("Added Course Subject <b>%s</b>.<BR>", $coursesub_display); |
96 |
|
|
mysql_query("UNLOCK TABLES", $con); |
97 |
|
|
} |
98 |
|
|
} |
99 |
|
|
else printf("%s", $err_msg); |
100 |
|
|
printf("<br><br>\n"); |
101 |
|
|
printf("</td></tr></table>\n"); |
102 |
|
|
printf("</center>\n"); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
|
106 |
|
|
/********************************************************** |
107 |
|
|
Function: insertFaculty |
108 |
|
|
Author: Paul Bramscher |
109 |
|
|
Last Modified: 06.24.2003 |
110 |
|
|
*********************************************************** |
111 |
|
|
Purpose: |
112 |
|
|
Inserts a faculty member. |
113 |
|
|
**********************************************************/ |
114 |
|
|
function insertFaculty($con, $faculty_email, $faculty_firstname, |
115 |
|
|
$faculty_lastname, $faculty_account) { |
116 |
|
|
|
117 |
|
|
/* |
118 |
|
|
Faculty must have both a unique non-blank staff_account, and non-blank last name. |
119 |
|
|
*/ |
120 |
|
|
|
121 |
|
|
// Error flag |
122 |
|
|
$err_code = 0; |
123 |
|
|
|
124 |
|
|
// Need for display/uniqueness |
125 |
|
|
$faculty_name_display = $faculty_firstname . " " . $faculty_lastname; |
126 |
|
|
$exists_id = existsFaculty($con, $faculty_firstname, $faculty_lastname); |
127 |
|
|
|
128 |
|
|
if ($exists_id > 0) { |
129 |
|
|
$err_code = 1; |
130 |
|
|
$err_msg = "Failed. '" . $faculty_name_display . "' already exists in the Faculty table."; |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
// Check for blank last name |
134 |
|
|
if ($faculty_lastname == "") { |
135 |
|
|
$err_code = 2; |
136 |
|
|
$err_msg = "Failed. Cannot enter a blank Last Name."; |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
printf("<center><h3>Adding Faculty...</h3>"); |
140 |
|
|
|
141 |
|
|
// Table |
142 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
143 |
|
|
printf("<tr><td><br>"); |
144 |
|
|
printf("<strong>Messages:</strong><br>"); |
145 |
|
|
|
146 |
|
|
// Add only if no errors encountered |
147 |
|
|
if ($err_code == 0) { |
148 |
|
|
|
149 |
|
|
// Clean up strings |
150 |
|
|
if (strlen($faculty_lastname) > 0) $faculty_lastname = textInmySQL($faculty_lastname); |
151 |
|
|
if (strlen($faculty_firstname) > 0) $faculty_firstname = textInmySQL($faculty_firstname); |
152 |
|
|
if (strlen($faculty_email) > 0) $faculty_email = textInmySQL($faculty_email); |
153 |
|
|
if (strlen($faculty_account) > 0) $faculty_account = textInmySQL($faculty_account); |
154 |
|
|
|
155 |
|
|
// Set up SQL |
156 |
|
|
$sql = "INSERT INTO faculty (faculty_lastname, faculty_firstname, |
157 |
|
|
faculty_email, faculty_account) VALUES ('" |
158 |
|
|
. $faculty_lastname |
159 |
|
|
. "', '" |
160 |
|
|
. $faculty_firstname |
161 |
|
|
. "', '" |
162 |
|
|
. $faculty_email |
163 |
|
|
. "', '" |
164 |
|
|
. $faculty_account |
165 |
|
|
. "')"; |
166 |
|
|
|
167 |
|
|
// Write the new row to the database |
168 |
|
|
if (!mysql_query($sql, $con)){ |
169 |
|
|
sql_err($con); |
170 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
171 |
|
|
bailout(); |
172 |
|
|
} |
173 |
|
|
else { |
174 |
|
|
printf("Added <b>%s</b> to the faculty table.<BR>\n", $faculty_name_display); |
175 |
|
|
mysql_query("UNLOCK TABLES", $con); |
176 |
|
|
} |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
else printf("%s", $err_msg); |
180 |
|
|
printf("<br><br>\n"); |
181 |
|
|
printf("</td></tr></table>\n"); |
182 |
|
|
printf("</center>\n"); |
183 |
|
|
} |
184 |
|
|
|
185 |
|
|
|
186 |
|
|
/********************************************************** |
187 |
|
|
Function: insertFeature |
188 |
|
|
Author: Paul Bramscher |
189 |
|
|
Last Modified: 05.21.2003 |
190 |
|
|
*********************************************************** |
191 |
|
|
Purpose: |
192 |
|
|
Inserts a feature. |
193 |
|
|
**********************************************************/ |
194 |
|
|
function insertFeature($con, $feature, $image_alt, $image_path) { |
195 |
|
|
|
196 |
|
|
// Error flag |
197 |
|
|
$err_code = 0; |
198 |
|
|
|
199 |
|
|
// Need for display/uniqueness |
200 |
|
|
$feature_display = $feature; |
201 |
|
|
$feature_search = textSearchmySQL($feature); |
202 |
|
|
|
203 |
|
|
// Check to see if already exists |
204 |
|
|
$exists = recordCount($con, "feature", "feature", $feature_search, "A"); |
205 |
|
|
if ($exists > 0) { |
206 |
|
|
$err_code = 1; |
207 |
|
|
$err_msg = "Failed. '" . $feature_display . "' already exists in the feature table."; |
208 |
|
|
} |
209 |
|
|
|
210 |
|
|
// Check for blank entry |
211 |
|
|
if ($feature == "") { |
212 |
|
|
$err_code = 2; |
213 |
|
|
$err_msg = "Failed. Cannot enter a blank feature."; |
214 |
|
|
} |
215 |
|
|
|
216 |
|
|
printf("<center><h3>Adding Feature...</h3>"); |
217 |
|
|
|
218 |
|
|
// Table |
219 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
220 |
|
|
printf("<tr><td><br>"); |
221 |
|
|
printf("<strong>Messages:</strong><br>"); |
222 |
|
|
|
223 |
|
|
// Add only if this feature doesn't already exist, and something was supplied |
224 |
|
|
if ($err_code == 0) { |
225 |
|
|
|
226 |
|
|
// Clean up strings |
227 |
|
|
if (strlen($feature) > 0) $feature = textInmySQL($feature); |
228 |
|
|
if (strlen($image_alt) > 0) $image_alt = textInmySQL($image_alt); |
229 |
|
|
if (strlen($image_path) >0) $image_path = textInmySQL($image_path); |
230 |
|
|
|
231 |
|
|
// Set up SQL |
232 |
|
|
$sql = "INSERT INTO feature (feature, image_alt, image_path) VALUES ('" |
233 |
|
|
. $feature |
234 |
|
|
. "', '" |
235 |
|
|
. $image_alt |
236 |
|
|
. "', '" |
237 |
|
|
. $image_path |
238 |
|
|
. "')"; |
239 |
|
|
|
240 |
|
|
// Write the new row to the database |
241 |
|
|
if (!mysql_query($sql, $con)){ |
242 |
|
|
sql_err($con); |
243 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
244 |
|
|
bailout(); |
245 |
|
|
} |
246 |
|
|
else { |
247 |
|
|
printf("Added Feature <b>%s</b>.<BR>", $feature_display); |
248 |
|
|
mysql_query("UNLOCK TABLES", $con); |
249 |
|
|
} |
250 |
|
|
} |
251 |
|
|
else printf("%s", $err_msg); |
252 |
|
|
printf("<br><br>\n"); |
253 |
|
|
printf("</td></tr></table>\n"); |
254 |
|
|
printf("</center>\n"); |
255 |
|
|
} |
256 |
|
|
|
257 |
|
|
|
258 |
|
|
/********************************************************** |
259 |
|
|
Function: insertInfotype |
260 |
|
|
Author: Paul Bramscher |
261 |
|
|
Last Modified: 05.21.2003 |
262 |
|
|
*********************************************************** |
263 |
|
|
Purpose: |
264 |
|
|
Inserts an information type. |
265 |
|
|
**********************************************************/ |
266 |
|
|
function insertInfotype($con, $infotype, $masterinfotype_id, $mastersubject_id) { |
267 |
|
|
|
268 |
|
|
// Error flag |
269 |
|
|
$err_code = 0; |
270 |
|
|
|
271 |
|
|
// Need for display/uniqueness purposes |
272 |
|
|
$infotype_display = $infotype; |
273 |
|
|
$infotype_search = textSearchmySQL($infotype); |
274 |
|
|
|
275 |
|
|
// Check to see if already exists |
276 |
|
|
$exists = recordCount($con, "infotype", "infotype", $infotype_search, "A"); |
277 |
|
|
|
278 |
|
|
// If exists in the table |
279 |
|
|
if ($exists > 0) { |
280 |
|
|
$err_code = 1; |
281 |
|
|
$err_msg = "Failed. '" . $infotype_display . "' already exists in the Information Type table."; |
282 |
|
|
} |
283 |
|
|
|
284 |
|
|
// Check for blank entry |
285 |
|
|
if ($infotype == "") { |
286 |
|
|
$err_code = 2; |
287 |
|
|
$err_msg = "Failed. Must supply some value for the Information Type name."; |
288 |
|
|
} |
289 |
|
|
|
290 |
|
|
|
291 |
|
|
printf("<center><h3>Adding Information Type...</h3>"); |
292 |
|
|
|
293 |
|
|
// Table |
294 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
295 |
|
|
printf("<tr><td><br>"); |
296 |
|
|
printf("<strong>Messages:</strong><br>"); |
297 |
|
|
|
298 |
|
|
// Add only if this infotype doesn't already exist |
299 |
|
|
if ($err_code == 0) { |
300 |
|
|
|
301 |
|
|
// Clean up strings |
302 |
|
|
if (strlen($infotype) > 0) $infotype = textInmySQL($infotype); |
303 |
|
|
|
304 |
|
|
// Set up SQL |
305 |
|
|
$sql = "INSERT INTO infotype (infotype, masterinfotype_id, mastersubject_id) VALUES ('" |
306 |
|
|
. $infotype |
307 |
|
|
. "', " |
308 |
|
|
. $masterinfotype_id |
309 |
|
|
. ", " |
310 |
|
|
. $mastersubject_id |
311 |
|
|
. ")"; |
312 |
|
|
|
313 |
|
|
// Write the new row to the database |
314 |
|
|
if (!mysql_query($sql, $con)){ |
315 |
|
|
sql_err($con); |
316 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
317 |
|
|
bailout(); |
318 |
|
|
} |
319 |
|
|
else { |
320 |
|
|
printf("Added Information Type <b>%s</b>.<BR>", $infotype_display); |
321 |
|
|
mysql_query("UNLOCK TABLES", $con); |
322 |
|
|
} |
323 |
|
|
} |
324 |
|
|
|
325 |
|
|
else printf("%s<BR><BR>", $err_msg); |
326 |
|
|
|
327 |
|
|
// Close the table |
328 |
|
|
printf("<BR>"); |
329 |
|
|
printf("</td></tr></table>"); |
330 |
|
|
printf("</center>"); |
331 |
|
|
} |
332 |
|
|
|
333 |
|
|
|
334 |
|
|
/********************************************************** |
335 |
|
|
Function: insertLibunit |
336 |
|
|
Author: Paul Bramscher |
337 |
|
|
Last Modified: 05.22.2003 |
338 |
|
|
*********************************************************** |
339 |
|
|
Purpose: |
340 |
|
|
Inserts the supplied library unit information into the |
341 |
|
|
database, and calls formLibunit back again, if the |
342 |
|
|
insert passed a few checks (unique, no blank values, etc.) |
343 |
|
|
**********************************************************/ |
344 |
|
|
function insertLibunit($con, $head_staff_id, $libunit, $libunit_abbrev) { |
345 |
|
|
|
346 |
|
|
/* |
347 |
|
|
Library Units must have both a unique name and unique abbreviation |
348 |
|
|
e.g. "Digital Library Developement Laboratory" and "DLDL" |
349 |
|
|
Additionally, empty values are not allowed. |
350 |
|
|
*/ |
351 |
|
|
|
352 |
|
|
// Error flag |
353 |
|
|
$err_code = 0; |
354 |
|
|
|
355 |
|
|
// Need for display/uniqueness purposes |
356 |
|
|
$libunit_display = $libunit; |
357 |
|
|
$libunit_abbrev_display = $libunit_abbrev; |
358 |
|
|
$libunit_search = textSearchmySQL($libunit); |
359 |
|
|
$libunit_abbrev_search = textSearchmySQL($libunit_abbrev); |
360 |
|
|
|
361 |
|
|
// Check to see if libunit already exists |
362 |
|
|
$exists = recordCount($con, "libunit", "libunit", $libunit_search, "A"); |
363 |
|
|
if ($exists > 0) { |
364 |
|
|
$err_code = 1; |
365 |
|
|
$err_msg = "Failed. '" . $libunit_display . "' already exists in the Library Unit table."; |
366 |
|
|
} |
367 |
|
|
|
368 |
|
|
// Check to see if libunit abbreviation already exists |
369 |
|
|
$exists = recordCount($con, "libunit", "libunit_abbrev", $libunit_abbrev_search, "A"); |
370 |
|
|
if ($exists > 0) { |
371 |
|
|
$err_code = 2; |
372 |
|
|
$err_msg = "Failed. '" . $libunit_abbrev_display . "' abbreviation already exists in the Library Unit table."; |
373 |
|
|
} |
374 |
|
|
|
375 |
|
|
// Check for blank linunit entry |
376 |
|
|
if ($libunit == "") { |
377 |
|
|
$err_code = 3; |
378 |
|
|
$err_msg = "Failed. Cannot enter a blank Library Unit."; |
379 |
|
|
} |
380 |
|
|
|
381 |
|
|
// Check for blank linunit abbrev entry |
382 |
|
|
if ($libunit_abbrev == "") { |
383 |
|
|
$err_code = 4; |
384 |
|
|
$err_msg = "Failed. Cannot enter a blank Library Unit abbreviation."; |
385 |
|
|
} |
386 |
|
|
|
387 |
|
|
// Add only if no errors encountered |
388 |
|
|
if ($err_code == 0) { |
389 |
|
|
|
390 |
|
|
if (strlen($libunit) > 0) $libunit = textInmySQL($libunit); |
391 |
|
|
if (strlen($libunit_abbrev) > 0) $libunit_abbrev = textInmySQL($libunit_abbrev); |
392 |
|
|
|
393 |
|
|
$sql = "INSERT INTO libunit (libunit, libunit_abbrev, head_staff_id) VALUES ('" |
394 |
|
|
. $libunit |
395 |
|
|
. "', '" |
396 |
|
|
. $libunit_abbrev |
397 |
|
|
. "', " |
398 |
|
|
. $head_staff_id |
399 |
|
|
. ")"; |
400 |
|
|
|
401 |
|
|
// Write the new row to the database |
402 |
|
|
mysql_query ("LOCK TABLE libunit WRITE", $con); |
403 |
|
|
if (!mysql_query($sql, $con)){ |
404 |
|
|
sql_err($con); |
405 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
406 |
|
|
bailout(); |
407 |
|
|
} |
408 |
|
|
else { |
409 |
|
|
$libunit_id = mysql_insert_id($con); |
410 |
|
|
mysql_query("UNLOCK TABLES", $con); |
411 |
|
|
formLibunit($con, $libunit_id); |
412 |
|
|
} |
413 |
|
|
} |
414 |
|
|
|
415 |
|
|
else { |
416 |
|
|
printf("<center><h3>Adding Library Unit...</h3>"); |
417 |
|
|
|
418 |
|
|
// Table |
419 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
420 |
|
|
printf("<tr><td><br>\n"); |
421 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
422 |
|
|
printf("%s", $err_msg); |
423 |
|
|
printf("<BR><BR>\n"); |
424 |
|
|
printf("</td></tr></table>\n"); |
425 |
|
|
printf("</center>\n"); |
426 |
|
|
} |
427 |
|
|
} |
428 |
|
|
|
429 |
|
|
|
430 |
|
|
/********************************************************** |
431 |
|
|
Function: insertLocation |
432 |
|
|
Author: Paul Bramscher |
433 |
|
|
Last Modified: 06.16.2003 |
434 |
|
|
*********************************************************** |
435 |
|
|
Purpose: |
436 |
|
|
Inserts a library/location. |
437 |
|
|
**********************************************************/ |
438 |
|
|
function insertLocation($con, $address1, $address2, $address3, |
439 |
|
|
$address4, $campus, $hoursURL, $location, $location_descr, $mainURL, |
440 |
|
|
$mapURL, $referenceURL, $telephone) { |
441 |
|
|
|
442 |
|
|
// Need for display purposes |
443 |
|
|
$location_display = $location; |
444 |
|
|
$location_search = textSearchmySQL($location); |
445 |
|
|
|
446 |
|
|
// Error flag |
447 |
|
|
$err_code = 0; |
448 |
|
|
|
449 |
|
|
// Check to see if already exists |
450 |
|
|
$exists = recordCount($con, "location", "location", $location_search, "A"); |
451 |
|
|
if ($exists > 0) { |
452 |
|
|
$err_code = 1; |
453 |
|
|
$err_msg = "Failed. '" . $location_display . "' already exists in the location table."; |
454 |
|
|
} |
455 |
|
|
|
456 |
|
|
// Check for blank entry |
457 |
|
|
if ($location == "") { |
458 |
|
|
$err_code = 2; |
459 |
|
|
$err_msg = "Failed. Cannot enter a blank location."; |
460 |
|
|
} |
461 |
|
|
|
462 |
|
|
printf("<center><h3>Adding Location...</h3>\n"); |
463 |
|
|
|
464 |
|
|
// Table |
465 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
466 |
|
|
printf("<tr><td><br>\n"); |
467 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
468 |
|
|
|
469 |
|
|
// Add only if this location doesn't already exist, and something was supplied |
470 |
|
|
if ($err_code == 0) { |
471 |
|
|
|
472 |
|
|
// Clean up strings |
473 |
|
|
if (strlen($location) > 0) $location = textInmySQL($location); |
474 |
|
|
if (strlen($location_descr) > 0) $location_descr = textInmySQL($location_descr); |
475 |
|
|
if (strlen($campus) > 0) $campus = textInmySQL($campus); |
476 |
|
|
if (strlen($address1) > 0) $address1 = textInmySQL($address1); |
477 |
|
|
if (strlen($address2) > 0) $address2 = textInmySQL($address2); |
478 |
|
|
if (strlen($address3) > 0) $address3 = textInmySQL($address3); |
479 |
|
|
if (strlen($address4) > 0) $address4 = textInmySQL($address4); |
480 |
|
|
if (strlen($telephone) > 0) $telephone = textInmySQL($telephone); |
481 |
|
|
if (strlen($mainURL) > 0) $mainURL = textInmySQL($mainURL); |
482 |
|
|
if (strlen($referenceURL) > 0) $referenceURL = textInmySQL($referenceURL); |
483 |
|
|
if (strlen($mapURL) > 0) $mapURL = textInmySQL($mapURL); |
484 |
|
|
if (strlen($hoursURL) > 0) $hoursURL = textInmySQL($hoursURL); |
485 |
|
|
|
486 |
|
|
// Set up SQL |
487 |
|
|
$sql = "INSERT INTO location (location, location_descr, campus, address1, |
488 |
|
|
address2, address3, address4, telephone, mainURL, referenceURL, |
489 |
|
|
mapURL, hoursURL) VALUES ('" |
490 |
|
|
. $location |
491 |
|
|
. "', '" |
492 |
|
|
. $location_descr |
493 |
|
|
. "', '" |
494 |
|
|
. $campus |
495 |
|
|
. "', '" |
496 |
|
|
. $address1 |
497 |
|
|
. "', '" |
498 |
|
|
. $address2 |
499 |
|
|
. "', '" |
500 |
|
|
. $address3 |
501 |
|
|
. "', '" |
502 |
|
|
. $address4 |
503 |
|
|
. "', '" |
504 |
|
|
. $telephone |
505 |
|
|
. "', '" |
506 |
|
|
. $mainURL |
507 |
|
|
. "', '" |
508 |
|
|
. $referenceURL |
509 |
|
|
. "', '" |
510 |
|
|
. $mapURL |
511 |
|
|
. "', '" |
512 |
|
|
. $hoursURL |
513 |
|
|
. "')"; |
514 |
|
|
|
515 |
|
|
// Write the new row to the database |
516 |
|
|
if (!mysql_query($sql, $con)){ |
517 |
|
|
sql_err($con); |
518 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
519 |
|
|
bailout(); |
520 |
|
|
} |
521 |
|
|
else { |
522 |
|
|
|
523 |
|
|
printf("Added <b>%s</b> location.", $location_display); |
524 |
|
|
mysql_query("UNLOCK TABLES", $con); |
525 |
|
|
} |
526 |
|
|
} |
527 |
|
|
|
528 |
|
|
else printf("%s", $err_msg); |
529 |
|
|
printf("<br><br>\n"); |
530 |
|
|
printf("</td></tr></table>\n"); |
531 |
|
|
printf("</center>\n"); |
532 |
|
|
|
533 |
|
|
} |
534 |
|
|
|
535 |
|
|
|
536 |
|
|
/********************************************************** |
537 |
|
|
Function: insertResource |
538 |
|
|
Author: Paul Bramscher |
539 |
|
|
Last Modified: 04.21.2003 |
540 |
|
|
*********************************************************** |
541 |
|
|
Purpose: |
542 |
|
|
Inserts a resource. |
543 |
|
|
**********************************************************/ |
544 |
|
|
function insertResource($con, $annotation, $author, $call_no, $cat_num, |
545 |
|
|
$coverage_detail, $edition, $infotype_id, $mastersubject_id, $other_title, |
546 |
|
|
$pub_date, $publisher, $sess_staff_account, $sources_indexed, $title, $url) { |
547 |
|
|
|
548 |
|
|
// Error flag |
549 |
|
|
$err_code = 0; |
550 |
|
|
|
551 |
|
|
// Check to see if already exists |
552 |
|
|
$exists = recordCount($con, "resource", "title", $title, "A"); |
553 |
|
|
|
554 |
|
|
// If exists in the table |
555 |
|
|
if ($exists > 0) { |
556 |
|
|
$err_code = 1; |
557 |
|
|
$err_msg = "Failed. '" . $title . "' already exists in the Resource table."; |
558 |
|
|
} |
559 |
|
|
|
560 |
|
|
// Check for blank entry |
561 |
|
|
if ($title == "") { |
562 |
|
|
$err_code = 2; |
563 |
|
|
$err_msg = "Failed. Must supply some value for the Title field."; |
564 |
|
|
} |
565 |
|
|
|
566 |
|
|
// Proceed only if no errors |
567 |
|
|
if ($err_code == 0) { |
568 |
|
|
|
569 |
|
|
// Clean up strings |
570 |
|
|
if (strlen($annotation) > 0) $annotation = textInmySQL($annotation); |
571 |
|
|
if (strlen($author) > 0) $author = textInmySQL($author); |
572 |
|
|
if (strlen($call_no) > 0) $call_no = textInmySQL($call_no); |
573 |
|
|
if (strlen($cat_num) > 0) $cat_num = textInmySQL($cat_num); |
574 |
|
|
if (strlen($coverage_detail) > 0) $coverage_detail = textInmySQL($coverage_detail); |
575 |
|
|
if (strlen($edition) > 0) $edition = textInmySQL($edition); |
576 |
|
|
if (strlen($other_title) > 0) $other_title = textInmySQL($other_title); |
577 |
|
|
if (strlen($pub_date) > 0) $pub_date = textInmySQL($pub_date); |
578 |
|
|
if (strlen($publisher) > 0) $publisher = textInmySQL($publisher); |
579 |
|
|
if (strlen($sources_indexed) > 0) $sources_indexed = textInmySQL($sources_indexed); |
580 |
|
|
if (strlen($title) > 0) $title = textInmySQL($title); |
581 |
|
|
if (strlen($url) > 0) $url = textInmySQL($url); |
582 |
|
|
|
583 |
|
|
// Build the SQL |
584 |
|
|
$sql = "INSERT INTO resource (annotation, author, call_no, cat_num, |
585 |
|
|
coverage_detail, date_created, date_modified, edition, |
586 |
|
|
infotype_id, other_title, pub_date, publisher, sources_indexed, |
587 |
|
|
title, url, account_created) VALUES ('" |
588 |
|
|
. $annotation |
589 |
|
|
. "', '" |
590 |
|
|
. $author |
591 |
|
|
. "', '" |
592 |
|
|
. $call_no |
593 |
|
|
. "', '" |
594 |
|
|
. $cat_num |
595 |
|
|
. "', '" |
596 |
|
|
. $coverage_detail |
597 |
|
|
. "', now(), now(), '" |
598 |
|
|
. $edition |
599 |
|
|
. "', " |
600 |
|
|
. $infotype_id |
601 |
|
|
. ", '" |
602 |
|
|
. $other_title |
603 |
|
|
. "', '" |
604 |
|
|
. $pub_date |
605 |
|
|
. "', '" |
606 |
|
|
. $publisher |
607 |
|
|
. "', '" |
608 |
|
|
. $sources_indexed |
609 |
|
|
. "', '" |
610 |
|
|
. $title |
611 |
|
|
. "', '" |
612 |
|
|
. $url |
613 |
|
|
. "', '" |
614 |
|
|
. $sess_staff_account |
615 |
|
|
. "')"; |
616 |
|
|
|
617 |
|
|
// Debugging |
618 |
|
|
// printf("sql was: %s<BR>", $sql); |
619 |
|
|
|
620 |
|
|
// Write the new record to the database |
621 |
|
|
mysql_query ("LOCK TABLE resource WRITE", $con); |
622 |
|
|
if (!mysql_query($sql, $con)){ |
623 |
|
|
sql_err($con); |
624 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
625 |
|
|
bailout(); |
626 |
|
|
} |
627 |
|
|
else { |
628 |
|
|
$resource_id = mysql_insert_id($con); |
629 |
|
|
mysql_query("UNLOCK TABLES", $con); |
630 |
|
|
|
631 |
|
|
// Now set up this resource with its first mastersubject |
632 |
|
|
// Note that id#1 = N/A and id#2 = (All), and are not used here. |
633 |
|
|
if ($mastersubject_id > 2) { |
634 |
|
|
$sql = "INSERT INTO res_mastersubject (resource_id, mastersubject_id) VALUES (" |
635 |
|
|
. $resource_id |
636 |
|
|
. ", " |
637 |
|
|
. $mastersubject_id |
638 |
|
|
. ")"; |
639 |
|
|
|
640 |
|
|
// Write the new res_mastersubject to the database |
641 |
|
|
mysql_query ("LOCK TABLE res_mastersubject WRITE", $con); |
642 |
|
|
if (!mysql_query($sql, $con)){ |
643 |
|
|
sql_err($con); |
644 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
645 |
|
|
bailout(); |
646 |
|
|
} |
647 |
|
|
else { |
648 |
|
|
mysql_query("UNLOCK TABLES", $con); |
649 |
|
|
} |
650 |
|
|
} |
651 |
|
|
} |
652 |
|
|
|
653 |
|
|
// Call the formResource page back, in case user wants to edit further |
654 |
|
|
formResource($con, $resource_id, 0, 0, ''); |
655 |
|
|
|
656 |
|
|
} // end insert new resource |
657 |
|
|
|
658 |
|
|
else { |
659 |
|
|
printf("<center><h3>Adding Resource...</h3>"); |
660 |
|
|
|
661 |
|
|
// Table |
662 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
663 |
|
|
printf("<tr><td><br>\n"); |
664 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
665 |
|
|
printf("%s", $err_msg); |
666 |
|
|
printf("<BR><BR>\n"); |
667 |
|
|
printf("</td></tr></table>\n"); |
668 |
|
|
printf("</center>\n"); |
669 |
|
|
} // end error messages |
670 |
|
|
|
671 |
|
|
} // end function |
672 |
|
|
|
673 |
|
|
|
674 |
|
|
/********************************************************** |
675 |
|
|
Function: insertSingleField |
676 |
|
|
Author: Paul Bramscher |
677 |
|
|
Last Modified: 05.21.2003 |
678 |
|
|
*********************************************************** |
679 |
|
|
Purpose: |
680 |
|
|
Inserts any single field value into any table. |
681 |
|
|
**********************************************************/ |
682 |
|
|
function insertSingleField($con, $display, $field, $newValue, $table){ |
683 |
|
|
|
684 |
|
|
// Error flag |
685 |
|
|
$err_code = 0; |
686 |
|
|
|
687 |
|
|
// Need for display/uniqueness purposes |
688 |
|
|
$newValue_search = textSearchmySQL($newValue); |
689 |
|
|
$newValue_display = $newValue; |
690 |
|
|
|
691 |
|
|
// Check to see if already exists |
692 |
|
|
$exists = recordCount($con, $table, $field, $newValue_search, "A"); |
693 |
|
|
if ($exists > 0) { |
694 |
|
|
$err_code = 1; |
695 |
|
|
$err_msg = "Failed. <b>" |
696 |
|
|
. $newValue_display |
697 |
|
|
. "</b> already exists in the " |
698 |
|
|
. $display |
699 |
|
|
. " table."; |
700 |
|
|
} |
701 |
|
|
|
702 |
|
|
// Check for blank entry |
703 |
|
|
if ($newValue == "") { |
704 |
|
|
$err_code = 2; |
705 |
|
|
$err_msg = "Failed. Cannot enter a blank <b>" |
706 |
|
|
. $display |
707 |
|
|
. "</b> value."; |
708 |
|
|
} |
709 |
|
|
|
710 |
|
|
// Draw page heading |
711 |
|
|
printf("<center><h3>Adding New %s</h3>", $display); |
712 |
|
|
|
713 |
|
|
printf("<table width =\"50%%\" border = \"3\" class=\"backLight\">"); |
714 |
|
|
printf("<tr><td><b>Messages:</b><br>"); |
715 |
|
|
|
716 |
|
|
// Add only if this item doesn't already exist, and a value was supplied |
717 |
|
|
if ($err_code == 0){ |
718 |
|
|
|
719 |
|
|
// Clean up strings |
720 |
|
|
$newValue = textInmySQL($newValue); |
721 |
|
|
|
722 |
|
|
// Build the SQL |
723 |
|
|
$sql = "INSERT INTO " |
724 |
|
|
. $table |
725 |
|
|
." (" |
726 |
|
|
. $field |
727 |
|
|
. ") VALUES ('" |
728 |
|
|
. $newValue |
729 |
|
|
. "')"; |
730 |
|
|
|
731 |
|
|
// Debugging |
732 |
|
|
// printf("sql was: %s<br>", $sql); |
733 |
|
|
|
734 |
|
|
if (!mysql_query ($sql, $con)){ |
735 |
|
|
sql_err($sql); |
736 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
737 |
|
|
bailout(); |
738 |
|
|
} |
739 |
|
|
else { |
740 |
|
|
$new_id = mysql_insert_id($con); |
741 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
742 |
|
|
printf("%s <b>%s</b> successfully added.\n", $display, $newValue_display); |
743 |
|
|
} |
744 |
|
|
} |
745 |
|
|
|
746 |
|
|
else printf ("%s\n", $err_msg); |
747 |
|
|
printf("<br><br></td></tr></table>"); |
748 |
|
|
printf("</center>"); |
749 |
|
|
} |
750 |
|
|
|
751 |
|
|
|
752 |
|
|
/********************************************************** |
753 |
|
|
Function: insertService |
754 |
|
|
Author: Paul Bramscher |
755 |
|
|
Last Modified: 05.21.2003 |
756 |
|
|
*********************************************************** |
757 |
|
|
Purpose: |
758 |
|
|
Inserts a service. |
759 |
|
|
**********************************************************/ |
760 |
|
|
function insertService($con, $address1, $address2, $address3, $address4, |
761 |
|
|
$email, $fax, $nonaff, $service, $serviceDescr, $serviceURL, $telephone) { |
762 |
|
|
|
763 |
|
|
// Error flag |
764 |
|
|
$err_code = 0; |
765 |
|
|
|
766 |
|
|
// Need for display/uniqueness |
767 |
|
|
$service_display = $service; |
768 |
|
|
$service_search = textSearchmySQL($service); |
769 |
|
|
|
770 |
|
|
// Check to see if already exists |
771 |
|
|
$exists = recordCount($con, "service", "service", $service_search, "A"); |
772 |
|
|
if ($exists > 0) { |
773 |
|
|
$err_code = 1; |
774 |
|
|
$err_msg = "Failed. '" . $service_display . "' already exists in the service table."; |
775 |
|
|
} |
776 |
|
|
|
777 |
|
|
// Check for blank entry |
778 |
|
|
if ($service == "") { |
779 |
|
|
$err_code = 2; |
780 |
|
|
$err_msg = "Failed. Cannot enter a blank service."; |
781 |
|
|
} |
782 |
|
|
|
783 |
|
|
// Add only if this service doesn't already exist, and something was supplied |
784 |
|
|
if ($err_code == 0) { |
785 |
|
|
|
786 |
|
|
// Clean up strings |
787 |
|
|
if (strlen($address1) > 0) $address1 = textInmySQL($address1); |
788 |
|
|
if (strlen($address2) > 0) $address2 = textInmySQL($address2); |
789 |
|
|
if (strlen($address3) > 0) $address3 = textInmySQL($address3); |
790 |
|
|
if (strlen($address4) > 0) $address4 = textInmySQL($address4); |
791 |
|
|
if (strlen($email) > 0) $email = textInmySQL($email); |
792 |
|
|
if (strlen($fax) > 0) $fax = textInmySQL($fax); |
793 |
|
|
if (strlen($service) > 0) $service = textInmySQL($service); |
794 |
|
|
if (strlen($serviceDescr) > 0) $serviceDescr = textInmySQL($serviceDescr); |
795 |
|
|
if (strlen($serviceURL) > 0) $serviceURL = textInmySQL($serviceURL); |
796 |
|
|
if (strlen($telephone) > 0) $telephone = textInmySQL($telephone); |
797 |
|
|
|
798 |
|
|
// Set up SQL |
799 |
|
|
$sql = "INSERT INTO service (address1, address2, address3, address4, |
800 |
|
|
email, fax, nonaff, service, serviceDescr, serviceURL, |
801 |
|
|
telephone) VALUES ('" |
802 |
|
|
. $address1 |
803 |
|
|
. "', '" |
804 |
|
|
. $address2 |
805 |
|
|
. "', '" |
806 |
|
|
. $address3 |
807 |
|
|
. "', '" |
808 |
|
|
. $address4 |
809 |
|
|
. "', '" |
810 |
|
|
. $email |
811 |
|
|
. "', '" |
812 |
|
|
. $fax |
813 |
|
|
. "', '" |
814 |
|
|
. $nonaff |
815 |
|
|
. "', '" |
816 |
|
|
. $service |
817 |
|
|
. "', '" |
818 |
|
|
. $serviceDescr |
819 |
|
|
. "', '" |
820 |
|
|
. $serviceURL |
821 |
|
|
. "', '" |
822 |
|
|
. $telephone |
823 |
|
|
. "')"; |
824 |
|
|
|
825 |
|
|
// Write the new row to the database |
826 |
|
|
mysql_query ("LOCK TABLE service WRITE", $con); |
827 |
|
|
if (!mysql_query($sql, $con)){ |
828 |
|
|
sql_err($con); |
829 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
830 |
|
|
bailout(); |
831 |
|
|
} |
832 |
|
|
else { |
833 |
|
|
$service_id = mysql_insert_id($con); |
834 |
|
|
mysql_query("UNLOCK TABLES", $con); |
835 |
|
|
formService($con, $service_id); |
836 |
|
|
} |
837 |
|
|
} |
838 |
|
|
else { |
839 |
|
|
// Draw page heading |
840 |
|
|
printf("<center><h3>Adding New Service...</h3>"); |
841 |
|
|
|
842 |
|
|
printf("<table width =\"50%%\" border = \"3\" class=\"backLight\">"); |
843 |
|
|
printf("<tr><td><b>Messages:</b><br>"); |
844 |
|
|
|
845 |
|
|
printf ("%s\n", $err_msg); |
846 |
|
|
printf("<br><br></td></tr></table>"); |
847 |
|
|
printf("</center>"); |
848 |
|
|
} |
849 |
|
|
|
850 |
|
|
} |
851 |
|
|
|
852 |
|
|
|
853 |
|
|
/********************************************************** |
854 |
|
|
Function: insertStaff |
855 |
|
|
Author: Paul Bramscher |
856 |
|
|
Last Modified: 06.23.2003 |
857 |
|
|
*********************************************************** |
858 |
|
|
Purpose: |
859 |
|
|
Inserts the supplied staffperson information, and calls |
860 |
|
|
formStaff back again if the insert was valid. |
861 |
|
|
**********************************************************/ |
862 |
|
|
function insertStaff($con, $access_id, $first_name, |
863 |
|
|
$last_name, $sess_access_level, $staff_account, $staff_email, $stafftitle_id) { |
864 |
|
|
|
865 |
|
|
/* |
866 |
|
|
Staff must have, at a minimum, a last name, first name, and unique staff account name. |
867 |
|
|
Uniqueness is enforced only on staff_account. |
868 |
|
|
*/ |
869 |
|
|
|
870 |
|
|
// Error flag |
871 |
|
|
$err_code = 0; |
872 |
|
|
|
873 |
|
|
// Need for display/uniqueness purposes |
874 |
|
|
$staff_account_display = $staff_account; |
875 |
|
|
$staff_account_search = textSearchmySQL($staff_account); |
876 |
|
|
|
877 |
|
|
// Check to see if the account name already exists |
878 |
|
|
$exists = recordCount($con, "staff", "staff_account", $staff_account_search, "A"); |
879 |
|
|
if ($exists > 0) { |
880 |
|
|
$err_code = 1; |
881 |
|
|
$err_msg = "Failed. '" . $staff_account_display . "' already exists in the Staff table."; |
882 |
|
|
} |
883 |
|
|
|
884 |
|
|
// Check for blank first name or last name |
885 |
|
|
if ($first_name == "" || $last_name == "") { |
886 |
|
|
$err_code = 2; |
887 |
|
|
$err_msg = "Failed. A first and last name must be supplied for all staff."; |
888 |
|
|
} |
889 |
|
|
|
890 |
|
|
// Check for blank staff account |
891 |
|
|
if ($staff_account == "") { |
892 |
|
|
$err_code = 3; |
893 |
|
|
$err_msg = "Failed. A staff account (x500 if applicable) must be supplied for all staff."; |
894 |
|
|
} |
895 |
|
|
|
896 |
|
|
// Check for access level higher than current access |
897 |
|
|
$this_access_level = lookupfield($con, "access", "access_id", $access_id, "access_level"); |
898 |
|
|
if ($this_access_level > $sess_access_level) { |
899 |
|
|
$err_code = 4; |
900 |
|
|
$err_msg = "Failed. You may not create staff with higher privileges than your own."; |
901 |
|
|
} |
902 |
|
|
|
903 |
|
|
// Add only if no errors encountered |
904 |
|
|
if ($err_code == 0) { |
905 |
|
|
|
906 |
|
|
// Clean up strings |
907 |
|
|
if (strlen($first_name) > 0) $first_name = textInmySQL($first_name); |
908 |
|
|
if (strlen($last_name) > 0) $last_name = textInmySQL($last_name); |
909 |
|
|
if (strlen($staff_account) > 0) $staff_account = textInmySQL($staff_account); |
910 |
|
|
if (strlen($staff_email) > 0) $staff_email = textInmySQL($staff_email); |
911 |
|
|
|
912 |
|
|
// Set up SQL |
913 |
|
|
$sql = "INSERT INTO staff (access_id, first_name, last_name, stafftitle_id, |
914 |
|
|
staff_account, staff_email) VALUES (" |
915 |
|
|
. $access_id |
916 |
|
|
. ", '" |
917 |
|
|
. $first_name |
918 |
|
|
. "', '" |
919 |
|
|
. $last_name |
920 |
|
|
. "', " |
921 |
|
|
. $stafftitle_id |
922 |
|
|
. ", '" |
923 |
|
|
. $staff_account |
924 |
|
|
. "', '" |
925 |
|
|
. $staff_email |
926 |
|
|
. "')"; |
927 |
|
|
|
928 |
|
|
// Debugging |
929 |
|
|
// printf("sql was: %s<br><br>\n", $sql); |
930 |
|
|
|
931 |
|
|
// Write the new row to the database |
932 |
|
|
mysql_query ("LOCK TABLE staff WRITE", $con); |
933 |
|
|
if (!mysql_query($sql, $con)){ |
934 |
|
|
sql_err($con); |
935 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
936 |
|
|
bailout(); |
937 |
|
|
} |
938 |
|
|
else { |
939 |
|
|
|
940 |
|
|
// Success, call formStaff back. |
941 |
|
|
$staff_id = mysql_insert_id($con); |
942 |
|
|
mysql_query("UNLOCK TABLES", $con); |
943 |
|
|
formStaff($con, $staff_id); |
944 |
|
|
} |
945 |
|
|
} |
946 |
|
|
else { |
947 |
|
|
// Failure message box |
948 |
|
|
printf("<center><h3>Adding Staff...</h3>\n"); |
949 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
950 |
|
|
printf("<tr><td><br>\n"); |
951 |
|
|
printf("<strong>Messages:</strong><br>\n"); |
952 |
|
|
printf("%s", $err_msg); |
953 |
|
|
printf("<br><br>\n"); |
954 |
|
|
printf("</td></tr></table>\n"); |
955 |
|
|
printf("</center>\n"); |
956 |
|
|
} |
957 |
|
|
} |
958 |
|
|
|
959 |
|
|
|
960 |
|
|
/********************************************************** |
961 |
|
|
Function: insertStyle |
962 |
|
|
Author: Paul Bramscher |
963 |
|
|
Last Modified: 05.22.2003 |
964 |
|
|
*********************************************************** |
965 |
|
|
Purpose: |
966 |
|
|
Inserts a style type. Note that css_file, footer_file, and |
967 |
|
|
header_file fields are merely pointers to those files. |
968 |
|
|
No error checking is done here to ensure their existence |
969 |
|
|
and permissions settings. This must be accomplished by |
970 |
|
|
someone with proper OS access. |
971 |
|
|
**********************************************************/ |
972 |
|
|
function insertStyle($con, $css_file, $footer_file, $header_file, $style_title) { |
973 |
|
|
|
974 |
|
|
// Error flag |
975 |
|
|
$err_code = 0; |
976 |
|
|
|
977 |
|
|
// Need for display/uniqueness |
978 |
|
|
$style_title_display = $style_title; |
979 |
|
|
$style_title_search = textSearchmySQL($style_title); |
980 |
|
|
|
981 |
|
|
// Check to see if already exists |
982 |
|
|
$exists = recordCount($con, "style", "style_title", $style_title_search, "A"); |
983 |
|
|
if ($exists > 0) { |
984 |
|
|
$err_code = 1; |
985 |
|
|
$err_msg = "Failed. '" . $style_title_display . "' already exists in the style table."; |
986 |
|
|
} |
987 |
|
|
|
988 |
|
|
// Check for blank entry |
989 |
|
|
if ($style_title == "") { |
990 |
|
|
$err_code = 2; |
991 |
|
|
$err_msg = "Failed. Cannot enter a blank style."; |
992 |
|
|
} |
993 |
|
|
|
994 |
|
|
printf("<center><h3>Adding Style...</h3>"); |
995 |
|
|
|
996 |
|
|
// Table |
997 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
998 |
|
|
printf("<tr><td><br>"); |
999 |
|
|
printf("<strong>Messages:</strong><br>"); |
1000 |
|
|
|
1001 |
|
|
// Add only if this style doesn't already exist, and something was supplied |
1002 |
|
|
if ($err_code == 0) { |
1003 |
|
|
|
1004 |
|
|
// Clean up strings |
1005 |
|
|
if (strlen($css_file) > 0) $css_file = textInmySQL($css_file); |
1006 |
|
|
if (strlen($footer_file) > 0) $footer_file = textInmySQL($footer_file); |
1007 |
|
|
if (strlen($header_file) > 0) $header_file = textInmySQL($header_file); |
1008 |
|
|
if (strlen($style_title) > 0) $style_title = textInmySQL($style_title); |
1009 |
|
|
|
1010 |
|
|
// Set up SQL |
1011 |
|
|
$sql = "INSERT INTO style (css_file, footer_file, header_file, style_title) VALUES ('" |
1012 |
|
|
. $css_file |
1013 |
|
|
. "', '" |
1014 |
|
|
. $footer_file |
1015 |
|
|
. "', '" |
1016 |
|
|
. $header_file |
1017 |
|
|
. "', '" |
1018 |
|
|
. $style_title |
1019 |
|
|
. "')"; |
1020 |
|
|
|
1021 |
|
|
// Write the new row to the database |
1022 |
|
|
if (!mysql_query($sql, $con)){ |
1023 |
|
|
sql_err($con); |
1024 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1025 |
|
|
bailout(); |
1026 |
|
|
} |
1027 |
|
|
else { |
1028 |
|
|
mysql_query("UNLOCK TABLES", $con); |
1029 |
|
|
printf("Added <b>%s</b> style.<br><br>\n", $style_title_display); |
1030 |
|
|
} |
1031 |
|
|
} |
1032 |
|
|
else printf("%s", $err_msg); |
1033 |
|
|
printf("<br><br>\n"); |
1034 |
|
|
printf("</td></tr></table>\n"); |
1035 |
|
|
printf("</center>\n"); |
1036 |
|
|
} |
1037 |
|
|
|
1038 |
|
|
|
1039 |
|
|
/********************************************************** |
1040 |
|
|
Function: insertSubject |
1041 |
|
|
Author: Paul Bramscher |
1042 |
|
|
Last Modified: 09.23.2003 |
1043 |
|
|
*********************************************************** |
1044 |
|
|
Purpose: |
1045 |
|
|
Inserts a subject. If successful, calls formSubject |
1046 |
|
|
back again. |
1047 |
|
|
**********************************************************/ |
1048 |
|
|
function insertSubject($con, $sess_staff_account, $sess_staff_id, $subject, $subject_descr, $sublocation_id) { |
1049 |
|
|
|
1050 |
|
|
// Error flag |
1051 |
|
|
$err_code = 0; |
1052 |
|
|
|
1053 |
|
|
// Need for display/uniqueness purposes |
1054 |
|
|
$subject_display = $subject; |
1055 |
|
|
$subject_search = textSearchmySQL($subject); |
1056 |
|
|
|
1057 |
|
|
// Check to see if already exists |
1058 |
|
|
$exists = recordCount($con, "subject", "subject", $subject_search, "A"); |
1059 |
|
|
if ($exists > 0) { |
1060 |
|
|
$err_code = 1; |
1061 |
|
|
$err_msg = "Failed. '" . $subject_display . "' already exists in the subject table."; |
1062 |
|
|
} |
1063 |
|
|
|
1064 |
|
|
// Check for blank entry |
1065 |
|
|
if ($subject == "") { |
1066 |
|
|
$err_code = 2; |
1067 |
|
|
$err_msg = "Failed. Cannot enter a blank subject."; |
1068 |
|
|
} |
1069 |
|
|
|
1070 |
|
|
// Add only if this subject doesn't already exist, and something was supplied |
1071 |
|
|
if ($err_code == 0) { |
1072 |
|
|
|
1073 |
|
|
// Clean up strings |
1074 |
|
|
$subject = textInmySQL($subject); |
1075 |
|
|
if (strlen($subject_descr) > 0) $subject_descr = textInmySQL($subject_descr); |
1076 |
|
|
|
1077 |
|
|
// Set up SQL |
1078 |
|
|
$sql = "INSERT INTO subject (subject, subject_descr, sublocation_id, rqs_date_created, rqs_account_created) VALUES ('" |
1079 |
|
|
. $subject |
1080 |
|
|
. "', '" |
1081 |
|
|
. $subject_descr |
1082 |
|
|
. "', " |
1083 |
|
|
. $sublocation_id |
1084 |
|
|
. ", now(), '" |
1085 |
|
|
. $sess_staff_account |
1086 |
|
|
. "')"; |
1087 |
|
|
|
1088 |
|
|
// Write the new row to the database |
1089 |
|
|
mysql_query ("LOCK TABLE subject WRITE", $con); |
1090 |
|
|
if (!mysql_query($sql, $con)){ |
1091 |
|
|
sql_err($con); |
1092 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1093 |
|
|
bailout(); |
1094 |
|
|
} |
1095 |
|
|
else { |
1096 |
|
|
$subject_id = mysql_insert_id($con); |
1097 |
|
|
mysql_query("UNLOCK TABLES", $con); |
1098 |
|
|
|
1099 |
|
|
// Insert this staff person as an assigned staff member to this subject |
1100 |
|
|
$sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES (" |
1101 |
|
|
. $subject_id |
1102 |
|
|
. ", " |
1103 |
|
|
. $sess_staff_id |
1104 |
|
|
. ")"; |
1105 |
|
|
|
1106 |
|
|
if (!mysql_query($sql, $con)){ |
1107 |
|
|
sql_err($con); |
1108 |
|
|
mysql_query ("UNLOCK TABLES", $con); |
1109 |
|
|
bailout(); |
1110 |
|
|
} |
1111 |
|
|
else { |
1112 |
|
|
mysql_query("UNLOCK TABLES", $con); |
1113 |
|
|
} |
1114 |
|
|
|
1115 |
|
|
formSubject($con, $subject_id); |
1116 |
|
|
} // good write of subject |
1117 |
|
|
} |
1118 |
|
|
|
1119 |
|
|
else { |
1120 |
|
|
|
1121 |
|
|
printf("<center><h3>Adding subject...</h3>"); |
1122 |
|
|
|
1123 |
|
|
// Table |
1124 |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
1125 |
|
|
printf("<tr><td><br>"); |
1126 |
|
|
printf("<strong>Messages:</strong><br>"); |
1127 |
|
|
|
1128 |
|
|
printf("%s<BR><BR>", $err_msg); |
1129 |
|
|
printf("</td></tr></table>"); |
1130 |
|
|
printf("</center>"); |
1131 |
|
|
} |
1132 |
|
|
|
1133 |
|
|
} // function |
1134 |
|
|
?> |