remove old readme
[atutor.git] / docs / mods / _standard / reading_list / display_resources.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2008                                      */
6 /* Written by Greg Gay, Joel Kronenberg & Chris Ridpath         */
7 /* Inclusive Design Institute                                   */
8 /* http://atutor.ca                                                                                             */
9 /*                                                              */
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 /****************************************************************/
14 // $Id$
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 authenticate(AT_PRIV_READING_LIST);
18
19 if (isset($_GET['edit'])) {
20         $_GET['resource_id'] = intval($_GET['resource_id']);
21
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');
27         }
28 } else if (isset($_GET['delete'])) {
29         $_GET['resource_id'] = intval($_GET['resource_id']);
30         header('Location: delete_resource.php?id='. $_GET['resource_id']);
31         exit;
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');
37                 exit;
38         }
39 }
40
41 require(AT_INCLUDE_PATH.'header.inc.php');
42
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);
46 ?>
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']; ?>">
50         <div class="row">
51                 <label for="question"><?php echo _AT('rl_type_of_resource'); ?></label><br />
52                 <select name="new_resource" class="dropdown" id="type">
53
54                 <?php foreach ($_rl_types as $key => $value): ?>
55                         <option value="<?php echo $key; ?>"><?php echo _AT($value); ?></option>
56                 <?php endforeach; ?>
57
58                 </select>
59         </div>
60
61         <div class="row buttons">
62                 <input type="submit" name="create" value="<?php echo _AT('create'); ?>" />
63         </div>
64 </form>
65 </fieldset>
66 </div>
67 <?php
68 $sql = "SELECT * FROM ".TABLE_PREFIX."external_resources WHERE course_id=$_SESSION[course_id] ORDER BY type";
69 $result = mysql_query($sql, $db);
70 ?>
71
72 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
73 <table class="data" style="width: 90%;">
74 <thead>
75 <tr>
76         <th>&nbsp;</th>
77         <th><?php echo _AT('type'); ?></th>
78         <th><?php echo _AT('title'); ?></th>
79         <th><?php echo _AT('author'); ?></th>
80 </tr>
81 </thead>
82 <tfoot>
83 <tr>
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>
86 </tr>
87 </tfoot>
88 <?php if ($row = mysql_fetch_assoc($result)) : ?>
89 <tbody>
90                 <?php $first=true; // check the first radio button ?>
91                 <?php do { ?>
92                         <tr onmousedown="document.form['t<?php echo $row['resource_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['resource_id']; ?>_0">
93                                 
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>
99                         </tr>
100                 <?php } while($row = mysql_fetch_assoc($result)); ?>
101 </tbody>
102 <?php else: ?>
103         <tr>
104                 <td colspan="2"><strong><?php echo _AT('none_found'); ?></strong></td>
105         </tr>
106 <?php endif; ?>
107 </table>
108 </form>
109
110 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>