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>Resource Drilldown</title>\n"); |
16 |
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS); |
17 |
printf("</HEAD>\n"); |
18 |
|
19 |
|
20 |
// Page header |
21 |
require_once ($GLOBAL_ADMIN_HEADER); |
22 |
|
23 |
|
24 |
// Collect access information |
25 |
if(isset($libsession)) { |
26 |
|
27 |
// Fetch session information |
28 |
$sessionClass = new sessionClass("", $libsession, "", ""); |
29 |
$accessClass = new accessClass($sessionClass); |
30 |
|
31 |
// Load user session variables |
32 |
$sess_time_human = $sessionClass->time_human; |
33 |
$sess_staff_account = $sessionClass->staff_account; |
34 |
$sess_access_level = $accessClass->access_level; |
35 |
$sess_access = $accessClass->access; |
36 |
$sess_last_name = $accessClass->last_name; |
37 |
$sess_first_name = $accessClass->first_name; |
38 |
|
39 |
} |
40 |
|
41 |
// If the cookie is set and access level is appropriate |
42 |
if(isset($libsession) && $sess_access_level >= 20) { |
43 |
|
44 |
// Initialize |
45 |
$exists = 0; |
46 |
|
47 |
// Cast as integer to be sure |
48 |
$resource_id = (int) $resource_id; |
49 |
|
50 |
// Check to see if resource exists |
51 |
$exists = existsRow($con, "resource", "resource_id", $resource_id); |
52 |
|
53 |
// If resource exists |
54 |
if ($exists > 0) { |
55 |
|
56 |
// Fetch the resource title |
57 |
$title = lookupField($con, "resource", "resource_id", $resource_id, "title"); |
58 |
|
59 |
printf("<center>\n"); |
60 |
printf("<h3>Resource Title '%s' (#%d) used on the following:</h3>", $title, $resource_id); |
61 |
|
62 |
|
63 |
// RQS Usage Drilldowns |
64 |
printf("<table width = \"75%%\" border=\"1\"><tr>\n"); |
65 |
printf("<td width=\"40%%\" class=\"cellPlain\">RQS Subject Page(s)</td>\n"); |
66 |
printf("<td width=\"40%%\" class=\"cellPlain\">Information Type</td>\n"); |
67 |
printf("<td width=\"20%%\" class=\"cellPlain\">Edit RQS Page</td>\n"); |
68 |
printf("</tr>\n"); |
69 |
|
70 |
|
71 |
|
72 |
// Build the query |
73 |
$sql = "SELECT DISTINCT |
74 |
s.subject, |
75 |
s.subject_id, |
76 |
i.infotype, |
77 |
m.masterinfotype |
78 |
|
79 |
FROM |
80 |
resource r |
81 |
LEFT JOIN res_sub_infotype rsi using (resource_id) |
82 |
LEFT JOIN subject s on rsi.subject_id = s.subject_id |
83 |
LEFT JOIN infotype i on rsi.infotype_id = i.infotype_id |
84 |
LEFT JOIN masterinfotype m on rsi.masterinfotype_id = m.masterinfotype_id |
85 |
|
86 |
WHERE s.subject_id > 0 AND r.resource_id = " |
87 |
. $resource_id |
88 |
. " ORDER BY s.subject"; |
89 |
|
90 |
// Initialize counter |
91 |
$rowcount = 0; |
92 |
|
93 |
$rs = xx_query($sql, $con); |
94 |
|
95 |
// Cycle through the result set |
96 |
while ( $row = xx_fetch_array ( $rs ) ) { |
97 |
$subject = Trim($row["subject"]); |
98 |
$subject_id = Trim($row["subject_id"]); |
99 |
$infotype = Trim($row["infotype"]); |
100 |
$masterinfotype = Trim($row["masterinfotype"]); |
101 |
|
102 |
// Make every other row colored |
103 |
if ($rowcount % 2 == 0) $color = " class=\"backLight\" "; |
104 |
else $color = ""; |
105 |
|
106 |
// New row |
107 |
printf("<tr>\n"); |
108 |
printf("<td %s>%s</td>\n", $color, $subject); |
109 |
printF("<td %s>%s -> %s</td>\n", $color, $masterinfotype, $infotype); |
110 |
printf("<td %s><a href=\"subject_builder.phtml?subject_id=%d\">Edit</a></td>\n", $color, $subject_id); |
111 |
printf("</tr>\n"); |
112 |
|
113 |
// Increment counter |
114 |
$rowcount++; |
115 |
} |
116 |
|
117 |
// Summary of RQS page uses |
118 |
printf("<tr><td colspan=\"2\" align=\"right\" class=\"backLight\">Total Research QuickStart Uses:</td>\n"); |
119 |
if (xx_num_rows($rs) == 0) printf("<td class=\"backLight\">(None)</td>\n"); |
120 |
else printf("<td class=\"backLight\">%d</td>\n", xx_num_rows($rs)); |
121 |
printf("</tr>\n"); |
122 |
|
123 |
// Close table |
124 |
printf("</table><br><br>\n"); |
125 |
|
126 |
|
127 |
// CourseLib Usage |
128 |
printf("<table width = \"75%%\" border=\"1\"><tr>\n"); |
129 |
printf("<td width=\"80%%\" class=\"cellPlain\">CourseLib Page(s)</td>\n"); |
130 |
printf("<td width=\"20%%\" class=\"cellPlain\">Edit</td>\n"); |
131 |
printf("</tr>\n"); |
132 |
|
133 |
|
134 |
// CourseLib Usage |
135 |
$sql = "SELECT DISTINCT p.page_id, c.course_concat |
136 |
FROM resource r |
137 |
LEFT JOIN element e using (resource_id) |
138 |
LEFT JOIN page p on e.page_id = p.page_id |
139 |
LEFT JOIN course c on p.page_id = c.page_id |
140 |
WHERE p.pagetype_id = 3 AND r.resource_id = " |
141 |
. $resource_id |
142 |
. " ORDER BY c.course_concat"; |
143 |
|
144 |
// Initialize counter |
145 |
$rowcount = 0; |
146 |
|
147 |
$rs = xx_query($sql, $con); |
148 |
|
149 |
// Cycle through the result set |
150 |
while ( $row = xx_fetch_array ( $rs ) ) { |
151 |
|
152 |
$page_id = Trim($row["page_id"]); |
153 |
$course_concat = Trim($row["course_concat"]); |
154 |
|
155 |
// Make every other row colored |
156 |
if ($rowcount % 2 == 0) $color = " class=\"backLight\" "; |
157 |
else $color = ""; |
158 |
|
159 |
// New row |
160 |
printf("<tr>\n"); |
161 |
printf("<td %s>%s</td>\n", $color, $course_concat); |
162 |
printf("<td %s><a href=\"scribe.phtml?page_id=%d\">Edit</a></td>\n", $color, $page_id); |
163 |
printf("</tr>\n"); |
164 |
|
165 |
// Increment counter |
166 |
$rowcount++; |
167 |
} |
168 |
|
169 |
// Summary of CourseScribe page uses |
170 |
printf("<tr><td align=\"right\" class=\"backLight\">Total CourseLib+ Uses:</td>\n"); |
171 |
if (xx_num_rows($rs) == 0) printf("<td class=\"backLight\">(None)</td>\n"); |
172 |
else printf("<td class=\"backLight\">%d</td>\n", xx_num_rows($rs)); |
173 |
printf("</tr>\n"); |
174 |
|
175 |
// Close table |
176 |
printf("</table><br><br>\n"); |
177 |
|
178 |
|
179 |
// FreeForm PageScribe Usage |
180 |
printf("<table width = \"75%%\" border=\"1\"><tr>\n"); |
181 |
printf("<td width=\"80%%\" class=\"cellPlain\">PageScribe Page(s)</td>\n"); |
182 |
printf("<td width=\"20%%\" class=\"cellPlain\">Edit</td>\n"); |
183 |
printf("</tr>\n"); |
184 |
|
185 |
|
186 |
// Freeform PageScribe Usage |
187 |
$sql = "SELECT DISTINCT p.page_id, p.page_title |
188 |
FROM resource r |
189 |
LEFT JOIN element e using (resource_id) |
190 |
LEFT JOIN page p on e.page_id = p.page_id |
191 |
WHERE pagetype_id = 2 AND r.resource_id = " |
192 |
. $resource_id |
193 |
. " ORDER BY p.page_title"; |
194 |
|
195 |
// Initialize counter |
196 |
$rowcount = 0; |
197 |
|
198 |
$rs = xx_query($sql, $con); |
199 |
|
200 |
// Cycle through the result set |
201 |
while ( $row = xx_fetch_array ( $rs ) ) { |
202 |
|
203 |
$page_id = Trim($row["page_id"]); |
204 |
$page_title = Trim($row["page_title"]); |
205 |
|
206 |
// Make every other row colored |
207 |
if ($rowcount % 2 == 0) $color = " class=\"backLight\" "; |
208 |
else $color = ""; |
209 |
|
210 |
// New row |
211 |
printf("<tr>\n"); |
212 |
printf("<td %s>%s</td>\n", $color, $page_title); |
213 |
printf("<td %s><a href=\"scribe.phtml?page_id=%d\">Edit</a></td>\n", $color, $page_id); |
214 |
printf("</tr>\n"); |
215 |
|
216 |
// Increment counter |
217 |
$rowcount++; |
218 |
} |
219 |
|
220 |
// Summary of FreeForm page uses |
221 |
printf("<tr><td align=\"right\" class=\"backLight\">Total PageScribe Uses:</td>\n"); |
222 |
if (xx_num_rows($rs) == 0) printf("<td class=\"backLight\">(None)</td>\n"); |
223 |
else printf("<td class=\"backLight\">%d</td>\n", xx_num_rows($rs)); |
224 |
printf("</tr>\n"); |
225 |
|
226 |
// Close table |
227 |
printf("</table><br><br>\n"); |
228 |
|
229 |
} // resource exists |
230 |
|
231 |
else { |
232 |
|
233 |
// Draw form heading |
234 |
printf("<center><h3>Not Found...</h3>"); |
235 |
|
236 |
// Table |
237 |
printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">"); |
238 |
printf("<tr><td><br>"); |
239 |
printf("<strong>Messages:</strong><br>"); |
240 |
printf("Resource ID#%s not found.<br><br>", $resource_id); |
241 |
printf("</td></tr>\n"); |
242 |
printf("</table></center>\n"); |
243 |
} |
244 |
|
245 |
// Link to return to admin console |
246 |
adminReturn($sess_access_level); |
247 |
|
248 |
} // logged in |
249 |
|
250 |
// No access page |
251 |
else require_once ($GLOBAL_NO_ACCESS); |
252 |
|
253 |
|
254 |
// Page footer |
255 |
require_once ($GLOBAL_ADMIN_FOOTER); |
256 |
?> |
257 |
|
258 |
</body> |
259 |
</html> |