539f4776b8ffb3ba05d7341748b63a318bc8e864
[atutor.git] / mods / social / settings.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2009                                                                              */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
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 /****************************************************************/
13 // $Id: privacy_settings.php 8423 2009-04-03 20:04:55Z hwong $
14 $_user_location = 'public';
15
16 define('AT_INCLUDE_PATH', '../../include/');
17 require (AT_INCLUDE_PATH.'vitals.inc.php');
18 require(AT_SOCIAL_INCLUDE.'constants.inc.php');
19 include(AT_SOCIAL_INCLUDE.'classes/PrivacyControl/PrivacyObject.class.php');
20 include(AT_SOCIAL_INCLUDE.'classes/PrivacyControl/PrivacyController.class.php');
21 include(AT_SOCIAL_INCLUDE.'classes/Application.class.php');
22 $_custom_css = $_base_path . AT_SOCIAL_BASENAME . 'module.css'; // use a custom stylesheet
23
24 if (!$_SESSION['valid_user']) {
25         require(AT_INCLUDE_PATH.'header.inc.php');
26         $info = array('INVALID_USER', $_SESSION['course_id']);
27         $msg->printInfos($info);
28         require(AT_INCLUDE_PATH.'footer.inc.php');
29         exit;
30 }
31
32 $controller = new PrivacyController();
33 $private_obj = $controller->getPrivacyObject($_SESSION['member_id']);
34
35 //headers start here
36 include(AT_INCLUDE_PATH.'header.inc.php'); 
37 $savant->display('pubmenu.tmpl.php');
38 $savant->display('settings/settings_menu.tmpl.php');
39 if (isset($_REQUEST['n']) && $_REQUEST['n']=='account_settings'){
40         //TODO
41         //Default to account settings
42         //Page prints from here
43         $savant->display('settings/account_settings.tmpl.php');
44 } elseif (isset($_REQUEST['n']) && $_REQUEST['n']=='application_settings'){
45         $app = new Application();
46         //handle application setting updates
47         if (isset($_POST['submit'])){
48                 //Updates
49                 $app->setHomeDisplaySettings($_POST['app']);
50                 //TODO print message/feedback
51                 $msg->addFeedback('SETTINGS_UPDATED');
52                 $msg->printAll();
53         }
54         
55         //initialization
56         $savant->assign('home_display', $app->getHomeDisplaySettings());
57         $savant->assign('my_apps', $list_of_my_apps = $app->listMyApplications());
58         $savant->display('settings/application_settings.tmpl.php');
59 } else {
60         //handle privacy setting updates
61         if (isset($_POST['submit'])){
62                 //Updates
63                 $private_obj->setProfile($_POST['profile_prefs']);
64                 $private_obj->setSearch($_POST['search_prefs']);
65                 $private_obj->setActivity($activity_prefs);
66
67                 //update privacy preference
68                 PrivacyController::updatePrivacyPreference($_SESSION['member_id'], $private_obj);
69
70                 //TODO print message/feedback
71                 $msg->addFeedback('SETTINGS_UPDATED');
72                 $msg->printAll();
73         }
74
75         //Page prints from here
76         $savant->assign('controller', $controller);
77         $savant->assign('profile_prefs', $private_obj->getProfile());
78         $savant->assign('search_prefs', $private_obj->getSearch());
79         $savant->assign('application_prefs', $private_obj->getActivity());
80         $savant->display('settings/privacy_settings.tmpl.php');
81 }
82 include(AT_INCLUDE_PATH.'footer.inc.php'); 
83 ?>