2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 */
6 /* Written by Greg Gay, Joel Kronenberg & Chris Ridpath */
7 /* Inclusive Design Institute */
10 /* This program is free software. You can redistribute it and/or*/
11 /* modify it under the terms of the GNU General Public License */
12 /* as published by the Free Software Foundation. */
13 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 authenticate(AT_PRIV_READING_LIST);
19 if (isset($_GET['edit'])) {
20 $_GET['resource_id'] = intval($_GET['resource_id']);
22 // what kind of resource is user going to edit?
23 $sql = "SELECT type FROM ".TABLE_PREFIX."external_resources WHERE course_id=$_SESSION[course_id] AND resource_id=$_GET[resource_id]";
24 $result = mysql_query($sql, $db);
25 if ($row = mysql_fetch_assoc($result)){
26 header('Location: add_resource_'.substr($_rl_types[$row['type']], 3).'.php?id='. $_GET['resource_id']. SEP. 'page_return=display_resources.php');
28 } else if (isset($_GET['delete'])) {
29 $_GET['resource_id'] = intval($_GET['resource_id']);
30 header('Location: delete_resource.php?id='. $_GET['resource_id']);
32 } else if (isset($_GET['create'])){
33 $_GET['new_resource'] = intval($_GET['new_resource']);
34 if (isset($_rl_types[$_GET['new_resource']])){
35 // Note: the '3' substring is used here to strip out the 'rl_' from the name
36 header('Location: add_resource_'.substr($_rl_types[$_GET['new_resource']], 3).'.php'. '?page_return=display_resources.php');
41 require(AT_INCLUDE_PATH.'header.inc.php');
43 $sql = "SELECT title, resource_id FROM ".TABLE_PREFIX."external_resources WHERE course_id=$_SESSION[course_id] AND type=".RL_TYPE_BOOK." ORDER BY title";
44 $result = mysql_query($sql, $db);
45 $num_books = mysql_num_rows($result);
47 <div class="input-form" style="width: 90%">
48 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('create'); ?></legend>
49 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
51 <label for="question"><?php echo _AT('rl_type_of_resource'); ?></label><br />
52 <select name="new_resource" class="dropdown" id="type">
54 <?php foreach ($_rl_types as $key => $value): ?>
55 <option value="<?php echo $key; ?>"><?php echo _AT($value); ?></option>
61 <div class="row buttons">
62 <input type="submit" name="create" value="<?php echo _AT('create'); ?>" />
68 $sql = "SELECT * FROM ".TABLE_PREFIX."external_resources WHERE course_id=$_SESSION[course_id] ORDER BY type";
69 $result = mysql_query($sql, $db);
72 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
73 <table class="data" style="width: 90%;">
77 <th><?php echo _AT('type'); ?></th>
78 <th><?php echo _AT('title'); ?></th>
79 <th><?php echo _AT('author'); ?></th>
84 <td colspan="6"><input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
85 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /></td>
88 <?php if ($row = mysql_fetch_assoc($result)) : ?>
90 <?php $first=true; // check the first radio button ?>
92 <tr onmousedown="document.form['t<?php echo $row['resource_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['resource_id']; ?>_0">
94 <td><input type="radio" id="t<?php echo $row['resource_id'];?>" name="resource_id" value="<?php echo $row['resource_id']; ?>"
95 <?php if ($first == true){ echo 'checked="checked"'; $first=false;} ?>/></td>
96 <td><?php echo _AT($_rl_types[$row['type']]); ?></td>
97 <td><label for="t<?php echo $row['resource_id'];?>"><strong><?php echo AT_print($row['title'], 'input.text'); ?></strong></label></td>
98 <td><?php echo AT_print($row['author'], 'input.text'); ?></td>
100 <?php } while($row = mysql_fetch_assoc($result)); ?>
104 <td colspan="2"><strong><?php echo _AT('none_found'); ?></strong></td>
110 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>