From: Duck (Jakob Munih) Date: Tue, 3 Mar 2009 19:40:13 +0000 (+0100) Subject: Start playing with FB X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b4e01ea2644bdb97a90092ba245defdbd698743a;p=horde.git Start playing with FB --- diff --git a/folks/config/conf.xml b/folks/config/conf.xml index 743430075..68dfb87aa 100644 --- a/folks/config/conf.xml +++ b/folks/config/conf.xml @@ -42,6 +42,7 @@ + letter diff --git a/folks/lib/Friends/facebook.php b/folks/lib/Friends/facebook.php new file mode 100644 index 000000000..85a834237 --- /dev/null +++ b/folks/lib/Friends/facebook.php @@ -0,0 +1,60 @@ + + * @package Folks + */ +class Folks_Friends_facebook extends Folks_Friends { + + /** + * Get user friends + * + * @return array of users + */ + protected function _getFriends() + { + global $conf, $prefs; + + if (!$conf['facebook']['enabled']) { + return PEAR::raiseError(_("No Facebook integration exists.")); + } + + $context = array('http_client' => new Horde_Http_Client(), + 'http_request' => new Horde_Controller_Request_Http()); + $facebook = new Horde_Service_Facebook($conf['facebook']['key'], + $conf['facebook']['secret'], + $context); + + $session = unserialize($prefs->getValue('facebook')); + $facebook->auth->setUser($session['uid'], $session['sid'], 0); + + $fql = 'SELECT uid, name FROM user WHERE uid IN (' + . 'SELECT uid2 FROM friend WHERE uid1=' . $session['uid'] . ')'; + + $results = $facebook->fql->run($fql); + $friends = array(); + foreach ($results as $result) { + $friends[$result['uid']] = $result['uid']; + } + + return $friends; + } + + /** + * Get avaiable groups + */ + public function getGroups() + { + return array('whitelist' => _("Friends")); + } +} \ No newline at end of file