/[libdata]/trunk/admin/page_results_brief.phtml
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/admin/page_results_brief.phtml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (show annotations)
Thu Mar 18 20:33:37 2004 UTC (20 years ago) by dpavlin
File size: 10386 byte(s)
changes made in version 2.00

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
12 // HTML header
13 printf("<HTML>\n");
14 printf("<HEAD>\n");
15 printf("<title>PageScribe-CourseLib Search Results</title>\n");
16 printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS);
17 printf("</HEAD>\n");
18
19
20 // Default access settings
21 $sess_time_human = "";
22 $sess_staff_account = "";
23 $sess_staff_id = 0;
24 $sess_access_level = 0;
25 $sess_access = "";
26 $sess_last_name = "";
27 $sess_first_name = "";
28
29
30 // Page header
31 require_once ($GLOBAL_ADMIN_HEADER);
32
33
34 // Collect access information
35 if(isset($libsession)) {
36
37 // Fetch session information
38 $sessionClass = new sessionClass("", $libsession, "", "");
39 $accessClass = new accessClass($sessionClass);
40
41 // Load user session variables
42 $sess_time_human = $sessionClass->time_human;
43 $sess_staff_account = $sessionClass->staff_account;
44 $sess_access_level = $accessClass->access_level;
45 $sess_access = $accessClass->access;
46 $sess_last_name = $accessClass->last_name;
47 $sess_first_name = $accessClass->first_name;
48
49 }
50
51 // If the cookie is set and access level is appropriate
52 if(isset($libsession) && $sess_access_level >= 20) {
53
54 // Orderby field function
55 function orderByField($noOrderSQL, $field_name, $validated){
56 $finalSQL = $noOrderSQL . " ORDER BY " . $field_name;
57 printf("<form method = \"POST\" action = \"page_results_brief.phtml\" >\n");
58 printf("<input type = \"Submit\" value = \"Sort\" >", $field_name);
59 printf("</form><br>\n");
60 }
61
62 // Display page heading
63 printf("<center><h3>Search Results</h3>\n");
64
65 // Set up a flagging variable to track possible problems with the search parameters
66 $problem = 0;
67
68 // Algorithm is cleared to search
69 if ($problem < 1) {
70
71 /* Select a distinct row of reference information, but build the extra
72 joins in case the user wants to limit by additional criteria. */
73
74 $sql = "SELECT DISTINCT
75 p.page_id,
76 p.page_title,
77 p.account_created,
78 p.account_modified,
79 p.date_created,
80 p.date_modified,
81 p.staff_coordinator,
82 c.course_concat,
83 c.course_id,
84 s.first_name,
85 s.last_name,
86 s.staff_account
87
88 FROM
89 page p
90 LEFT JOIN course c using (page_id)
91 LEFT JOIN staff s on p.staff_coordinator = s.staff_id ";
92
93 // Dont' join with course_personnel unless we must. This, of course, is not very profound.
94 if (strlen($pers_lastname) > 1 || $faculty_id > 0 || $pers_staff_id > 0) $sql .= "LEFT JOIN course_personnel cp on c.course_id = cp.course_id ";
95
96 $sql .= "LEFT JOIN page_staff ps on p.page_id = ps.page_id
97
98 WHERE (
99 ( p.page_id > 0 ) ";
100
101
102 // If user limited by course introductory text
103 if (strlen($intro_text) > 1){
104
105 $intro_text = textSearchmySQL($intro_text);
106 $sql .= " AND (c.introheader1 LIKE '%"
107 . $intro_text
108 . "%' OR c.introheader2 LIKE '%"
109 . $intro_text
110 . "%' OR c.intromessage1 LIKE '%"
111 . $intro_text
112 . "%' OR c.intromessage2 LIKE '%"
113 . $intro_text
114 . "%')";
115 }
116
117 // If user limited by page title
118 if ($page_title !=""){
119
120 $page_title = textSearchmySQL($page_title);
121 $sql .= " AND (p.page_title LIKE '%"
122 . $page_title
123 . "%')";
124 }
125
126 // If user limited by date created
127 if ($date_created !=""){
128
129 $date_created = textSearchmySQL($date_created);
130 $sql .= " AND (p.date_created LIKE '%"
131 . $date_created
132 . "%')";
133 }
134
135 // If user limited by date modified
136 if ($date_modified !=""){
137
138 $date_modified = textSearchmySQL($date_modified);
139 $sql .= " AND (p.date_modified LIKE '%"
140 . $date_modified
141 . "%')";
142 }
143
144 // If user limited by staff coordinator
145 if ($staff_coordinator > 1){
146 $sql .= " AND (p.staff_coordinator ="
147 . $staff_coordinator
148 . ")";
149 }
150
151 // If user limited by staff co-maintainer
152 if ($comaintainer_id > 1){
153 $sql .= " AND (ps.staff_id ="
154 . $comaintainer_id
155 . ")";
156 }
157
158 // If user limited by page type
159 if ($pagetype_id > 1){
160 $sql .= " AND (p.pagetype_id ="
161 . $pagetype_id
162 . ")";
163 }
164
165 // If user limited by faculty_id or TA/Other instructor. These are all LEFT JOIN special cases.
166 if ($faculty_id > 0 || $pers_staff_id > 0 || strlen($pers_lastname) > 1){
167
168 /*
169 We need this section regrettably. The problem is in joining to
170 course_personnel. We can't simply AND conditions to it since
171 a particular row can't be both a staff, faculty, and TA/Other.
172 It is only one of the above. Adding AND's affect the same row, and will
173 automatically revert to false. If you can visualize this problem, you're
174 good -- very good. Otherwise, look ye upon this code and despair!
175 */
176
177 // Flag it to TRUE when the first clause is found.
178 $cp_flag = 0;
179
180 // Check for faculty_id first
181 if ($faculty_id > 0) {
182 $sql .= " AND (cp.faculty_id = " . $faculty_id;
183 $cp_flag = 1;
184 }
185
186 // Check for staff_id (as course personnel) next. Determine whether to AND or OR
187 if ($pers_staff_id > 0) {
188 if ($cp_flag == 0) {
189 $sql .= " AND (cp.staff_id = " . $pers_staff_id;
190 $cp_flag = 1;
191 }
192 else $sql .= " OR cp.staff_id = " . $pers_staff_id;
193 }
194
195 // Check for instructor personnel last name
196 if (strlen($pers_lastname) > 0) {
197 if ($cp_flag == 0) {
198
199 $pers_lastname = textSearchmySQL($pers_lastname);
200 $sql .= " AND (cp.pers_lastname LIKE '%" . $pers_lastname . "%'";
201 $cp_flag = 1;
202 }
203 else $sql .= " OR cp.pers_lastname LIKE '%" . $pers_lastname . "%'";
204 }
205
206 // At some point above we've added a paren, so close it.
207 $sql .= ")";
208
209 } // limited by course personnel
210
211 // If user limited by account (x500 if applicable) created
212 if (strlen($account_created) > 1){
213
214 $account_created = textSearchmySQL($account_created);
215 $sql .= " AND (p.account_created ='"
216 . $account_created
217 . "')";
218 }
219
220 // If user limited by account (x500 if applicable) modified
221 if (strlen($account_modified) > 1){
222
223 $account_modified = textSearchmySQL($account_modified);
224 $sql .= " AND (p.account_modified ='"
225 . $account_modified
226 . "')";
227 }
228
229 // If user limited by course subject id
230 if ($coursesub_id > 0){
231 $sql .= " AND (c.coursesub_id ="
232 . $coursesub_id
233 . ")";
234 }
235
236 // If user limited by campus_id
237 if ($campus_id > 0){
238 $sql .= " AND (c.campus_id ="
239 . $campus_id
240 . ")";
241 }
242
243 // If user limited by term_id
244 if ($term_id > 0){
245 $sql .= " AND (c.term_id ="
246 . $term_id
247 . ")";
248 }
249
250 // If user limited by course year
251 if (strlen($course_year) > 1){
252
253 $course_year = textSearchmySQL($course_year);
254 $sql .= " AND (c.course_year ='"
255 . $course_year
256 . "')";
257 }
258
259 // cap it off
260 $sql .= ")";
261
262 // Order by
263 if ($orderby !="" && $orderdir != ""){
264 $sql .= " ORDER BY " . $orderby . " " . $orderdir;
265 }
266
267 $rs = xx_tryquery ($sql);
268
269 // Table
270 printf("<center><table width=\"90%%\" border =\"1\" bgcolor =\"#ffffff\" cellpadding=\"4\">");
271
272 // Page ID
273 printf("<tr><td width = \"5%%\" class=\"cellPlain\">\n");
274 printf("Page ID#");
275 printf("</td>\n");
276
277 // Edit
278 printf("<td width=\"10%%\" align=\"center\" class=\"cellPlain\">Command</td>\n");
279
280 // Page coordinator
281 printf("<td width=\"20%%\" class=\"cellPlain\">Coordinator</td>\n");
282
283 // Page/Course Title
284 printf("<td width = \"45%%\" class=\"cellPlain\">\n");
285 printf("Page/Course Title");
286 printf("</td>\n");
287
288 // Date created
289 printf("<td width = \"10%%\" class=\"cellPlain\">\n");
290 printf("Created");
291 printf("</td>\n");
292
293 // Date modified
294 printf("<td width = \"10%%\" class=\"cellPlain\">\n");
295 printf("Modified");
296 printf("</td>\n");
297
298 // Close row
299 printf("</tr>\n");
300
301 // Initialize counter
302 $rowcount = 0;
303
304 // Cycle through the result set
305 while ( $row = xx_fetch_array ($rs, xx_ASSOC)) {
306 $page_id = $row["page_id"];
307 $page_title = Trim($row["page_title"]);
308 $date_created = substr($row["date_created"], 0, 10);
309 $date_modified = substr($row["date_modified"], 0, 10);
310 $course_concat = Trim($row["course_concat"]);
311
312 $first_name = Trim($row["first_name"]);
313 $last_name = Trim($row["last_name"]);
314 $staff_account = Trim($row["staff_account"]);
315
316 $staff_display = $first_name . " " . $last_name . " (" . $staff_account . ")";
317
318
319 // New row
320 if ($rowcount % 2 == 0) $color = " class=\"backLight\" ";
321 else $color ="";
322
323 // Use full course name if this is a coursescribe page
324 if (strlen($course_concat) > 0) $page_title = $course_concat;
325
326 // Pull out any HTML
327 $page_title = strip_tags($page_title);
328
329 // Page id
330 printf("<tr>");
331 printf("<td width=\"5%%\" %s>\n", $color);
332 printf("<a href=\"%spage.phtml?page_id=%d\">%d</a>\n",$GLOBAL_SCRIBE_URL, $page_id, $page_id);
333 printf("</td>\n");
334
335 // Edit/View command
336 printf("<td width=\"10%%\"align=\"center\" %s>\n", $color);
337 printf("<a href=\"%spage.phtml?page_id=%d\">View</a> | ",$GLOBAL_SCRIBE_URL, $page_id);
338 printf("<a href=\"scribe.phtml?page_id="
339 . $page_id
340 . "\">Edit</a>\n");
341 printf("</td>\n");
342
343 // Staff Coordinator
344 printf("<td width=\"20%%\" %s>%s</td>\n", $color, $staff_display);
345
346 // Title
347 printf("<td width=\"45%%\" %s>%s</td>\n", $color, $page_title);
348
349 // Date created
350 printf("<td width=\"10%%\" %s>%s</td>\n", $color, $date_created);
351
352 // Date last modified
353 printf("<td width=\"10%%\" %s>%s</td>\n", $color, $date_modified);
354
355 // Close row
356 printf("</tr>\n");
357
358 // Increment counter
359 $rowcount++;
360
361 }
362
363 // Search statistics
364 printf("<tr><td align = \"right\" colspan =\"6\" class=\"backLight\">");
365 $records = "record";
366 printf("<BR>Returned %d ", xx_num_rows($rs));
367 if (xx_num_rows($rs) != 1) $records .= "s";
368 printf($records);
369 printf(".");
370
371 // Close off the table
372 printf ("</td></tr></table></center><BR>");
373
374 }
375
376 printf("<center>");
377
378 // Error trapping
379 // No search criteria supplied
380 if ($problem == 2) printf ("No search criteria supplied. Please go back and select some criteria.<br><br");
381
382 printf("</center>");
383
384 // Link to return to admin console
385 adminReturn($sess_access_level);
386
387 } // logged in
388
389 // No access page
390 else require_once ($GLOBAL_NO_ACCESS);
391
392
393 // Page footer
394 require_once ($GLOBAL_ADMIN_FOOTER);
395 ?>
396
397 </body>
398 </html>

  ViewVC Help
Powered by ViewVC 1.1.26