1 |
<?php |
2 |
// Load globals |
3 |
require_once ("global_vars.php"); |
4 |
|
5 |
// Includes |
6 |
require_once ($GLOBAL_ADMIN_INC."sessionClass.php"); |
7 |
require_once ($GLOBAL_ADMIN_INC."accessClass.php"); |
8 |
require_once ($GLOBAL_ADMIN_INC."db_connect.php"); |
9 |
require_once ($GLOBAL_ADMIN_INC."app_controls.php"); |
10 |
|
11 |
// HTML header |
12 |
printf("<HTML>\n"); |
13 |
printf("<HEAD>\n"); |
14 |
printf("<title>Resource Search Results</title>\n"); |
15 |
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS); |
16 |
printf("</HEAD>\n"); |
17 |
|
18 |
|
19 |
// Page header |
20 |
require_once ($GLOBAL_ADMIN_HEADER); |
21 |
|
22 |
|
23 |
// Collect access information |
24 |
if(isset($libsession)) { |
25 |
|
26 |
// Fetch session information |
27 |
$sessionClass = new sessionClass("", $libsession, "", ""); |
28 |
$accessClass = new accessClass($sessionClass); |
29 |
|
30 |
// Load user session variables |
31 |
$sess_time_human = $sessionClass->time_human; |
32 |
$sess_staff_account = $sessionClass->staff_account; |
33 |
$sess_access_level = $accessClass->access_level; |
34 |
$sess_access = $accessClass->access; |
35 |
$sess_last_name = $accessClass->last_name; |
36 |
$sess_first_name = $accessClass->first_name; |
37 |
|
38 |
} |
39 |
|
40 |
// If the cookie is set and access level is appropriate |
41 |
if(isset($libsession) && $sess_access_level >= 20) { |
42 |
|
43 |
// Display page heading |
44 |
printf("<center><h3>Resource Search Results</h3>\n"); |
45 |
|
46 |
// Set up a flagging variable to track possible problems with the search parameters |
47 |
$problem = 0; |
48 |
|
49 |
// Make sure some criteria was chosen (i.e. we don't want to return ALL records) |
50 |
// However, a "*" for record_id means a wildcard. |
51 |
|
52 |
if ($account_created == "" && $account_modified == "" && $subject == "" && $author == "" && $annotation == "" && $subject_id < 1 && $title == "" && |
53 |
$date_created == "" && $date_modified == "" && $location =="" && $location_id < 1 && |
54 |
$infotype_id =="" && $resource_id < 1 && $resource_id != "*" && $cat_num < 1 && $url =="" && $call_no =="" && $feature_id < 1) $problem = 2; |
55 |
if ($resource_id == "*") $resource_id = ""; |
56 |
|
57 |
// Algorithm is cleared to search |
58 |
if ($problem < 1) { |
59 |
|
60 |
// Clean up strings |
61 |
//if (strlen($annotation) > 0) $annotation = textInmySQL($annotation); |
62 |
//if (strlen($author) > 0) $author = textInmySQL($author); |
63 |
//if (strlen($call_no) > 0) $call_no = textInmySQL($call_no); |
64 |
//if (strlen($cat_num) > 0) $cat_num = textInmySQL($cat_num); |
65 |
//if (strlen($coverage_detail) > 0) $coverage_detail = textInmySQL($coverage_detail); |
66 |
//if (strlen($edition) > 0) $edition = textInmySQL($edition); |
67 |
//if (strlen($other_title) > 0) $other_title = textInmySQL($other_title); |
68 |
//if (strlen($pub_date) > 0) $pub_date = textInmySQL($pub_date); |
69 |
//if (strlen($publisher) > 0) $publisher = textInmySQL($publisher); |
70 |
//if (strlen($sources_indexed) > 0) $sources_indexed = textInmySQL($sources_indexed); |
71 |
//if (strlen($title)> 0) $title = textInHTML($title); |
72 |
//if (strlen($url) > 0) $url = textInmySQL($url); |
73 |
|
74 |
|
75 |
/* Select a distinct row of reference information, but build the extra |
76 |
joins in case the user wants to limit by additional criteria. */ |
77 |
|
78 |
$sql = "SELECT DISTINCT |
79 |
r.resource_id, |
80 |
r.date_created, |
81 |
r.date_modified, |
82 |
r.title, |
83 |
r.annotation, |
84 |
r.cat_num, |
85 |
r.call_no, |
86 |
r.publisher, |
87 |
r.pub_date, |
88 |
r.author, |
89 |
r.url |
90 |
|
91 |
FROM |
92 |
resource r |
93 |
LEFT JOIN res_loc rl using (resource_id) "; |
94 |
|
95 |
if ($feature_id > 0) $sql .= |
96 |
"LEFT JOIN res_feature rf on r.resource_id = rf.resource_id "; |
97 |
|
98 |
$sql .="WHERE ( |
99 |
( r.resource_id > 0 ) "; |
100 |
|
101 |
// If user limited by author |
102 |
if ($author != ""){ |
103 |
|
104 |
$author = textSearchmySQL($author); |
105 |
$sql .= " AND (r.author LIKE '%" . $author . "%')"; |
106 |
} |
107 |
|
108 |
// If user limited by annotation keyword or phrase |
109 |
if ($annotation != ""){ |
110 |
|
111 |
$annotation = textSearchmySQL($annotation); |
112 |
$sql .= " AND (r.annotation LIKE '%" . $annotation . "%')"; |
113 |
} |
114 |
|
115 |
// If user limited by feature id |
116 |
if ($feature_id > 0){ |
117 |
$sql .= " AND (rf.feature_id =" |
118 |
. $feature_id |
119 |
. ")"; |
120 |
} |
121 |
|
122 |
// If user limited by url |
123 |
if ($url != ""){ |
124 |
|
125 |
$url = textSearchmySQL($url); |
126 |
$sql .= " AND (r.url LIKE '%" . $url . "%')"; |
127 |
} |
128 |
|
129 |
// If user limited by title |
130 |
if ($title !=""){ |
131 |
|
132 |
$title = textSearchmySQL($title); |
133 |
$sql .= " AND (r.title LIKE '%" |
134 |
. $title |
135 |
. "%')"; |
136 |
} |
137 |
|
138 |
// If user limited by date created |
139 |
if ($date_created !=""){ |
140 |
|
141 |
$date_created = textSearchmySQL($date_created); |
142 |
$sql .= " AND (r.date_created LIKE '%" |
143 |
. $date_created |
144 |
. "%')"; |
145 |
} |
146 |
|
147 |
// If user limited by date modified |
148 |
if ($date_modified !=""){ |
149 |
|
150 |
$date_modified = textSearchmySQL($date_modified); |
151 |
$sql .= " AND (r.date_modified LIKE '%" |
152 |
. $date_modified |
153 |
. "%')"; |
154 |
} |
155 |
|
156 |
// If user limited by pub date |
157 |
if ($pub_date !=""){ |
158 |
|
159 |
$pub_date = textSearchmySQL($pub_date); |
160 |
$sql .= " AND (r.pub_date ='" |
161 |
. $pub_date |
162 |
. "')"; |
163 |
} |
164 |
|
165 |
// If user limited by information type id |
166 |
if ($infotype_id > 0){ |
167 |
$sql .= " AND (r.infotype_id =" |
168 |
. $infotype_id |
169 |
. ")"; |
170 |
} |
171 |
|
172 |
// If user limited by location id |
173 |
if ($location_id > 0){ |
174 |
$sql .= " AND (rl.location_id =" |
175 |
. $location_id |
176 |
. ")"; |
177 |
} |
178 |
|
179 |
// If user limited by call number |
180 |
if ($call_no !=""){ |
181 |
|
182 |
$call_no = textSearchmySQL($call_no); |
183 |
$sql .= " AND (r.call_no LIKE '%" |
184 |
. $call_no |
185 |
. "%')"; |
186 |
} |
187 |
|
188 |
// If user limited by resource id |
189 |
if ($resource_id !=""){ |
190 |
// Cast as integer to avoid possible problems |
191 |
$resource_id = (int) $resource_id; |
192 |
$sql .= " AND (r.resource_id = " |
193 |
. $resource_id |
194 |
. ")"; |
195 |
} |
196 |
|
197 |
// If user limited by catalog number |
198 |
if ($cat_num !=""){ |
199 |
|
200 |
$cat_num = textSearchmySQL($cat_num); |
201 |
$sql .= " AND (r.cat_num ='" |
202 |
. $cat_num |
203 |
. "')"; |
204 |
} |
205 |
|
206 |
// If user limited by account_created |
207 |
if ($account_created !=""){ |
208 |
|
209 |
$account_created = textSearchmySQL($account_created); |
210 |
$sql .= " AND (r.account_created ='" |
211 |
. $account_created |
212 |
. "')"; |
213 |
} |
214 |
|
215 |
// If user limited by account_modified |
216 |
if ($account_modified !=""){ |
217 |
|
218 |
$account_modified = textSearchmySQL($account_modified); |
219 |
$sql .= " AND (r.account_modified ='" |
220 |
. $account_modified |
221 |
. "')"; |
222 |
} |
223 |
|
224 |
// cap it off |
225 |
$sql .= ")"; |
226 |
|
227 |
// Order by |
228 |
if ($orderby !="" && $orderdir != ""){ |
229 |
$sql .= " ORDER BY " . $orderby . " " . $orderdir; |
230 |
} |
231 |
|
232 |
// Debugging |
233 |
//printf("sql was: %s<BR>", $sql); |
234 |
|
235 |
|
236 |
if ( !$rs = xx_query ( $sql, $con ) ) { |
237 |
sql_err ( $sql ) And bailout(); |
238 |
} |
239 |
|
240 |
// Table |
241 |
printf("<center><table width=\"90%%\" border =\"1\" bgcolor =\"#ffffff\" cellpadding=\"4\">"); |
242 |
|
243 |
// Row header |
244 |
printf("<tr><td width = \"10%%\" class=\"cellPlain\">\n"); |
245 |
printf("ID#"); |
246 |
printf("</td>\n"); |
247 |
|
248 |
printf("<td class=\"cellPlain\">Cmd</td>\n"); |
249 |
|
250 |
printf("<td width = \"20%%\" class=\"cellPlain\">\n"); |
251 |
printf("Usage Drilldown"); |
252 |
printf("</td>\n"); |
253 |
|
254 |
printf("<td width = \"70%%\" class=\"cellPlain\">\n"); |
255 |
printf("Resource"); |
256 |
printf("</td></tr>\n"); |
257 |
|
258 |
// Initialize counter |
259 |
$rowcount = 0; |
260 |
|
261 |
// Cycle through the result set of unique reference id's. |
262 |
while ( $row = xx_fetch_array ( $rs ) ) { |
263 |
$resource_id = $row["resource_id"]; |
264 |
$title = Trim($row["title"]); |
265 |
$publisher = Trim($row["publisher"]); |
266 |
$pub_date = Trim($row["pub_date"]); |
267 |
$record_id = Trim($row["record_id"]); |
268 |
$cat_num = Trim($row["cat_num"]); |
269 |
$annotation = Trim($row["annotation"]); |
270 |
$author = Trim($row["author"]); |
271 |
$call_no = Trim($row["call_no"]); |
272 |
$url = Trim($row["url"]); |
273 |
|
274 |
// Make every other row colored |
275 |
if ($rowcount % 2 == 0) $color = " class=\"backLight\" "; |
276 |
else $color = ""; |
277 |
|
278 |
// For display purposes |
279 |
if (strlen($url) > 1 && strlen($call_no) < 1) { |
280 |
$call_no = "<a href = \" " . $url . " \" >" . $url . "</a>"; |
281 |
$call_no_label = "URL"; |
282 |
} |
283 |
else $call_no_label = "Call No."; |
284 |
if (strlen($title) < 1) $title = " "; |
285 |
if (strlen($pub_date) < 1) $pub_date = " "; |
286 |
|
287 |
// Resource ID # |
288 |
printf("<tr>"); |
289 |
printf("<td width = \"10%%\" %s>\n", $color); |
290 |
printf("%d ", $resource_id); |
291 |
printf("</td>\n"); |
292 |
|
293 |
printf("<td align=\"center\" %s>\n", $color); |
294 |
printf("<a href=\"operation.phtml?operation=Edit&table=resource&key_id=" |
295 |
. $resource_id |
296 |
. "\">Edit</a>"); |
297 |
printf("</td>\n"); |
298 |
|
299 |
// Detail page |
300 |
printf("<td width = \"20%%\" %s>\n", $color); |
301 |
printf("<a href=\"res_drill.phtml?resource_id=%d\">[Drilldown]</a>\n", $resource_id); |
302 |
printf("</td>\n"); |
303 |
|
304 |
// Resource |
305 |
printf("<td width = \"70%%\" %s>\n", $color); |
306 |
printf("Title: %s<BR>", $title); |
307 |
if (strlen($author) > 0) printf("Author: %s<br>", $author); |
308 |
if (strlen($call_no) > 0) printf("%s: %s<br>", $call_no_label, $call_no); |
309 |
printf("</td></tr>\n"); |
310 |
|
311 |
// Increment counter |
312 |
$rowcount++; |
313 |
} |
314 |
|
315 |
// Search statistics |
316 |
printf("<tr><td align = \"right\" colspan =\"4\" class=\"backLight\">\n"); |
317 |
$records = "record"; |
318 |
printf("<BR>Returned %d ", xx_num_rows($rs)); |
319 |
if (xx_num_rows($rs) != 1) $records .= "s"; |
320 |
printf($records); |
321 |
printf("."); |
322 |
|
323 |
// Close off the table |
324 |
printf ("</td></tr></table></center><BR>\n"); |
325 |
|
326 |
} |
327 |
|
328 |
printf("<center>\n"); |
329 |
|
330 |
// Error trapping |
331 |
// No search criteria supplied |
332 |
if ($problem == 2) printf ("No search criteria supplied. Please go back and select some criteria.<br><br>\n"); |
333 |
|
334 |
printf("</center>\n"); |
335 |
|
336 |
// Link to return to admin console |
337 |
adminReturn($sess_access_level); |
338 |
|
339 |
} // logged in |
340 |
|
341 |
|
342 |
// No access |
343 |
else require_once ($GLOBAL_NO_ACCESS); |
344 |
|
345 |
|
346 |
// Page footer |
347 |
require_once ($GLOBAL_ADMIN_FOOTER); |
348 |
?> |
349 |
|
350 |
</body> |
351 |
</html> |