2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002 - 2009 */
6 /* Adaptive Technology Resource Centre / University of Toronto */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
13 define('AT_INCLUDE_PATH', 'include/');
14 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 // handle ajax post request from course index page and student tools index page
19 if (isset($_POST['from']))
21 $from = $_POST['from'];
22 if ($_POST['moved_modules'] <> '') $final_home_links = $addslashes($_POST['moved_modules']);
25 // handle ajax post request to remove module from course index page and student tools index page
26 if ($_POST['remove'] <> '')
28 $remove_module = $_POST['remove'];
30 if ($from == 'course_index')
31 $sql = "SELECT home_links links FROM ".TABLE_PREFIX."courses WHERE course_id=$_SESSION[course_id]";
32 else if ($from == 'student_tools')
33 $sql = "SELECT links FROM ".TABLE_PREFIX."fha_student_tools WHERE course_id=$_SESSION[course_id]";
35 $result = mysql_query($sql, $db);
36 $row= mysql_fetch_assoc($result);
38 if (substr($row['links'], 0, strlen($remove_module)) == $remove_module)
39 $final_home_links = substr($row['links'], strlen($remove_module)+1);
41 $final_home_links = preg_replace('/\|'.preg_quote($remove_module, '/').'/', '', $row['links']);
44 // save the module display order into db
45 if ($from == 'course_index')
46 $sql = "UPDATE ".TABLE_PREFIX."courses SET home_links='$final_home_links' WHERE course_id=$_SESSION[course_id]";
47 else if ($from == 'student_tools')
48 $sql = "UPDATE ".TABLE_PREFIX."fha_student_tools SET links='$final_home_links' WHERE course_id=$_SESSION[course_id]";
50 $result = mysql_query($sql, $db);