From: Michael J. Rubinsky Date: Tue, 24 Feb 2009 16:00:54 +0000 (-0500) Subject: Move Friends methods to a dedicated class, fix class header in Fql.php X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9bb7f5c5832167ffe463a9823a8ae4c7ebf9bd86;p=horde.git Move Friends methods to a dedicated class, fix class header in Fql.php --- diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook.php b/framework/Service_Facebook/lib/Horde/Service/Facebook.php index 89e83af85..bfcf7799d 100644 --- a/framework/Service_Facebook/lib/Horde/Service/Facebook.php +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook.php @@ -270,59 +270,6 @@ class Horde_Service_Facebook } /** - * Returns whether or not pairs of users are friends. - * Note that the Facebook friend relationship is symmetric. - * - * @param string $uids1 comma-separated list of ids (id_1, id_2,...) - * of some length X - * @param string $uids2 comma-separated list of ids (id_A, id_B,...) - * of SAME length X - * - * @return array An array with uid1, uid2, and bool if friends, e.g.: - * array(0 => array('uid1' => id_1, 'uid2' => id_A, 'are_friends' => 1), - * 1 => array('uid1' => id_2, 'uid2' => id_B, 'are_friends' => 0) - * ...) - * @error - * API_EC_PARAM_USER_ID_LIST - */ - public function &friends_areFriends($uids1, $uids2) - { - return $this->call_method('facebook.friends.areFriends', - array('uids1' => $uids1, 'uids2' => $uids2)); - } - - /** - * Returns the friends of the current session user. - * - * @param int $flid (Optional) Only return friends on this friend list. - * @param int $uid (Optional) Return friends for this user. - * - * @return array An array of friends - */ - public function &friends_get($flid=null, $uid = null) - { - $params = array(); - if ($uid) { - $params['uid'] = $uid; - } - if ($flid) { - $params['flid'] = $flid; - } - - return $this->call_method('facebook.friends.get', $params); - } - - /** - * Returns the set of friend lists for the current session user. - * - * @return array An array of friend list objects - */ - public function &friends_getLists() - { - return $this->call_method('facebook.friends.getLists'); - } - - /** * Returns groups according to the filters specified. * * @param int $uid (Optional) User associated with groups. A null diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook/Fql.php b/framework/Service_Facebook/lib/Horde/Service/Facebook/Fql.php index 497b35783..e995a8af2 100644 --- a/framework/Service_Facebook/lib/Horde/Service/Facebook/Fql.php +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook/Fql.php @@ -1,6 +1,12 @@ + * @category Horde + * @package Horde_Service_Facebook */ class Horde_Service_Facebook_Fql extends Horde_Service_Facebook_Base { diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook/Friends.php b/framework/Service_Facebook/lib/Horde/Service/Facebook/Friends.php new file mode 100644 index 000000000..7d249faac --- /dev/null +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook/Friends.php @@ -0,0 +1,85 @@ + + * @category Horde + * @package Horde_Service_Facebook + */ +class Horde_Servce_Facebook_Friends extends Horde_Service_Facebook_Base +{ + /** + * Returns whether or not pairs of users are friends. + * Note that the Facebook friend relationship is symmetric. + * + * @param string $uids1 comma-separated list of ids (id_1, id_2,...) + * of some length X + * @param string $uids2 comma-separated list of ids (id_A, id_B,...) + * of SAME length X + * + * @return array An array with uid1, uid2, and bool if friends, e.g.: + * array(0 => array('uid1' => id_1, 'uid2' => id_A, 'are_friends' => 1), + * 1 => array('uid1' => id_2, 'uid2' => id_B, 'are_friends' => 0) + * ...) + * @error + * API_EC_PARAM_USER_ID_LIST + */ + public function &areFriends($uids1, $uids2) + { + // Session key is *required* + if (empty($this->_sessionKey)) { + throw new Horde_FaceBook_Exception('session_key is required', + Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED); + } + + return $this->_facebook->call_method('facebook.friends.areFriends', + array('uids1' => $uids1, + 'uids2' => $uids2, + 'session_key' => $this->_sessionKey)); + } + + /** + * Returns the friends of the current session user. + * + * @param int $flid (Optional) Only return friends on this friend list. + * @param int $uid (Optional) Return friends for this user. + * + * @return array An array of friends + */ + public function &get($flid = null, $uid = null) + { + // Session key is *required* + if (empty($this->_sessionKey)) { + throw new Horde_FaceBook_Exception('session_key is required', + Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED); + } + $params = array(); + if ($uid) { + $params['uid'] = $uid; + } + if ($flid) { + $params['flid'] = $flid; + } + + return $this->_facebook->call_method('facebook.friends.get', $params); + } + + /** + * Returns the set of friend lists for the current session user. + * + * @return array An array of friend list objects + */ + public function &getLists() + { + // Session key is *required* + if (empty($this->_sessionKey)) { + throw new Horde_FaceBook_Exception('session_key is required', + Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED); + } + return $this->_facebook->call_method('facebook.friends.getLists', + array('session_key' => $this->_sessionKey)); + } + +} \ No newline at end of file diff --git a/framework/Service_Facebook/package.xml b/framework/Service_Facebook/package.xml index 0484780f9..d69bc3467 100644 --- a/framework/Service_Facebook/package.xml +++ b/framework/Service_Facebook/package.xml @@ -35,6 +35,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -65,13 +66,13 @@ http://pear.php.net/dtd/package-2.0.xsd"> + -