X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=gpluspost%2Fgpluspost.php;h=c8918e1cc73eb7632f6345407f938b98195a132a;hb=18784a484b04b5f74e6d4dca516b2dc20cffe953;hp=1df6e7500858e72062cb06314e62fd070df3ce92;hpb=087871cd8d27ce6ea1472db0e0da5e84f47ec5bf;p=friendica-addons.git diff --git a/gpluspost/gpluspost.php b/gpluspost/gpluspost.php index 1df6e750..c8918e1c 100644 --- a/gpluspost/gpluspost.php +++ b/gpluspost/gpluspost.php @@ -5,6 +5,7 @@ * Description: Posts to a Google+ page with the help of Hootsuite * Version: 0.1 * Author: Michael Vogel + * Status: Unsupported */ function gpluspost_install() { @@ -97,8 +98,8 @@ function gpluspost_settings(&$a,&$s) { if (gpluspost_nextscripts()) { /* // To-Do: Option to check the credentials if requested - if (($username != "") AND ($password != "")) { - require_once("addon/googleplus/postToGooglePlus.php"); + if (($username != "") && ($password != "")) { + require_once("addon/gpluspost/postToGooglePlus.php"); $loginError = doConnectToGooglePlus2($username, $password); if ($loginError) $s .= '

Login Error. Please enter the correct credentials.

'; @@ -230,27 +231,28 @@ function gpluspost_send(&$a,&$b) { return; // if post comes from Google+ don't send it back - if (!get_pconfig($b["uid"],'gpluspost','no_loop_prevention') and ($b['app'] == "Google+")) + if (!get_pconfig($b["uid"],'gpluspost','no_loop_prevention') && (($b['app'] == "Google+") || ($b["extid"] == NETWORK_GPLUS))) return; - // Always do the export via RSS-Feed (even if NextScripts is enabled), since it doesn't hurt - $itemlist = get_pconfig($b["uid"],'gpluspost','itemlist'); - $items = explode(",", $itemlist); + if (!gpluspost_nextscripts()) { + // Posting via RSS-Feed and Hootsuite + $itemlist = get_pconfig($b["uid"],'gpluspost','itemlist'); + $items = explode(",", $itemlist); - $i = 0; - $newitems = array($b['id']); - foreach ($items AS $item) - if ($i++ < 9) - $newitems[] = $item; + $i = 0; + $newitems = array($b['id']); + foreach ($items AS $item) + if ($i++ < 9) + $newitems[] = $item; - $itemlist = implode(",", $newitems); + $itemlist = implode(",", $newitems); - logger('gpluspost_send: new itemlist: '.$itemlist." for uid ".$b["uid"]); + logger('gpluspost_send: new itemlist: '.$itemlist." for uid ".$b["uid"]); - set_pconfig($b["uid"],'gpluspost','itemlist', $itemlist); + set_pconfig($b["uid"],'gpluspost','itemlist', $itemlist); - // Posting via NextScripts - if (gpluspost_nextscripts()) { + } else { + // Posting via NextScripts $username = get_pconfig($b['uid'],'gpluspost','username'); $password = get_pconfig($b['uid'],'gpluspost','password'); $page = get_pconfig($b['uid'],'gpluspost','page'); @@ -329,7 +331,7 @@ function gpluspost_queue_hook(&$a,&$b) { logger('gpluspost_queue: run'); - $r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid` + $r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid` WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1", intval($x['cid']) ); @@ -347,7 +349,7 @@ function gpluspost_queue_hook(&$a,&$b) { $success = false; if($username && $password) { - require_once("addon/googleplus/postToGooglePlus.php"); + require_once("addon/gpluspost/postToGooglePlus.php"); logger('gpluspost_queue: able to post for user '.$username); @@ -432,7 +434,7 @@ function gpluspost_init() { foreach ($items AS $item) gpluspost_feeditem($item, $uid); } else { - $items = q("SELECT `id` FROM `item` FORCE INDEX (`received`) WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent` ORDER BY `received` DESC LIMIT 10"); + $items = q("SELECT `id` FROM `item` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent` ORDER BY `received` DESC LIMIT 10"); foreach ($items AS $item) gpluspost_feeditem($item["id"], $uid); } @@ -525,7 +527,7 @@ function gpluspost_feeditem($pid, $uid) { else if ($image != "") $msglink = $image; - if (($msglink == "") AND $skipwithoutlink) + if (($msglink == "") && $skipwithoutlink) continue; else if ($msglink == "") $msglink = $item["plink"];