]> git.mxchange.org Git - friendica-addons.git/blobdiff - gpluspost/gpluspost.php
Merge pull request #256 from annando/1502-new-community-setting
[friendica-addons.git] / gpluspost / gpluspost.php
index ab0d07e8e4f2954fe0cd18b6b93b1daeb37bc52f..f9459b5a1fce207704927c4be83e862e9535b716 100644 (file)
@@ -182,6 +182,9 @@ function gpluspost_settings_post(&$a,&$b) {
                        set_pconfig(local_user(),'fromgplus','account',trim($_POST['fromgplus-account']));
                        $enable = ((x($_POST,'fromgplus-enable')) ? intval($_POST['fromgplus-enable']) : 0);
                        set_pconfig(local_user(),'fromgplus','enable', $enable);
+
+                       if (!$enable)
+                               del_pconfig(local_user(),'fromgplus','lastdate');
                }
        }
 }
@@ -227,27 +230,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') and (($b['app'] == "Google+") OR ($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');
@@ -268,7 +272,7 @@ function gpluspost_send(&$a,&$b) {
                        $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);
+                       $data = plaintext($a, $item, 0, false, 9);
 
                        logger('gpluspost_send: data: '.print_r($data, true), LOGGER_DEBUG);