* @category Pugin
* @package StatusNet
* @author Zach Copley <zach@status.net>
- * @copyright 2010 StatusNet, Inc.
+ * @copyright 2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
*/
class FacebookBridgePlugin extends Plugin
{
- public $appId = null; // Facebook application ID
- public $secret = null; // Facebook application secret
+ public $appId; // Facebook application ID
+ public $secret; // Facebook application secret
+
public $facebook = null; // Facebook application instance
public $dir = null; // Facebook plugin dir
*/
function initialize()
{
+
+ // Allow the id and key to be passed in
+ // Control panel will override
+
+ if (isset($this->appId)) {
+ $appId = common_config('facebook', 'appid');
+ if (empty($appId)) {
+ Config::save(
+ 'facebook',
+ 'appid',
+ $this->appId
+ );
+ }
+ }
+
+ if (isset($this->secret)) {
+ $secret = common_config('facebook', 'secret');
+ if (empty($secret)) {
+ Config::save('facebook', 'secret', $this->secret);
+ }
+ }
+
$this->facebook = Facebookclient::getFacebook(
$this->appId,
$this->secret
*/
function onAutoload($cls)
{
-
$dir = dirname(__FILE__);
//common_debug("class = " . $cls);
default:
return true;
}
-
}
/**
function onRouterInitialized($m)
{
// Always add the admin panel route
- $m->connect('admin/facebook', array('action' => 'facebookadminpanel'));
-
- // Only add these routes if an application has been setup on
- // Facebook for the plugin to use.
- if ($this->hasApplication()) {
+ $m->connect('panel/facebook', array('action' => 'facebookadminpanel'));
- $m->connect(
- 'main/facebooklogin',
- array('action' => 'facebooklogin')
- );
- $m->connect(
- 'main/facebookfinishlogin',
- array('action' => 'facebookfinishlogin')
- );
- $m->connect(
- 'settings/facebook',
- array('action' => 'facebooksettings')
- );
- $m->connect(
- 'facebook/deauthorize',
- array('action' => 'facebookdeauthorize')
- );
-
- }
+ $m->connect(
+ 'main/facebooklogin',
+ array('action' => 'facebooklogin')
+ );
+ $m->connect(
+ 'main/facebookfinishlogin',
+ array('action' => 'facebookfinishlogin')
+ );
+ $m->connect(
+ 'settings/facebook',
+ array('action' => 'facebooksettings')
+ );
+ $m->connect(
+ 'facebook/deauthorize',
+ array('action' => 'facebookdeauthorize')
+ );
return true;
}
* Add a login tab for Facebook, but only if there's a Facebook
* application defined for the plugin to use.
*
- * @param Action &action the current action
+ * @param Action $action the current action
*
* @return void
*/
- function onEndLoginGroupNav(&$action)
+ function onEndLoginGroupNav($action)
{
$action_name = $action->trimmed('action');
if ($this->hasApplication()) {
$action->menuItem(
+ // TRANS: Menu item for "Facebook" login.
common_local_url('facebooklogin'),
_m('MENU', 'Facebook'),
- // TRANS: Tooltip for menu item "Facebook".
- _m('Login or register using Facebook'),
+ // TRANS: Menu title for "Facebook" login.
+ _m('Login or register using Facebook.'),
'facebooklogin' === $action_name
);
}
return true;
}
+ /**
+ * If the plugin's installed, this should be accessible to admins
+ */
+ function onAdminPanelCheck($name, &$isOK)
+ {
+ if ($name == 'facebook') {
+ $isOK = true;
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Add a Facebook tab to the admin panels
*
$nav->out->menuItem(
common_local_url('facebookadminpanel'),
- // TRANS: Menu item.
+ // TRANS: Menu item for "Facebook" in administration panel.
_m('MENU','Facebook'),
- // TRANS: Tooltip for menu item "Facebook".
- _m('Facebook integration configuration'),
+ // TRANS: Menu title for "Facebook" in administration panel.
+ _m('Facebook integration configuration.'),
$action_name == 'facebookadminpanel',
'nav_facebook_admin_panel'
);
* Add a tab for user-level Facebook settings if the user
* has a link to Facebook
*
- * @param Action &action the current action
+ * @param Action $action the current action
*
* @return void
*/
- function onEndConnectSettingsNav(&$action)
+ function onEndConnectSettingsNav($action)
{
if ($this->hasApplication()) {
$action_name = $action->trimmed('action');
- // CurrentUserDesignAction stores the current user in $cur
- $user = $action->getCurrentUser();
+ $user = common_current_user();
$flink = null;
$action->menuItem(
common_local_url('facebooksettings'),
- // TRANS: Menu item tab.
+ // TRANS: Menu item for "Facebook" in user settings.
_m('MENU','Facebook'),
- // TRANS: Tooltip for menu item "Facebook".
- _m('Facebook settings'),
+ // TRANS: Menu title for "Facebook" in user settings.
+ _m('Facebook settings.'),
$action_name === 'facebooksettings'
);
-
}
}
-
}
/*
if (!empty($appId) && !empty($secret)) {
return true;
}
-
}
return false;
common_debug("LOGOUT URL = $logoutUrl");
common_redirect($logoutUrl, 303);
}
-
}
}
*/
function onStartEnqueueNotice($notice, &$transports)
{
- if (self::hasApplication() && $notice->isLocal()) {
+ if (self::hasApplication() && $notice->isLocal() && $notice->inScope(null)) {
array_push($transports, 'facebook');
}
return true;
{
$client = new Facebookclient($notice);
$client->streamRemove();
-
+
return true;
}
*/
function onEndFavorNotice(Profile $profile, Notice $notice)
{
- $client = new Facebookclient($notice);
+ $client = new Facebookclient($notice, $profile);
$client->like();
return true;
*/
function onEndDisfavorNotice(Profile $profile, Notice $notice)
{
- $client = new Facebookclient($notice);
+ $client = new Facebookclient($notice, $profile);
$client->unLike();
return true;
'author' => 'Craig Andrews, Zach Copley',
'homepage' => 'http://status.net/wiki/Plugin:FacebookBridge',
'rawdescription' =>
+ // TRANS: Plugin description.
_m('A plugin for integrating StatusNet with Facebook.')
);