2 /****************************************************************************/
\r
4 /****************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /****************************************************************************/
\r
15 define('AT_INCLUDE_PATH', '../../../../include/');
\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
\r
18 require (AT_INCLUDE_PATH.'../mods/_standard/links/lib/links.inc.php');
\r
20 if (!manage_links()) {
\r
21 $msg->addError('ACCESS_DENIED');
\r
22 header('Location: '.AT_BASE_HREF.'mods/_standard/links/index.php');
\r
26 if (isset($_POST['edit']) && isset($_POST['link_id'])) {
\r
27 header('Location: edit.php?lid='.$_POST['link_id']);
\r
29 } else if (isset($_POST['delete']) && isset($_POST['link_id'])) {
\r
30 header('Location: delete.php?lid='.$_POST['link_id']);
\r
32 } else if (isset($_POST['view']) && isset($_POST['link_id'])) {
\r
33 $onload = 'window.open(\''.AT_BASE_HREF.'mods/_standard/links/index.php?view='.$_POST['link_id'].'\',\'link\');';
\r
34 } else if (!empty($_POST)) {
\r
35 $msg->addError('NO_ITEM_SELECTED');
\r
38 $categories = get_link_categories(true);
\r
40 require(AT_INCLUDE_PATH.'header.inc.php');
\r
43 $col = addslashes($_GET['col']);
\r
48 if ($_GET['order']) {
\r
49 $order = addslashes($_GET['order']);
\r
54 if (!isset($_GET['cat_parent_id'])) {
\r
57 $parent_id = intval($_GET['cat_parent_id']);
\r
60 if ($_SESSION['groups']) {
\r
61 $groups = implode(',', $_SESSION['groups']);
\r
63 // not in any groups
\r
67 $auth = manage_links();
\r
69 if ($auth == LINK_CAT_AUTH_ALL) {
\r
70 $sql = "SELECT * FROM ".TABLE_PREFIX."links L INNER JOIN ".TABLE_PREFIX."links_categories C USING (cat_id) WHERE ((owner_id=$_SESSION[course_id] AND owner_type=".LINK_CAT_COURSE.") OR (owner_id IN ($groups) AND owner_type=".LINK_CAT_GROUP."))";
\r
71 } else if ($auth == LINK_CAT_AUTH_GROUP) {
\r
72 $sql = "SELECT * FROM ".TABLE_PREFIX."links L INNER JOIN ".TABLE_PREFIX."links_categories C USING (cat_id) WHERE owner_id IN ($groups) AND owner_type=".LINK_CAT_GROUP;
\r
73 } else if ($auth == LINK_CAT_AUTH_COURSE) {
\r
74 $sql = "SELECT * FROM ".TABLE_PREFIX."links L INNER JOIN ".TABLE_PREFIX."links_categories C USING (cat_id) WHERE ((owner_id=$_SESSION[course_id] AND owner_type=".LINK_CAT_COURSE.") OR (owner_id IN ($groups) AND owner_type=".LINK_CAT_GROUP."))";
\r
78 $sql .= " AND L.cat_id=$parent_id";
\r
80 $sql .= " ORDER BY $col $order";
\r
82 $result = mysql_query($sql, $db);
\r
84 if (!empty($categories)) {
\r
87 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
\r
88 <div class="input-form">
\r
90 <h3><label for="category_parent"><?php echo _AT('select_cat'); ?></label></h3>
\r
94 <select name="cat_parent_id" id="category_parent"><?php
\r
97 $current_cat_id = $parent_id;
\r
98 $exclude = false; /* don't exclude the children */
\r
100 $current_cat_id = $cat_id;
\r
101 $exclude = true; /* exclude the children */
\r
104 echo '<option value="0"> '._AT('cats_all').' </option>';
\r
105 select_link_categories($categories, 0, $current_cat_id, FALSE);
\r
110 <div class="row buttons">
\r
111 <input type="submit" name="cat_links" value="<?php echo _AT('cats_view_links'); ?>" />
\r
117 <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
\r
119 <table class="data" summary="" rules="cols">
\r
122 <th scope="col"> </th>
\r
123 <th scope="col"><?php echo _AT('title'); ?></th>
\r
124 <th scope="col"><?php echo _AT('category'); ?></th>
\r
125 <th scope="col"><?php echo _AT('submitted_by'); ?></th>
\r
126 <th scope="col"><?php echo _AT('approved'); ?></th>
\r
127 <th scope="col"><?php echo _AT('hit_count'); ?></th>
\r
132 if ($row = mysql_fetch_assoc($result)) { ?>
\r
135 <td colspan="6"><input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /> <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /> <input type="submit" name="view" value="<?php echo _AT('view'); ?>" /></td>
\r
140 if ($row['owner_type'] == LINK_CAT_GROUP) {
\r
141 $row['name'] = get_group_name($row['owner_id']);
\r
144 <tr onmousedown="document.form['m<?php echo $row['link_id']; ?>'].checked = true;rowselect(this);" id="r_<?php echo $row['link_id'];?>">
\r
145 <td width="10"><input type="radio" name="link_id" value="<?php echo $row['link_id'].'-'.$row['owner_type'].'-'.$row['owner_id']; ?>" id="m<?php echo $row['link_id']; ?>" /></td>
\r
146 <td><label for="m<?php echo $row['link_id']; ?>"><?php echo AT_print($row['LinkName'], 'resource_links.LinkName'); ?></label></td>
\r
147 <td><?php echo AT_print($row['name'], 'resource_links.CatName'); ?></td>
\r
148 <td><?php echo AT_print($row['SubmitName'], 'resource_links.SubmitName'); ?></td>
\r
150 <td align="center"><?php
\r
151 if($row['Approved']) {
\r
156 <td align="center"><?php echo $row['hits']; ?></td>
\r
159 } while ($row = mysql_fetch_assoc($result));
\r
164 <td colspan="6"><?php echo _AT('none_found'); ?></td>
\r
174 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>