Make Facebook plugin look for API key and secret before doing anything
This commit is contained in:
parent
32c08f53de
commit
f7ba5566bc
@ -79,6 +79,25 @@ class FacebookPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if there is an API key and secret defined
|
||||||
|
* for Facebook integration.
|
||||||
|
*
|
||||||
|
* @return boolean result
|
||||||
|
*/
|
||||||
|
|
||||||
|
static function hasKeys()
|
||||||
|
{
|
||||||
|
$apiKey = common_config('facebook', 'apikey');
|
||||||
|
$apiSecret = common_config('facebook', 'secret');
|
||||||
|
|
||||||
|
if (!empty($apiKey) && !empty($apiSecret)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Facebook app actions to the router table
|
* Add Facebook app actions to the router table
|
||||||
*
|
*
|
||||||
@ -91,6 +110,9 @@ class FacebookPlugin extends Plugin
|
|||||||
|
|
||||||
function onStartInitializeRouter($m)
|
function onStartInitializeRouter($m)
|
||||||
{
|
{
|
||||||
|
$m->connect('admin/facebook', array('action' => 'facebookadminpanel'));
|
||||||
|
|
||||||
|
if (self::hasKeys()) {
|
||||||
|
|
||||||
// Facebook App stuff
|
// Facebook App stuff
|
||||||
|
|
||||||
@ -100,7 +122,6 @@ class FacebookPlugin extends Plugin
|
|||||||
array('action' => 'facebooksettings'));
|
array('action' => 'facebooksettings'));
|
||||||
$m->connect('facebook/app/invite.php', array('action' => 'facebookinvite'));
|
$m->connect('facebook/app/invite.php', array('action' => 'facebookinvite'));
|
||||||
$m->connect('facebook/app/remove', array('action' => 'facebookremove'));
|
$m->connect('facebook/app/remove', array('action' => 'facebookremove'));
|
||||||
$m->connect('admin/facebook', array('action' => 'facebookadminpanel'));
|
|
||||||
|
|
||||||
// Facebook Connect stuff
|
// Facebook Connect stuff
|
||||||
|
|
||||||
@ -108,6 +129,7 @@ class FacebookPlugin extends Plugin
|
|||||||
$m->connect('main/facebooklogin', array('action' => 'FBConnectLogin'));
|
$m->connect('main/facebooklogin', array('action' => 'FBConnectLogin'));
|
||||||
$m->connect('settings/facebook', array('action' => 'FBConnectSettings'));
|
$m->connect('settings/facebook', array('action' => 'FBConnectSettings'));
|
||||||
$m->connect('xd_receiver.html', array('action' => 'FBC_XDReceiver'));
|
$m->connect('xd_receiver.html', array('action' => 'FBC_XDReceiver'));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -338,6 +360,9 @@ class FacebookPlugin extends Plugin
|
|||||||
|
|
||||||
function reqFbScripts($action)
|
function reqFbScripts($action)
|
||||||
{
|
{
|
||||||
|
if (!self::hasKeys()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// If you're logged in w/FB Connect, you always need the FB stuff
|
// If you're logged in w/FB Connect, you always need the FB stuff
|
||||||
|
|
||||||
@ -410,6 +435,8 @@ class FacebookPlugin extends Plugin
|
|||||||
|
|
||||||
function onStartPrimaryNav($action)
|
function onStartPrimaryNav($action)
|
||||||
{
|
{
|
||||||
|
if (self::hasKeys()) {
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
$connect = 'FBConnectSettings';
|
$connect = 'FBConnectSettings';
|
||||||
@ -448,6 +475,7 @@ class FacebookPlugin extends Plugin
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -462,6 +490,7 @@ class FacebookPlugin extends Plugin
|
|||||||
|
|
||||||
function onEndLoginGroupNav(&$action)
|
function onEndLoginGroupNav(&$action)
|
||||||
{
|
{
|
||||||
|
if (self::hasKeys()) {
|
||||||
|
|
||||||
$action_name = $action->trimmed('action');
|
$action_name = $action->trimmed('action');
|
||||||
|
|
||||||
@ -469,7 +498,7 @@ class FacebookPlugin extends Plugin
|
|||||||
_m('Facebook'),
|
_m('Facebook'),
|
||||||
_m('Login or register using Facebook'),
|
_m('Login or register using Facebook'),
|
||||||
'FBConnectLogin' === $action_name);
|
'FBConnectLogin' === $action_name);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,13 +512,15 @@ class FacebookPlugin extends Plugin
|
|||||||
|
|
||||||
function onEndConnectSettingsNav(&$action)
|
function onEndConnectSettingsNav(&$action)
|
||||||
{
|
{
|
||||||
|
if (self::hasKeys()) {
|
||||||
|
|
||||||
$action_name = $action->trimmed('action');
|
$action_name = $action->trimmed('action');
|
||||||
|
|
||||||
$action->menuItem(common_local_url('FBConnectSettings'),
|
$action->menuItem(common_local_url('FBConnectSettings'),
|
||||||
_m('Facebook'),
|
_m('Facebook'),
|
||||||
_m('Facebook Connect Settings'),
|
_m('Facebook Connect Settings'),
|
||||||
$action_name === 'FBConnectSettings');
|
$action_name === 'FBConnectSettings');
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,6 +534,8 @@ class FacebookPlugin extends Plugin
|
|||||||
|
|
||||||
function onStartLogout($action)
|
function onStartLogout($action)
|
||||||
{
|
{
|
||||||
|
if (self::hasKeys()) {
|
||||||
|
|
||||||
$action->logout();
|
$action->logout();
|
||||||
$fbuid = $this->loggedIn();
|
$fbuid = $this->loggedIn();
|
||||||
|
|
||||||
@ -516,7 +549,7 @@ class FacebookPlugin extends Plugin
|
|||||||
$e->getMessage());
|
$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,7 +595,9 @@ class FacebookPlugin extends Plugin
|
|||||||
|
|
||||||
function onStartEnqueueNotice($notice, &$transports)
|
function onStartEnqueueNotice($notice, &$transports)
|
||||||
{
|
{
|
||||||
|
if (self::hasKeys()) {
|
||||||
array_push($transports, 'facebook');
|
array_push($transports, 'facebook');
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +610,9 @@ class FacebookPlugin extends Plugin
|
|||||||
*/
|
*/
|
||||||
function onEndInitializeQueueManager($manager)
|
function onEndInitializeQueueManager($manager)
|
||||||
{
|
{
|
||||||
|
if (self::hasKeys()) {
|
||||||
$manager->connect('facebook', 'FacebookQueueHandler');
|
$manager->connect('facebook', 'FacebookQueueHandler');
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user