1 |
<?php |
<?php |
2 |
/********************************************************** |
/********************************************************** |
3 |
Function Library: update.php |
Function Library: update.php |
4 |
Original Author: Paul Bramscher <brams006@tc.umn.edu> |
Original Author: Paul Bramscher <brams006@umn.edu> |
5 |
Last Modified: 09.30.2003 by Paul Bramscher |
Last Modified: 03.16.2004 by Paul Bramscher |
6 |
*********************************************************** |
*********************************************************** |
7 |
Comments: |
Comments: |
8 |
This library brings together all SQL update functions for |
This library brings together all SQL update functions for |
12 |
respectively. |
respectively. |
13 |
*********************************************************** |
*********************************************************** |
14 |
Table of Contents: |
Table of Contents: |
|
|
|
15 |
purgePassword |
purgePassword |
16 |
updateCoursesub |
updateCoursesub |
17 |
updateFaculty |
updateFaculty |
26 |
updateStaff |
updateStaff |
27 |
updateStyle |
updateStyle |
28 |
updateSubject |
updateSubject |
29 |
|
updateVendor |
|
|
|
30 |
**********************************************************/ |
**********************************************************/ |
31 |
|
|
32 |
|
|
33 |
/********************************************************** |
/********************************************************** |
34 |
Function: purgePassword |
Function: purgePassword |
35 |
Author: Paul Bramscher |
Author: Paul Bramscher |
36 |
Last Modified: 06.23.2003 |
Last Modified: 03.15.2004 |
37 |
*********************************************************** |
*********************************************************** |
38 |
Purpose: |
Purpose: |
39 |
This function purges the locally encrypted mySQL stored |
This function purges the locally encrypted mySQL stored |
42 |
value of the password and bring it to an HTML form, neither |
value of the password and bring it to an HTML form, neither |
43 |
in plaintext nor in a "password" type HTML form field. |
in plaintext nor in a "password" type HTML form field. |
44 |
**********************************************************/ |
**********************************************************/ |
45 |
function purgePassword($con, $staff_id){ |
function purgePassword($staff_id){ |
46 |
|
|
47 |
// Draw form heading |
msgTableOpen(1, "Purging Password..."); |
48 |
printf("<center><h3>Purging Password...</h3>"); |
printf("<b>Messages:</b><br>\n"); |
|
|
|
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">"); |
|
|
printf("<tr><td><br>"); |
|
|
printf("<strong>Messages:</strong><br>"); |
|
|
|
|
|
// Problem flag for each step |
|
|
$problem = 0; |
|
49 |
|
|
50 |
if ($staff_id > 0) { |
if ($staff_id > 0) { |
|
$sql = "UPDATE staff SET password = NULL WHERE staff_id = " . $staff_id; |
|
51 |
|
|
52 |
if (!mysql_query ($sql, $con)){ |
$sql = "UPDATE staff SET password = NULL WHERE staff_id = " . $staff_id; |
53 |
$problem = 1; |
if (xx_tryquery ($sql)) printf("Successfully purged password for this staff account."); |
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("Purged password successfully for this staff account.<br><BR>\n"); |
|
|
} |
|
54 |
|
|
55 |
} |
} |
56 |
else printf("Staff ID not found.</b>.<br><br>\n"); |
else printf("Staff ID not found."); |
57 |
|
|
58 |
printf("</td></tr></table>\n"); |
printf("<br><br>\n"); |
59 |
printf("</center>\n"); |
msgTableClose(); |
60 |
} |
} |
61 |
|
|
62 |
|
|
63 |
/********************************************************** |
/********************************************************** |
64 |
Function: updateCoursesub |
Function: updateCoursesub |
65 |
Author: Paul Bramscher |
Author: Paul Bramscher |
66 |
Last Modified: 06.03.2003 |
Last Modified: 03.16.2004 |
67 |
*********************************************************** |
*********************************************************** |
68 |
Purpose: |
Purpose: |
69 |
Update supplied course subject id. |
Update supplied course subject id. |
70 |
**********************************************************/ |
**********************************************************/ |
71 |
function updateCoursesub($con, $campus_id, $cip_code, $coursesub, $coursesub_descr, $coursesub_id) { |
function updateCoursesub($campus_id, $cip_code, $coursesub, $coursesub_descr, $coursesub_id) { |
72 |
|
|
73 |
|
msgTableOpen(1, "Updating Course Subject (ID# " . $coursesub_id . ")"); |
74 |
|
printf("<b>Messages:</b><br>\n"); |
75 |
|
|
76 |
// Error flag |
// Error flag |
77 |
$err_code = 0; |
$err_code = 0; |
81 |
$coursesub_search = textSearchmySQL($coursesub); |
$coursesub_search = textSearchmySQL($coursesub); |
82 |
|
|
83 |
// Check to see if already exists |
// Check to see if already exists |
84 |
$exists = recordCount($con, "coursesub", "coursesub", $coursesub_search, "A"); |
$exists = recordCount("coursesub", "coursesub", $coursesub_search, "A"); |
85 |
$exists_id = lookupField($con, "coursesub", "coursesub", $coursesub_search, "coursesub_id"); |
$exists_id = lookupField("coursesub", "coursesub", $coursesub_search, "coursesub_id"); |
86 |
|
|
87 |
// If exists in the courseub table under a different coursesub_id |
// If exists in the courseub table under a different coursesub_id |
88 |
if ($exists > 0 && $exists_id != $coursesub_id) { |
if ($exists > 0 && $exists_id != $coursesub_id) { |
89 |
$err_code = 1; |
$err_code = 1; |
90 |
$err_msg = "Failed. '" . $coursesub_display . "' already exists in the course subject table."; |
$err_msg = "Failed. <b>" . $coursesub_display . "</b> already exists in the course subject table."; |
91 |
} |
} |
92 |
|
|
93 |
// Check for blank entry |
// Check for blank entry |
96 |
$err_msg = "Failed. Must supply some value for the course subject."; |
$err_msg = "Failed. Must supply some value for the course subject."; |
97 |
} |
} |
98 |
|
|
|
printf("<center><h3>Updating Course Subject...</h3>\n"); |
|
|
|
|
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
|
|
printf("<tr><td><br>\n"); |
|
|
printf("<strong>Messages:</strong><br>"); |
|
|
|
|
99 |
// Perform the update only if no errors encountered |
// Perform the update only if no errors encountered |
100 |
if ($err_code == 0) { |
if ($err_code == 0) { |
101 |
|
|
115 |
. $campus_id |
. $campus_id |
116 |
. " WHERE coursesub_id =" |
. " WHERE coursesub_id =" |
117 |
. $coursesub_id; |
. $coursesub_id; |
118 |
|
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> course subject.", $coursesub_display); |
|
if (!mysql_query ($sql, $con)){ |
|
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("Updated <b>%s</b> course subject.<BR><BR>\n", $coursesub_display); |
|
|
} |
|
119 |
} |
} |
|
|
|
120 |
else printf("%s", $err_msg); |
else printf("%s", $err_msg); |
121 |
|
|
122 |
printf("<br><br>\n"); |
printf("<br><br>\n"); |
123 |
printf("</td></tr></table>\n"); |
msgTableClose(); |
|
printf("</center>\n"); |
|
|
|
|
124 |
} |
} |
125 |
|
|
126 |
|
|
127 |
/********************************************************** |
/********************************************************** |
128 |
Function: updateFaculty |
Function: updateFaculty |
129 |
Author: Paul Bramscher |
Author: Paul Bramscher |
130 |
Last Modified: 06.24.2003 |
Last Modified: 03.16.2004 |
131 |
*********************************************************** |
*********************************************************** |
132 |
Purpose: |
Purpose: |
133 |
Update supplied faculty id. |
Update supplied faculty id. Faculty must have both a |
134 |
|
unique non-blank staff_account, and non-blank last name. |
135 |
**********************************************************/ |
**********************************************************/ |
136 |
function updateFaculty($con, $faculty_email, $faculty_firstname, |
function updateFaculty($faculty_email, $faculty_firstname, |
137 |
$faculty_id, $faculty_lastname, $faculty_account) { |
$faculty_id, $faculty_lastname, $faculty_account) { |
138 |
|
|
139 |
/* |
msgTableOpen(1, "Updating Faculty (ID# " . $faculty_id . ")"); |
140 |
Faculty must have both a unique non-blank staff_account, and non-blank last name. |
printf("<b>Messages:</b><br>\n"); |
|
*/ |
|
141 |
|
|
142 |
// Error flag |
// Error flag |
143 |
$err_code = 0; |
$err_code = 0; |
146 |
$faculty_name_display = $faculty_firstname . " " . $faculty_lastname; |
$faculty_name_display = $faculty_firstname . " " . $faculty_lastname; |
147 |
|
|
148 |
// Check to see if already exists |
// Check to see if already exists |
149 |
$exists_id = existsFaculty($con, $faculty_firstname, $faculty_lastname); |
$exists_id = existsFaculty($faculty_firstname, $faculty_lastname); |
150 |
|
|
151 |
if ($exists_id > 0 && $exists_id != $faculty_id) { |
if ($exists_id > 0 && $exists_id != $faculty_id) { |
152 |
$err_code = 1; |
$err_code = 1; |
153 |
$err_msg = "Failed. '" . $faculty_name_display . "' already exists in the Faculty table."; |
$err_msg = "Failed. <b>" . $faculty_name_display . "</b> already exists in the Faculty table."; |
154 |
} |
} |
155 |
|
|
156 |
// Check for blank last name |
// Check for blank last name |
159 |
$err_msg = "Failed. Cannot have a blank Last Name."; |
$err_msg = "Failed. Cannot have a blank Last Name."; |
160 |
} |
} |
161 |
|
|
|
|
|
|
printf("<center><h3>Updating Faculty...</h3>"); |
|
|
|
|
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
|
|
printf("<tr><td><br>"); |
|
|
printf("<strong>Messages:</strong><br>"); |
|
|
|
|
162 |
if ($err_code == 0 ) { |
if ($err_code == 0 ) { |
163 |
|
|
164 |
// Clean up strings |
// Clean up strings |
178 |
. $faculty_account |
. $faculty_account |
179 |
. "' WHERE faculty_id =" |
. "' WHERE faculty_id =" |
180 |
. $faculty_id; |
. $faculty_id; |
181 |
|
if (xx_tryquery ($sql)) printf("Successfully updated faculty person <b>%s</b>.", $faculty_name_display); |
|
if (!mysql_query ($sql, $con)){ |
|
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("Successfully updated Faculty <b>%s</b><BR><BR>\n", $faculty_name_display); |
|
|
} |
|
182 |
} |
} |
|
|
|
183 |
else printf("%s", $err_msg); |
else printf("%s", $err_msg); |
184 |
|
|
185 |
printf("<br><br>\n"); |
printf("<br><br>\n"); |
186 |
printf("</td></tr></table>\n"); |
msgTableClose(); |
|
printf("</center>\n"); |
|
|
|
|
187 |
} |
} |
188 |
|
|
189 |
|
|
190 |
/********************************************************** |
/********************************************************** |
191 |
Function: updateFeature |
Function: updateFeature |
192 |
Author: Paul Bramscher |
Author: Paul Bramscher |
193 |
Last Modified: 05.21.2003 |
Last Modified: 03.16.2004 |
194 |
*********************************************************** |
*********************************************************** |
195 |
Purpose: |
Purpose: |
196 |
Update supplied feature id. |
Update supplied feature id. |
197 |
**********************************************************/ |
**********************************************************/ |
198 |
function updateFeature($con, $feature, $feature_id, $image_alt, $image_path) { |
function updateFeature($feature, $feature_id, $image_alt, $image_path) { |
199 |
|
|
200 |
|
msgTableOpen(1, "Updating Feature (ID# " . $feature_id . ")"); |
201 |
|
printf("<b>Messages:</b><br>\n"); |
202 |
|
|
203 |
// Error flag |
// Error flag |
204 |
$err_code = 0; |
$err_code = 0; |
208 |
$feature_search = textSearchmySQL($feature); |
$feature_search = textSearchmySQL($feature); |
209 |
|
|
210 |
// Check to see if already exists |
// Check to see if already exists |
211 |
$exists = recordCount($con, "feature", "feature", $feature_search, "A"); |
$exists = recordCount("feature", "feature", $feature_search, "A"); |
212 |
$exists_id = lookupField($con, "feature", "feature", $feature_search, "feature_id"); |
$exists_id = lookupField("feature", "feature", $feature_search, "feature_id"); |
213 |
|
|
214 |
// If exists in the feature table under a different feature_id |
// If exists in the feature table under a different feature_id |
215 |
if ($exists > 0 && $exists_id != $feature_id) { |
if ($exists > 0 && $exists_id != $feature_id) { |
216 |
$err_code = 1; |
$err_code = 1; |
217 |
$err_msg = "Failed. '" . $feature_display . "' already exists in the feature table."; |
$err_msg = "Failed. <b>" . $feature_display . "</b> already exists in the feature table."; |
218 |
} |
} |
219 |
|
|
220 |
// Check for blank entry |
// Check for blank entry |
223 |
$err_msg = "Failed. Must supply some value for the feature."; |
$err_msg = "Failed. Must supply some value for the feature."; |
224 |
} |
} |
225 |
|
|
|
printf("<center><h3>Updating Feature...</h3>\n"); |
|
|
|
|
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
|
|
printf("<tr><td><br>\n"); |
|
|
printf("<strong>Messages:</strong><br>"); |
|
|
|
|
|
|
|
226 |
// Perform the update only if no errors encountered |
// Perform the update only if no errors encountered |
227 |
if ($err_code == 0) { |
if ($err_code == 0) { |
228 |
|
|
240 |
. $image_path |
. $image_path |
241 |
. "' WHERE feature_id =" |
. "' WHERE feature_id =" |
242 |
. $feature_id; |
. $feature_id; |
243 |
|
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> feature.", $feature_display); |
|
if (!mysql_query ($sql, $con)){ |
|
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("Updated <b>%s</b> feature.<BR><BR>\n", $feature_display); |
|
|
} |
|
244 |
} |
} |
|
|
|
245 |
else printf("%s", $err_msg); |
else printf("%s", $err_msg); |
246 |
|
|
247 |
printf("<br><br>\n"); |
printf("<br><br>\n"); |
248 |
printf("</td></tr></table>\n"); |
msgTableClose(); |
|
printf("</center>\n"); |
|
249 |
|
|
250 |
} |
} |
251 |
|
|
253 |
/********************************************************** |
/********************************************************** |
254 |
Function: updateInfotype |
Function: updateInfotype |
255 |
Author: Paul Bramscher |
Author: Paul Bramscher |
256 |
Last Modified: 06.05.2003 |
Last Modified: 03.16.2004 |
257 |
*********************************************************** |
*********************************************************** |
258 |
Purpose: |
Purpose: |
259 |
Update supplied infotype id. |
Update supplied infotype id. |
260 |
**********************************************************/ |
**********************************************************/ |
261 |
function updateInfotype($con, $infotype, $infotype_id, $masterinfotype_id, $mastersubject_id) { |
function updateInfotype($infotype, $infotype_id, $masterinfotype_id, $mastersubject_id) { |
262 |
|
|
263 |
|
msgTableOpen(1, "Updating Information Type (ID# " . $infotype_id . ")"); |
264 |
|
printf("<b>Messages:</b><br>\n"); |
265 |
|
|
266 |
// Error flag |
// Error flag |
267 |
$err_code = 0; |
$err_code = 0; |
271 |
$infotype_search = textSearchmySQL($infotype); |
$infotype_search = textSearchmySQL($infotype); |
272 |
|
|
273 |
// Check to see if already exists |
// Check to see if already exists |
274 |
$exists = recordCount($con, "infotype", "infotype", $infotype_search, "A"); |
$exists = recordCount("infotype", "infotype", $infotype_search, "A"); |
275 |
$exists_id = lookupField($con, "infotype", "infotype", $infotype_search, "infotype_id"); |
$exists_id = lookupField("infotype", "infotype", $infotype_search, "infotype_id"); |
276 |
|
|
277 |
// If exists in the infotype table under a different infotype_id (not editing the name of this infotype) |
// If exists in the infotype table under a different infotype_id (not editing the name of this infotype) |
278 |
if ($exists > 0 && $exists_id != $infotype_id) { |
if ($exists > 0 && $exists_id != $infotype_id) { |
285 |
$err_code = 2; |
$err_code = 2; |
286 |
$err_msg = "Failed. Must supply some value for the Information Type name."; |
$err_msg = "Failed. Must supply some value for the Information Type name."; |
287 |
} |
} |
|
|
|
|
printf("<center><h3>Updating Infotype...</h3>"); |
|
|
|
|
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
|
|
printf("<tr><td><br>"); |
|
|
printf("<strong>Messages:</strong><br>"); |
|
288 |
|
|
289 |
// Proceed if no errors encountered |
// Proceed if no errors encountered |
290 |
if ($err_code == 0) { |
if ($err_code == 0) { |
292 |
// Clean up strings |
// Clean up strings |
293 |
$infotype = textInmySQL($infotype); |
$infotype = textInmySQL($infotype); |
294 |
|
|
|
|
|
295 |
// First, update affected RQS relationships |
// First, update affected RQS relationships |
296 |
$sql = "UPDATE res_sub_infotype SET masterinfotype_id = " |
$sql = "UPDATE res_sub_infotype SET masterinfotype_id = " |
297 |
. $masterinfotype_id |
. $masterinfotype_id |
298 |
. " WHERE infotype_id = " |
. " WHERE infotype_id = " |
299 |
. $infotype_id; |
. $infotype_id; |
300 |
|
if (xx_tryquery ($sql)) printf("Updated affected RQS relationships (if any).<BR>\n"); |
|
if (!mysql_query ($sql, $con)){ |
|
|
$err_code = 1; |
|
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("Updated affected RQS relationships (if any)<BR>\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($err_code == 0) { |
|
301 |
|
|
302 |
// Build the SQL |
// Build the SQL |
303 |
$sql = "UPDATE infotype SET infotype = '" |
$sql = "UPDATE infotype SET infotype = '" |
308 |
. $mastersubject_id |
. $mastersubject_id |
309 |
. " WHERE infotype_id =" |
. " WHERE infotype_id =" |
310 |
. $infotype_id; |
. $infotype_id; |
311 |
|
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> information type.", $infotype_display); |
|
if (!mysql_query ($sql, $con)){ |
|
|
$err_code = 1; |
|
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("Updated Information Type to <b>%s</b>.<BR><BR>\n", $infotype_display); |
|
|
} |
|
|
|
|
312 |
} |
} |
313 |
|
else printf("%s", $err_msg); |
314 |
|
|
315 |
else printf("%s<BR><BR>", $err_msg); |
printf("<br><br>\n"); |
316 |
|
msgTableClose(); |
|
printf("<BR>"); |
|
|
printf("</td></tr></table><BR>"); |
|
|
printf("</center>"); |
|
317 |
|
|
318 |
} |
} |
319 |
|
|
321 |
/********************************************************** |
/********************************************************** |
322 |
Function: updateLibunit |
Function: updateLibunit |
323 |
Author: Paul Bramscher |
Author: Paul Bramscher |
324 |
Last Modified: 05.22.2003 |
Last Modified: 03.16.2004 |
325 |
*********************************************************** |
*********************************************************** |
326 |
Purpose: |
Purpose: |
327 |
Updates the supplied library unit id with new information. |
Updates the supplied library unit id with new information. |
328 |
|
Library Units must have both a unique name and unique |
329 |
|
abbreviation e.g. "Digital Library Developement |
330 |
|
Laboratory" and "DLDL". |
331 |
**********************************************************/ |
**********************************************************/ |
332 |
function updateLibunit($con, $head_staff_id, $libunit, $libunit_abbrev, $libunit_id) { |
function updateLibunit($head_staff_id, $libunit, $libunit_abbrev, $libunit_id) { |
|
|
|
|
/* |
|
|
Library Units must have both a unique name and unique abbreviation |
|
|
e.g. "Digital Library Developement Laboratory" and "DLDL" |
|
|
Additionally, empty values are not allowed. |
|
|
*/ |
|
333 |
|
|
334 |
// Error flag |
// Error flag |
335 |
$err_code = 0; |
$err_code = 0; |
341 |
$libunit_abbrev_search = textSearchmySQL($libunit_abbrev); |
$libunit_abbrev_search = textSearchmySQL($libunit_abbrev); |
342 |
|
|
343 |
// Check to see if libunit already exists |
// Check to see if libunit already exists |
344 |
$exists = recordCount($con, "libunit", "libunit", $libunit_search, "A"); |
$exists = recordCount("libunit", "libunit", $libunit_search, "A"); |
345 |
$exists_id = lookupField($con, "libunit", "libunit", $libunit_search, "libunit_id"); |
$exists_id = lookupField("libunit", "libunit", $libunit_search, "libunit_id"); |
346 |
if ($exists > 0 && $exists_id != $libunit_id) { |
if ($exists > 0 && $exists_id != $libunit_id) { |
347 |
$err_code = 1; |
$err_code = 1; |
348 |
$err_msg = "Failed. '" . $libunit_display . "' already exists in the Library Unit table."; |
$err_msg = "Failed. <b>" . $libunit_display . "</b> already exists in the Library Unit table."; |
349 |
} |
} |
350 |
|
|
351 |
// Check to see if libunit abbreviation already exists |
// Check to see if libunit abbreviation already exists |
352 |
$exists = recordCount($con, "libunit", "libunit_abbrev", $libunit_abbrev_search, "A"); |
$exists = recordCount("libunit", "libunit_abbrev", $libunit_abbrev_search, "A"); |
353 |
$exists_id = lookupField($con, "libunit", "libunit_abbrev", $libunit_abbrev_search, "libunit_id"); |
$exists_id = lookupField("libunit", "libunit_abbrev", $libunit_abbrev_search, "libunit_id"); |
354 |
|
|
355 |
if ($exists > 0 && $exists_id != $libunit_id) { |
if ($exists > 0 && $exists_id != $libunit_id) { |
356 |
$err_code = 2; |
$err_code = 2; |
357 |
$err_msg = "Failed. '" . $libunit_abbrev_display . "' abbreviation already exists in the Library Unit table."; |
$err_msg = "Failed. <b>" . $libunit_abbrev_display . "</b> abbreviation already exists in the Library Unit table."; |
358 |
} |
} |
359 |
|
|
360 |
// Check for blank linunit entry |
// Check for blank linunit entry |
384 |
. $head_staff_id |
. $head_staff_id |
385 |
. " WHERE libunit_id =" |
. " WHERE libunit_id =" |
386 |
. $libunit_id; |
. $libunit_id; |
387 |
|
xx_tryquery ($sql); |
388 |
if (!mysql_query ($sql, $con)){ |
formLibunit($libunit_id); |
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
|
|
|
// Call the libunit form back |
|
|
formLibunit($con, $libunit_id); |
|
|
} |
|
389 |
} |
} |
390 |
|
|
391 |
else { |
else { |
392 |
printf("<center><h3>Updating Library Unit...</h3>"); |
msgTableOpen(1, "Updating Library Unit (ID# " . $libunit_id . ")"); |
393 |
|
printf("<b>Messages:</b><br>\n"); |
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
|
|
printf("<tr><td><br>\n"); |
|
|
printf("<strong>Messages:</strong><br>\n"); |
|
394 |
printf("%s", $err_msg); |
printf("%s", $err_msg); |
395 |
printf("<BR><BR>\n"); |
printf("<br><br>\n"); |
396 |
printf("</td></tr></table>\n"); |
msgTableClose(); |
|
printf("</center>\n"); |
|
397 |
} |
} |
398 |
} |
} |
399 |
|
|
401 |
/********************************************************** |
/********************************************************** |
402 |
Function: updateLocation |
Function: updateLocation |
403 |
Author: Paul Bramscher |
Author: Paul Bramscher |
404 |
Last Modified: 04.21.2003 |
Last Modified: 03.16.2004 |
405 |
*********************************************************** |
*********************************************************** |
406 |
Purpose: |
Purpose: |
407 |
Update supplied location id. |
Update supplied location id. |
408 |
**********************************************************/ |
**********************************************************/ |
409 |
function updateLocation($con, $address1, $address2, |
function updateLocation($address1, $address2, |
410 |
$address3, $address4, $campus, $hoursURL, $location, $location_descr, |
$address3, $address4, $campus, $hoursURL, $location, $location_descr, |
411 |
$location_id, $mainURL, $mapURL, $referenceURL, $telephone) { |
$location_id, $mainURL, $mapURL, $referenceURL, $telephone) { |
412 |
|
|
413 |
|
msgTableOpen(1, "Updating Locating (ID# " . $location_id . ")"); |
414 |
|
printf("<b>Messages:</b><br>\n"); |
415 |
|
|
416 |
// Error flag |
// Error flag |
417 |
$err_code = 0; |
$err_code = 0; |
418 |
|
|
421 |
$location_search = textSearchmySQL($location); |
$location_search = textSearchmySQL($location); |
422 |
|
|
423 |
// Check to see if already exists |
// Check to see if already exists |
424 |
$exists = recordCount($con, "location", "location", $location_search, "A"); |
$exists = recordCount("location", "location", $location_search, "A"); |
425 |
$exists_id = lookupField($con, "location", "location", $location_search, "location_id"); |
$exists_id = lookupField("location", "location", $location_search, "location_id"); |
426 |
|
|
427 |
// If exists in the location table under a different location_id |
// If exists in the location table under a different location_id |
428 |
if ($exists > 0 && $exists_id != $location_id) { |
if ($exists > 0 && $exists_id != $location_id) { |
429 |
$err_code = 1; |
$err_code = 1; |
430 |
$err_msg = "Failed. '" . $location_display . "' already exists in the location table."; |
$err_msg = "Failed. <b>" . $location_display . "</b> already exists in the location table."; |
431 |
} |
} |
432 |
|
|
433 |
// Check for blank entry |
// Check for blank entry |
435 |
$err_code = 2; |
$err_code = 2; |
436 |
$err_msg = "Failed. Must supply some value for the location name."; |
$err_msg = "Failed. Must supply some value for the location name."; |
437 |
} |
} |
|
|
|
|
printf("<center><h3>Updating Location...</h3>\n"); |
|
|
|
|
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
|
|
printf("<tr><td><br>\n"); |
|
|
printf("<strong>Messages:</strong><br>\n"); |
|
438 |
|
|
439 |
// Perform the update only if no errors encountered |
// Perform the update only if no errors encountered |
440 |
if ($err_code == 0) { |
if ($err_code == 0) { |
480 |
. $telephone |
. $telephone |
481 |
. "' WHERE location_id =" |
. "' WHERE location_id =" |
482 |
. $location_id; |
. $location_id; |
483 |
|
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> location.", $location_display); |
|
if (!mysql_query ($sql, $con)){ |
|
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("Updated Location to <b>%s</b>.<BR><BR>\n", $location_display); |
|
|
} |
|
484 |
} |
} |
485 |
else printf("%s", $err_msg); |
else printf("%s", $err_msg); |
486 |
|
|
487 |
printf("<br><br>\n"); |
printf("<br><br>\n"); |
488 |
printf("</td></tr></table>\n"); |
msgTableClose(); |
|
printf("</center>\n"); |
|
489 |
|
|
490 |
} |
} |
491 |
|
|
493 |
/********************************************************** |
/********************************************************** |
494 |
Function: updatePassword |
Function: updatePassword |
495 |
Author: Paul Bramscher |
Author: Paul Bramscher |
496 |
Last Modified: 06.23.2003 |
Last Modified: 03.15.2004 |
497 |
*********************************************************** |
*********************************************************** |
498 |
Purpose: |
Purpose: |
499 |
Changes the locally encrypted and mySQL stored password to |
Changes the locally encrypted and mySQL stored password to |
507 |
a user forgets his/her password, it must be reset by an |
a user forgets his/her password, it must be reset by an |
508 |
administrator. |
administrator. |
509 |
**********************************************************/ |
**********************************************************/ |
510 |
function updatePassword($con, $password, $password_confirm, $staff_id) { |
function updatePassword($password, $password_confirm, $staff_id) { |
511 |
|
|
512 |
// Error flag |
// Error flag |
513 |
$err_code = 0; |
$err_code = 0; |
533 |
. "') WHERE staff_id =" |
. "') WHERE staff_id =" |
534 |
. $staff_id; |
. $staff_id; |
535 |
|
|
536 |
if (!mysql_query ($sql, $con)){ |
xx_tryquery ($sql); |
537 |
sql_err($sql); |
formStaff($staff_id); |
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
|
|
|
// Call the staff form back |
|
|
formStaff($con, $staff_id); |
|
|
} |
|
538 |
} |
} |
539 |
|
|
540 |
else { |
else { |
541 |
printf("<center><h3>Updating Local Password...</h3>"); |
msgTableOpen(1, "Updating Local Password..."); |
542 |
|
printf("<b>Messages:</b><br>\n"); |
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
|
|
printf("<tr><td><br>\n"); |
|
|
printf("<strong>Messages:</strong><br>\n"); |
|
543 |
printf("%s", $err_msg); |
printf("%s", $err_msg); |
544 |
printf("<BR><BR>\n"); |
printf("<br><br>\n"); |
545 |
printf("</td></tr></table>\n"); |
msgTableClose(); |
|
printf("</center>\n"); |
|
546 |
} |
} |
547 |
} |
} |
548 |
|
|
550 |
/********************************************************** |
/********************************************************** |
551 |
Function: updateResource |
Function: updateResource |
552 |
Author: Paul Bramscher |
Author: Paul Bramscher |
553 |
Last Modified: 05.07.2003 |
Last Modified: 03.16.2004 |
554 |
*********************************************************** |
*********************************************************** |
555 |
Purpose: |
Purpose: |
556 |
Update supplied resource id, and call formResource back |
Update supplied resource id, and call formResource back |
557 |
again. |
again. |
558 |
**********************************************************/ |
**********************************************************/ |
559 |
function updateResource($con, $annotation, $author, $call_no, $cat_num, $coverage_detail, |
function updateResource($annotation, $author, $call_no, $cat_num, $coverage_detail, |
560 |
$edition, $infotype_id, $key_id, $other_title, $pub_date, $publisher, $sess_staff_account, |
$edition, $guide_url, $infotype_id, $key_id, $other_title, $pub_date, $publisher, |
561 |
$sources_indexed, $title, $url) { |
$resource_message, $resource_status, $sess_staff_account, $sources_indexed, |
562 |
|
$title, $url, $vendor_id) { |
563 |
|
|
564 |
|
$resource_id = (int) $key_id; |
565 |
|
|
566 |
|
// Error flag |
567 |
|
$err_code = 0; |
568 |
|
|
569 |
|
// Need for display/uniqueness purposes |
570 |
|
$title_display = $title; |
571 |
|
$title_search = textSearchmySQL($title); |
572 |
|
|
573 |
|
// Check to see if already exists |
574 |
|
$exists = recordCount("resource", "title", $title_search, "A"); |
575 |
|
$exists_id = lookupField("resource", "title", $title_search, "resource_id"); |
576 |
|
|
577 |
|
// If exists in the resource table under a different resource_id |
578 |
|
if ($exists > 0 && $exists_id != $resource_id) { |
579 |
|
$err_code = 1; |
580 |
|
$err_msg = "Failed. <b>" . $title_display . "</b> already exists in the resource table."; |
581 |
|
} |
582 |
|
|
583 |
|
// Check for blank entry |
584 |
|
if ($title == "") { |
585 |
|
$err_code = 2; |
586 |
|
$err_msg = "Failed. Must supply some value for the resource title."; |
587 |
|
} |
588 |
|
|
589 |
// Clean up strings |
// Clean up strings |
590 |
if (strlen($annotation) > 0) $annotation = textInmySQL($annotation); |
if (strlen($annotation) > 0) $annotation = textInmySQL($annotation); |
591 |
if (strlen($author) > 0) $author = textInmySQL($author); |
if (strlen($author) > 0) $author = textInmySQL($author); |
599 |
if (strlen($sources_indexed) > 0) $sources_indexed = textInmySQL($sources_indexed); |
if (strlen($sources_indexed) > 0) $sources_indexed = textInmySQL($sources_indexed); |
600 |
if (strlen($title)> 0) $title = textInmySQL($title); |
if (strlen($title)> 0) $title = textInmySQL($title); |
601 |
if (strlen($url) > 0) $url = textInmySQL($url); |
if (strlen($url) > 0) $url = textInmySQL($url); |
602 |
|
if (strlen($guide_url) > 0) $guide_url = textInmySQL($guide_url); |
603 |
|
if (strlen($resource_message) > 0) $resource_message = textInmySQL($resource_message); |
604 |
|
if ($resource_status < 1) { |
605 |
|
$resource_status = ""; |
606 |
|
$resource_message = ""; |
607 |
|
} |
608 |
|
|
609 |
// Set up SQL |
// Update only if no errors encountered |
610 |
$sql = "UPDATE resource SET annotation = '" |
if ($err_code == 0) { |
|
. $annotation |
|
|
. "', author = '" |
|
|
. $author |
|
|
. "', call_no = '" |
|
|
. $call_no |
|
|
. "', cat_num = '" |
|
|
. $cat_num |
|
|
. "', coverage_detail = '" |
|
|
. $coverage_detail |
|
|
. "', date_modified = now() " |
|
|
. ", edition = '" |
|
|
. $edition |
|
|
. "', infotype_id = " |
|
|
. $infotype_id |
|
|
. ", other_title = '" |
|
|
. $other_title |
|
|
. "', pub_date = '" |
|
|
. $pub_date |
|
|
. "', publisher = '" |
|
|
. $publisher |
|
|
. "', sources_indexed = '" |
|
|
. $sources_indexed |
|
|
. "', title = '" |
|
|
. $title |
|
|
. "', url = '" |
|
|
. $url |
|
|
. "', vendor_id = '" |
|
|
. $vendor_id |
|
|
. "', account_modified = '" |
|
|
. $sess_staff_account |
|
|
. "' WHERE resource_id = " |
|
|
. $key_id; |
|
611 |
|
|
612 |
// printf("sql was: %s<br><br>\n", $sql); |
// Set up SQL |
613 |
|
$sql = "UPDATE resource SET annotation = '" |
614 |
// Edit the record |
. $annotation |
615 |
mysql_query ("LOCK TABLE resource WRITE", $con); |
. "', author = '" |
616 |
if (!mysql_query($sql, $con)){ |
. $author |
617 |
sql_err($con); |
. "', call_no = '" |
618 |
mysql_query ("UNLOCK TABLES", $con); |
. $call_no |
619 |
bailout(); |
. "', cat_num = '" |
620 |
} |
. $cat_num |
621 |
else { |
. "', coverage_detail = '" |
622 |
mysql_query("UNLOCK TABLES", $con); |
. $coverage_detail |
623 |
formResource($con, $key_id, 0, 0, ''); |
. "', date_modified = now() " |
624 |
} |
. ", edition = '" |
625 |
|
. $edition |
626 |
|
. "', guide_url = '" |
627 |
|
. $guide_url |
628 |
|
. "', infotype_id = " |
629 |
|
. $infotype_id |
630 |
|
. ", other_title = '" |
631 |
|
. $other_title |
632 |
|
. "', pub_date = '" |
633 |
|
. $pub_date |
634 |
|
. "', publisher = '" |
635 |
|
. $publisher |
636 |
|
. "', resource_message = '" |
637 |
|
. $resource_message |
638 |
|
. "', resource_status = '" |
639 |
|
. $resource_status |
640 |
|
. "', sources_indexed = '" |
641 |
|
. $sources_indexed |
642 |
|
. "', title = '" |
643 |
|
. $title |
644 |
|
. "', url = '" |
645 |
|
. $url |
646 |
|
. "', vendor_id = '" |
647 |
|
. $vendor_id |
648 |
|
. "', account_modified = '" |
649 |
|
. $sess_staff_account |
650 |
|
. "' WHERE resource_id = " |
651 |
|
. $key_id; |
652 |
|
|
653 |
|
xx_tryquery ($sql); |
654 |
|
formResource($key_id, 0, 0, ''); |
655 |
|
} |
656 |
|
|
657 |
|
else { |
658 |
|
msgTableOpen(1, "Updating Resource (ID# " . $resource_id . ")"); |
659 |
|
printf("<b>Messages:</b><br>\n"); |
660 |
|
printf("%s", $err_msg); |
661 |
|
printf("<br><br>\n"); |
662 |
|
msgTableClose(); |
663 |
|
} |
664 |
} |
} |
665 |
|
|
666 |
|
|
667 |
/********************************************************** |
/********************************************************** |
668 |
Function: updateService |
Function: updateService |
669 |
Author: Paul Bramscher |
Author: Paul Bramscher |
670 |
Last Modified: 05.21.2003 |
Last Modified: 03.16.2004 |
671 |
*********************************************************** |
*********************************************************** |
672 |
Purpose: |
Purpose: |
673 |
Update supplied service id and call formService back again. |
Update supplied service id and call formService back again. |
674 |
**********************************************************/ |
**********************************************************/ |
675 |
function updateService($con, $address1, $address2, $address3, $address4, $email, |
function updateService($address1, $address2, $address3, $address4, $email, |
676 |
$fax, $nonaff, $service, $serviceDescr, $service_id, $serviceURL, $telephone) { |
$fax, $nonaff, $service, $serviceDescr, $service_id, $serviceURL, $telephone) { |
677 |
|
|
678 |
// Error flag |
// Error flag |
683 |
$service_search = textSearchmySQL($service); |
$service_search = textSearchmySQL($service); |
684 |
|
|
685 |
// Check to see if already exists |
// Check to see if already exists |
686 |
$exists = recordCount($con, "service", "service", $service_search, "A"); |
$exists = recordCount("service", "service", $service_search, "A"); |
687 |
$exists_id = lookupField($con, "service", "service", $service_search, "service_id"); |
$exists_id = lookupField("service", "service", $service_search, "service_id"); |
688 |
|
|
689 |
if ($exists > 0 && $exists_id != $service_id) { |
if ($exists > 0 && $exists_id != $service_id) { |
690 |
$err_code = 1; |
$err_code = 1; |
691 |
$err_msg = "Failed. '" . $service_display . "' already exists in the service table."; |
$err_msg = "Failed. <b>" . $service_display . "</b> already exists in the service table."; |
692 |
} |
} |
693 |
|
|
694 |
// Check for blank entry |
// Check for blank entry |
737 |
. "' WHERE service_id =" |
. "' WHERE service_id =" |
738 |
. $service_id; |
. $service_id; |
739 |
|
|
740 |
if (!mysql_query ($sql, $con)){ |
xx_tryquery ($sql); |
741 |
sql_err($sql); |
formService($service_id); |
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
|
|
|
// Call the service form back |
|
|
formService($con, $service_id); |
|
|
} |
|
742 |
|
|
743 |
} |
} |
744 |
|
|
745 |
else { |
else { |
746 |
printf("<center><h3>Updating Service...</h3>"); |
msgTableOpen(1, "Updating Service (ID# " . $service_id . ")"); |
747 |
|
printf("<b>Messages:</b><br>\n"); |
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
|
|
printf("<tr><td><br>\n"); |
|
|
printf("<strong>Messages:</strong><br>\n"); |
|
748 |
printf("%s", $err_msg); |
printf("%s", $err_msg); |
749 |
printf("<BR><BR>\n"); |
printf("<br><br>\n"); |
750 |
printf("</td></tr></table>\n"); |
msgTableClose(); |
|
printf("</center>\n"); |
|
751 |
} |
} |
|
|
|
752 |
} |
} |
753 |
|
|
754 |
|
|
755 |
/********************************************************** |
/********************************************************** |
756 |
Function: updateSingleField |
Function: updateSingleField |
757 |
Author: Paul Bramscher |
Author: Paul Bramscher |
758 |
Last Modified: 05.21.2003 |
Last Modified: 03.16.2004 |
759 |
*********************************************************** |
*********************************************************** |
760 |
Purpose: |
Purpose: |
761 |
Updates any single field in any supplied table. Checks |
Updates any single field in any supplied table. Checks |
762 |
for uniqueness and blank value. |
for uniqueness and blank value. |
763 |
**********************************************************/ |
**********************************************************/ |
764 |
function updateSingleField($con, $display, $display_field, $key_field, |
function updateSingleField($display, $display_field, $key_field, |
765 |
$key_id, $newValue, $table){ |
$key_id, $newValue, $table){ |
766 |
|
|
767 |
|
msgTableOpen(1, "Updating " . $display . " (ID# " . $key_id . ")"); |
768 |
|
printf("<b>Messages:</b><br>\n"); |
769 |
|
|
770 |
// Error flag |
// Error flag |
771 |
$err_code = 0; |
$err_code = 0; |
773 |
$newValue_search = textSearchmySQL($newValue); |
$newValue_search = textSearchmySQL($newValue); |
774 |
|
|
775 |
// Check to see if already exists |
// Check to see if already exists |
776 |
$exists = recordCount($con, $table, $display_field, $newValue_search, "A"); |
$exists = recordCount($table, $display_field, $newValue_search, "A"); |
777 |
$exists_id = lookupField($con, $table, $display_field, $newValue_search, $key_field); |
$exists_id = lookupField($table, $display_field, $newValue_search, $key_field); |
778 |
|
|
779 |
// If exists in the infotype table under a different infotype_id (not editing the name of this infotype) |
// If exists in the infotype table under a different infotype_id (not editing the name of this infotype) |
780 |
if ($exists > 0 && $exists_id != $key_field) { |
if ($exists > 0 && $exists_id != $key_field) { |
790 |
$err_msg = "Failed. Must supply some value for the <b>" |
$err_msg = "Failed. Must supply some value for the <b>" |
791 |
. $display |
. $display |
792 |
. "</b>."; |
. "</b>."; |
793 |
} |
} |
|
|
|
|
// Draw page heading |
|
|
printf("<center><h3>Updating %s...</h3>", $display); |
|
|
|
|
|
printf("<table width =\"50%%\" border = \"3\" class=\"backLight\">"); |
|
|
printf("<tr><td><font face = \"Arial\">"); |
|
|
printf("<b>Messages:</b><br>\n"); |
|
794 |
|
|
795 |
// Continue if no errors |
// Continue if no errors |
796 |
if ($err_code == 0) { |
if ($err_code == 0) { |
809 |
. $key_field |
. $key_field |
810 |
. " = " |
. " = " |
811 |
. $key_id; |
. $key_id; |
812 |
|
if (xx_tryquery ($sql)) printf("Successfully changed %s to <b>%s</b>.", $display, $newValue_display); |
|
if (!mysql_query ($sql, $con)){ |
|
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("%s successfully changed to <b>%s</b>.\n", $display, $newValue_display); |
|
|
} |
|
813 |
|
|
814 |
} |
} |
|
|
|
815 |
else printf("%s", $err_msg); |
else printf("%s", $err_msg); |
816 |
|
|
817 |
printf("<br><br></td></tr></table><br>"); |
printf("<br><br>\n"); |
818 |
printf("</center>"); |
msgTableClose(); |
819 |
} |
} |
820 |
|
|
821 |
|
|
822 |
/********************************************************** |
/********************************************************** |
823 |
Function: updateStaff |
Function: updateStaff |
824 |
Author: Paul Bramscher |
Author: Paul Bramscher |
825 |
Last Modified: 06.23.2003 |
Last Modified: 03.15.2004 |
826 |
*********************************************************** |
*********************************************************** |
827 |
Purpose: |
Purpose: |
828 |
Updates the supplied staff id with new information. |
Updates the supplied staff id with new information. Staff |
829 |
|
must have, at a minimum, a last name, first name, and |
830 |
|
unique staff account name. Uniqueness is enforced only on |
831 |
|
staff_account. |
832 |
**********************************************************/ |
**********************************************************/ |
833 |
function updateStaff($con, $access_id, $first_name, |
function updateStaff($access_id, $first_name, |
834 |
$last_name, $sess_access_level, $staff_account, $staff_email, $staff_id, $stafftitle_id) { |
$last_name, $sess_access_level, $staff_account, |
835 |
|
$staff_email, $staff_id, $stafftitle_id) { |
|
/* |
|
|
Staff must have, at a minimum, a last name, first name, and unique staff account |
|
|
name. Uniqueness is enforced only on staff_account. |
|
|
*/ |
|
836 |
|
|
837 |
// Error flag |
// Error flag |
838 |
$err_code = 0; |
$err_code = 0; |
842 |
$staff_account_search = textSearchmySQL($staff_account); |
$staff_account_search = textSearchmySQL($staff_account); |
843 |
|
|
844 |
// Check to see if the staff_account already exists |
// Check to see if the staff_account already exists |
845 |
$exists = recordCount($con, "staff", "staff_account", $staff_account_search, "A"); |
$exists = recordCount("staff", "staff_account", $staff_account_search, "A"); |
846 |
$exists_id = lookupField($con, "staff", "staff_account", $staff_account_search, "staff_id"); |
$exists_id = lookupField("staff", "staff_account", $staff_account_search, "staff_id"); |
847 |
|
|
848 |
if ($exists > 0 && $exists_id != $staff_id) { |
if ($exists > 0 && $exists_id != $staff_id) { |
849 |
$err_code = 1; |
$err_code = 1; |
850 |
$err_msg = "Failed. '" . $staff_account_display . "' already exists in the Staff table."; |
$err_msg = "Failed. <b>" . $staff_account_display . "</b> already exists in the Staff table."; |
851 |
} |
} |
852 |
|
|
853 |
// Check for blank first name or last name |
// Check for blank first name or last name |
863 |
} |
} |
864 |
|
|
865 |
// Check for access level higher than current access |
// Check for access level higher than current access |
866 |
$this_access_level = lookupfield($con, "access", "access_id", $access_id, "access_level"); |
$this_access_level = lookupfield("access", "access_id", $access_id, "access_level"); |
867 |
if ($this_access_level > $sess_access_level) { |
if ($this_access_level > $sess_access_level) { |
868 |
$err_code = 4; |
$err_code = 4; |
869 |
$err_msg = "Failed. You may not promote staff to higher privileges than your own."; |
$err_msg = "Failed. You may not promote staff to higher privileges than your own."; |
894 |
. "' WHERE staff_id =" |
. "' WHERE staff_id =" |
895 |
. $staff_id; |
. $staff_id; |
896 |
|
|
897 |
if (!mysql_query ($sql, $con)){ |
xx_tryquery ($sql); |
898 |
sql_err($sql); |
formStaff($staff_id); |
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
// Success. Call formStaff back. |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
formStaff($con, $staff_id); |
|
|
} |
|
899 |
} |
} |
900 |
else { |
else { |
901 |
|
msgTableOpen(1, "Updating Staff ID# " . $staff_id); |
902 |
printf("<center><h3>Updating Staff...</h3>\n"); |
printf("<b>Messages:</b><br>\n"); |
903 |
|
printf("%s", $err_msg); |
904 |
// Table |
printf("<br><br>\n"); |
905 |
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n"); |
msgTableClose(); |
|
printf("<tr><td><br>\n"); |
|
|
printf("<strong>Messages:</strong><br>\n"); |
|
|
|
|
|
printf("%s<BR><BR>\n", $err_msg); |
|
|
printf("</td></tr></table>\n"); |
|
|
printf("</center>\n"); |
|
906 |
} |
} |
907 |
} |
} |
908 |
|
|
910 |
/********************************************************** |
/********************************************************** |
911 |
Function: updateStyle |
Function: updateStyle |
912 |
Author: Paul Bramscher |
Author: Paul Bramscher |
913 |
Last Modified: 05.22.2003 |
Last Modified: 03.15.2004 |
914 |
*********************************************************** |
*********************************************************** |
915 |
Purpose: |
Purpose: |
916 |
Update the supplied style id. As with the insert transaction, |
Update the supplied style id. As with the insert transaction, |
917 |
no error checking is done to ensure that the supplied files |
no error checking is done to ensure that the supplied files |
918 |
actually exist and have proper permissions. |
actually exist and have proper permissions. |
919 |
**********************************************************/ |
**********************************************************/ |
920 |
function updateStyle($con, $css_file, $footer_file, $header_file, $style_id, $style_title) { |
function updateStyle($css_file, $footer_file, $header_file, $style_id, $style_title) { |
921 |
|
|
922 |
|
msgTableOpen(1, "Updating Style ID# " . $style_id); |
923 |
|
printf("<b>Messages:</b><br>\n"); |
924 |
|
|
925 |
// Error flag |
// Error flag |
926 |
$err_code = 0; |
$err_code = 0; |
930 |
$style_title_search = textSearchmySQL($style_title); |
$style_title_search = textSearchmySQL($style_title); |
931 |
|
|
932 |
// Check to see if already exists under a different style_id |
// Check to see if already exists under a different style_id |
933 |
$exists = recordCount($con, "style", "style_title", $style_title_search, "A"); |
$exists = recordCount("style", "style_title", $style_title_search, "A"); |
934 |
$exists_id = lookupField($con, "style", "style_title", $style_title_search, "style_id"); |
$exists_id = lookupField("style", "style_title", $style_title_search, "style_id"); |
935 |
|
|
936 |
if ($exists > 0 && $exists_id != $style_id) { |
if ($exists > 0 && $exists_id != $style_id) { |
937 |
$err_code = 1; |
$err_code = 1; |
938 |
$err_msg = "Failed. '" . $style_title_display . "' already exists in the style table."; |
$err_msg = "Failed. <b>" . $style_title_display . "</b> already exists in the style table."; |
939 |
} |
} |
940 |
|
|
941 |
// Check for blank entry |
// Check for blank entry |
944 |
$err_msg = "Failed. Cannot enter a blank style."; |
$err_msg = "Failed. Cannot enter a blank style."; |
945 |
} |
} |
946 |
|
|
|
printf("<center><h3>Updating Style...</h3>"); |
|
|
|
|
|
// Table |
|
|
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
|
|
printf("<tr><td><br>"); |
|
|
printf("<strong>Messages:</strong><br>"); |
|
|
|
|
947 |
if ($err_code == 0) { |
if ($err_code == 0) { |
948 |
|
|
949 |
// Clean up strings |
// Clean up strings |
963 |
. $header_file |
. $header_file |
964 |
. "' WHERE style_id =" |
. "' WHERE style_id =" |
965 |
. $style_id; |
. $style_id; |
966 |
|
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> style.", $style_title_display); |
|
if (!mysql_query ($sql, $con)){ |
|
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
printf("Successfully updated <b>%s</b> style.", $style_title_display); |
|
|
} |
|
967 |
} |
} |
968 |
else printf("%s", $err_msg); |
else printf("%s", $err_msg); |
969 |
|
|
970 |
printf("<br><br>\n"); |
printf("<br><br>\n"); |
971 |
printf("</td></tr></table>\n"); |
msgTableClose(); |
|
printf("</center>\n"); |
|
|
|
|
972 |
} |
} |
973 |
|
|
974 |
|
|
975 |
/********************************************************** |
/********************************************************** |
976 |
Function: updateSubject |
Function: updateSubject |
977 |
Author: Paul Bramscher |
Author: Paul Bramscher |
978 |
Last Modified: 06.11.2003 |
Last Modified: 03.16.2004 |
979 |
*********************************************************** |
*********************************************************** |
980 |
Purpose: |
Purpose: |
981 |
Update the supplied subject id, and call formSubject back |
Update the supplied subject id, and call formSubject back |
982 |
again. |
again. |
983 |
**********************************************************/ |
**********************************************************/ |
984 |
function updateSubject($con, $subject, $subject_descr, $subject_id, $sublocation_id) { |
function updateSubject($subject, $subject_descr, $subject_id, $sublocation_id) { |
985 |
|
|
986 |
// Error flag |
// Error flag |
987 |
$err_code = 0; |
$err_code = 0; |
991 |
$subject_search = textSearchmySQL($subject); |
$subject_search = textSearchmySQL($subject); |
992 |
|
|
993 |
// Check to see if already exists |
// Check to see if already exists |
994 |
$exists = recordCount($con, "subject", "subject", $subject_search, "A"); |
$exists = recordCount("subject", "subject", $subject_search, "A"); |
995 |
$exists_id = lookupField($con, "subject", "subject", $subject_search, "subject_id"); |
$exists_id = lookupField("subject", "subject", $subject_search, "subject_id"); |
996 |
|
|
997 |
// If exists in the subject table under a different subject_id (not editing the name of this subject) |
// If exists in the subject table under a different subject_id (not editing the name of this subject) |
998 |
if ($exists > 0 && $exists_id != $subject_id) { |
if ($exists > 0 && $exists_id != $subject_id) { |
999 |
$err_code = 1; |
$err_code = 1; |
1000 |
$err_msg = "Failed. '" . $subject . "' already exists in the subject table."; |
$err_msg = "Failed. <b>" . $subject . "</b> already exists in the subject table."; |
1001 |
} |
} |
1002 |
|
|
1003 |
// Check for blank entry |
// Check for blank entry |
1021 |
. "', sublocation_id =" |
. "', sublocation_id =" |
1022 |
. $sublocation_id |
. $sublocation_id |
1023 |
. " WHERE subject_id = " . $subject_id; |
. " WHERE subject_id = " . $subject_id; |
1024 |
|
xx_tryquery($sql); |
1025 |
if (!mysql_query ($sql, $con)){ |
formSubject($subject_id); |
|
sql_err($sql); |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
bailout(); |
|
|
} |
|
|
else { |
|
|
mysql_query ("UNLOCK TABLES", $con); |
|
|
formSubject($con, $subject_id); |
|
|
} // updated subject |
|
|
|
|
1026 |
} |
} |
1027 |
|
|
1028 |
else { |
else { |
1029 |
|
msgTableOpen(1, "Updating Subject (ID# " . $subject_id . ")"); |
1030 |
|
printf("<b>Messages:</b><br>\n"); |
1031 |
|
printf("%s", $err_msg); |
1032 |
|
printf("<br><br>\n"); |
1033 |
|
msgTableClose(); |
1034 |
|
} |
1035 |
|
} |
1036 |
|
|
1037 |
|
|
1038 |
|
/********************************************************** |
1039 |
|
Function: updateVendor |
1040 |
|
Author: Paul Bramscher |
1041 |
|
Last Modified: 03.16.2004 |
1042 |
|
*********************************************************** |
1043 |
|
Purpose: |
1044 |
|
Update supplied vendor id. |
1045 |
|
**********************************************************/ |
1046 |
|
function updateVendor($vendor, $vendor_descr, $vendor_id, |
1047 |
|
$vendor_message, $vendor_status) { |
1048 |
|
|
1049 |
|
msgTableOpen(1, "Updating Vendor (ID# " . $vendor_id . ")"); |
1050 |
|
printf("<b>Messages:</b><br>\n"); |
1051 |
|
|
1052 |
|
// Error flag |
1053 |
|
$err_code = 0; |
1054 |
|
|
1055 |
|
// Need for display/uniqueness |
1056 |
|
$vendor_display = $vendor; |
1057 |
|
$vendor_search = textSearchmySQL($vendor); |
1058 |
|
|
1059 |
|
// Check to see if already exists |
1060 |
|
$exists = recordCount("vendor", "vendor", $vendor_search, "A"); |
1061 |
|
$exists_id = lookupField("vendor", "vendor", $vendor_search, "vendor_id"); |
1062 |
|
|
1063 |
printf("<center><h3>Updating subject...</h3>"); |
// If exists in the vendor table under a different vendor_id |
1064 |
|
if ($exists > 0 && $exists_id != $vendor_id) { |
1065 |
|
$err_code = 1; |
1066 |
|
$err_msg = "Failed. <b>" . $vendor_display . "</b> already exists in the vendor table."; |
1067 |
|
} |
1068 |
|
|
1069 |
|
// Check for blank entry |
1070 |
|
if ($vendor == "") { |
1071 |
|
$err_code = 2; |
1072 |
|
$err_msg = "Failed. Must supply some value for the vendor."; |
1073 |
|
} |
1074 |
|
|
1075 |
|
// Perform the update only if no errors encountered |
1076 |
|
if ($err_code == 0) { |
1077 |
|
|
1078 |
// Table |
// Clean up strings |
1079 |
printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">"); |
$vendor = textInmySQL($vendor); |
1080 |
printf("<tr><td><br>"); |
if (strlen($vendor_descr) > 0) $vendor_descr = textInmySQL($vendor_descr); |
1081 |
printf("<strong>Messages:</strong><br>"); |
if (strlen($vendor_message) > 0) $vendor_message = textInmySQL($vendor_message); |
1082 |
|
if ($vendor_status < 1) { |
1083 |
printf("%s<BR><BR>", $err_msg); |
$vendor_status = ""; |
1084 |
printf("</td></tr></table>"); |
$vendor_message = ""; |
1085 |
printf("</center>"); |
} |
1086 |
|
|
1087 |
|
// Build the SQL |
1088 |
|
$sql = "UPDATE vendor SET vendor = '" |
1089 |
|
. $vendor |
1090 |
|
. "', vendor_descr ='" |
1091 |
|
. $vendor_descr |
1092 |
|
. "', vendor_message ='" |
1093 |
|
. $vendor_message |
1094 |
|
. "', vendor_status ='" |
1095 |
|
. $vendor_status |
1096 |
|
. "' WHERE vendor_id =" |
1097 |
|
. $vendor_id; |
1098 |
|
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> vendor.", $vendor_display); |
1099 |
} |
} |
1100 |
|
else printf("%s", $err_msg); |
1101 |
|
|
1102 |
|
printf("<br><br>\n"); |
1103 |
|
msgTableClose(); |
1104 |
} |
} |
1105 |
?> |
?> |