X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=twitter%2Ftwitter.php;h=1fdcb89ca773d59cede3b2f70978ff3a9442abee;hb=936afb42c4240a9288252ddc272fa78a9baf4caa;hp=76b92ac811f82733ead1fe7a9efc23ea7d30ccf2;hpb=1b7dcbd0bb5288e0ab5308d69ad59bc008049c7c;p=friendica-addons.git diff --git a/twitter/twitter.php b/twitter/twitter.php index 76b92ac8..1fdcb89c 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -334,27 +334,33 @@ function twitter_settings(&$a,&$s) { } -function twitter_post_local(&$a,&$b) { +function twitter_post_local(&$a, &$b) { - if($b['edit']) + if ($b['edit']) { return; + } - if((local_user()) && (local_user() == $b['uid']) && (! $b['private']) && (! $b['parent']) ) { + if (!local_user() || (local_user() != $b['uid'])) { + return; + } - $twitter_post = intval(get_pconfig(local_user(),'twitter','post')); - $twitter_enable = (($twitter_post && x($_REQUEST,'twitter_enable')) ? intval($_REQUEST['twitter_enable']) : 0); + $twitter_post = intval(get_pconfig(local_user(), 'twitter', 'post')); + $twitter_enable = (($twitter_post && x($_REQUEST, 'twitter_enable')) ? intval($_REQUEST['twitter_enable']) : 0); - // if API is used, default to the chosen settings - if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'twitter','post_by_default'))) - $twitter_enable = 1; + // if API is used, default to the chosen settings + if ($b['api_source'] && intval(get_pconfig(local_user(), 'twitter', 'post_by_default'))) { + $twitter_enable = 1; + } - if(! $twitter_enable) + if (!$twitter_enable) { return; + } - if(strlen($b['postopts'])) + if (strlen($b['postopts'])) { $b['postopts'] .= ','; - $b['postopts'] .= 'twitter'; } + + $b['postopts'] .= 'twitter'; } function twitter_action($a, $uid, $pid, $action) { @@ -545,8 +551,20 @@ function twitter_post_hook(&$a,&$b) { } if(strlen($msg) && ($image == "")) { +// ----------------- + $max_char = 280; + require_once("include/plaintext.php"); + $msgarr = plaintext($a, $b, $max_char, true, 8); + $msg = $msgarr["text"]; + + if (($msg == "") && isset($msgarr["title"])) + $msg = shortenmsg($msgarr["title"], $max_char - 50); + + if (isset($msgarr["url"])) + $msg .= "\n".$msgarr["url"]; +// ----------------- $url = 'statuses/update'; - $post = array('status' => $msg); + $post = array('status' => $msg, 'weighted_character_count' => 'true'); if ($iscomment) $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9);