X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=fbpost%2Ffbpost.php;h=93a31e2b4d6ac640fa9e81dfc1465fc520472872;hb=2e96c60a478156a9dae89d9ab9d35c6eebf543e6;hp=db905a1573d8d6a4f8a81fb457eeb54400b3a638;hpb=81e05e62745ce8d18cb9d6fd9d80a7d5978b178e;p=friendica-addons.git
diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php
index db905a15..93a31e2b 100644
--- a/fbpost/fbpost.php
+++ b/fbpost/fbpost.php
@@ -96,7 +96,7 @@ function fbpost_init(&$a) {
if(strpos($x,'access_token=') !== false) {
$token = str_replace('access_token=', '', $x);
- if(strpos($token,'&') !== false)
+ if(strpos($token,'&') !== false)
$token = substr($token,0,strpos($token,'&'));
set_pconfig($uid,'facebook','access_token',$token);
set_pconfig($uid,'facebook','post','1');
@@ -152,6 +152,12 @@ function fbpost_post(&$a) {
set_pconfig($uid,'facebook','post_to_page', $values[0]);
set_pconfig($uid,'facebook','page_access_token', $values[1]);
+ $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fbsync' AND `installed`");
+ if (count($result) > 0) {
+ set_pconfig(local_user(),'fbsync','sync',intval($_POST['fbsync']));
+ set_pconfig(local_user(),'fbsync','create_user',intval($_POST['create_user']));
+ }
+
info( t('Settings updated.') . EOL);
}
@@ -183,6 +189,9 @@ function fbpost_content(&$a) {
info( t('Facebook Post disabled') . EOL);
}
+ require_once("mod/settings.php");
+ settings_init($a);
+
$o = '';
$fb_installed = false;
@@ -207,7 +216,15 @@ function fbpost_content(&$a) {
$a->page['htmlhead'] .= '' . "\r\n";
- $o .= '
' . t('Facebook') . '
';
+ $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fbsync' AND `installed`");
+ $fbsync = (count($result) > 0);
+
+ if($fbsync)
+ $title = t('Facebook Import/Export/Mirror');
+ else
+ $title = t('Facebook Export/Mirror');
+
+ $o .= ''.$title.'
';
if(! $fb_installed) {
$o .= '';
+ if ($fbsync) {
+
+ $o .= '';
+
+ $sync_enabled = get_pconfig(local_user(),'fbsync','sync');
+ $checked = (($sync_enabled) ? ' checked="checked" ' : '');
+ $o .= '' . ' ' . t('Import Facebook newsfeed.') . EOL;
+ $create_user = get_pconfig(local_user(),'fbsync','create_user');
+ $checked = (($create_user) ? ' checked="checked" ' : '');
+ $o .= '' . ' ' . t('Automatically create contacts.') . EOL;
+
+ }
+ $o .= '';
}
return $o;
@@ -292,10 +321,18 @@ function fbpost_content(&$a) {
*/
function fbpost_plugin_settings(&$a,&$b) {
+ $enabled = get_pconfig(local_user(),'facebook','post');
+ $css = (($enabled) ? '' : '-disabled');
+
+ $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fbsync' AND `installed`");
+ if(count($result) > 0)
+ $title = t('Facebook Import/Export/Mirror');
+ else
+ $title = t('Facebook Export/Mirror');
+
$b .= '
';
-
}
@@ -571,7 +608,8 @@ function fbpost_post_hook(&$a,&$b) {
$allow_str = dbesc(implode(', ',$recipients));
if($allow_str) {
- $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $allow_str ) AND `network` = 'face'");
+ logger("fbpost_post_hook: private post to: ".$allow_str, LOGGER_DEBUG);
+ $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $allow_str ) AND `network` = 'face'");
if(count($r))
foreach($r as $rr)
$allow_arr[] = $rr['notify'];
@@ -579,7 +617,7 @@ function fbpost_post_hook(&$a,&$b) {
$deny_str = dbesc(implode(', ',$deny));
if($deny_str) {
- $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $deny_str ) AND `network` = 'face'");
+ $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $deny_str ) AND `network` = 'face'");
if(count($r))
foreach($r as $rr)
$deny_arr[] = $rr['notify'];
@@ -633,22 +671,32 @@ function fbpost_post_hook(&$a,&$b) {
logger('fbpost_post_hook: original msg=' . $msg, LOGGER_DATA);
- // To-Do: if it is a reply, then only do a simple bbcode2plain conversion
- $msgarr = fbpost_createmsg($b);
- $msg = $msgarr["msg"];
- $link = $msgarr["link"];
- $image = $msgarr["image"];
- $linkname = $msgarr["linkname"];
+ if ($toplevel) {
+ $msgarr = fbpost_createmsg($b);
+ $msg = $msgarr["msg"];
+ $link = $msgarr["link"];
+ $image = $msgarr["image"];
+ $linkname = $msgarr["linkname"];
- // Fallback - if message is empty
- if(!strlen($msg))
- $msg = $linkname;
+ // Fallback - if message is empty
+ if(!strlen($msg))
+ $msg = $linkname;
- if(!strlen($msg))
- $msg = $link;
+ if(!strlen($msg))
+ $msg = $link;
- if(!strlen($msg))
- $msg = $image;
+ if(!strlen($msg))
+ $msg = $image;
+ } else {
+ require_once("include/bbcode.php");
+ require_once("include/html2plain.php");
+ $msg = bb_CleanPictureLinks($msg);
+ $msg = bbcode($msg, false, false, 2, true);
+ $msg = trim(html2plain($msg, 0));
+ $link = "";
+ $image = "";
+ $linkname = "";
+ }
// If there is nothing to post then exit
if(!strlen($msg))
@@ -962,7 +1010,7 @@ function fbpost_get_app_access_token() {
logger('fb_get_app_access_token: returned access token: ' . $x, LOGGER_DATA);
$token = str_replace('access_token=', '', $x);
- if(strpos($token,'&') !== false)
+ if(strpos($token,'&') !== false)
$token = substr($token,0,strpos($token,'&'));
if ($token == "") {
@@ -1105,7 +1153,7 @@ function fbpost_fetchwall($a, $uid) {
}
if ($content)
- $_REQUEST["body"] .= "\n\n";
+ $_REQUEST["body"] .= "\n";
if ($type)
$_REQUEST["body"] .= "[class=type-".$type."]";