2 /****************************************************************************/
4 /****************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
17 require (AT_INCLUDE_PATH.'vitals.inc.php');
18 require (AT_INCLUDE_PATH.'../mods/_standard/links/lib/links.inc.php');
20 if (!manage_links()) {
21 $_pages['mods/_standard/links/index.php']['children'] = array('mods/_standard/links/add.php');
24 if (isset($_GET['view'])) {
25 $_GET['view'] = intval($_GET['view']);
27 $sql = "SELECT Url, hits FROM ".TABLE_PREFIX."links WHERE link_id=$_GET[view]";
28 $results = mysql_query($sql,$db);
30 if ($row = mysql_fetch_assoc($results)) {
31 if (!authenticate(AT_PRIV_LINKS, AT_PRIV_RETURN)) {
34 $sql = "UPDATE ".TABLE_PREFIX."links SET hits=$row[hits] WHERE link_id=$_GET[view]";
35 mysql_query($sql,$db);
38 //http://www.atutor.ca/atutor/mantis/view.php?id=3853
39 $is_http = preg_match("/^http/", $row['Url']);
41 $row['Url'] = 'http://' . $row['Url'];
45 header('Location: ' . $row['Url']);
50 require (AT_INCLUDE_PATH.'header.inc.php');
52 if ($_GET['reset_filter']) {
56 $_GET['cat_parent_id'] = intval($_GET['cat_parent_id']);
58 //get appropriate categories
59 $categories = get_link_categories();
61 //ascending decscending columns...
63 $orders = array('asc' => 'desc', 'desc' => 'asc');
64 $cols = array('LinkName' => 1, 'name' => 1, 'description' => 1);
66 if (isset($_GET['asc'])) {
68 $col = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'LinkName';
69 } else if (isset($_GET['desc'])) {
71 $col = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'LinkName';
79 if ($_GET['search']) {
80 $_GET['search'] = trim($_GET['search']);
81 $page_string .= SEP.'search='.urlencode($_GET['search']);
82 $search = $addslashes($_GET['search']);
83 $search = str_replace(array('%','_'), array('\%', '\_'), $search);
84 $search = '%'.$search.'%';
85 $search = "((LinkName LIKE '$search') OR (description LIKE '$search'))";
90 //view links of a child category
91 if ($_GET['cat_parent_id']) {
92 $children = get_child_categories ($_GET['cat_parent_id'], $categories);
93 $cat_sql = "C.cat_id IN ($children $_GET[cat_parent_id])";
94 $parent_id = intval($_GET['cat_parent_id']);
101 $tmp_groups = implode(',', $_SESSION['groups']);
103 if (!empty($tmp_groups)) {
104 $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 ($tmp_groups) AND owner_type=".LINK_CAT_GROUP.")) AND L.Approved=1 AND $search AND $cat_sql ORDER BY $col $order";
106 $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.") AND L.Approved=1 AND $search AND $cat_sql ORDER BY $col $order";
108 $result = mysql_query($sql, $db);
109 $num_results = mysql_num_rows($result);
112 <?php if ($num_results > 0 || isset($_GET['filter'])): ?>
113 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
115 <div class="input-form">
117 <h3><?php echo _AT('results_found', $num_results); ?></h3>
121 <label for="category_parent"><?php echo _AT('select_cat'); ?></label>
123 <?php if (!empty($categories)): ?>
124 <select name="cat_parent_id" id="category_parent"><?php
126 $current_cat_id = $parent_id;
127 $exclude = false; /* don't exclude the children */
129 $current_cat_id = $cat_id;
130 $exclude = true; /* exclude the children */
133 echo '<option value="0"> '._AT('cats_all').' </option>';
134 select_link_categories($categories, 0, $current_cat_id, FALSE);
141 <label for="search"><?php echo _AT('search'); ?> (<?php echo _AT('title').', '._AT('description'); ?>)</label><br />
142 <input type="text" name="search" id="search" size="20" value="<?php echo htmlspecialchars($_GET['search']); ?>" />
146 <div class="row buttons">
147 <input type="submit" name="filter" value="<?php echo _AT('filter'); ?>" />
148 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" />
154 <table class="data static" summary="" rules="cols">
156 <?php if ($col == 'LinkName'): ?>
159 <?php elseif($col == 'name'): ?>
163 <?php elseif($col == 'description'): ?>
170 <th scope="col"><a href="<?php echo url_rewrite('mods/_standard/links/index.php?'.$orders[$order].'=LinkName'.$page_string); ?>"><?php echo _AT('title'); ?></a></th>
171 <th scope="col"><a href="<?php echo url_rewrite('mods/_standard/links/index.php?'.$orders[$order].'=name'.$page_string); ?>"><?php echo _AT('category'); ?></a></th>
172 <th scope="col"><a href="<?php echo url_rewrite('mods/_standard/links/index.php?'.$orders[$order].'=description'.$page_string); ?>"><?php echo _AT('description'); ?></a></th>
176 <?php if ($row = mysql_fetch_assoc($result)) : ?>
180 <tr onmousedown="document.form['m<?php echo $row['link_id']; ?>'].checked = true;">
181 <td><a href="<?php echo url_rewrite('mods/_standard/links/index.php?view='.$row['link_id']); ?>" target="_new" title="<?php echo AT_print($row['LinkName'], 'links.LinkName'); ?>"><?php echo AT_print($row['LinkName'], 'links.LinkName'); ?></a></td>
183 if (empty($row['name'])) {
184 $row['name'] = get_group_name($row['owner_id']);
186 echo AT_print($row['name'], 'links.name');
188 <td><?php echo AT_print($row['Description'], 'links.Description'); ?></td>
191 } while ($row = mysql_fetch_assoc($result)); ?>
194 <td colspan="3"><?php echo _AT('none_found'); ?></td>
200 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>