remove old readme
[atutor.git] / mods / _standard / social / sprofile.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2009                                                                              */
6 /* Inclusive Design Institute                                   */
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$
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 require(AT_SOCIAL_INCLUDE.'friends.inc.php');
20 require(AT_SOCIAL_INCLUDE.'classes/PrivacyControl/PrivacyController.class.php');
21 require(AT_SOCIAL_INCLUDE.'classes/PrivacyControl/PrivacyObject.class.php');
22 $_custom_css = $_base_path . AT_SOCIAL_BASENAME . 'module.css'; // use a custom stylesheet
23
24 /*
25 if (!$_SESSION['valid_user']) {
26         require(AT_INCLUDE_PATH.'header.inc.php');
27         $info = array('INVALID_USER', $_SESSION['course_id']);
28         $msg->printInfos($info);
29         require(AT_INCLUDE_PATH.'footer.inc.php');
30         exit;
31 }
32 */
33
34 // Get profile object
35 $id = intval($_GET['id']);
36 if ($id=='' || $id==0){
37         $id = $_SESSION['member_id'];
38 }
39 $_SESSION['last_visited_page'] = $_base_href.AT_SOCIAL_BASENAME.'sprofile.php?id='.$id;
40
41 // Get member friends
42 $friends = getFriends($id);
43
44 // Get mutual friends
45 if ($id!=$_SESSION['member_id']){
46         $my_friends = getFriends($_SESSION['member_id']);
47         $mutual_friends = array_intersect($friends, $my_friends);
48 } else {
49         $mutual_friends = array();
50 }
51
52 // Get activities       
53 $act_obj = new Activity();
54 $activities = $act_obj->getActivities($id);
55
56 // Member object
57 $profile = new Member($id);
58
59 // Tracks
60 if ($profile->getID() != $_SESSION['member_id']){
61         $profile->addVisitor($_SESSION['member_id']);
62 }
63
64 // Privacy Controller
65 $pc = new PrivacyController();
66 $privacy_obj = $pc->getPrivacyObject($id);
67 if ($privacy_obj==null){
68         //no such person
69         //add error and redirect back to is own page?
70 //      header('Location: sprofile.php');
71 //      exit;   
72 } else {
73         $relationship = $pc->getRelationship($id);
74         $profile_prefs = $privacy_obj->getProfile();
75 }
76
77 // Delete activities
78 if (isset($_GET['delete'])){
79         $id = intval($_GET['delete']);
80         if ($id > 0){
81                 if ($act_obj->deleteActivity($id)){
82                         $msg->addFeedBack('ACTIVITY_DELETED');
83                 } else {
84                         $msg->addError('ACTIVITY_DELETE_FAILED');
85                 }
86                 header('Location: '.url_rewrite(AT_SOCIAL_BASENAME.'sprofile.php', AT_PRETTY_URL_HEADER));
87                 exit;
88         }
89 }
90
91 // Display
92 include(AT_INCLUDE_PATH.'header.inc.php');
93
94 $savant->display('social/pubmenu.tmpl.php');
95 if (!empty($mutual_friends)){
96         $savant->assign('mutual_friends', $mutual_friends);
97 }
98 $savant->assign('scope', ($id!=$_SESSION['member_id']) ? 'viewer' : 'owner');
99 $savant->assign('profile', $profile->getDetails());
100 $savant->assign('education', $profile->getEducation());
101 $savant->assign('position', $profile->getPosition());
102 $savant->assign('websites', $profile->getWebsites());
103 $savant->assign('friends', $friends);
104 $savant->assign('activities', $activities);
105 $savant->assign('prefs', $profile_prefs);
106 $savant->assign('relationship', $relationship);
107 $savant->assign('representation', $profile->getRepresentation());
108 $savant->assign('contact', $profile->getContact());
109 $savant->assign('personal', $profile->getPersonal());
110
111 $savant->display('social/sprofile.tmpl.php');
112 include(AT_INCLUDE_PATH.'footer.inc.php');
113 ?>