Overview

Packages

  • Folks
  • None

Classes

  • Folks
  • Folks_Activity_Form
  • Folks_Api
  • Folks_Application
  • Folks_Block_Activities
  • Folks_Block_Friends
  • Folks_Block_Know
  • Folks_Block_New
  • Folks_Block_Random
  • Folks_Block_Recent
  • Folks_Driver
  • Folks_Driver_sql
  • Folks_Friends
  • Folks_Friends_application
  • Folks_Friends_facebook
  • Folks_Friends_prefs
  • Folks_Friends_shared
  • Folks_Friends_sql
  • Folks_Login_Form
  • Folks_Notification
  • Folks_Notification_facebook
  • Folks_Notification_letter
  • Folks_Notification_mail
  • Folks_Notification_tickets
  • Folks_Search_Form
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Folks facebook firends implementation
 4:  *
 5:  * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * See the enclosed file COPYING for license information (GPL). If you
 8:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 9:  *
10:  * @author  Duck <duck@obala.net>
11:  * @package Folks
12:  */
13: class Folks_Friends_facebook extends Folks_Friends {
14: 
15:     /**
16:      * FB connection parameters
17:      */
18:     private $_facebook;
19:     private $_sid;
20:     private $_uid;
21: 
22:     /**
23:      * Get user friends
24:      *
25:      * @return array of users
26:      */
27:     protected function _getFriends()
28:     {
29:         if (!$this->_loadFB) {
30:             return $this->_fb;
31:         }
32: 
33:         try {
34:             $friends = $this->_fb->friends->get(null, $this->_uid);
35:         } catch (Horde_Service_Facebook_Exception $e) {
36:             return PEAR::raiseError($e->getMessage());
37:         }
38: 
39:         return $friends;
40:     }
41: 
42:     /**
43:      * Get avaiable groups
44:      */
45:     public function getGroups()
46:     {
47:         if (!$this->_loadFB) {
48:             return $this->_fb;
49:         }
50: 
51:         try {
52:             $groups = $this->_fb->friends->getLists();
53:         } catch (Horde_Service_Facebook_Exception $e) {
54:             return PEAR::raiseError($e->getMessage());
55:         }
56: 
57:         return $groups;
58:     }
59: 
60: 
61:     /**
62:      * Load FB content
63:      */
64:     private function _loadFB()
65:     {
66:         if ($this->_fb) {
67:             return true;
68:         }
69: 
70:         if (!$conf['facebook']['enabled']) {
71:             $this->_fb = PEAR::raiseError(_("No Facebook integration exists."));
72:             return false;
73:         }
74: 
75:         // Check FB user config
76:         $fbp = unserialize($prefs->getValue('facebook'));
77:         if (!$fbp || empty($fbp['uid'])) {
78:             $this->_fb = PEAR::raiseError(_("User has no link."));
79:             return false;
80:         }
81: 
82:         try {
83:             $facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook');
84:         } catch (Horde_Exception $e) {
85:             $error = PEAR::raiseError($e->getMessage(), $e->getCode());
86:             Horde::logMessage($error, 'ERR');
87: 
88:             return $error;
89:         }
90:         $this->_fb->auth->setUser($fbp['uid'], $fbp['sid'], 0);
91: 
92:         return true;
93:     }
94: }
95: 
API documentation generated by ApiGen