$PREFERENCES = preferences_load("dashboard");
 $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_RELATIVE . "/javascript/tabpane/tabpane.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>";
 $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_RELATIVE . "/javascript/rssreader.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>";
 $HEAD[] = "<link href=\"" . ENTRADA_RELATIVE . "/css/tabpane.css?release=" . html_encode(APPLICATION_VERSION) . "\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />";
 $HEAD[] = "<link href=\"" . ENTRADA_RELATIVE . "/javascript/calendar/css/xc2_default.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />";
 $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_RELATIVE . "/javascript/calendar/config/xc2_default.js\"></script>";
 $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_RELATIVE . "/javascript/calendar/script/xc2_inpage.js\"></script>";
 $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_RELATIVE . "/javascript/calendar/script/xc2_timestamp.js\"></script>";
 $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_RELATIVE . "/javascript/dashboard-ics.js\"></script>";
 $JQUERY[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_RELATIVE . "/javascript/jquery/jquery.weekcalendar.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>\n";
 $JQUERY[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_RELATIVE . "/javascript/jquery/jquery.qtip.min.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>\n";
 $JQUERY[] = "<link href=\"" . ENTRADA_RELATIVE . "/css/jquery/jquery.weekcalendar.css?release=" . html_encode(APPLICATION_VERSION) . "\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />\n";
 /**
  * Fetch the latest feeds and links for this user.
  */
 $dashboard_feeds = dashboard_fetch_feeds();
 $dashboard_links = dashboard_fetch_links();
 /**
  * Display current weather conditions in the sidebar.
  */
 $sidebar_html = display_weather();
 if ($sidebar_html != "") {
     new_sidebar_item("Weather Forecast", display_weather(), "weather", "open");
 }
 //generates courses for use with the ics files
 $COURSE_LIST = array();
 $results = courses_fetch_courses(true, true);
 if ($results) {
     foreach ($results as $result) {
         $COURSE_LIST[$result["course_id"]] = html_encode(($result["course_code"] ? $result["course_code"] . ": " : "") . $result["course_name"]);
     }
 * @author Developer: Harry Brundage <*****@*****.**>
 * @copyright Copyright 2010 Queen's University. All Rights Reserved.
 *
*/
@set_include_path(implode(PATH_SEPARATOR, array(dirname(__FILE__) . "/../core", dirname(__FILE__) . "/../core/includes", dirname(__FILE__) . "/../core/library", get_include_path())));
/**
 * Include the Entrada init code.
 */
require_once "init.inc.php";
if (isset($_SESSION["isAuthorized"]) && (bool) $_SESSION["isAuthorized"]) {
    if ($ENTRADA_ACL->amIAllowed("dashboard", "update")) {
        $MODULE = "dashboard";
        switch ($_GET["action"]) {
            case "save":
                $PREFERENCES = preferences_load($MODULE);
                $default_feeds = dashboard_fetch_feeds(true);
                //true fetches only the defaults and no personalized feeds
                $_SESSION[APPLICATION_IDENTIFIER][$MODULE]["feed_break"] = $_POST["break"];
                //Massage the POST'd data into a easier understood format: [1 => [title, url], 2 => [title, url] ... ]
                $new_feeds = array();
                foreach ($_POST as $attribute => $array) {
                    if ($attribute != "break" && $attribute != "_") {
                        foreach ($array as $index => $value) {
                            $new_feeds[$index][$attribute] = $value;
                        }
                    }
                }
                //Find all the non removable urls from the default feeds
                $non_removable_feed_urls = array();
                foreach ($default_feeds as $key => $array) {
                    if (isset($array["removable"]) && !$array["removable"]) {