]> git.mxchange.org Git - friendica-addons.git/blobdiff - buffer/buffer.php
Merge remote-tracking branch 'upstream/master'
[friendica-addons.git] / buffer / buffer.php
index f6d16eaedaa498e65d5daa95f6531905ae36a418..99e1233b3792484c38b8064df45ac6a5b75bb55b 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 /**
  * Name: Buffer Post Connector
- * Description: Post to Buffer
- * Version: 0.1 alpha
+ * Description: Post to Buffer (Linkedin, App.net, Google+, Facebook, Twitter)
+ * Version: 0.2
  * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
  */
 require('addon/buffer/bufferapp.php');
@@ -60,6 +60,13 @@ function buffer_plugin_admin(&$a, &$o){
                '$client_secret' => array('client_secret', t('Client Secret'),  get_config('buffer', 'client_secret' ), ''),
        ));
 }
+function buffer_plugin_admin_post(&$a){
+        $client_id     =       ((x($_POST,'client_id'))              ? notags(trim($_POST['client_id']))   : '');
+        $client_secret =       ((x($_POST,'client_secret'))   ? notags(trim($_POST['client_secret'])): '');
+        set_config('buffer','client_id',$client_id);
+        set_config('buffer','client_secret',$client_secret);
+        info( t('Settings updated.'). EOL );
+}
 
 function buffer_connect(&$a) {
 
@@ -195,23 +202,8 @@ function buffer_settings_post(&$a,&$b) {
                        set_pconfig(local_user(),'buffer','post',false);
                        set_pconfig(local_user(),'buffer','post_by_default',false);
                } else {
-                       // filtering the username if it is filled wrong
-                       $user = $_POST['buffer_user'];
-                       if (strstr($user, "@")) {
-                               $pos = strpos($user, "@");
-                               if ($pos > 0)
-                                       $user = substr($user, 0, $pos);
-                       }
-
-                       // Filtering the hostname if someone is entering it with "http"
-                       $host = $_POST['buffer_host'];
-                       $host = trim($host);
-                       $host = str_replace(array("https://", "http://"), array("", ""), $host);
-
                        set_pconfig(local_user(),'buffer','post',intval($_POST['buffer']));
                        set_pconfig(local_user(),'buffer','post_by_default',intval($_POST['buffer_bydefault']));
-
-                       //header("Location: ".$a->get_baseurl()."/buffer/connect");
                }
        }
 }
@@ -326,6 +318,7 @@ function buffer_send(&$a,&$b) {
                                                $post["preview"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($post["preview"]);
                                }
 
+                               //if ($profile->service == "twitter") {
                                if ($includedlinks) {
                                        if (isset($post["url"]))
                                                $post["url"] = short_link($post["url"]);
@@ -337,7 +330,14 @@ function buffer_send(&$a,&$b) {
 
                                // Seems like a bug to me
                                // Buffer doesn't add links to Twitter and App.net (but pictures)
-                               if ($includedlinks AND isset($post["url"]))
+                               //if ($includedlinks AND isset($post["url"]))
+                               if (($profile->service == "twitter") AND isset($post["url"]))
+                                       $post["text"] .= " ".$post["url"];
+                               elseif (($profile->service == "appdotnet") AND isset($post["url"]) AND isset($post["title"])) {
+                                       $post["title"] = shortenmsg($post["title"], 90);
+                                       $post["text"] = shortenmsg($post["text"], $limit - (24 + strlen($post["title"])));
+                                       $post["text"] .= "\n[".$post["title"]."](".$post["url"].")";
+                               } elseif (($profile->service == "appdotnet") AND isset($post["url"]))
                                        $post["text"] .= " ".$post["url"];
 
                                $message = array();