*/
function initialize()
{
- common_debug("XXXXXXXXXXXX " . $this->appId);
// Check defaults and configuration for application ID and secret
if (empty($this->appId)) {
$this->appId = common_config('facebook', 'appid');
}
if (empty($this->facebook)) {
- common_debug('instantiating facebook obj');
$this->facebook = new Facebook(
array(
'appId' => $this->appId,
);
}
- common_debug("FACEBOOK = " . var_export($this->facebook, true));
-
return true;
}
}
/*
- * Add a tab for managing Facebook Connect settings
+ * Add a tab for user-level Facebook settings
*
* @param Action &action the current action
*
if ($this->hasApplication()) {
$action_name = $action->trimmed('action');
- $action->menuItem(common_local_url('facebooksettings'),
- // @todo CHECKME: Should be 'Facebook Connect'?
- // TRANS: Menu item tab.
- _m('MENU','Facebook'),
- // TRANS: Tooltip for menu item "Facebook".
- _m('Facebook Connect Settings'),
- $action_name === 'facebooksettings');
+ $action->menuItem(
+ common_local_url('facebooksettings'),
+ // TRANS: Menu item tab.
+ _m('MENU','Facebook'),
+ // TRANS: Tooltip for menu item "Facebook".
+ _m('Facebook settings'),
+ $action_name === 'facebooksettings'
+ );
}
return true;
return true;
}
+ /*
+ * Log the user out of Facebook, per the Facebook authentication guide
+ *
+ * @param Action action the action
+ */
+ function onEndLogout($action)
+ {
+ $session = $this->facebook->getSession();
+ $fbuser = null;
+ $fbuid = null;
+
+ if ($session) {
+ try {
+ $fbuid = $this->facebook->getUser();
+ $fbuser = $this->facebook->api('/me');
+ } catch (FacebookApiException $e) {
+ common_log(LOG_ERROR, $e, __FILE__);
+ }
+ }
+
+ if (!empty($fbuser)) {
+
+ $logoutUrl = $this->facebook->getLogoutUrl(
+ array('next' => common_local_url('public'))
+ );
+
+ common_log(
+ LOG_INFO,
+ sprintf(
+ "Logging user out of Facebook (fbuid = %s)",
+ $fbuid
+ ),
+ __FILE__
+ );
+
+ common_redirect($logoutUrl, 303);
+ }
+ }
+
+ /*
+ * Add fbml namespace so Facebook's JavaScript SDK can parse and render
+ * XFBML tags (e.g: <fb:login-button>)
+ *
+ * @param Action $action current action
+ * @param array $attrs array of attributes for the HTML tag
+ *
+ * @return nothing
+ */
function onStartHtmlElement($action, $attrs) {
$attrs = array_merge($attrs, array('xmlns:fb' => 'http://www.facebook.com/2008/fbml'));
return true;
}
+ /*
+ * Add version info for this plugin
+ *
+ * @param array &$versions plugin version descriptions
+ */
function onPluginVersion(&$versions)
{
- $versions[] = array('name' => 'Facebook Single-Sign-On',
- 'version' => STATUSNET_VERSION,
- 'author' => 'Zach Copley',
- 'homepage' => 'http://status.net/wiki/Plugin:FacebookSSO',
- 'rawdescription' =>
- _m('A plugin for single-sign-on with Facebook.'));
+ $versions[] = array(
+ 'name' => 'Facebook Single-Sign-On',
+ 'version' => STATUSNET_VERSION,
+ 'author' => 'Zach Copley',
+ 'homepage' => 'http://status.net/wiki/Plugin:FacebookSSO',
+ 'rawdescription' =>
+ _m('A plugin for single-sign-on with Facebook.')
+ );
+
return true;
}
}
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * @category Pugin
+ * @category Plugin
* @package StatusNet
* @author Zach Copley <zach@status.net>
* @copyright 2010 StatusNet, Inc.
class FacebookloginAction extends Action
{
+
function handle($args)
{
parent::handle($args);
);
$session = $facebook->getSession();
- $me = null;
+ $fbuser = null;
if ($session) {
try {
if (!empty($user)) {
- common_debug(
+ common_log(
+ LOG_INFO,
sprintf(
- 'Logged in Facebook user $s as user %d (%s)',
- $this->fbuid,
+ 'Logged in Facebook user %s as user %s (%s)',
+ $fbuid,
$user->id,
$user->nickname
),
$this->elementStart('fieldset');
$attrs = array(
- 'show-faces' => 'true',
- 'width' => '100',
- 'max-rows' => '2',
+ //'show-faces' => 'true',
+ //'max-rows' => '4',
+ //'width' => '600',
'perms' => 'user_location,user_website,offline_access,publish_stream'
);