* Name: Facebook Connector
* Version: 1.3
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
- * Tobias Hößl <https://github.com/CatoTH/>
+ * Author: Tobias Hößl <https://github.com/CatoTH/>
+ *
*/
/**
}
}
-
if($a->argc != 2)
return;
+
$nick = $a->argv[1];
+
if(strlen($nick))
$r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($nick)
elseif (is_array($subs)) {
$o .= t('The given API Key seems to work correctly.') . '<br>';
$working_connection = true;
- } else $o .= t('The correctness of the API Key could not be detected. Somthing strange\'s going on.') . '<br>';
+ } else $o .= t('The correctness of the API Key could not be detected. Something strange\'s going on.') . '<br>';
}
$o .= '<label for="fb_appid">' . t('App-ID / API-Key') . '</label><input id="fb_appid" name="appid" type="text" value="' . escape_tags($appid ? $appid : "") . '"><br style="clear: both;">';
if(preg_match("/\[img\](.*?)\[\/img\]/is",$b['body'],$matches))
$image = $matches[1];
+ // When saved into the database the content is sent through htmlspecialchars
+ // That means that we have to decode all image-urls
+ $image = htmlspecialchars_decode($image);
+
// Checking for a bookmark element
$body = $b['body'];
if (strpos($body, "[bookmark") !== false) {
// Fallback - if message is empty
if(!strlen($msg))
- $msg = $link;
+ $msg = $linkname;
if(!strlen($msg))
- $msg = $image;
+ $msg = $link;
if(!strlen($msg))
- $msg = $linkname;
+ $msg = $image;
// If there is nothing to post then exit
if(!strlen($msg))
'access_token' => $fb_token,
'message' => $msg
);
- if(isset($image)) {
+ if(trim($image) != "") {
$postvars['picture'] = $image;
}
- if(isset($link)) {
+ if(trim($link) != "") {
$postvars['link'] = $link;
// The following doesn't work - why?
$postvars['source'] = $link;
}
}
- if(isset($linkname))
+ if(trim($linkname) != "")
$postvars['name'] = $linkname;
}
$fb_enable = (($fb_post && x($_REQUEST,'facebook_enable')) ? intval($_REQUEST['facebook_enable']) : 0);
// if API is used, default to the chosen settings
- if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default')))
- $fb_enable = 1;
+ // but allow a specific override
+
+ if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default'))) {
+ if(! x($_REQUEST,'facebook_enable'))
+ $fb_enable = 1;
+ }
if(! $fb_enable)
return;