2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2009 */
6 /* Adaptive Technology Resource Centre / University of Toronto */
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 /****************************************************************/
14 $_user_location = 'public';
16 define('AT_INCLUDE_PATH', '../../include/');
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 include(AT_SOCIAL_INCLUDE.'friends.inc.php');
19 include(AT_SOCIAL_INCLUDE.'classes/Application.class.php');
20 $_custom_css = $_base_path . AT_SOCIAL_BASENAME . 'module.css'; // use a custom stylesheet
22 if (!$_SESSION['valid_user']) {
23 require(AT_INCLUDE_PATH.'header.inc.php');
24 $info = array('INVALID_USER', $_SESSION['course_id']);
25 $msg->printInfos($info);
26 require(AT_INCLUDE_PATH.'footer.inc.php');
31 $app = new Application();
34 if (isset($_POST['add_application']) && isset($_POST['app_url'])){
35 //check if curl is installed
36 if (!extension_loaded('curl')){
37 $msg->addError('CURL_NOT_INSTALLED');
38 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
41 $app_url = $addslashes(trim($_POST['app_url']));
42 $gadget = $app->parseModulePrefs($app_url);
45 if (empty($gadget->errors)){
46 //add applicatoin to database
47 $app->addApplication($gadget);
48 $msg->addFeedback('GADGET_ADDED_SUCCESSFULLY');
49 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
52 $msg->addError(array('GADGET_ADDED_FAILURE', implode(', ', $gadget->errors)));
53 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
59 if (isset($_POST['show_applications'])){
60 $list_of_all_apps = $app->listApplications();
63 //Display individual application
64 if (isset($_REQUEST['app_id'])){
65 $_REQUEST['app_id'] = intval($_REQUEST['app_id']);
66 $app = new Application($_REQUEST['app_id']); //testing application 1, 2
69 if (isset($_GET['add']) && intval($_GET['add'])==1){
70 $app->addMemberApplication($_SESSION['member_id'], $_GET['app_id']);
71 $msg->addFeedback('GADGET_ADDED_SUCCESSFULLY');
72 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
77 if (isset($_GET['delete']) && intval($_GET['delete']) > 0) {
78 $app->deleteApplication();
79 $msg->addFeedback('GADGET_REMOVED_SUCCESSFULLY');
80 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
84 //Display application settings
85 if (isset($_GET['settings'])){
86 include(AT_INCLUDE_PATH.'header.inc.php');
87 $savant->assign('settings', $app->getSettings()); //userPrefs
88 $savant->assign('user_settings', $app->getApplicationSettings($_SESSION['member_id']));
89 $savant->assign('app_id', $app->getId()); //id
90 $savant->display('application_settings.tmpl.php');
91 include(AT_INCLUDE_PATH.'footer.inc.php');
96 if (isset($_POST['app_settings'])){
97 foreach ($app->getSettings() as $key=>$value){
98 if(isset($_POST[$key])){
99 //save values iff it is in the userPrefs serialized string.
100 //don't save values blindly from the $_POST.
101 $value = $addslashes($_POST[$key]);
102 $app->setApplicationSettings($_SESSION['member_id'], $key, $value);
105 $msg->addFeedback('GADGET_SETTINGS_SAVED');
106 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
110 //loop through all app and print out the thumbnail
111 $iframe_url = $app->getIframeUrl($_REQUEST['id'], 'canvas', $_GET['appParams']);
114 include(AT_INCLUDE_PATH.'header.inc.php');
115 $savant->assign('iframe_url', $iframe_url);
116 $savant->assign('app', $app);
117 $savant->display('individual_application.tmpl.php');
118 include(AT_INCLUDE_PATH.'footer.inc.php');
122 //list all my applications
123 $list_of_my_apps = $app->listMyApplications();
125 include(AT_INCLUDE_PATH.'header.inc.php');
126 $savant->display('pubmenu.tmpl.php');
127 $savant->assign('list_of_my_apps', $list_of_my_apps);
128 $savant->assign('list_of_all_apps', $list_of_all_apps);
129 $savant->display('applications.tmpl.php');
130 include(AT_INCLUDE_PATH.'footer.inc.php');