X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=blobdiff_plain;f=buffer%2Fbuffer.php;h=b90d90908364b199a42e16bb30068cbb7dff89c8;hp=f5f88e10658f27fd0de508e30df93cac24a94f89;hb=27b60e003f92dd9f3aebbeddb34ebb905488ca82;hpb=42eefed6e68d241bd8bdf9eceea96abc445a9cac diff --git a/buffer/buffer.php b/buffer/buffer.php index f5f88e10..b90d9090 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -5,8 +5,9 @@ * Version: 0.2 * Author: Michael Vogel */ -require('addon/buffer/bufferapp.php'); +require 'addon/buffer/bufferapp.php'; +use Friendica\App; use Friendica\Core\Config; use Friendica\Core\PConfig; @@ -56,12 +57,12 @@ function buffer_content(&$a) { function buffer_plugin_admin(&$a, &$o){ $t = get_markup_template( "admin.tpl", "addon/buffer/" ); - $o = replace_macros($t, array( + $o = replace_macros($t, [ '$submit' => t('Save Settings'), // name, label, value, help, [extra values] - '$client_id' => array('client_id', t('Client ID'), Config::get('buffer', 'client_id' ), ''), - '$client_secret' => array('client_secret', t('Client Secret'), Config::get('buffer', 'client_secret' ), ''), - )); + '$client_id' => ['client_id', t('Client ID'), Config::get('buffer', 'client_id' ), ''], + '$client_secret' => ['client_secret', t('Client Secret'), Config::get('buffer', 'client_secret' ), ''], + ]); } function buffer_plugin_admin_post(&$a){ $client_id = ((x($_POST,'client_id')) ? notags(trim($_POST['client_id'])) : ''); @@ -236,16 +237,26 @@ function buffer_post_local(&$a,&$b) { $b['postopts'] .= 'buffer'; } -function buffer_send(&$a,&$b) { +function buffer_send(App $a, &$b) +{ + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { + return; + } - if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + if(! strstr($b['postopts'],'buffer')) { return; + } - if(! strstr($b['postopts'],'buffer')) + if($b['parent'] != $b['id']) { return; + } - if($b['parent'] != $b['id']) + // Dont't post if the post doesn't belong to us. + // This is a check for forum postings + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + if ($b['contact-id'] != $self['id']) { return; + } // if post comes from buffer don't send it back //if($b['app'] == "Buffer") @@ -324,7 +335,7 @@ function buffer_send(&$a,&$b) { $item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]); } - $post = plaintext($a, $item, $limit, $includedlinks, $htmlmode); + $post = plaintext($item, $limit, $includedlinks, $htmlmode); logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures @@ -358,7 +369,7 @@ function buffer_send(&$a,&$b) { elseif ($profile->service == "google") $post["text"] .= html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); // Send a special blank to identify the post through the "fromgplus" addon - $message = array(); + $message = []; $message["text"] = $post["text"]; $message["profile_ids[]"] = $profile->id; $message["shorten"] = false;