function onStartShowHTML($action)
{
- if ($this->requiresFB($action)) {
+ if ($this->reqFbScripts($action)) {
// XXX: Horrible hack to make Safari, FF2, and Chrome work with
// Facebook Connect. These browser cannot use Facebook's
function onStartShowHeader($action)
{
- if ($this->requiresFB($action)) {
+ if ($this->reqFbScripts($action)) {
$apikey = common_config('facebook', 'apikey');
$plugin_path = common_path('plugins/FBConnect');
FB_RequireFeatures(
["XFBML"],
function() {
- FB.Facebook.init("%s", "../xd_receiver.html");
+ FB.init("%s", "../xd_receiver.html",
+ {"doNotUseCachedConnectState":true });
+
}
); }
function onEndShowFooter($action)
{
- if ($this->requiresFB($action)) {
+ if ($this->reqFbScripts($action)) {
$action->element('script',
array('type' => 'text/javascript',
function onEndShowLaconicaStyles($action)
{
- if ($this->requiresFB($action)) {
+ if ($this->reqFbScripts($action)) {
$action->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
* @return boolean true
*/
- function requiresFB($action) {
+ function reqFbScripts($action) {
// If you're logged in w/FB Connect, you always need the FB stuff
try {
$facebook = getFacebook();
- $fbuid = getFacebook()->get_loggedin_user();
+ $fbuid = $facebook->api_client->users_getLoggedInUser();
} catch (Exception $e) {
common_log(LOG_WARNING,
- 'Problem getting Facebook client: ' .
+ 'Problem getting Facebook user: ' .
$e->getMessage());
}
if (!empty($fbuid)) {
+ /* Default FB silhouette pic for FB users who haven't
+ uploaded a profile pic yet. */
+
+ $silhouetteUrl =
+ 'http://static.ak.fbcdn.net/pics/q_silhouette.gif';
+
+ $url = $this->getProfilePicURL($fbuid);
+
$action->elementStart('li', array('id' => 'nav_fb'));
- $action->elementStart('fb:profile-pic', array('uid' => $fbuid,
- 'linked' => 'false',
- 'width' => 16,
- 'height' => 16));
- $action->elementEnd('fb:profile-pic');
- $iconurl = common_path('/plugins/FBConnect/fbfavicon.ico');
- $action->element('img', array('src' => $iconurl));
+ $action->element('img', array('id' => 'fbc_profile-pic',
+ 'src' => (!empty($url)) ? $url : $silhouetteUrl,
+ 'alt' => 'Facebook Connect User',
+ 'width' => '16'), '');
+
+ $iconurl = common_path('plugins/FBConnect/fbfavicon.ico');
+ $action->element('img', array('id' => 'fb_favicon',
+ 'src' => $iconurl));
$action->elementEnd('li');
$title = _('Logout from the site');
$text = _('Logout');
- $html = sprintf('<li id="nav_logout"><a href="%s" title="%s" ' .
- 'onclick="FB.Connect.logout(function() { goto_logout() })">%s</a></li>',
- $logout_url, $title, $text);
+ $html = sprintf('<li id="nav_logout"><a href="#" title="%s" ' .
+ 'onclick="FB.Connect.logoutAndRedirect(\'%s\');">%s</a></li>',
+ $title, $logout_url, $text);
$action->raw($html);
$action->menuItem(common_local_url('register'),
_('Register'), _('Create an account'), false, 'nav_register');
}
- $action->menuItem(common_local_url('openidlogin'),
- _('OpenID'), _('Login with OpenID'), false, 'nav_openid');
$action->menuItem(common_local_url('login'),
_('Login'), _('Login to the site'), false, 'nav_login');
}
function onStartShowLocalNavBlock($action)
{
- $action_name = get_class($action);
+ $action_name = get_class($action);
$login_actions = array('LoginAction', 'RegisterAction',
'OpenidloginAction', 'FBConnectLoginAction');
return true;
}
+ function getProfilePicURL($fbuid)
+ {
+
+ $facebook = getFacebook();
+ $url = null;
+
+ try {
+
+ $fqry = 'SELECT pic_square FROM user WHERE uid = %s';
+
+ $result = $facebook->api_client->fql_query(sprintf($fqry, $fbuid));
+
+ if (!empty($result)) {
+ $url = $result[0]['pic_square'];
+ }
+
+ } catch (Exception $e) {
+ common_log(LOG_WARNING, "Facebook client failure requesting profile pic!");
+ }
+
+ return $url;
+
+ }
+
}