2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002 - 2009 */
6 /* Inclusive Design Institute */
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(str_replace('-', '/', $_POST['moved_modules']));
24 // when pretty url is turned on, revert the pretty urls back to regular urls
25 if ($_config['pretty_url'] > 0)
27 $home_links = explode('|', $final_home_links);
28 $final_home_links = '';
29 if (is_array($home_links))
31 foreach ($home_links as $link)
33 $url_parser = new UrlParser($link);
34 $pathinfo = $url_parser->getPathArray();
35 $final_home_links .= $pathinfo[1]->getPath(). $pathinfo[1]->getFileName(). '|';
37 $final_home_links = substr($final_home_links, 0, -1);
42 // handle ajax post request to remove module from course index page and student tools index page
43 if ($_POST['remove'] <> '')
45 $remove_module = $_POST['remove'];
47 // when pretty url is turned on, revert the pretty url back to regular url
48 if ($_config['pretty_url'] > 0)
50 if (substr($remove_module, 0, 6) == 'go.php') $remove_module = substr($remove_module, 6);
52 $url_parser = new UrlParser($remove_module);
53 $pathinfo = $url_parser->getPathArray();
54 $remove_module = $pathinfo[1]->getPath(). $pathinfo[1]->getFileName();
57 if ($from == 'course_index')
58 $sql = "SELECT home_links links FROM ".TABLE_PREFIX."courses WHERE course_id=$_SESSION[course_id]";
59 else if ($from == 'student_tools')
60 $sql = "SELECT links FROM ".TABLE_PREFIX."fha_student_tools WHERE course_id=$_SESSION[course_id]";
62 $result = mysql_query($sql, $db);
63 $row= mysql_fetch_assoc($result);
65 if (substr($row['links'], 0, strlen($remove_module)) == $remove_module)
66 $final_home_links = substr($row['links'], strlen($remove_module)+1);
68 $final_home_links = preg_replace('/\|'.preg_quote($remove_module, '/').'/', '', $row['links']);
71 // save the module display order into db
72 if ($from == 'course_index')
73 $sql = "UPDATE ".TABLE_PREFIX."courses SET home_links='$final_home_links' WHERE course_id=$_SESSION[course_id]";
74 else if ($from == 'student_tools')
75 $sql = "UPDATE ".TABLE_PREFIX."fha_student_tools SET links='$final_home_links' WHERE course_id=$_SESSION[course_id]";
77 $result = mysql_query($sql, $db);