diff options
Diffstat (limited to 'addon/facebook/facebook.php')
-rw-r--r-- | addon/facebook/facebook.php | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index 73518afb2..47e7691e4 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -111,13 +111,13 @@ function facebook_init(&$a) { $token = substr($token,0,strpos($token,'&')); set_pconfig($uid,'facebook','access_token',$token); set_pconfig($uid,'facebook','post','1'); + set_pconfig($uid,'facebook','no_linking',1); fb_get_self($uid); fb_get_friends($uid); fb_consume_all($uid); } - // todo: is this a browser session or a server session? where do we go? } } @@ -214,7 +214,7 @@ function fb_get_friends($uid) { dbesc(($jp->nickname) ? $jp->nickname : strtolower($jp->first_name)), dbesc('https://graph.facebook.com/' . $jp->id . '/picture'), dbesc(NETWORK_FACEBOOK), - intval(REL_BUD), + intval(CONTACT_IS_FRIEND), intval(1), intval(1) ); @@ -258,6 +258,8 @@ function fb_get_friends($uid) { } } +// This is the POST method to the facebook settings page +// Content is posted to Facebook in the function facebook_post_hook() function facebook_post(&$a) { @@ -298,6 +300,8 @@ function facebook_post(&$a) { return; } +// Facebook settings form + function facebook_content(&$a) { if(! local_user()) { @@ -347,14 +351,18 @@ function facebook_content(&$a) { $o .= '<form action="facebook" method="post" >'; $post_by_default = get_pconfig(local_user(),'facebook','post_by_default'); $checked = (($post_by_default) ? ' checked="checked" ' : ''); - $o .= '<input type="checkbox" name="post_by_default" value="1"' . $checked . '/>' . ' ' . t('Post to Facebook by default') . '<br />'; + $o .= '<input type="checkbox" name="post_by_default" value="1"' . $checked . '/>' . ' ' . t('Post to Facebook by default') . EOL; $no_linking = get_pconfig(local_user(),'facebook','no_linking'); $checked = (($no_linking) ? '' : ' checked="checked" '); - $o .= '<input type="checkbox" name="facebook_linking" value="1"' . $checked . '/>' . ' ' . t('Link all your Facebook friends and conversations') . '<br />'; - - + $o .= '<input type="checkbox" name="facebook_linking" value="1"' . $checked . '/>' . ' ' . t('Link all your Facebook friends and conversations') . EOL ; + $hidden = (($a->user['hidewall'] || get_config('system','block_public')) ? true : false); + if(! $hidden) { + $o .= EOL; + $o .= t('Warning: Your Facebook privacy settings can not be imported.') . EOL; + $o .= t('Linked Facebook items <strong>may</strong> be publicly visible, depending on your privacy settings for this website/account.') . EOL; + } $o .= '<input type="submit" name="submit" value="' . t('Submit') . '" /></form></div>'; } @@ -522,6 +530,13 @@ function facebook_post_hook(&$a,&$b) { $fb_enable = (($fb_post && x($_POST,'facebook_enable')) ? intval($_POST['facebook_enable']) : 0); $fb_token = get_pconfig(local_user(),'facebook','access_token'); + // if API is used, default to the chosen settings + if($_POST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default'))) + $fb_enable = 1; + + + + logger('facebook: $fb_post: ' . $fb_post . ' $fb_enable: ' . $fb_enable . ' $fb_token: ' . $fb_token,LOGGER_DEBUG); // post to facebook if it's a public post and we've ticked the 'post to Facebook' box, @@ -564,7 +579,7 @@ function facebook_post_hook(&$a,&$b) { $msg = preg_replace("/\[img\](.*?)\[\/img\]/is", t('Image: ') . '$1', $msg); - if((strpos($link,$a->get_baseurl()) !== false) && (! $image)) + if((strpos($link,z_root()) !== false) && (! $image)) $image = $a->get_baseurl() . '/images/friendika-64.jpg'; $msg = trim(strip_tags(bbcode($msg))); @@ -746,6 +761,8 @@ function fb_consume_all($uid) { $access_token = get_pconfig($uid,'facebook','access_token'); if(! $access_token) return; + + $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token); if($s) { $j = json_decode($s); @@ -772,13 +789,12 @@ function fb_consume_stream($uid,$j,$wall = false) { intval($uid) ); - $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1", + $user = q("SELECT `nickname`, `blockwall` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid) ); if(count($user)) $my_local_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; - $self_id = get_pconfig($uid,'facebook','self_id'); if(! count($j->data) || (! strlen($self_id))) return; |