/**
  * 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;
 }
Ejemplo n.º 2
0
/**
 * Get a list of people you may know
 */
function getPeopleYouMayKnow(){
	global $db;
	$counter = 0;
	$people_you_may_know = array();
	$pending_requests = getPendingRequests(true);

	$sql = 'SELECT MAX(member_id) FROM '.TABLE_PREFIX.'members';
	$result = mysql_query($sql, $db);
	if ($result){
		list($max_id) = mysql_fetch_array($result);
	} else {
		return null;
	}
	
	//if we ran out of people, quit;
	while($counter++ < $max_id){
		//if we get enough people we might know, quit; 
		if (sizeof($people_you_may_know) >= SOCIAL_NUMBER_OF_PEOPLE_YOU_MAY_KNOW){
			break;
		}
		//get new random member
		$random_member = rand(1, $max_id);	//seed is generated automatically since php 4.2.0

		//if this person is myself, next
		if ($random_member==$_SESSION['member_id']){
			continue;
		}

		//if this person is already on pending, next.
		if (isset($pending_requests[$random_member])){
			continue;
		}
		

		//if we have added this random number before, next.
		if (in_array($random_member, $people_you_may_know)){
			continue;
		}

		if (isFriendOfFriend($_SESSION['member_id'], $random_member)){
			$people_you_may_know[] = $random_member;
		}
	}
	return $people_you_may_know;
}