2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2009 */
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 /****************************************************************/
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 = urldecode(trim($_POST['app_url']));
42 //grep the XML file out from any given URL
43 preg_match('/url\=((http[s]?\:\/\/)?(.*)\.xml)/', $app_url, $matches);
45 $app_url = $matches[1];
47 //validate app_url to make sure it always has http:// on it
48 if (preg_match('/^http[s]?\:\/\//', $app_url)==0){
49 $app_url = 'http://'.$app_url;
52 $gadget = $app->parseModulePrefs($app_url);
55 if (empty($gadget->errors)){
56 //add applicatoin to database
57 $app->addApplication($gadget);
58 $msg->addFeedback('GADGET_ADDED_SUCCESSFULLY');
59 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
62 $msg->addError(array('GADGET_ADDED_FAILURE', implode(', ', $gadget->errors)));
63 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
69 if (isset($_POST['show_applications'])){
70 $list_of_all_apps = $app->listApplications();
73 //Display individual application
74 if (isset($_REQUEST['app_id'])){
75 $_REQUEST['app_id'] = intval($_REQUEST['app_id']);
76 $app = new Application($_REQUEST['app_id']); //testing application 1, 2
79 if (isset($_GET['add']) && intval($_GET['add'])==1){
80 $app->addMemberApplication($_SESSION['member_id'], $_GET['app_id']);
81 $msg->addFeedback('GADGET_ADDED_SUCCESSFULLY');
82 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
87 if (isset($_GET['delete']) && intval($_GET['delete']) > 0) {
88 $app->deleteApplication();
89 $msg->addFeedback('GADGET_REMOVED_SUCCESSFULLY');
90 header('Location: '. $_SERVER['HTTP_REFERER']);
94 //Display application settings
95 if (isset($_GET['settings'])){
96 include(AT_INCLUDE_PATH.'header.inc.php');
97 $savant->assign('settings', $app->getSettings()); //userPrefs
98 $savant->assign('user_settings', $app->getApplicationSettings($_SESSION['member_id']));
99 $savant->assign('app_id', $app->getId()); //id
100 $savant->display('social/application_settings.tmpl.php');
101 include(AT_INCLUDE_PATH.'footer.inc.php');
106 if (isset($_POST['app_settings'])){
107 foreach ($app->getSettings() as $key=>$value){
108 if(isset($_POST[$key])){
109 //save values iff it is in the userPrefs serialized string.
110 //don't save values blindly from the $_POST.
111 $value = $addslashes($_POST[$key]);
112 $app->setApplicationSettings($_SESSION['member_id'], $key, $value);
115 $msg->addFeedback('GADGET_SETTINGS_SAVED');
116 header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
120 //loop through all app and print out the thumbnail
121 $iframe_url = $app->getIframeUrl($_REQUEST['id'], 'canvas', $_GET['appParams']);
124 include(AT_INCLUDE_PATH.'header.inc.php');
125 $savant->assign('iframe_url', $iframe_url);
126 $savant->assign('app', $app);
127 $savant->display('social/individual_application.tmpl.php');
128 include(AT_INCLUDE_PATH.'footer.inc.php');
132 //list all my applications
133 $list_of_my_apps = $app->listMyApplications();
135 include(AT_INCLUDE_PATH.'header.inc.php');
136 $savant->display('social/pubmenu.tmpl.php');
137 $savant->assign('list_of_my_apps', $list_of_my_apps);
138 $savant->assign('list_of_all_apps', $list_of_all_apps);
139 $savant->display('social/applications.tmpl.php');
140 include(AT_INCLUDE_PATH.'footer.inc.php');