+ if (!get_pconfig($b["uid"],'gpluspost','no_loop_prevention') and ($b['app'] == "Google+"))
+ return;
+
+ 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;
+
+ $itemlist = implode(",", $newitems);
+
+ logger('gpluspost_send: new itemlist: '.$itemlist." for uid ".$b["uid"]);
+
+ set_pconfig($b["uid"],'gpluspost','itemlist', $itemlist);
+
+ } 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');
+
+ $success = false;
+
+ if($username && $password) {
+ require_once("addon/gpluspost/postToGooglePlus.php");
+ require_once("include/plaintext.php");
+
+ $item = $b;
+
+ // Markup for Google+
+ if ($item["title"] != "")
+ $item["title"] = "*".$item["title"]."*";
+
+ $item["body"] = preg_replace("(\[b\](.*?)\[\/b\])ism",'*$1*',$item["body"]);
+ $item["body"] = preg_replace("(\[i\](.*?)\[\/i\])ism",'_$1_',$item["body"]);
+ $item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]);
+
+ $data = plaintext($a, $item, 0, false, 9);
+
+ logger('gpluspost_send: data: '.print_r($data, true), LOGGER_DEBUG);
+
+ $loginError = doConnectToGooglePlus2($username, $password);
+ if (!$loginError) {
+ if ($data["url"] != "")
+ $lnk = doGetGoogleUrlInfo2($data["url"]);
+ elseif ($data["image"] != "")
+ $lnk = array('img'=>$data["image"]);
+ else
+ $lnk = "";
+
+ // Send a special blank to identify the post through the "fromgplus" addon
+ $blank = html_entity_decode(" ", ENT_QUOTES, 'UTF-8');
+
+ doPostToGooglePlus2($data["text"].$blank, $lnk, $page);
+
+ $success = true;
+
+ logger('gpluspost_send: '.$b['uid'].' success', LOGGER_DEBUG);
+ } else
+ logger('gpluspost_send: '.$b['uid'].' failed '.$loginError, LOGGER_DEBUG);