1 |
dpavlin |
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 Element 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 |
dpavlin |
67 |
// 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 |
dpavlin |
1 |
// 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 = \"element_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>Element 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 |
|
|
e.page_id, |
76 |
|
|
r.title, |
77 |
|
|
p.page_title, |
78 |
|
|
p.date_created, |
79 |
|
|
p.date_modified, |
80 |
|
|
c.course_concat, |
81 |
|
|
s.first_name, |
82 |
|
|
s.last_name, |
83 |
|
|
t.staff_account |
84 |
|
|
FROM |
85 |
|
|
element e |
86 |
|
|
LEFT JOIN resource r using (resource_id) |
87 |
|
|
LEFT JOIN staff s on e.staff_id = s.staff_id |
88 |
|
|
LEFT JOIN location l on e.location_id = l.location_id |
89 |
|
|
LEFT JOIN service v on e.service_id = v.service_id |
90 |
|
|
LEFT JOIN page p on e.page_id = p.page_id |
91 |
|
|
LEFT JOIN staff t on p.staff_coordinator = t.staff_id |
92 |
|
|
LEFT JOIN course c on e.page_id = c.page_id |
93 |
|
|
WHERE (e.element_id > 0"; |
94 |
|
|
|
95 |
|
|
// If user limited by page title |
96 |
|
|
if ($page_title != ""){ |
97 |
|
|
|
98 |
|
|
$page_title = textSearchmySQL($page_title); |
99 |
|
|
$sql .= " AND (p.page_title LIKE '%" |
100 |
|
|
. $page_title |
101 |
|
|
. "%')"; |
102 |
|
|
|
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
// If user limited by element label |
106 |
|
|
if ($label != ""){ |
107 |
|
|
|
108 |
|
|
$label = textSearchmySQL($label); |
109 |
|
|
$sql .= " AND (e.label LIKE '%" |
110 |
|
|
. $label |
111 |
|
|
. "%')"; |
112 |
|
|
|
113 |
|
|
} |
114 |
|
|
|
115 |
|
|
// If user limited by element url |
116 |
|
|
if ($label_url != ""){ |
117 |
|
|
|
118 |
|
|
$label_url = textSearchmySQL($label_url); |
119 |
|
|
$sql .= " AND (e.label_url LIKE '%" |
120 |
|
|
. $label_url |
121 |
|
|
. "%')"; |
122 |
|
|
|
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
// If user limited by element descr |
126 |
|
|
if ($element_descr != ""){ |
127 |
|
|
|
128 |
|
|
$element_descr = textSearchmySQL($element_descr); |
129 |
|
|
$sql .= " AND (e.element_descr LIKE '%" |
130 |
|
|
. $element_descr |
131 |
|
|
. "%')"; |
132 |
|
|
|
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
// If user limited by resource |
136 |
|
|
if ($resource_id > 1){ |
137 |
|
|
$sql .= " AND (e.resource_id =" |
138 |
|
|
. $resource_id |
139 |
|
|
. ")"; |
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
// If user limited by service |
143 |
|
|
if ($service_id > 1){ |
144 |
|
|
$sql .= " AND (e.service_id =" |
145 |
|
|
. $service_id |
146 |
|
|
. ")"; |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
// If user limited by location |
150 |
|
|
if ($location_id > 1){ |
151 |
|
|
$sql .= " AND (e.location_id =" |
152 |
|
|
. $location_id |
153 |
|
|
. ")"; |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
|
157 |
|
|
// If user limited by staff-as-element |
158 |
|
|
if ($staff_id > 1){ |
159 |
|
|
$sql .= " AND (e.staff_id =" |
160 |
|
|
. $staff_id |
161 |
|
|
. ")"; |
162 |
|
|
} |
163 |
|
|
|
164 |
|
|
// cap it off |
165 |
|
|
$sql .= ")"; |
166 |
|
|
|
167 |
|
|
|
168 |
|
|
// Order by |
169 |
|
|
if ($orderby !="" && $orderdir != ""){ |
170 |
|
|
$sql .= " ORDER BY " . $orderby . " " . $orderdir; |
171 |
|
|
} |
172 |
|
|
|
173 |
|
|
// Debugging |
174 |
|
|
// printf("sql was: %s<BR>", $sql); |
175 |
|
|
|
176 |
dpavlin |
69 |
$rs = xx_tryquery($sql); |
177 |
dpavlin |
1 |
|
178 |
|
|
// Table |
179 |
|
|
printf("<center><table width=\"90%%\" border =\"1\" bgcolor =\"#ffffff\" cellpadding=\"4\">"); |
180 |
|
|
|
181 |
|
|
// Page ID |
182 |
|
|
printf("<tr><td width = \"5%%\" class=\"cellPlain\">\n"); |
183 |
|
|
printf("Page ID#"); |
184 |
|
|
printf("</td>\n"); |
185 |
|
|
|
186 |
|
|
// Edit |
187 |
|
|
printf("<td width=\"10%%\" align=\"center\" class=\"cellPlain\">Command</td>\n"); |
188 |
|
|
|
189 |
|
|
// Page coordinator |
190 |
|
|
printf("<td width=\"20%%\" class=\"cellPlain\">Coordinator ID</td>\n"); |
191 |
|
|
|
192 |
|
|
// Page/Course Title |
193 |
|
|
printf("<td width = \"45%%\" class=\"cellPlain\">\n"); |
194 |
|
|
printf("Page/Course Title"); |
195 |
|
|
printf("</td>\n"); |
196 |
|
|
|
197 |
|
|
// Date created |
198 |
|
|
printf("<td width = \"10%%\" class=\"cellPlain\">\n"); |
199 |
|
|
printf("Created"); |
200 |
|
|
printf("</td>\n"); |
201 |
|
|
|
202 |
|
|
// Date created |
203 |
|
|
printf("<td width = \"10%%\" class=\"cellPlain\">\n"); |
204 |
|
|
printf("Modified"); |
205 |
|
|
printf("</td>\n"); |
206 |
|
|
|
207 |
|
|
// Close row |
208 |
|
|
printf("</tr>\n"); |
209 |
|
|
|
210 |
|
|
// Initialize counter |
211 |
|
|
$rowcount = 0; |
212 |
|
|
|
213 |
|
|
// Cycle through the result set |
214 |
dpavlin |
69 |
while ( $row = xx_fetch_array ($rs, xx_ASSOC)) { |
215 |
dpavlin |
1 |
$page_id = $row["page_id"]; |
216 |
|
|
$page_title = Trim($row["page_title"]); |
217 |
|
|
$date_created = substr($row["date_created"], 0, 10); |
218 |
|
|
$date_modified = substr($row["date_modified"], 0, 10); |
219 |
|
|
$course_concat = Trim($row["course_concat"]); |
220 |
|
|
|
221 |
|
|
$first_name = Trim($row["first_name"]); |
222 |
|
|
$last_name = Trim($row["last_name"]); |
223 |
|
|
$staff_account = Trim($row["staff_account"]); |
224 |
|
|
|
225 |
|
|
// New row |
226 |
|
|
if ($rowcount % 2 == 0) $color = " class=\"backLight\" "; |
227 |
|
|
else $color =""; |
228 |
|
|
|
229 |
|
|
// Use full course name if this is a coursescribe page |
230 |
|
|
if (strlen($course_concat) > 0) $page_title = $course_concat; |
231 |
|
|
|
232 |
|
|
// Pull out any HTML |
233 |
|
|
$page_title = strip_tags($page_title); |
234 |
|
|
|
235 |
|
|
// Page id |
236 |
|
|
printf("<tr>"); |
237 |
|
|
printf("<td width=\"5%%\" %s>\n", $color); |
238 |
|
|
printf("<a href=\"%spage.phtml?page_id=%d\">%d</a>\n",$GLOBAL_SCRIBE_URL, $page_id, $page_id); |
239 |
|
|
printf("</td>\n"); |
240 |
|
|
|
241 |
|
|
// Edit/View command |
242 |
|
|
printf("<td width=\"10%%\"align=\"center\" %s>\n", $color); |
243 |
|
|
printf("<a href=\"%spage.phtml?page_id=%d\">View</a> | ",$GLOBAL_SCRIBE_URL, $page_id); |
244 |
|
|
printf("<a href=\"scribe.phtml?page_id=" |
245 |
|
|
. $page_id |
246 |
|
|
. "\">Edit</a>\n"); |
247 |
|
|
printf("</td>\n"); |
248 |
|
|
|
249 |
|
|
// Staff Coordinator |
250 |
|
|
printf("<td width=\"20%%\" %s>%s</td>\n", $color, $staff_account); |
251 |
|
|
|
252 |
|
|
// Title |
253 |
|
|
printf("<td width=\"45%%\" %s>%s</td>\n", $color, $page_title); |
254 |
|
|
|
255 |
|
|
// Date created |
256 |
|
|
printf("<td width=\"10%%\" %s>%s</td>\n", $color, $date_created); |
257 |
|
|
|
258 |
|
|
// Date last modified |
259 |
|
|
printf("<td width=\"10%%\" %s>%s</td>\n", $color, $date_modified); |
260 |
|
|
|
261 |
|
|
// Close row |
262 |
|
|
printf("</tr>\n"); |
263 |
|
|
|
264 |
|
|
// Increment counter |
265 |
|
|
$rowcount++; |
266 |
|
|
|
267 |
|
|
} |
268 |
|
|
|
269 |
|
|
// Search statistics |
270 |
|
|
printf("<tr><td align = \"right\" colspan =\"6\" class=\"backLight\">"); |
271 |
|
|
$records = "record"; |
272 |
dpavlin |
69 |
printf("<BR>Returned %d ", xx_num_rows($rs)); |
273 |
|
|
if (xx_num_rows($rs) != 1) $records .= "s"; |
274 |
dpavlin |
1 |
printf($records); |
275 |
|
|
printf("."); |
276 |
|
|
|
277 |
|
|
// Close off the table |
278 |
|
|
printf ("</td></tr></table></center><BR>"); |
279 |
|
|
|
280 |
|
|
} |
281 |
|
|
|
282 |
|
|
printf("<center>"); |
283 |
|
|
|
284 |
|
|
// Error trapping |
285 |
|
|
// No search criteria supplied |
286 |
|
|
if ($problem == 2) printf ("No search criteria supplied. Please go back and select some criteria.<br><br"); |
287 |
|
|
|
288 |
|
|
printf("</center>"); |
289 |
|
|
|
290 |
|
|
// Link to return to admin console |
291 |
|
|
adminReturn($sess_access_level); |
292 |
|
|
|
293 |
|
|
} // logged in |
294 |
|
|
|
295 |
|
|
// No access page |
296 |
|
|
else require_once ($GLOBAL_NO_ACCESS); |
297 |
|
|
|
298 |
|
|
|
299 |
|
|
// Page footer |
300 |
|
|
require_once ($GLOBAL_ADMIN_FOOTER); |
301 |
|
|
?> |
302 |
|
|
|
303 |
|
|
</body> |
304 |
|
|
</html> |