3 * StatusNet, the distributed open-source microblogging tool
5 * Plugin to add a StatusNet Facebook application
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Zach Copley <zach@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
35 * Facebook plugin to add a StatusNet Facebook application
39 * @author Zach Copley <zach@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41 * @link http://status.net/
44 class FacebookPlugin extends Plugin
48 * Add Facebook app actions to the router table
50 * Hook for RouterInitialized event.
52 * @param Net_URL_Mapper &$m path-to-action mapper
54 * @return boolean hook return
57 function onRouterInitialized(&$m)
59 $m->connect('facebook', array('action' => 'facebookhome'));
60 $m->connect('facebook/index.php', array('action' => 'facebookhome'));
61 $m->connect('facebook/settings.php', array('action' => 'facebooksettings'));
62 $m->connect('facebook/invite.php', array('action' => 'facebookinvite'));
63 $m->connect('facebook/remove', array('action' => 'facebookremove'));
69 * Automatically load the actions and libraries used by the Facebook app
71 * @param Class $cls the class
73 * @return boolean hook return
76 function onAutoload($cls)
79 case 'FacebookAction':
80 case 'FacebookhomeAction':
81 case 'FacebookinviteAction':
82 case 'FacebookremoveAction':
83 case 'FacebooksettingsAction':
84 include_once INSTALLDIR . '/plugins/Facebook/' .
85 strtolower(mb_substr($cls, 0, -6)) . '.php';
93 * Add a Facebook queue item for each notice
95 * @param Notice $notice the notice
96 * @param array &$transports the list of transports (queues)
98 * @return boolean hook return
100 function onStartEnqueueNotice($notice, &$transports)
102 array_push($transports, 'facebook');
107 * broadcast the message when not using queuehandler
109 * @param Notice &$notice the notice
110 * @param array $queue destination queue
112 * @return boolean hook return
114 function onUnqueueHandleNotice(&$notice, $queue)
116 if (($queue == 'facebook') && ($this->_isLocal($notice))) {
117 facebookBroadcastNotice($notice);
124 * Determine whether the notice was locally created
126 * @param Notice $notice
128 * @return boolean locality
130 function _isLocal($notice)
132 return ($notice->is_local == Notice::LOCAL_PUBLIC ||
133 $notice->is_local == Notice::LOCAL_NONPUBLIC);
137 * Add Facebook queuehandler to the list of daemons to start
139 * @param array $daemons the list fo daemons to run
141 * @return boolean hook return
144 function onGetValidDaemons($daemons)
146 array_push($daemons, INSTALLDIR .
147 '/plugins/Facebook/facebookqueuehandler.php');