/** * Get the relationship between Session[member_id] and the given id. * Relationship can be friends, friends of friends, network, family, aquaintance, etc. * TODO: Confirm that the order of checks is not important. Draw a control flow diagram to check this. * For now, Friends of friends > Groups * @param int the member that we want to find the relationship to the session[member] * @return relationship status */ function getRelationship($id) { //if id = self, always true (cause i should be able to see my own profile) if (isset($_SESSION['member_id'])) { if ($id == $_SESSION['member_id']) { return AT_SOCIAL_OWNER_VISIBILITY; } //is friend of friend? if (isFriendOfFriend($id, $_SESSION['member_id']) == true) { return AT_SOCIAL_FRIENDS_OF_FRIENDS_VISIBILITY; } //is in some of the groups together? $social_groups = new SocialGroups(); $my_group = $social_groups->getMemberGroups($_SESSION['member_id']); $person_group = $social_groups->getMemberGroups($id); $groups_intersection = array_intersect($my_group, $person_group); //groups intersection //If it is not empty or not null, then these 2 people share a group if (!empty($groups_intersection) > 0) { return AT_SOCIAL_GROUPS_VISIBILITY; } $sql = "SELECT relationship FROM %ssocial_friends WHERE (member_id=%d AND friend_id=%d) OR (member_id=%d AND friend_id=%d)"; $relationship = queryDB($sql, array(TABLE_PREFIX, $id, $_SESSION['member_id'], $_SESSION['member_id'], $id)); } // NOT SURE IF THIS IS WORKING WITH QUERYDB // if (isset($result)){ // list($relationship) = mysql_fetch_row($result); // } //If the relationship is not set, this implies that it's not in the table, //implying that the user has never set its privacy settings, meaning a default is needed if (!isset($relationship)) { return AT_SOCIAL_NETWORK_VISIBILITY; } return $relationship; }
//paginator settings $page = intval($_GET['p']); if (!$page) { $page = 1; } $count = (($page-1) * SOCIAL_GROUP_MAX) + 1; $offset = ($page-1) * SOCIAL_GROUP_MAX; // Get activities $act_obj = new Activity(); $activities = $act_obj->getActivities($id); // Get social group class $social_group = new SocialGroups(); $my_groups = $social_group->getMemberGroups($_SESSION['member_id']); //to get the size $num_pages = sizeof($my_groups)/SOCIAL_GROUP_MAX; $my_groups = $social_group->getMemberGroups($_SESSION['member_id'], $offset); //Display include(AT_INCLUDE_PATH.'header.inc.php'); $savant->display('social/pubmenu.tmpl.php'); if($num_pages > 1){ ?> <div class="pageinator_box"> <?php print_paginator($page, $num_pages, '', 1); ?> </div> <?php
</div> </div> <?php } ?> </div> </div> <?php } ?> <!-- groups --><br /><br /><br /> <div class="my-network-groups"><br /> <?php //if my groups array is not empty. $social_group = new SocialGroups(); $my_groups = $social_group->getMemberGroups($_SESSION['member_id']); $random_groups = array(); for ($i = 0; sizeof($random_groups) < SOCIAL_GROUP_HOMEPAGE_MAX && $i < sizeof($my_groups); $i++) { $grp = $my_groups[rand(0, sizeof($my_groups) - 1)]; if (in_array($grp, $random_groups)) { continue; } else { $random_groups[] = $grp; } } //assign $savant->assign('my_groups', $random_groups); $savant->assign('randomize_groups', true); $savant->display('social/tiny_sgroups.tmpl.php'); ?> </div>