1 |
dpavlin |
1 |
<?php |
2 |
|
|
/********************************************************** |
3 |
|
|
Function Library: update.php |
4 |
dpavlin |
67 |
Original Author: Paul Bramscher <brams006@umn.edu> |
5 |
|
|
Last Modified: 03.16.2004 by Paul Bramscher |
6 |
dpavlin |
1 |
*********************************************************** |
7 |
|
|
Comments: |
8 |
|
|
This library brings together all SQL update functions for |
9 |
|
|
LibData general setup tables. Those pertaining to |
10 |
|
|
PageScribe and SubjectBuilder are located in |
11 |
|
|
scribe_application.php and subject_builder.php |
12 |
|
|
respectively. |
13 |
|
|
*********************************************************** |
14 |
|
|
Table of Contents: |
15 |
|
|
purgePassword |
16 |
|
|
updateCoursesub |
17 |
|
|
updateFaculty |
18 |
|
|
updateFeature |
19 |
|
|
updateInfotype |
20 |
|
|
updateLibunit |
21 |
|
|
updateLocation |
22 |
|
|
updatePassword |
23 |
|
|
updateResource |
24 |
|
|
updateService |
25 |
|
|
updateSingleField |
26 |
|
|
updateStaff |
27 |
|
|
updateStyle |
28 |
|
|
updateSubject |
29 |
dpavlin |
67 |
updateVendor |
30 |
dpavlin |
1 |
**********************************************************/ |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/********************************************************** |
34 |
|
|
Function: purgePassword |
35 |
|
|
Author: Paul Bramscher |
36 |
dpavlin |
67 |
Last Modified: 03.15.2004 |
37 |
dpavlin |
1 |
*********************************************************** |
38 |
|
|
Purpose: |
39 |
|
|
This function purges the locally encrypted mySQL stored |
40 |
|
|
password for the supplied staff id (sets to NULL). Note |
41 |
|
|
that at no point does this system actually retrieve the |
42 |
|
|
value of the password and bring it to an HTML form, neither |
43 |
|
|
in plaintext nor in a "password" type HTML form field. |
44 |
|
|
**********************************************************/ |
45 |
dpavlin |
67 |
function purgePassword($staff_id){ |
46 |
dpavlin |
1 |
|
47 |
dpavlin |
67 |
msgTableOpen(1, "Purging Password..."); |
48 |
|
|
printf("<b>Messages:</b><br>\n"); |
49 |
dpavlin |
1 |
|
50 |
dpavlin |
67 |
if ($staff_id > 0) { |
51 |
dpavlin |
1 |
|
52 |
|
|
$sql = "UPDATE staff SET password = NULL WHERE staff_id = " . $staff_id; |
53 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully purged password for this staff account."); |
54 |
dpavlin |
1 |
|
55 |
|
|
} |
56 |
dpavlin |
67 |
else printf("Staff ID not found."); |
57 |
dpavlin |
1 |
|
58 |
dpavlin |
67 |
printf("<br><br>\n"); |
59 |
|
|
msgTableClose(); |
60 |
dpavlin |
1 |
} |
61 |
|
|
|
62 |
|
|
|
63 |
|
|
/********************************************************** |
64 |
|
|
Function: updateCoursesub |
65 |
|
|
Author: Paul Bramscher |
66 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
67 |
dpavlin |
1 |
*********************************************************** |
68 |
|
|
Purpose: |
69 |
|
|
Update supplied course subject id. |
70 |
|
|
**********************************************************/ |
71 |
dpavlin |
67 |
function updateCoursesub($campus_id, $cip_code, $coursesub, $coursesub_descr, $coursesub_id) { |
72 |
dpavlin |
1 |
|
73 |
dpavlin |
67 |
msgTableOpen(1, "Updating Course Subject (ID# " . $coursesub_id . ")"); |
74 |
|
|
printf("<b>Messages:</b><br>\n"); |
75 |
|
|
|
76 |
dpavlin |
1 |
// Error flag |
77 |
|
|
$err_code = 0; |
78 |
|
|
|
79 |
|
|
// Need for display/uniqueness |
80 |
|
|
$coursesub_display = $coursesub; |
81 |
|
|
$coursesub_search = textSearchmySQL($coursesub); |
82 |
|
|
|
83 |
|
|
// Check to see if already exists |
84 |
dpavlin |
67 |
$exists = recordCount("coursesub", "coursesub", $coursesub_search, "A"); |
85 |
|
|
$exists_id = lookupField("coursesub", "coursesub", $coursesub_search, "coursesub_id"); |
86 |
dpavlin |
1 |
|
87 |
|
|
// If exists in the courseub table under a different coursesub_id |
88 |
|
|
if ($exists > 0 && $exists_id != $coursesub_id) { |
89 |
|
|
$err_code = 1; |
90 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $coursesub_display . "</b> already exists in the course subject table."; |
91 |
dpavlin |
1 |
} |
92 |
|
|
|
93 |
|
|
// Check for blank entry |
94 |
|
|
if ($coursesub == "") { |
95 |
|
|
$err_code = 2; |
96 |
|
|
$err_msg = "Failed. Must supply some value for the course subject."; |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
// Perform the update only if no errors encountered |
100 |
|
|
if ($err_code == 0) { |
101 |
|
|
|
102 |
|
|
// Clean up strings |
103 |
|
|
$coursesub = textInmySQL($coursesub); |
104 |
|
|
$coursesub_descr = textInmySQL($coursesub_descr); |
105 |
|
|
$cip_code = textInmySQL($cip_code); |
106 |
|
|
|
107 |
|
|
// Build the SQL |
108 |
|
|
$sql = "UPDATE coursesub SET coursesub = '" |
109 |
|
|
. $coursesub |
110 |
|
|
. "', coursesub_descr ='" |
111 |
|
|
. $coursesub_descr |
112 |
|
|
. "', cip_code = '" |
113 |
|
|
. $cip_code |
114 |
|
|
. "', campus_id = " |
115 |
|
|
. $campus_id |
116 |
|
|
. " WHERE coursesub_id =" |
117 |
|
|
. $coursesub_id; |
118 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> course subject.", $coursesub_display); |
119 |
dpavlin |
1 |
} |
120 |
dpavlin |
67 |
else printf("%s", $err_msg); |
121 |
dpavlin |
1 |
|
122 |
|
|
printf("<br><br>\n"); |
123 |
dpavlin |
67 |
msgTableClose(); |
124 |
dpavlin |
1 |
} |
125 |
|
|
|
126 |
|
|
|
127 |
|
|
/********************************************************** |
128 |
|
|
Function: updateFaculty |
129 |
|
|
Author: Paul Bramscher |
130 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
131 |
dpavlin |
1 |
*********************************************************** |
132 |
|
|
Purpose: |
133 |
dpavlin |
67 |
Update supplied faculty id. Faculty must have both a |
134 |
|
|
unique non-blank staff_account, and non-blank last name. |
135 |
dpavlin |
1 |
**********************************************************/ |
136 |
dpavlin |
67 |
function updateFaculty($faculty_email, $faculty_firstname, |
137 |
dpavlin |
1 |
$faculty_id, $faculty_lastname, $faculty_account) { |
138 |
|
|
|
139 |
dpavlin |
67 |
msgTableOpen(1, "Updating Faculty (ID# " . $faculty_id . ")"); |
140 |
|
|
printf("<b>Messages:</b><br>\n"); |
141 |
dpavlin |
1 |
|
142 |
|
|
// Error flag |
143 |
|
|
$err_code = 0; |
144 |
|
|
|
145 |
|
|
// Need for display/uniqueness |
146 |
|
|
$faculty_name_display = $faculty_firstname . " " . $faculty_lastname; |
147 |
|
|
|
148 |
|
|
// Check to see if already exists |
149 |
dpavlin |
67 |
$exists_id = existsFaculty($faculty_firstname, $faculty_lastname); |
150 |
dpavlin |
1 |
|
151 |
|
|
if ($exists_id > 0 && $exists_id != $faculty_id) { |
152 |
|
|
$err_code = 1; |
153 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $faculty_name_display . "</b> already exists in the Faculty table."; |
154 |
dpavlin |
1 |
} |
155 |
|
|
|
156 |
|
|
// Check for blank last name |
157 |
|
|
if ($faculty_lastname == "") { |
158 |
|
|
$err_code = 2; |
159 |
|
|
$err_msg = "Failed. Cannot have a blank Last Name."; |
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
if ($err_code == 0 ) { |
163 |
|
|
|
164 |
|
|
// Clean up strings |
165 |
|
|
if (strlen($faculty_lastname) > 0) $faculty_lastname = textInmySQL($faculty_lastname); |
166 |
|
|
if (strlen($faculty_firstname) > 0) $faculty_firstname = textInmySQL($faculty_firstname); |
167 |
|
|
if (strlen($faculty_email) > 0) $faculty_email = textInmySQL($faculty_email); |
168 |
|
|
if (strlen($faculty_account) > 0) $faculty_account = textInmySQL($faculty_account); |
169 |
|
|
|
170 |
|
|
// Build the SQL |
171 |
|
|
$sql = "UPDATE faculty SET faculty_lastname = '" |
172 |
|
|
. $faculty_lastname |
173 |
|
|
. "', faculty_firstname ='" |
174 |
|
|
. $faculty_firstname |
175 |
|
|
. "', faculty_email ='" |
176 |
|
|
. $faculty_email |
177 |
|
|
. "', faculty_account ='" |
178 |
|
|
. $faculty_account |
179 |
|
|
. "' WHERE faculty_id =" |
180 |
|
|
. $faculty_id; |
181 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully updated faculty person <b>%s</b>.", $faculty_name_display); |
182 |
dpavlin |
1 |
} |
183 |
dpavlin |
67 |
else printf("%s", $err_msg); |
184 |
dpavlin |
1 |
|
185 |
|
|
printf("<br><br>\n"); |
186 |
dpavlin |
67 |
msgTableClose(); |
187 |
dpavlin |
1 |
} |
188 |
|
|
|
189 |
|
|
|
190 |
|
|
/********************************************************** |
191 |
|
|
Function: updateFeature |
192 |
|
|
Author: Paul Bramscher |
193 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
194 |
dpavlin |
1 |
*********************************************************** |
195 |
|
|
Purpose: |
196 |
|
|
Update supplied feature id. |
197 |
|
|
**********************************************************/ |
198 |
dpavlin |
67 |
function updateFeature($feature, $feature_id, $image_alt, $image_path) { |
199 |
dpavlin |
1 |
|
200 |
dpavlin |
67 |
msgTableOpen(1, "Updating Feature (ID# " . $feature_id . ")"); |
201 |
|
|
printf("<b>Messages:</b><br>\n"); |
202 |
|
|
|
203 |
dpavlin |
1 |
// Error flag |
204 |
|
|
$err_code = 0; |
205 |
|
|
|
206 |
|
|
// Need for display/uniqueness |
207 |
|
|
$feature_display = $feature; |
208 |
|
|
$feature_search = textSearchmySQL($feature); |
209 |
|
|
|
210 |
|
|
// Check to see if already exists |
211 |
dpavlin |
67 |
$exists = recordCount("feature", "feature", $feature_search, "A"); |
212 |
|
|
$exists_id = lookupField("feature", "feature", $feature_search, "feature_id"); |
213 |
dpavlin |
1 |
|
214 |
|
|
// If exists in the feature table under a different feature_id |
215 |
|
|
if ($exists > 0 && $exists_id != $feature_id) { |
216 |
|
|
$err_code = 1; |
217 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $feature_display . "</b> already exists in the feature table."; |
218 |
dpavlin |
1 |
} |
219 |
|
|
|
220 |
|
|
// Check for blank entry |
221 |
|
|
if ($feature == "") { |
222 |
|
|
$err_code = 2; |
223 |
|
|
$err_msg = "Failed. Must supply some value for the feature."; |
224 |
|
|
} |
225 |
|
|
|
226 |
|
|
// Perform the update only if no errors encountered |
227 |
|
|
if ($err_code == 0) { |
228 |
|
|
|
229 |
|
|
// Clean up strings |
230 |
|
|
$feature = textInmySQL($feature); |
231 |
|
|
$image_alt = textInmySQL($image_alt); |
232 |
|
|
$image_path = textInmySQL($image_path); |
233 |
|
|
|
234 |
|
|
// Build the SQL |
235 |
|
|
$sql = "UPDATE feature SET feature = '" |
236 |
|
|
. $feature |
237 |
|
|
. "', image_alt ='" |
238 |
|
|
. $image_alt |
239 |
|
|
. "', image_path ='" |
240 |
|
|
. $image_path |
241 |
|
|
. "' WHERE feature_id =" |
242 |
|
|
. $feature_id; |
243 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> feature.", $feature_display); |
244 |
dpavlin |
1 |
} |
245 |
|
|
else printf("%s", $err_msg); |
246 |
|
|
|
247 |
|
|
printf("<br><br>\n"); |
248 |
dpavlin |
67 |
msgTableClose(); |
249 |
dpavlin |
1 |
|
250 |
|
|
} |
251 |
|
|
|
252 |
|
|
|
253 |
|
|
/********************************************************** |
254 |
|
|
Function: updateInfotype |
255 |
|
|
Author: Paul Bramscher |
256 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
257 |
dpavlin |
1 |
*********************************************************** |
258 |
|
|
Purpose: |
259 |
|
|
Update supplied infotype id. |
260 |
|
|
**********************************************************/ |
261 |
dpavlin |
67 |
function updateInfotype($infotype, $infotype_id, $masterinfotype_id, $mastersubject_id) { |
262 |
dpavlin |
1 |
|
263 |
dpavlin |
67 |
msgTableOpen(1, "Updating Information Type (ID# " . $infotype_id . ")"); |
264 |
|
|
printf("<b>Messages:</b><br>\n"); |
265 |
|
|
|
266 |
dpavlin |
1 |
// Error flag |
267 |
|
|
$err_code = 0; |
268 |
|
|
|
269 |
|
|
// Need for display/uniqueness purposes |
270 |
|
|
$infotype_display = $infotype; |
271 |
|
|
$infotype_search = textSearchmySQL($infotype); |
272 |
|
|
|
273 |
|
|
// Check to see if already exists |
274 |
dpavlin |
67 |
$exists = recordCount("infotype", "infotype", $infotype_search, "A"); |
275 |
|
|
$exists_id = lookupField("infotype", "infotype", $infotype_search, "infotype_id"); |
276 |
dpavlin |
1 |
|
277 |
|
|
// 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) { |
279 |
|
|
$err_code = 1; |
280 |
|
|
$err_msg = "Failed. <b>" . $infotype_display . "</b> already exists in the Information Type table."; |
281 |
|
|
} |
282 |
|
|
|
283 |
|
|
// Check for blank entry |
284 |
|
|
if ($infotype == "") { |
285 |
|
|
$err_code = 2; |
286 |
|
|
$err_msg = "Failed. Must supply some value for the Information Type name."; |
287 |
|
|
} |
288 |
|
|
|
289 |
|
|
// Proceed if no errors encountered |
290 |
|
|
if ($err_code == 0) { |
291 |
|
|
|
292 |
|
|
// Clean up strings |
293 |
|
|
$infotype = textInmySQL($infotype); |
294 |
|
|
|
295 |
|
|
// First, update affected RQS relationships |
296 |
|
|
$sql = "UPDATE res_sub_infotype SET masterinfotype_id = " |
297 |
|
|
. $masterinfotype_id |
298 |
|
|
. " WHERE infotype_id = " |
299 |
|
|
. $infotype_id; |
300 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Updated affected RQS relationships (if any).<BR>\n"); |
301 |
dpavlin |
1 |
|
302 |
|
|
// Build the SQL |
303 |
|
|
$sql = "UPDATE infotype SET infotype = '" |
304 |
|
|
. $infotype |
305 |
|
|
. "', masterinfotype_id =" |
306 |
|
|
. $masterinfotype_id |
307 |
|
|
. ", mastersubject_id =" |
308 |
|
|
. $mastersubject_id |
309 |
|
|
. " WHERE infotype_id =" |
310 |
|
|
. $infotype_id; |
311 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> information type.", $infotype_display); |
312 |
dpavlin |
1 |
} |
313 |
dpavlin |
67 |
else printf("%s", $err_msg); |
314 |
dpavlin |
1 |
|
315 |
dpavlin |
67 |
printf("<br><br>\n"); |
316 |
|
|
msgTableClose(); |
317 |
dpavlin |
1 |
|
318 |
|
|
} |
319 |
|
|
|
320 |
|
|
|
321 |
|
|
/********************************************************** |
322 |
|
|
Function: updateLibunit |
323 |
|
|
Author: Paul Bramscher |
324 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
325 |
dpavlin |
1 |
*********************************************************** |
326 |
|
|
Purpose: |
327 |
|
|
Updates the supplied library unit id with new information. |
328 |
dpavlin |
67 |
Library Units must have both a unique name and unique |
329 |
|
|
abbreviation e.g. "Digital Library Developement |
330 |
|
|
Laboratory" and "DLDL". |
331 |
dpavlin |
1 |
**********************************************************/ |
332 |
dpavlin |
67 |
function updateLibunit($head_staff_id, $libunit, $libunit_abbrev, $libunit_id) { |
333 |
dpavlin |
1 |
|
334 |
|
|
// Error flag |
335 |
|
|
$err_code = 0; |
336 |
|
|
|
337 |
|
|
// Need for display/uniqueness purposes |
338 |
|
|
$libunit_display = $libunit; |
339 |
|
|
$libunit_abbrev_display = $libunit_abbrev; |
340 |
|
|
$libunit_search = textSearchmySQL($libunit); |
341 |
|
|
$libunit_abbrev_search = textSearchmySQL($libunit_abbrev); |
342 |
|
|
|
343 |
|
|
// Check to see if libunit already exists |
344 |
dpavlin |
67 |
$exists = recordCount("libunit", "libunit", $libunit_search, "A"); |
345 |
|
|
$exists_id = lookupField("libunit", "libunit", $libunit_search, "libunit_id"); |
346 |
dpavlin |
1 |
if ($exists > 0 && $exists_id != $libunit_id) { |
347 |
|
|
$err_code = 1; |
348 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $libunit_display . "</b> already exists in the Library Unit table."; |
349 |
dpavlin |
1 |
} |
350 |
|
|
|
351 |
|
|
// Check to see if libunit abbreviation already exists |
352 |
dpavlin |
67 |
$exists = recordCount("libunit", "libunit_abbrev", $libunit_abbrev_search, "A"); |
353 |
|
|
$exists_id = lookupField("libunit", "libunit_abbrev", $libunit_abbrev_search, "libunit_id"); |
354 |
dpavlin |
1 |
|
355 |
|
|
if ($exists > 0 && $exists_id != $libunit_id) { |
356 |
|
|
$err_code = 2; |
357 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $libunit_abbrev_display . "</b> abbreviation already exists in the Library Unit table."; |
358 |
dpavlin |
1 |
} |
359 |
|
|
|
360 |
|
|
// Check for blank linunit entry |
361 |
|
|
if ($libunit == "") { |
362 |
|
|
$err_code = 3; |
363 |
|
|
$err_msg = "Failed. Cannot enter a blank Library Unit."; |
364 |
|
|
} |
365 |
|
|
|
366 |
|
|
// Check for blank linunit abbrev entry |
367 |
|
|
if ($libunit_abbrev == "") { |
368 |
|
|
$err_code = 4; |
369 |
|
|
$err_msg = "Failed. Cannot enter a blank Library Unit abbreviation."; |
370 |
|
|
} |
371 |
|
|
|
372 |
|
|
// Add only if no errors encountered |
373 |
|
|
if ($err_code == 0) { |
374 |
|
|
|
375 |
|
|
if (strlen($libunit) > 0) $libunit = textInmySQL($libunit); |
376 |
|
|
if (strlen($libunit_abbrev) > 0) $libunit_abbrev = textInmySQL($libunit_abbrev); |
377 |
|
|
|
378 |
|
|
// Build the SQL |
379 |
|
|
$sql = "UPDATE libunit SET libunit = '" |
380 |
|
|
. $libunit |
381 |
|
|
. "', libunit_abbrev ='" |
382 |
|
|
. $libunit_abbrev |
383 |
|
|
. "', head_staff_id =" |
384 |
|
|
. $head_staff_id |
385 |
|
|
. " WHERE libunit_id =" |
386 |
|
|
. $libunit_id; |
387 |
dpavlin |
69 |
xx_tryquery ($sql); |
388 |
dpavlin |
67 |
formLibunit($libunit_id); |
389 |
dpavlin |
1 |
} |
390 |
|
|
|
391 |
|
|
else { |
392 |
dpavlin |
67 |
msgTableOpen(1, "Updating Library Unit (ID# " . $libunit_id . ")"); |
393 |
|
|
printf("<b>Messages:</b><br>\n"); |
394 |
dpavlin |
1 |
printf("%s", $err_msg); |
395 |
dpavlin |
67 |
printf("<br><br>\n"); |
396 |
|
|
msgTableClose(); |
397 |
dpavlin |
1 |
} |
398 |
|
|
} |
399 |
|
|
|
400 |
|
|
|
401 |
|
|
/********************************************************** |
402 |
|
|
Function: updateLocation |
403 |
|
|
Author: Paul Bramscher |
404 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
405 |
dpavlin |
1 |
*********************************************************** |
406 |
|
|
Purpose: |
407 |
|
|
Update supplied location id. |
408 |
|
|
**********************************************************/ |
409 |
dpavlin |
67 |
function updateLocation($address1, $address2, |
410 |
dpavlin |
1 |
$address3, $address4, $campus, $hoursURL, $location, $location_descr, |
411 |
|
|
$location_id, $mainURL, $mapURL, $referenceURL, $telephone) { |
412 |
dpavlin |
67 |
|
413 |
|
|
msgTableOpen(1, "Updating Locating (ID# " . $location_id . ")"); |
414 |
|
|
printf("<b>Messages:</b><br>\n"); |
415 |
|
|
|
416 |
dpavlin |
1 |
// Error flag |
417 |
|
|
$err_code = 0; |
418 |
|
|
|
419 |
|
|
// Need for display/uniqueness purposes |
420 |
|
|
$location_display = $location; |
421 |
|
|
$location_search = textSearchmySQL($location); |
422 |
|
|
|
423 |
|
|
// Check to see if already exists |
424 |
dpavlin |
67 |
$exists = recordCount("location", "location", $location_search, "A"); |
425 |
|
|
$exists_id = lookupField("location", "location", $location_search, "location_id"); |
426 |
dpavlin |
1 |
|
427 |
|
|
// If exists in the location table under a different location_id |
428 |
|
|
if ($exists > 0 && $exists_id != $location_id) { |
429 |
|
|
$err_code = 1; |
430 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $location_display . "</b> already exists in the location table."; |
431 |
dpavlin |
1 |
} |
432 |
|
|
|
433 |
|
|
// Check for blank entry |
434 |
|
|
if ($location == "") { |
435 |
|
|
$err_code = 2; |
436 |
|
|
$err_msg = "Failed. Must supply some value for the location name."; |
437 |
|
|
} |
438 |
|
|
|
439 |
|
|
// Perform the update only if no errors encountered |
440 |
|
|
if ($err_code == 0) { |
441 |
|
|
|
442 |
|
|
// Clean up strings |
443 |
|
|
if (strlen($location) > 0) $location = textInmySQL($location); |
444 |
|
|
if (strlen($location_descr) > 0) $location_descr = textInmySQL($location_descr); |
445 |
|
|
if (strlen($campus) > 0) $campus = textInmySQL($campus); |
446 |
|
|
if (strlen($address1) > 0) $address1 = textInmySQL($address1); |
447 |
|
|
if (strlen($address2) > 0) $address2 = textInmySQL($address2); |
448 |
|
|
if (strlen($address3) > 0) $address3 = textInmySQL($address3); |
449 |
|
|
if (strlen($address4) > 0) $address4 = textInmySQL($address4); |
450 |
|
|
if (strlen($telephone) > 0) $telephone = textInmySQL($telephone); |
451 |
|
|
if (strlen($mainURL) > 0) $mainURL = textInmySQL($mainURL); |
452 |
|
|
if (strlen($referenceURL) > 0) $referenceURL = textInmySQL($referenceURL); |
453 |
|
|
if (strlen($mapURL) > 0) $mapURL = textInmySQL($mapURL); |
454 |
|
|
if (strlen($hoursURL) > 0) $hoursURL = textInmySQL($hoursURL); |
455 |
|
|
|
456 |
|
|
// Build the SQL |
457 |
|
|
$sql = "UPDATE location SET location = '" |
458 |
|
|
. $location |
459 |
|
|
. "', location_descr ='" |
460 |
|
|
. $location_descr |
461 |
|
|
. "', campus ='" |
462 |
|
|
. $campus |
463 |
|
|
. "', address1 ='" |
464 |
|
|
. $address1 |
465 |
|
|
. "', address2 ='" |
466 |
|
|
. $address2 |
467 |
|
|
. "', address3 ='" |
468 |
|
|
. $address3 |
469 |
|
|
. "', address4 ='" |
470 |
|
|
. $address4 |
471 |
|
|
. "', mainURL ='" |
472 |
|
|
. $mainURL |
473 |
|
|
. "', hoursURL ='" |
474 |
|
|
. $hoursURL |
475 |
|
|
. "', referenceURL ='" |
476 |
|
|
. $referenceURL |
477 |
|
|
. "', mapURL ='" |
478 |
|
|
. $mapURL |
479 |
|
|
. "', telephone ='" |
480 |
|
|
. $telephone |
481 |
|
|
. "' WHERE location_id =" |
482 |
|
|
. $location_id; |
483 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> location.", $location_display); |
484 |
dpavlin |
1 |
} |
485 |
|
|
else printf("%s", $err_msg); |
486 |
|
|
|
487 |
|
|
printf("<br><br>\n"); |
488 |
dpavlin |
67 |
msgTableClose(); |
489 |
dpavlin |
1 |
|
490 |
|
|
} |
491 |
|
|
|
492 |
|
|
|
493 |
|
|
/********************************************************** |
494 |
|
|
Function: updatePassword |
495 |
|
|
Author: Paul Bramscher |
496 |
dpavlin |
67 |
Last Modified: 03.15.2004 |
497 |
dpavlin |
1 |
*********************************************************** |
498 |
|
|
Purpose: |
499 |
|
|
Changes the locally encrypted and mySQL stored password to |
500 |
|
|
the newly supplied value. Note that the new password and |
501 |
|
|
the "confirm" must match, and it must be 6 characters |
502 |
|
|
minimum. As with purgePassword, at no time does this |
503 |
|
|
system bring the password out of the database and present |
504 |
|
|
it on an HTML form, neither in plaintext nor in a |
505 |
|
|
"password" type HTML form field. The password in plaintext |
506 |
|
|
is never viewable to the system, nor to mySQL itself. If |
507 |
|
|
a user forgets his/her password, it must be reset by an |
508 |
|
|
administrator. |
509 |
|
|
**********************************************************/ |
510 |
dpavlin |
67 |
function updatePassword($password, $password_confirm, $staff_id) { |
511 |
dpavlin |
1 |
|
512 |
|
|
// Error flag |
513 |
|
|
$err_code = 0; |
514 |
|
|
|
515 |
|
|
// Check for less than 6 char. |
516 |
|
|
if (strlen($password) < 6) { |
517 |
|
|
$err_code = 1; |
518 |
|
|
$err_msg = "Failed. Password must be 6 characters minimum."; |
519 |
|
|
} |
520 |
|
|
|
521 |
|
|
// Check for mis-matched password and confirm |
522 |
|
|
if ($password != $password_confirm) { |
523 |
|
|
$err_code = 2; |
524 |
|
|
$err_msg = "Failed. Password and confirm password didn't match."; |
525 |
|
|
} |
526 |
|
|
|
527 |
|
|
// Update only if no errors encountered |
528 |
|
|
if ($err_code == 0) { |
529 |
|
|
|
530 |
|
|
// Build the SQL |
531 |
|
|
$sql = "UPDATE staff SET password = password('" |
532 |
|
|
. $password |
533 |
|
|
. "') WHERE staff_id =" |
534 |
|
|
. $staff_id; |
535 |
|
|
|
536 |
dpavlin |
69 |
xx_tryquery ($sql); |
537 |
dpavlin |
67 |
formStaff($staff_id); |
538 |
dpavlin |
1 |
} |
539 |
|
|
|
540 |
|
|
else { |
541 |
dpavlin |
67 |
msgTableOpen(1, "Updating Local Password..."); |
542 |
|
|
printf("<b>Messages:</b><br>\n"); |
543 |
dpavlin |
1 |
printf("%s", $err_msg); |
544 |
dpavlin |
67 |
printf("<br><br>\n"); |
545 |
|
|
msgTableClose(); |
546 |
dpavlin |
1 |
} |
547 |
|
|
} |
548 |
|
|
|
549 |
|
|
|
550 |
|
|
/********************************************************** |
551 |
|
|
Function: updateResource |
552 |
|
|
Author: Paul Bramscher |
553 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
554 |
dpavlin |
1 |
*********************************************************** |
555 |
|
|
Purpose: |
556 |
|
|
Update supplied resource id, and call formResource back |
557 |
|
|
again. |
558 |
|
|
**********************************************************/ |
559 |
dpavlin |
67 |
function updateResource($annotation, $author, $call_no, $cat_num, $coverage_detail, |
560 |
|
|
$edition, $guide_url, $infotype_id, $key_id, $other_title, $pub_date, $publisher, |
561 |
|
|
$resource_message, $resource_status, $sess_staff_account, $sources_indexed, |
562 |
|
|
$title, $url, $vendor_id) { |
563 |
dpavlin |
1 |
|
564 |
dpavlin |
67 |
$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 |
dpavlin |
1 |
// Clean up strings |
590 |
|
|
if (strlen($annotation) > 0) $annotation = textInmySQL($annotation); |
591 |
|
|
if (strlen($author) > 0) $author = textInmySQL($author); |
592 |
|
|
if (strlen($call_no) > 0) $call_no = textInmySQL($call_no); |
593 |
|
|
if (strlen($cat_num) > 0) $cat_num = textInmySQL($cat_num); |
594 |
|
|
if (strlen($coverage_detail) > 0) $coverage_detail = textInmySQL($coverage_detail); |
595 |
|
|
if (strlen($edition) > 0) $edition = textInmySQL($edition); |
596 |
|
|
if (strlen($other_title) > 0) $other_title = textInmySQL($other_title); |
597 |
|
|
if (strlen($pub_date) > 0) $pub_date = textInmySQL($pub_date); |
598 |
|
|
if (strlen($publisher) > 0) $publisher = textInmySQL($publisher); |
599 |
|
|
if (strlen($sources_indexed) > 0) $sources_indexed = textInmySQL($sources_indexed); |
600 |
|
|
if (strlen($title)> 0) $title = textInmySQL($title); |
601 |
|
|
if (strlen($url) > 0) $url = textInmySQL($url); |
602 |
dpavlin |
67 |
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 |
dpavlin |
1 |
|
609 |
dpavlin |
67 |
// Update only if no errors encountered |
610 |
|
|
if ($err_code == 0) { |
611 |
dpavlin |
1 |
|
612 |
dpavlin |
67 |
// Set up SQL |
613 |
|
|
$sql = "UPDATE resource SET annotation = '" |
614 |
|
|
. $annotation |
615 |
|
|
. "', author = '" |
616 |
|
|
. $author |
617 |
|
|
. "', call_no = '" |
618 |
|
|
. $call_no |
619 |
|
|
. "', cat_num = '" |
620 |
|
|
. $cat_num |
621 |
|
|
. "', coverage_detail = '" |
622 |
|
|
. $coverage_detail |
623 |
|
|
. "', 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 |
dpavlin |
1 |
|
653 |
dpavlin |
69 |
xx_tryquery ($sql); |
654 |
dpavlin |
67 |
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 |
dpavlin |
1 |
} |
665 |
|
|
|
666 |
|
|
|
667 |
|
|
/********************************************************** |
668 |
|
|
Function: updateService |
669 |
|
|
Author: Paul Bramscher |
670 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
671 |
dpavlin |
1 |
*********************************************************** |
672 |
|
|
Purpose: |
673 |
|
|
Update supplied service id and call formService back again. |
674 |
|
|
**********************************************************/ |
675 |
dpavlin |
67 |
function updateService($address1, $address2, $address3, $address4, $email, |
676 |
dpavlin |
1 |
$fax, $nonaff, $service, $serviceDescr, $service_id, $serviceURL, $telephone) { |
677 |
|
|
|
678 |
|
|
// Error flag |
679 |
|
|
$err_code = 0; |
680 |
|
|
|
681 |
|
|
// Need for display/uniqueness |
682 |
|
|
$service_display = $service; |
683 |
|
|
$service_search = textSearchmySQL($service); |
684 |
|
|
|
685 |
|
|
// Check to see if already exists |
686 |
dpavlin |
67 |
$exists = recordCount("service", "service", $service_search, "A"); |
687 |
|
|
$exists_id = lookupField("service", "service", $service_search, "service_id"); |
688 |
dpavlin |
1 |
|
689 |
|
|
if ($exists > 0 && $exists_id != $service_id) { |
690 |
|
|
$err_code = 1; |
691 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $service_display . "</b> already exists in the service table."; |
692 |
dpavlin |
1 |
} |
693 |
|
|
|
694 |
|
|
// Check for blank entry |
695 |
|
|
if ($service == "") { |
696 |
|
|
$err_code = 2; |
697 |
|
|
$err_msg = "Failed. Cannot enter a blank service."; |
698 |
|
|
} |
699 |
|
|
|
700 |
|
|
if ($err_code == 0) { |
701 |
|
|
|
702 |
|
|
// Clean up strings |
703 |
|
|
if (strlen($address1) > 0) $address1 = textInmySQL($address1); |
704 |
|
|
if (strlen($address2) > 0) $address2 = textInmySQL($address2); |
705 |
|
|
if (strlen($address3) > 0) $address3 = textInmySQL($address3); |
706 |
|
|
if (strlen($address4) > 0) $address4 = textInmySQL($address4); |
707 |
|
|
if (strlen($email) > 0) $email = textInmySQL($email); |
708 |
|
|
if (strlen($fax) > 0) $fax = textInmySQL($fax); |
709 |
|
|
if (strlen($service) > 0) $service = textInmySQL($service); |
710 |
|
|
if (strlen($serviceDescr) > 0) $serviceDescr = textInmySQL($serviceDescr); |
711 |
|
|
if (strlen($serviceURL) > 0) $serviceURL = textInmySQL($serviceURL); |
712 |
|
|
if (strlen($telephone) > 0) $telephone = textInmySQL($telephone); |
713 |
|
|
|
714 |
|
|
// Build the SQL |
715 |
|
|
$sql = "UPDATE service SET service = '" |
716 |
|
|
. $service |
717 |
|
|
. "', serviceDescr ='" |
718 |
|
|
. $serviceDescr |
719 |
|
|
. "', address1 ='" |
720 |
|
|
. $address1 |
721 |
|
|
. "', address2 ='" |
722 |
|
|
. $address2 |
723 |
|
|
. "', address3 ='" |
724 |
|
|
. $address3 |
725 |
|
|
. "', address4 ='" |
726 |
|
|
. $address4 |
727 |
|
|
. "', serviceURL ='" |
728 |
|
|
. $serviceURL |
729 |
|
|
. "', email ='" |
730 |
|
|
. $email |
731 |
|
|
. "', fax ='" |
732 |
|
|
. $fax |
733 |
|
|
. "', telephone ='" |
734 |
|
|
. $telephone |
735 |
|
|
. "', nonaff = '" |
736 |
|
|
. $nonaff |
737 |
|
|
. "' WHERE service_id =" |
738 |
|
|
. $service_id; |
739 |
|
|
|
740 |
dpavlin |
69 |
xx_tryquery ($sql); |
741 |
dpavlin |
67 |
formService($service_id); |
742 |
dpavlin |
1 |
|
743 |
|
|
} |
744 |
|
|
|
745 |
|
|
else { |
746 |
dpavlin |
67 |
msgTableOpen(1, "Updating Service (ID# " . $service_id . ")"); |
747 |
|
|
printf("<b>Messages:</b><br>\n"); |
748 |
dpavlin |
1 |
printf("%s", $err_msg); |
749 |
dpavlin |
67 |
printf("<br><br>\n"); |
750 |
|
|
msgTableClose(); |
751 |
dpavlin |
1 |
} |
752 |
|
|
} |
753 |
|
|
|
754 |
|
|
|
755 |
|
|
/********************************************************** |
756 |
|
|
Function: updateSingleField |
757 |
|
|
Author: Paul Bramscher |
758 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
759 |
dpavlin |
1 |
*********************************************************** |
760 |
|
|
Purpose: |
761 |
|
|
Updates any single field in any supplied table. Checks |
762 |
|
|
for uniqueness and blank value. |
763 |
|
|
**********************************************************/ |
764 |
dpavlin |
67 |
function updateSingleField($display, $display_field, $key_field, |
765 |
dpavlin |
1 |
$key_id, $newValue, $table){ |
766 |
dpavlin |
67 |
|
767 |
|
|
msgTableOpen(1, "Updating " . $display . " (ID# " . $key_id . ")"); |
768 |
|
|
printf("<b>Messages:</b><br>\n"); |
769 |
dpavlin |
1 |
|
770 |
|
|
// Error flag |
771 |
|
|
$err_code = 0; |
772 |
|
|
|
773 |
|
|
$newValue_search = textSearchmySQL($newValue); |
774 |
|
|
|
775 |
|
|
// Check to see if already exists |
776 |
dpavlin |
67 |
$exists = recordCount($table, $display_field, $newValue_search, "A"); |
777 |
|
|
$exists_id = lookupField($table, $display_field, $newValue_search, $key_field); |
778 |
dpavlin |
1 |
|
779 |
|
|
// 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) { |
781 |
|
|
$err_code = 1; |
782 |
|
|
$err_msg = "Failed. <b>" . $newValue . "</b> already exists in the <b>" |
783 |
|
|
. $table |
784 |
|
|
. "</b> table.\n"; |
785 |
|
|
} |
786 |
|
|
|
787 |
|
|
// Check for blank entry |
788 |
|
|
if ($newValue == "") { |
789 |
|
|
$err_code = 2; |
790 |
|
|
$err_msg = "Failed. Must supply some value for the <b>" |
791 |
|
|
. $display |
792 |
|
|
. "</b>."; |
793 |
dpavlin |
67 |
} |
794 |
dpavlin |
1 |
|
795 |
|
|
// Continue if no errors |
796 |
|
|
if ($err_code == 0) { |
797 |
|
|
|
798 |
|
|
$newValue_display = $newValue; |
799 |
|
|
$newValue = textInmySQL($newValue); |
800 |
|
|
|
801 |
|
|
// Build the SQL |
802 |
|
|
$sql = "UPDATE " |
803 |
|
|
. $table |
804 |
|
|
. " SET " |
805 |
|
|
. $display_field |
806 |
|
|
. " = '" |
807 |
|
|
. $newValue |
808 |
|
|
. "' WHERE " |
809 |
|
|
. $key_field |
810 |
|
|
. " = " |
811 |
|
|
. $key_id; |
812 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully changed %s to <b>%s</b>.", $display, $newValue_display); |
813 |
dpavlin |
1 |
|
814 |
|
|
} |
815 |
|
|
else printf("%s", $err_msg); |
816 |
|
|
|
817 |
dpavlin |
67 |
printf("<br><br>\n"); |
818 |
|
|
msgTableClose(); |
819 |
dpavlin |
1 |
} |
820 |
|
|
|
821 |
|
|
|
822 |
|
|
/********************************************************** |
823 |
|
|
Function: updateStaff |
824 |
|
|
Author: Paul Bramscher |
825 |
dpavlin |
67 |
Last Modified: 03.15.2004 |
826 |
dpavlin |
1 |
*********************************************************** |
827 |
|
|
Purpose: |
828 |
dpavlin |
67 |
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 |
dpavlin |
1 |
**********************************************************/ |
833 |
dpavlin |
67 |
function updateStaff($access_id, $first_name, |
834 |
|
|
$last_name, $sess_access_level, $staff_account, |
835 |
|
|
$staff_email, $staff_id, $stafftitle_id) { |
836 |
dpavlin |
1 |
|
837 |
|
|
// Error flag |
838 |
|
|
$err_code = 0; |
839 |
|
|
|
840 |
|
|
// Need for display/uniqueness purposes |
841 |
|
|
$staff_account_display = $staff_account; |
842 |
|
|
$staff_account_search = textSearchmySQL($staff_account); |
843 |
|
|
|
844 |
|
|
// Check to see if the staff_account already exists |
845 |
dpavlin |
67 |
$exists = recordCount("staff", "staff_account", $staff_account_search, "A"); |
846 |
|
|
$exists_id = lookupField("staff", "staff_account", $staff_account_search, "staff_id"); |
847 |
dpavlin |
1 |
|
848 |
|
|
if ($exists > 0 && $exists_id != $staff_id) { |
849 |
|
|
$err_code = 1; |
850 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $staff_account_display . "</b> already exists in the Staff table."; |
851 |
dpavlin |
1 |
} |
852 |
|
|
|
853 |
|
|
// Check for blank first name or last name |
854 |
|
|
if ($first_name == "" || $last_name == "") { |
855 |
|
|
$err_code = 2; |
856 |
|
|
$err_msg = "Failed. A first and last name must be supplied for all staff."; |
857 |
|
|
} |
858 |
|
|
|
859 |
|
|
// Check for blank staff_account |
860 |
|
|
if ($staff_account == "") { |
861 |
|
|
$err_code = 3; |
862 |
|
|
$err_msg = "Failed. A staff account must be supplied for all staff."; |
863 |
|
|
} |
864 |
|
|
|
865 |
|
|
// Check for access level higher than current access |
866 |
dpavlin |
67 |
$this_access_level = lookupfield("access", "access_id", $access_id, "access_level"); |
867 |
dpavlin |
1 |
if ($this_access_level > $sess_access_level) { |
868 |
|
|
$err_code = 4; |
869 |
|
|
$err_msg = "Failed. You may not promote staff to higher privileges than your own."; |
870 |
|
|
} |
871 |
|
|
|
872 |
|
|
// Continue only if no errors. |
873 |
|
|
if ($err_code == 0) { |
874 |
|
|
|
875 |
|
|
// Clean up strings |
876 |
|
|
if (strlen($first_name) > 0) $first_name = textInmySQL($first_name); |
877 |
|
|
if (strlen($last_name) > 0) $last_name = textInmySQL($last_name); |
878 |
|
|
if (strlen($staff_account) > 0) $staff_account = textInmySQL($staff_account); |
879 |
|
|
if (strlen($staff_email) > 0) $staff_email = textInmySQL($staff_email); |
880 |
|
|
|
881 |
|
|
// Build the SQL |
882 |
|
|
$sql = "UPDATE staff SET access_id = " |
883 |
|
|
. $access_id |
884 |
|
|
. ", first_name ='" |
885 |
|
|
. $first_name |
886 |
|
|
. "', last_name ='" |
887 |
|
|
. $last_name |
888 |
|
|
. "', stafftitle_id = " |
889 |
|
|
. $stafftitle_id |
890 |
|
|
. ", staff_account = '" |
891 |
|
|
. $staff_account |
892 |
|
|
. "', staff_email = '" |
893 |
|
|
. $staff_email |
894 |
|
|
. "' WHERE staff_id =" |
895 |
|
|
. $staff_id; |
896 |
|
|
|
897 |
dpavlin |
69 |
xx_tryquery ($sql); |
898 |
dpavlin |
67 |
formStaff($staff_id); |
899 |
dpavlin |
1 |
} |
900 |
|
|
else { |
901 |
dpavlin |
67 |
msgTableOpen(1, "Updating Staff ID# " . $staff_id); |
902 |
|
|
printf("<b>Messages:</b><br>\n"); |
903 |
|
|
printf("%s", $err_msg); |
904 |
|
|
printf("<br><br>\n"); |
905 |
|
|
msgTableClose(); |
906 |
dpavlin |
1 |
} |
907 |
|
|
} |
908 |
|
|
|
909 |
|
|
|
910 |
|
|
/********************************************************** |
911 |
|
|
Function: updateStyle |
912 |
|
|
Author: Paul Bramscher |
913 |
dpavlin |
67 |
Last Modified: 03.15.2004 |
914 |
dpavlin |
1 |
*********************************************************** |
915 |
|
|
Purpose: |
916 |
|
|
Update the supplied style id. As with the insert transaction, |
917 |
|
|
no error checking is done to ensure that the supplied files |
918 |
|
|
actually exist and have proper permissions. |
919 |
|
|
**********************************************************/ |
920 |
dpavlin |
67 |
function updateStyle($css_file, $footer_file, $header_file, $style_id, $style_title) { |
921 |
dpavlin |
1 |
|
922 |
dpavlin |
67 |
msgTableOpen(1, "Updating Style ID# " . $style_id); |
923 |
|
|
printf("<b>Messages:</b><br>\n"); |
924 |
|
|
|
925 |
dpavlin |
1 |
// Error flag |
926 |
|
|
$err_code = 0; |
927 |
|
|
|
928 |
|
|
// Need for display/uniqueness |
929 |
|
|
$style_title_display = $style_title; |
930 |
|
|
$style_title_search = textSearchmySQL($style_title); |
931 |
|
|
|
932 |
|
|
// Check to see if already exists under a different style_id |
933 |
dpavlin |
67 |
$exists = recordCount("style", "style_title", $style_title_search, "A"); |
934 |
|
|
$exists_id = lookupField("style", "style_title", $style_title_search, "style_id"); |
935 |
dpavlin |
1 |
|
936 |
|
|
if ($exists > 0 && $exists_id != $style_id) { |
937 |
|
|
$err_code = 1; |
938 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $style_title_display . "</b> already exists in the style table."; |
939 |
dpavlin |
1 |
} |
940 |
|
|
|
941 |
|
|
// Check for blank entry |
942 |
|
|
if ($style_title == "") { |
943 |
|
|
$err_code = 2; |
944 |
|
|
$err_msg = "Failed. Cannot enter a blank style."; |
945 |
|
|
} |
946 |
|
|
|
947 |
|
|
if ($err_code == 0) { |
948 |
|
|
|
949 |
|
|
// Clean up strings |
950 |
|
|
if (strlen($css_file) > 0) $css_file = textInmySQL($css_file); |
951 |
|
|
if (strlen($footer_file) > 0) $footer_file = textInmySQL($footer_file); |
952 |
|
|
if (strlen($header_file) > 0) $header_file = textInmySQL($header_file); |
953 |
|
|
if (strlen($style_title) > 0) $style_title = textInmySQL($style_title); |
954 |
|
|
|
955 |
|
|
// Build the SQL |
956 |
|
|
$sql = "UPDATE style SET style_title = '" |
957 |
|
|
. $style_title |
958 |
|
|
. "', css_file ='" |
959 |
|
|
. $css_file |
960 |
|
|
. "', footer_file ='" |
961 |
|
|
. $footer_file |
962 |
|
|
. "', header_file ='" |
963 |
|
|
. $header_file |
964 |
|
|
. "' WHERE style_id =" |
965 |
|
|
. $style_id; |
966 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> style.", $style_title_display); |
967 |
dpavlin |
1 |
} |
968 |
|
|
else printf("%s", $err_msg); |
969 |
dpavlin |
67 |
|
970 |
dpavlin |
1 |
printf("<br><br>\n"); |
971 |
dpavlin |
67 |
msgTableClose(); |
972 |
dpavlin |
1 |
} |
973 |
|
|
|
974 |
|
|
|
975 |
|
|
/********************************************************** |
976 |
|
|
Function: updateSubject |
977 |
|
|
Author: Paul Bramscher |
978 |
dpavlin |
67 |
Last Modified: 03.16.2004 |
979 |
dpavlin |
1 |
*********************************************************** |
980 |
|
|
Purpose: |
981 |
|
|
Update the supplied subject id, and call formSubject back |
982 |
|
|
again. |
983 |
|
|
**********************************************************/ |
984 |
dpavlin |
67 |
function updateSubject($subject, $subject_descr, $subject_id, $sublocation_id) { |
985 |
dpavlin |
1 |
|
986 |
|
|
// Error flag |
987 |
|
|
$err_code = 0; |
988 |
|
|
|
989 |
|
|
// Need for display/uniqueness purposes |
990 |
|
|
$subject_display = $subject; |
991 |
|
|
$subject_search = textSearchmySQL($subject); |
992 |
|
|
|
993 |
|
|
// Check to see if already exists |
994 |
dpavlin |
67 |
$exists = recordCount("subject", "subject", $subject_search, "A"); |
995 |
|
|
$exists_id = lookupField("subject", "subject", $subject_search, "subject_id"); |
996 |
dpavlin |
1 |
|
997 |
|
|
// 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) { |
999 |
|
|
$err_code = 1; |
1000 |
dpavlin |
67 |
$err_msg = "Failed. <b>" . $subject . "</b> already exists in the subject table."; |
1001 |
dpavlin |
1 |
} |
1002 |
|
|
|
1003 |
|
|
// Check for blank entry |
1004 |
|
|
if ($subject == "") { |
1005 |
|
|
$err_code = 2; |
1006 |
|
|
$err_msg = "Failed. Must supply some value for the subject name."; |
1007 |
|
|
} |
1008 |
|
|
|
1009 |
|
|
// Perform the update only if no errors encountered |
1010 |
|
|
if ($err_code == 0) { |
1011 |
|
|
|
1012 |
|
|
// Clean up strings |
1013 |
|
|
$subject = textInmySQL($subject); |
1014 |
|
|
if (strlen($subject_descr) > 0) $subject_descr = textInmySQL($subject_descr); |
1015 |
|
|
|
1016 |
|
|
// Build the SQL |
1017 |
|
|
$sql = "UPDATE subject SET subject = '" |
1018 |
|
|
. $subject |
1019 |
|
|
. "', subject_descr = '" |
1020 |
|
|
. $subject_descr |
1021 |
|
|
. "', sublocation_id =" |
1022 |
|
|
. $sublocation_id |
1023 |
|
|
. " WHERE subject_id = " . $subject_id; |
1024 |
dpavlin |
69 |
xx_tryquery($sql); |
1025 |
dpavlin |
67 |
formSubject($subject_id); |
1026 |
|
|
} |
1027 |
dpavlin |
1 |
|
1028 |
dpavlin |
67 |
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 |
dpavlin |
1 |
} |
1035 |
dpavlin |
67 |
} |
1036 |
dpavlin |
1 |
|
1037 |
dpavlin |
67 |
|
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 |
dpavlin |
1 |
|
1063 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
|
1075 |
dpavlin |
67 |
// Perform the update only if no errors encountered |
1076 |
|
|
if ($err_code == 0) { |
1077 |
dpavlin |
1 |
|
1078 |
dpavlin |
67 |
// Clean up strings |
1079 |
|
|
$vendor = textInmySQL($vendor); |
1080 |
|
|
if (strlen($vendor_descr) > 0) $vendor_descr = textInmySQL($vendor_descr); |
1081 |
|
|
if (strlen($vendor_message) > 0) $vendor_message = textInmySQL($vendor_message); |
1082 |
|
|
if ($vendor_status < 1) { |
1083 |
|
|
$vendor_status = ""; |
1084 |
|
|
$vendor_message = ""; |
1085 |
|
|
} |
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 |
dpavlin |
69 |
if (xx_tryquery ($sql)) printf("Successfully updated <b>%s</b> vendor.", $vendor_display); |
1099 |
dpavlin |
1 |
} |
1100 |
dpavlin |
67 |
else printf("%s", $err_msg); |
1101 |
|
|
|
1102 |
|
|
printf("<br><br>\n"); |
1103 |
|
|
msgTableClose(); |
1104 |
dpavlin |
1 |
} |
1105 |
dpavlin |
67 |
?> |