/[libdata]/trunk/admin/subject_builder.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

Annotation of /trunk/admin/subject_builder.phtml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Fri Dec 5 18:40:00 2003 UTC (20 years, 4 months ago) by dpavlin
File size: 18263 byte(s)
Initial revision

1 dpavlin 2 <?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     require_once ($GLOBAL_ADMIN_INC."forms.php");
11    
12     // HTML header
13     printf("<HTML>\n");
14     printf("<HEAD>\n");
15     printf("<title>RQS Subject Builder</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_staff_id = $accessClass->staff_id;
35     $sess_access_level = $accessClass->access_level;
36     $sess_access = $accessClass->access;
37     $sess_last_name = $accessClass->last_name;
38     $sess_first_name = $accessClass->first_name;
39    
40     }
41    
42    
43     // Default authorization
44     $auth_subject = 0;
45    
46    
47     // Flag to make sure that the current user has sufficient access for this subject
48     $auth_subject = authSubject($con, $sess_access_level, $sess_staff_id, $subject_id);
49    
50    
51     // If the cookie is set and access level is appropriate
52     if(isset($libsession) && $sess_access_level >= 20 && $auth_subject == 1) {
53    
54     // Default to incoming letter A if nothing selected
55     if ($letter == "" && $limitstring == "" && $masterinfotype_id < 1 && $feature_id < 1) $letter = "A";
56    
57     printf("<table border =\"0\">\n");
58     printf("<tr><td colspan=\"2\">");
59    
60     /**********************************
61     ** Display user's subject choice **
62     **********************************/
63    
64     $subject = lookupField($con, "subject", "subject_id", $subject_id, "subject");
65     printf("<h2>Research QuickStart: %s</h2>", $subject);
66     printf("</td></tr>\n");
67    
68    
69     /*******************
70     ** Preview option **
71     *******************/
72    
73     printf("<tr><td>\n");
74     printf("<form method =\"POST\" action=\"%srqs.phtml?subject_id=%s\" >\n", $GLOBAL_RQS_URL, $subject_id);
75     printf("<br><input type=\"submit\" value =\"Preview This Page\">\n");
76     printf("</form>\n");
77     printf("</td>\n");
78    
79     printf("<td>\n");
80     printf("<form method =\"POST\" action=\"%srqs.phtml?core=1&subject_id=%s\" >\n", $GLOBAL_RQS_URL, $subject_id);
81     printf("<br><input type=\"submit\" value =\"Preview Core Only\">\n");
82     printf("</form>\n");
83    
84     printf("</td></tr></table><br>\n");
85    
86    
87     /*******************************
88     ** Publish toggle & page info **
89     *******************************/
90    
91     // Collect the data
92     $sql = "SELECT
93     rqs_date_created,
94     rqs_date_modified,
95     rqs_account_created,
96     rqs_account_modified,
97     rqs_published
98     FROM
99     subject
100     WHERE
101     subject_id = "
102     . $subject_id;
103    
104     $rs = mysql_query($sql, $con);
105     $row = mysql_fetch_array ($rs);
106     $rqs_date_modified = $row["rqs_date_modified"];
107     $rqs_date_created = $row["rqs_date_created"];
108     $rqs_account_created = $row["rqs_account_created"];
109     $rqs_account_modified = $row["rqs_account_modified"];
110     $rqs_published = $row["rqs_published"];
111    
112     printf("<table width=\"95%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\"><tr>\n");
113     printf("<td colspan =\"4\" class=\"cellPlain\">RQS Page Status</td></tr>\n");
114    
115     // Date created
116     printf("<td>\n");
117     printf("<b>Created:</b> %s (%s)\n", $rqs_date_created, $rqs_account_created);
118     printf("</td>\n");
119    
120     // Date modified
121     printf("<td>\n");
122     printf("<b>Modified:</b> %s (%s)\n", $rqs_date_modified, $rqs_account_modified);
123     printf("</td>\n");
124    
125     // Publish status
126     if ($rqs_published > 0) {
127     printf("<form method=\"POST\" action=\"subject_transaction.phtml\">\n");
128     printf("<input type =\"hidden\" name=\"transaction\" value =\"rqsUnpublish\">\n");
129     printf("<input type=\"hidden\" name=\"subject_id\" value=\"%d\">\n", $subject_id);
130     printf("<td><b>Pub Status:</b> Published</td>\n");
131     printf("<td><input type=\"submit\" value=\"Unpublish\">\n");
132     printf("</form>\n");
133     printf("</td>\n");
134     }
135     else {
136     printf("<form method=\"POST\" action=\"subject_transaction.phtml\">\n");
137     printf("<input type =\"hidden\" name=\"transaction\" value =\"rqsPublish\">\n");
138     printf("<input type=\"hidden\" name=\"subject_id\" value=\"%d\">\n", $subject_id);
139     printf("<td><b>Pub Status:</b> Not published</td>\n");
140     printf("<td><input type=\"submit\" value=\"Publish\">\n");
141     printf("</form>\n");
142     printf("</td>\n");
143     }
144     printf("</tr>\n");
145     printf("</table><br>\n");
146    
147    
148     // Outer table for main page body
149     printf("<table width=\"100%%\" border=\"0\">\n");
150     printf("<tr><td width=\"50%%\" valign=\"top\">\n");
151    
152    
153     /*********************************
154     ** Add Resource - Select Limits **
155     *********************************/
156    
157     printf("<table width = \"75%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
158     printf("<tr><td colspan=\"2\" align=\"left\" class=\"cellPlain\">\n");
159     printf("<a name=\"select\">Select Resource</a>");
160     printf("</td></tr>\n");
161    
162     printf("<tr><td colspan=\"2\">\n");
163    
164     // Limit to letter
165     printf("Narrow Resource List To:<br>\n");
166     if ($letter != "") printf("Starting With <b>%s</b>\n", $letter);
167     else if ($limitstring != "") printf ("Titles or Descriptions Containing <b>\"%s\"</b>\n", $limitstring);
168     else printf ("All Resources\n");
169    
170     // User limited by masterinfotype, display it
171     if ($masterinfotype_id > 0) {
172     $masterinfotype = lookupField($con, "masterinfotype", "masterinfotype_id", $masterinfotype_id, "masterinfotype");
173     printf(" within <b>%s</b>\n", $masterinfotype);
174     }
175    
176     // User limited by feature, display it
177     if ($feature_id > 0) {
178     $feature = lookupField($con, "feature", "feature_id", $feature_id, "feature");
179     printf(" involving <b>%s</b>\n", $feature);
180     }
181    
182     printf("</td></tr>\n");
183    
184     /********************
185     ** Limit by Letter **
186     ********************/
187    
188     printf("<tr><td colspan=\"2\" bgcolor = \"#ffffff\" align=\"center\" >\n");
189     printf("<a href=\"subject_builder.phtml?subject_id=%d&letter=All#select\">A-Z</a> | ", $subject_id);
190    
191     // Draw the alphabet
192     for ($ascii_char = 65; $ascii_char <= 90; $ascii_char++) {
193     if ($ascii_char == 77 || $asci_char == 90) printf("<BR><BR>\n");
194     else printf(" | ");
195     printf("<a href=\"subject_builder.phtml?subject_id=%d&letter=%s#select\">%s</a>", $subject_id, chr($ascii_char), chr($ascii_char));
196    
197     }
198     printf("</td></tr>\n");
199    
200     /***********
201     ** Search **
202     ***********/
203    
204     printf("<tr><td class = \"cellPlain\">Title or Description:</td><td>\n");
205     printf("<form method=\"POST\" action=\"subject_builder.phtml#select\">\n");
206     printf("<input type=\"hidden\" name=\"subject_id\" value=\"%d\">\n", $subject_id);
207     printf("<input type=\"text\" name=\"limitstring\" value =\"%s\" size =\"20\">\n", $limitstring);
208     printf(" and/or</td></tr>\n");
209    
210    
211     /*******************
212     ** Masterinfotype **
213     *******************/
214    
215     printf("<tr><td class = \"cellPlain\">Master Info Type:</td><td>\n");
216     printf("<select name = \"masterinfotype_id\">\n");
217     printf("<option value=\"0\">All</option>\n");
218     dropDownFieldSelected($con, "masterinfotype", "masterinfotype", "masterinfotype_id", " WHERE masterinfotype_id > 1 ", $masterinfotype_id);
219     printf("</select>\n");
220     printf(" and/or</td></tr>\n");
221    
222     /************
223     ** Feature **
224     ************/
225    
226     printf("<tr><td class = \"cellPlain\" >Feature:</td><td>\n");
227     printf("<select name = \"feature_id\">\n");
228     printf("<option value=\"0\">All</option>\n");
229     dropDownFieldSelected($con, "feature", "feature", "feature_id", " WHERE feature_id > 1 ", $feature_id);
230     printf("</select>\n");
231    
232     printf("<input type=\"submit\" value =\"Limit\"></form>\n");
233    
234     printf("</td></tr>\n");
235    
236     /*************************
237     ** The Add-Resource Box **
238     *************************/
239    
240     printf("<tr><td colspan = \"2\" align = \"center\" >\n");
241     printf("<form method =\"POST\" action=\"subject_transaction.phtml\" >\n");
242     printf("<b>Add a Resource to this RQS page</b><BR>\n");
243     printf("<select name = \"resource_id\" size = \"5\" >\n");
244    
245     // Determine any limits and draw the box
246     if (strlen($letter) > 0 && $letter != "All") $limit = $letter;
247     if (strlen($limitstring) > 0) $limit = $limitstring;
248     dropDownResource($con, 0, $limit, $masterinfotype_id, $feature_id);
249     printf("</select><br>\n");
250    
251     printf("<input type =\"hidden\" name=\"subject_id\" value =\"%d\">\n", $subject_id);
252     printf("<input type =\"hidden\" name=\"transaction\" value =\"insertSubjectBuilder\">\n");
253     printf("<br><input type=\"submit\" name =\"highlighted\" value =\"Add\">\n");
254     printf(" <input type=\"submit\" name =\"highlighted\" value =\"Add Core\">\n");
255     printf("</form>");
256     if ($recent > 0) printf("<a href=\"#r%d\">Jump to Most Recently Added</a>\n", $recent);
257     print "Can't find the resource you need to add? <a href=\"console.phtml\">Add a New Resource</a><br />\n";
258     printf("</td></tr></table><BR>\n");
259    
260    
261     // Close outer cell
262     printf("</td>\n");
263    
264     /*************************
265     ** Select Related Pages **
266     *************************/
267    
268     printf("<td width=\"50%%\" valign=\"top\" align=\"right\">\n");
269     formAssignSubOtherSub($con, $subject_id);
270    
271     printf("<br>\n");
272     formAssignSubPage($con, $subject_id);
273    
274     // Close outer cell, row, and table
275     printf("</td></tr></table>\n");
276    
277    
278     /*************************************************************************
279     ** Main body table. Table of contents in left cell, resources in right **
280     *************************************************************************/
281    
282     printf("<table width=\"100%%\" border=\"0\" cellpadding=\"4\">\n");
283     printf("<tr><td width=\"20%%\" valign=\"top\" class=\"backLight\">\n");
284    
285    
286     /***********************************
287     ** Generate the table of contents **
288     ***********************************/
289    
290     printf("<b>Contents of this page:</b><br><br>\n");
291     // Generate the list
292     $sql = "SELECT DISTINCT mi.masterinfotype_id, mi.masterinfotype, i.infotype_id, i.infotype FROM
293     res_sub_infotype rsi,
294     infotype i,
295     masterinfotype mi
296    
297     WHERE
298     rsi.subject_id = "
299     . $subject_id
300     . " AND mi.masterinfotype_id = i.masterinfotype_id AND
301     rsi.infotype_id = i.infotype_id
302     ORDER BY mi.masterinfotype, i.infotype";
303    
304     $rs = mysql_query($sql, $con);
305    
306     $rows = mysql_num_rows($rs);
307    
308     // initialize
309     $last_masterinfotype_id = 0;
310    
311     $rowcount = 0;
312     while ($row = mysql_fetch_array ($rs)) {
313    
314     // Fetch information types for this subject
315     $infotype_id = $row["infotype_id"];
316     $infotype = $row["infotype"];
317     $masterinfotype_id = $row["masterinfotype_id"];
318     $masterinfotype = $row["masterinfotype"];
319    
320     if ($last_masterinfotype_id != $masterinfotype_id) {
321     if ($rowcount > 0) printf("</ul>\n");
322     printf("<b><a href=\"subject_builder.phtml?subject_id=%d#m%d\">%s</a></b>\n", $subject_id, $masterinfotype_id, $masterinfotype);
323     printf("<ul>\n");
324     }
325    
326     printf("<li><a href=\"subject_builder.phtml?subject_id=%d#i%d\">%s</a></li>\n", $subject_id, $infotype_id, $infotype);
327    
328    
329     $last_masterinfotype_id = $masterinfotype_id;
330     $rowcount++;
331    
332     };
333    
334     // Close remaining ul tag
335     if ($rowcount > 0) printf("</ul>\n");
336    
337     // Close table of contents cell
338     printf("</td>\n");
339    
340     // Resources, main body cell
341     printf("<td width=\"80%%\" valign=\"top\">");
342    
343    
344     /***************************
345     ** Generate the resources **
346     ***************************/
347    
348     $sql = "SELECT
349     rsi.description,
350     rsi.highlighted,
351     m.masterinfotype_id,
352     m.masterinfotype,
353     i.infotype_id,
354     i.infotype,
355     r.resource_id,
356     r.title,
357     r.author,
358     r.annotation,
359     r.url,
360     r.cat_num
361     FROM res_sub_infotype rsi,
362     infotype i, masterinfotype m, resource r
363     WHERE
364     rsi.subject_id = "
365     . $subject_id
366     . " AND rsi.masterinfotype_id = m.masterinfotype_id AND
367     rsi.infotype_id = i.infotype_id AND
368     rsi.masterinfotype_id = m.masterinfotype_id AND
369     rsi.resource_id = r.resource_id
370     ORDER BY m.masterinfotype, i.infotype, r.title";
371    
372     $rs = mysql_query($sql, $con);
373    
374     // printf("sql was: %s<BR><BR>", $sql);
375    
376     while ($row = mysql_fetch_array ($rs)) {
377    
378     // Fetch information types for this subject
379     $description = $row["description"];
380     $masterinfotype = $row["masterinfotype"];
381     $masterinfotype_id = $row["masterinfotype_id"];
382     $infotype = $row["infotype"];
383     $infotype_id = $row["infotype_id"];
384     $title = $row["title"];
385     $author = $row["author"];
386     $annotation = $row["annotation"];
387     $resource_id = $row["resource_id"];
388     $url = $row["url"];
389     $cat_num = $row["cat_num"];
390     $highlighted = $row["highlighted"];
391    
392    
393     // Header info
394     if ($last_m != $masterinfotype) printf("<h3><a name=\"m%d\">%s</a></h3>", $masterinfotype_id, $masterinfotype);
395     if ($last_i != $infotype) printf("<b><a name=\"i%d\">%s</a></b><br><br>", $infotype_id, $infotype);
396    
397    
398     // Edit mode
399     if ($selected_resource_id == $resource_id && $selected_infotype_id == $infotype_id) {
400    
401     // Build an anchor
402     printf("<a name = \"%d\" > </a>\n", $resource_id);
403    
404     printf("<table border=\"1\" class=\"backLight\">\n");
405     printf("<tr><td class=\"cellPlain\">\n");
406     printf("Edit This Instance");
407     printf("</td></tr>\n");
408     printf("<form method=\"POST\" action =\"subject_transaction.phtml\">\n");
409     printf("<tr><td>\n");
410     printf("<b>Title:</b> %s<br>\n", $title);
411     if (strlen($url) > 0 ) printf ("<b>URL:</b> <a href=\"%s\">%s</a><BR>\n", $url, $url);
412    
413     // Change information type
414     printf("<br><b>Information Type:</b><br>\n");
415     printf("<select name =\"infotype_id\">\n");
416     dropDownInfotype($con, $infotype_id, $subject_id);
417     printf("</select><BR><BR>\n");
418    
419     // Set to highlighted status
420     printf("<b>Highlighted/core resource?");
421     printf("&nbsp;&nbsp;");
422     // Default radio button to appropriate value
423     if ($highlighted != 1) $no_check = " CHECKED ";
424     else $yes_check = " CHECKED ";
425     // Radio buttons
426     printf("Yes <input type = \"radio\" name =\"highlighted\" value = \"1\" %s> ", $yes_check);
427     printf("&nbsp;&nbsp;");
428     printf("No <input type = \"radio\" name =\"highlighted\" value = \"0\" %s></b><br><br>", $no_check);
429    
430     // Reset the checked status
431     $yes_check = "";
432     $no_check = "";
433    
434     // Use default description if none specified
435     printf("<b>Use resource default description?");
436     printf("&nbsp;&nbsp;");
437    
438     // Default radio button to appropriate value
439     if (strlen($description) > 0) $no_check = " CHECKED ";
440     else $yes_check = " CHECKED ";
441    
442     // Radio buttons
443     printf("Yes <input type = \"radio\" name =\"descr_default\" value = \"1\" %s> ", $yes_check);
444     printf("&nbsp;&nbsp;");
445     printf("No <input type = \"radio\" name =\"descr_default\" value = \"0\" %s></b>", $no_check);
446    
447     // Change description here
448     printf("<br><br>If not, click \"no\" and make changes below:<br>\n");
449     printf("<b>This description:</b><BR>\n");
450     printf("<textarea cols=\"60\" rows=\"4\" name =\"description\">\n");
451     if (strlen($description) > 0) printf("%s", $description);
452     else printf("%s", $annotation);
453     printf("</textarea>\n");
454    
455     // Form variables and submit
456     printf("<input type=\"hidden\" name=\"transaction\" value=\"updateSubjectBuilder\">\n");
457     printf("<input type =\"hidden\" name =\"resource_id\" value =\"%d\">\n", $resource_id);
458     printf("<input type=\"hidden\" name =\"subject_id\" value =\"%s\">\n", $subject_id);
459     printf("<input type=\"hidden\" name =\"old_infotype_id\" value =\"%s\">\n", $infotype_id);
460    
461     // Hand-hold HTML to make the buttons appear together
462     printf("<table><tr><td>\n");
463     printf("<input type = \"submit\" value =\"Save Changes\">\n");
464     printf("</td>\n");
465     printf("</form>\n");
466     printf("<form method=\"POST\" action=\"subject_builder.phtml?subject_id=%d#r%d\">", $subject_id, $resource_id);
467     printf("<td>\n");
468     printf("<input type=\"submit\" value=\"Cancel\">\n");
469     printf("</td>\n");
470     printf("</form>\n");
471     printf("</tr></table>\n");
472    
473     printf("</td></tr></table><BR><BR>\n");
474    
475     }
476    
477    
478     // Display mode
479     else {
480    
481     printf("<a name=\"r%d\">Title:</a> %s<br>\n", $resource_id, $title);
482     if (strlen($url) > 0 ) printf ("URL: <a href=\"%s\">%s</a><BR>\n", $url, $url);
483     printf("Description: ");
484     if (strlen($description) > 0) printf("<i>%s</i> ", $description);
485     else printf("<i>%s</i> ", $annotation);
486    
487     // Edit options
488     printf("<table border =\"1\" cellpadding = \"0\" cellspacing = \"3\" class=\"backLight\"><tr>\n");
489    
490     // Edit base resource entry
491     printf("<form method =\"POST\" action=\"operation.phtml?operation=Edit&table=resource&key_id=%d\" >\n", $resource_id);
492     printf("<td>\n");
493     printf("<input type=\"hidden\" name=\"operation\" value=\"Edit\">\n");
494     printf("<input type =\"hidden\" name =\"table\" value =\"resource\">\n");
495     printf("<input type = \"submit\" name = \"edit\" value =\"Edit Base Resource\">\n");
496     printf("</td></form>\n");
497    
498     // Edit this entry
499     printf("<form method =\"POST\" action=\"subject_builder.phtml#%d\" >\n", $resource_id);
500     printf("<td>\n");
501     printf("<input type=\"hidden\" name=\"operation\" value=\"editSubjectBuilder\">\n");
502     printf("<input type =\"hidden\" name =\"selected_resource_id\" value =\"%d\">\n", $resource_id);
503     printf("<input type=\"hidden\" name =\"subject_id\" value =\"%s\">\n", $subject_id);
504     printf("<input type=\"hidden\" name =\"selected_infotype_id\" value =\"%d\">\n", $infotype_id);
505     printf("<input type = \"submit\" name = \"edit\" value =\"Edit This Instance\">\n");
506     printf("</td></form>\n");
507    
508     // Remove this entry
509     printf("<form method =\"POST\" action=\"subject_transaction.phtml\" >\n");
510     printf("<td>\n");
511     printf("<input type=\"hidden\" name=\"transaction\" value=\"deleteSubjectBuilder\">\n");
512     printf("<input type=\"hidden\" name =\"resource_id\" value =\"%d\">\n", $resource_id);
513     printf("<input type=\"hidden\" name =\"subject_id\" value =\"%d\">\n", $subject_id);
514     printf("<input type=\"hidden\" name =\"infotype_id\" value =\"%d\">\n", $infotype_id);
515     printf("<input type = \"submit\" value =\"Remove\">\n");
516     printf("</td></form></tr></table><br><br>\n");
517    
518     } // end display mode
519    
520     $last_m = $masterinfotype;
521     $last_i = $infotype;
522    
523     } // end all rows
524    
525    
526     // Close main body table
527     printf("</td></tr></table>\n");
528    
529    
530     } // logged in user
531    
532     // No access page
533     else require_once ($GLOBAL_NO_ACCESS);
534    
535     // Page footer
536     require_once ($GLOBAL_ADMIN_FOOTER);
537     ?>
538    
539     </center>
540     </body>
541     </html>

  ViewVC Help
Powered by ViewVC 1.1.26