remove old readme
[atutor.git] / mods / _standard / social / index.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010                                             */
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.'friends.inc.php');
19 require(AT_SOCIAL_INCLUDE.'classes/Applications.class.php');
20 require(AT_SOCIAL_INCLUDE.'classes/SocialGroups/SocialGroup.class.php');
21 require(AT_SOCIAL_INCLUDE.'classes/SocialGroups/SocialGroups.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 //Handles search queries from side menu
34 if (isset($_GET['searchFriends']) && $_GET['friendsName']!=''){
35         $wanted = $addslashes($_GET['friendsName']);
36         $friends = searchFriends($wanted, true);
37 }
38
39 //Handles remove request
40 if (isset($_GET['remove'])){
41         $id = intval($_GET['id']);
42 //      if (isset($_GET['confirm_remove'])){
43                 removeFriend($id);
44                 header('Location: '.url_rewrite(AT_SOCIAL_BASENAME.AT_SOCIAL_INDEX, AT_PRETTY_URL_IS_HEADER));
45                 exit;
46 //      }
47 //      $msg->addConfirm("are_you_sure?");
48 //      header('Location: '.url_rewrite(AT_SOCIAL_BASENAME.'index.php?remove=yes'.SEP.'id='.$id.SEP.'confirm_remove=yes'));
49 }
50
51 //Handles request approval, and rejection
52 if (isset($_GET['approval'])){
53         $id = intval($_GET['id']);
54         if ($_GET['approval'] == 'y'){
55                 approveFriendRequest($id);
56                 $sql_notify = "SELECT first_name, last_name, email FROM ".TABLE_PREFIX."members WHERE member_id=$id";
57                 $result_notify = mysql_query($sql_notify, $db);
58                 $row_notify = mysql_fetch_assoc($result_notify);
59
60                 if ($row_notify['email'] != '') {
61                         require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
62                         $body = _AT('notification_accept_contact', get_display_name($_SESSION['member_id']), $_base_href.AT_SOCIAL_BASENAME.'index_mystart.php');
63                         $sender = get_display_name($_SESSION['member_id']);
64                         $mail = new ATutorMailer;
65                         $mail->AddAddress($row_notify['email'], $sender);
66                         $mail->FromName = $_config['site_name'];
67                         $mail->From     = $_config['contact_email'];
68                         $mail->Subject  = _AT('contact_accepted');
69                         $mail->Body     = $body;
70
71                         if(!$mail->Send()) {
72                                 $msg->addError('SENDING_ERROR');
73                         }
74                         unset($mail);
75                 }
76
77         } elseif ($_GET['approval'] == 'n'){
78                 rejectFriendRequest($id);
79         }
80         header('Location: '.url_rewrite(AT_SOCIAL_BASENAME.AT_SOCIAL_INDEX, AT_PRETTY_URL_IS_HEADER));
81         exit;
82 }
83
84 include (AT_INCLUDE_PATH.'header.inc.php'); 
85 ?>
86 <div class="social-wrapper">
87         <div class="network-activity"> 
88                 <?php
89                         //network updates
90                         $actvity_obj = new Activity();
91                         $savant->assign('activities', $actvity_obj->getFriendsActivities($_SESSION['member_id']));
92                         $savant->display('social/activities.tmpl.php');
93
94                         //applications/gagdets
95                         $applications_obj = new Applications();
96                         $savant->assign('list_of_my_apps', $applications_obj->listMyApplications(true));
97                         $savant->display('social/tiny_applications.tmpl.php');
98 //                      echo '<div class="gadget_wrapper">';
99 //                      echo '<div class="gadget_title_bar">Applications</div>';
100 //                      echo '<div class="gadget_container">TODO: GADGETS/Applications</div>';
101 //                      echo '</div>';
102                 ?>
103         </div>
104
105         <div class="my-contacts">
106                 <?php                   
107                         //if friends array is not empty.
108                         if (!empty($friends)){
109                                 $savant->assign('friends', $friends);
110                         } else {
111                                 $savant->assign('friends', getFriends($_SESSION['member_id'], SOCIAL_FRIEND_HOMEPAGE_MAX));
112                         }
113                         $savant->assign('group_invitations', getGroupInvitations());
114                         $savant->assign('group_requests', getGroupRequests());
115                         $savant->assign('pending_requests', getPendingRequests());
116                         $savant->display('social/friend_list.tmpl.php'); 
117                 ?>              
118         </div>
119                 
120         <?php 
121         $people_you_may_know = getPeopleYouMayKnow();   
122         if(!empty($people_you_may_know)):
123         ?>
124         <!-- people you may know -->
125         <div class="people-you-may-know">
126                 
127                 <div class="headingbox">
128                         <h3><?php echo _AT('people_you_may_know'); ?></h3>
129                 </div>
130                 <div class="contentbox">
131                 <?php foreach ($people_you_may_know as $index=>$id): ?>
132                         <div id="contentbox-a">
133                                 <div id="contentbox-b">
134                                         <?php echo printSocialProfileImg($id); ?>                                       
135                                         <?php echo printSocialName($id); ?>
136                                         <a href="<?php echo AT_SOCIAL_BASENAME; ?>connections.php?id=<?php echo $id; ?>"><img src="<?php echo $_base_href.AT_SOCIAL_BASENAME; ?>images/plus_icon.gif" alt="<?php echo _AT('add_to_friends'); ?>" title="<?php echo _AT('add_to_friends'); ?>" border="0" /></a>
137                                 </div>
138                         </div>
139                 <?php endforeach; ?>
140                 </div>
141         </div>
142         <?php endif; ?>
143         <!-- groups --><br /><br /><br />
144         <div class="my-network-groups"><br />
145         <?php                   
146                 //if my groups array is not empty.
147                 $social_group = new SocialGroups();
148                 $my_groups = $social_group->getMemberGroups($_SESSION['member_id']);
149                 $random_groups = array();
150                 for ($i=0; (sizeof($random_groups)<SOCIAL_GROUP_HOMEPAGE_MAX && $i<sizeof($my_groups)); $i++){
151                         $grp = $my_groups[rand(0, sizeof($my_groups)-1)];
152                 
153                         if (in_array($grp, $random_groups)){
154                                 continue;
155                         } else {
156                                 $random_groups[] = $grp;
157                         }
158                 }
159                 //assign
160                 $savant->assign('my_groups', $random_groups);
161                 $savant->assign('randomize_groups', true);
162                 $savant->display('social/tiny_sgroups.tmpl.php');
163         ?>
164         </div>
165 <div style="clear:both;"></div>
166 </div>
167
168 <?php include (AT_INCLUDE_PATH.'footer.inc.php'); ?>