/** * Sends an invitation to a friend via email. When the friend receives the email, the code in the email * invitation will allow them to connect to the originating user. * * @return array */ public function execute() { error_log('RSVP URL is ' . $this->m_rsvp); Api_Bo_Friends::inviteFriendsByEmail($this->getUserId(), $this->getNetworkId(), $this->m_rsvp, $this->m_email); // No exception means it worked return array('response' => '1'); }
/** * Queries the friends and users table to match the query given. * If no query is provided it returns all friends. * * @return array */ public function execute() { $fuid = $this->getApiParam('fuid'); Api_Bo_Friends::createFriend($this->getUserId(), $fuid); // No exception means it worked $response = array(); $response['response'] = '1'; return $response; }
/** * Execute the Friends.getAppUsers method * * @return The user ids that are the friends. * * For example if the friend uids are 2,3,4 then the return value would be: * array( 'uid'=> (2,3,4) ) * ) */ public function execute() { $users = Api_Bo_Friends::getAppUsers($this->getNetworkId(), $this->getUserId(), $this->getContext()->getApiKey()); $response = array(); if (null != $users) { foreach ($users as $u) { $response['uid'][] = $u['user_id']; } } return $response; }
/** * Enter description here... * * @param unknown_type $userId * @param unknown_type $uid * @param unknown_type $gid * @return unknown */ public static function getGroups($loggedInUserId, $uid = null, $gids = null) { $uid = null == $uid ? $loggedInUserId : $uid; $areFriends = Api_Bo_Friends::checkFriends($loggedInUserId, $uid); if ($areFriends) { if (null == $gids || empty($gids)) { return Api_Dao_Group::getGroupsByUserId($uid)->toArray(); } return Api_Dao_Group::getGroupsByUserIdAndGroupIds($uid, $gids)->toArray(); } return array(); }
/** * Queries the friends and users table to match the query given. * If no query is provided it returns all friends. * * @return array */ public function execute() { $q = $this->getApiParam('query'); $ret = Api_Bo_Friends::searchFriends($this->getUserId(), $q); $response = array(); if (empty($ret)) { $response['friends'] = array(); } else { $response['friends'] = $ret; } return $response; }
/** * Execute the Friends.get method * * @return The user ids that are the friends. * * For example if the friend uids are 2,3,4 then the return value would be * array( uid=> array(2,3,4) ) * */ public function execute() { $response = array(); $friends = null; if ($this->m_uid == null) { $friends = Api_Bo_Friends::getFriends($this->getUserId()); } else { // What type of friend check should we do? $friends = Api_Bo_Friends::getFriends($this->m_uid); } if (empty($friends)) { $response['uid'] = ''; } else { $response['uid'] = $friends; } return $response; }
public function execute() { $response = array(); // can only be sent to friends $friends = Api_Bo_Friends::getFriends($this->getUserId()); $sendFriends = array_intersect($this->recipients, $friends); if (count($sendFriends) > 0) { // get Email address for each friend. $response['result'] = implode(",", $sendFriends); $mailid = Api_Bo_Notification::createMail($this->getUserId(), $this->subject); foreach ($sendFriends as $friend) { Api_Bo_Notification::addUserToMail($mailid, $friend); } Api_Bo_Notification::addMessage($mailid, $this->getUserId(), $this->message, 1); Api_Bo_Notification::sendEmail($this->getUserId(), $sendFriends, $this->subject, $this->message); } return $response; }
/** * Queries the friends and users table to match the query given. * If no query is provided it returns all friends. * * @return array */ public function execute() { $fuid = $this->getApiParam('fuid'); $access = $this->getApiParam('access'); $status = $this->getApiParam('status'); if ($access < 0 || $access > 2) { error_log("Received an invalid access level in FriendsAccept: {$access}"); $access = 0; } if ($status < 0 || $status > 3) { error_log("Received an invalid status in FriendsAccept: {$status}"); $status = 3; } Api_Bo_Friends::acceptInvite($this->getUserId(), $fuid, $status, $access); // No exception means it worked $response = array(); $response['response'] = '1'; return $response; }
/** * Gets the events based on the parameters passed in * * @param int $loggedInUserId * @param int $uid * @param date_time $start_time * @param date_time $end_time * @param array $eids * @param string $rsvp * @return array */ public static function getEvents($loggedInUserId, $uid = null, $start_time = null, $end_time = null, $eids = null, $rsvp = null) { if ($uid == null && $eids != null) { $members = Api_Dao_Events::getEventMembersAsArray($loggedInUserId, null, null); return Api_Dao_Events::getEventsByEidsAndMembers($eids, $members, $start_time, $end_time)->toArray(); } else { $privacy = false; if ($uid !== null && $uid != $loggedInUserId) { $privacy = self::RS_FBDB_ACCESS_PRIVATE; } $uid = $uid == null ? $loggedInUserId : $uid; // Make sure the logged in user and the uid passed are friends $areFriends = Api_Bo_Friends::checkFriends($loggedInUserId, $uid); if (!$areFriends) { return array(); } $members = Api_Dao_Events::getEventMembersAsArray($uid, $rsvp, $eids); return Api_Dao_Events::getEventsByMembers($members, $start_time, $end_time, $privacy)->toArray(); } }
/** * Execute the Friends.areFriends method * * @return An array of values as xml. There is one element in the outer array * named 'friend_info'. This element is an array made up of 3 sub-elements which are defined as * 'uid1', 'uid2', 'are_friends'. 'uid1' is user id 1, 'uid2' is user id 2, and 'are_friends' is * either a 0 or 1. * * For example if the uids in the get request look like * http://www.acme.com/foo?uid1=1,1,1&uid2=2,3,4 and assuming 1 and 2 are friends and 1 and 3 are friends * and 1 and 4 are not friends then the return value would be * array( * 'friend_info' => array( * array( 'uid1'=>1, 'uid2'=>2, 'are_friends'=>1 ), * array( 'uid1'=>1, 'uid2'=>3, 'are_friends'=>1 ), * array( 'uid1'=>1, 'uid2'=>4, 'are_friends'=>0 ) * ) * ) */ public function execute() { return Api_Bo_Friends::getFriendsAreFriends($this->uid1, $this->uid2); }
/** * @return float number of friends that the average user has */ private function getAverageCountOfFriendsPerUser() { $_totalFriends = Api_Bo_Friends::getTotalCountOfFriends(); return (double) $_totalFriends / $this->totalUsers; }
/** * Checks to see if two users are friends, if they are returns true, otherwise false * * @param int $loggedInUserId * @param int $uid * @return boolean */ public static function checkFriends($loggedInUserId, $uid) { // Indeed, you are friends with yourself if ($uid == $loggedInUserId) { return true; } if ($uid != null) { $faf = Api_Bo_Friends::getFriendsAreFriends($loggedInUserId, $uid); if ($faf['friend_info'][0]['are_friends'] == 1) { return true; } } return false; }