diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-07-02 08:22:09 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-07-02 08:22:09 -0400 |
commit | d04ab14a5a15f9119bedca1332eb516ecf5ca483 (patch) | |
tree | ad7fdf3b4a585c5d97bcac44b01ba2fbb8887b97 /plugins/FBConnect/FBConnectPlugin.php | |
parent | aea546c12234e9b24abba8da5d172a99e8b93ac2 (diff) | |
parent | 734f631e1ea9022c6de492e0d2979c9ca00585a4 (diff) |
Merge branch '0.8.x' of git@gitorious.org:+laconica-developers/laconica/dev into 0.8.x
Diffstat (limited to 'plugins/FBConnect/FBConnectPlugin.php')
-rw-r--r-- | plugins/FBConnect/FBConnectPlugin.php | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/plugins/FBConnect/FBConnectPlugin.php b/plugins/FBConnect/FBConnectPlugin.php index d45d2718c..d8af1a4e8 100644 --- a/plugins/FBConnect/FBConnectPlugin.php +++ b/plugins/FBConnect/FBConnectPlugin.php @@ -70,7 +70,7 @@ class FBConnectPlugin extends Plugin 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 @@ -106,7 +106,7 @@ class FBConnectPlugin extends Plugin function onStartShowHeader($action) { - if ($this->requiresFB($action)) { + if ($this->reqFbScripts($action)) { $apikey = common_config('facebook', 'apikey'); $plugin_path = common_path('plugins/FBConnect'); @@ -145,7 +145,7 @@ class FBConnectPlugin extends Plugin function onEndShowFooter($action) { - if ($this->requiresFB($action)) { + if ($this->reqFbScripts($action)) { $action->element('script', array('type' => 'text/javascript', @@ -157,7 +157,7 @@ class FBConnectPlugin extends Plugin function onEndShowLaconicaStyles($action) { - if ($this->requiresFB($action)) { + if ($this->reqFbScripts($action)) { $action->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', @@ -175,7 +175,7 @@ class FBConnectPlugin extends Plugin * @return boolean true */ - function requiresFB($action) { + function reqFbScripts($action) { // If you're logged in w/FB Connect, you always need the FB stuff @@ -220,7 +220,7 @@ class FBConnectPlugin extends Plugin try { $facebook = getFacebook(); - $fbuid = getFacebook()->get_loggedin_user(); + $fbuid = getFacebook()->get_loggedin_user(); } catch (Exception $e) { common_log(LOG_WARNING, @@ -248,15 +248,24 @@ class FBConnectPlugin extends Plugin 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'); @@ -320,7 +329,7 @@ class FBConnectPlugin extends Plugin function onStartShowLocalNavBlock($action) { - $action_name = get_class($action); + $action_name = get_class($action); $login_actions = array('LoginAction', 'RegisterAction', 'OpenidloginAction', 'FBConnectLoginAction'); @@ -361,4 +370,28 @@ class FBConnectPlugin extends Plugin 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; + + } + } |