X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=addon%2Ftwitter%2Ftwitter.php;h=1dce9d2f66a38b5b0b6b28f1ec55742504b33442;hb=8cc6e69705c40b942ff74f757d8db743c479646a;hp=fef6583f6b05c59089a6fd6a890d53c5f7847c7f;hpb=6709beb2ac776bb06bd0d9d7749faac9a065863c;p=friendica.git diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php index fef6583f6b..1dce9d2f66 100644 --- a/addon/twitter/twitter.php +++ b/addon/twitter/twitter.php @@ -76,6 +76,9 @@ function twitter_jot_nets(&$a,&$b) { function twitter_settings_post ($a,$post) { if(! local_user()) return; + // don't check twitter settings if twitter submit button is not clicked + if (!x($_POST,'twitter-submit')) return; + if (isset($_POST['twitter-disconnect'])) { /*** * if the twitter-disconnect checkbox is set, clear the OAuth key/secret pair @@ -159,7 +162,7 @@ function twitter_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; - $s .= ''; + $s .= ''; } else { /*** * we have an OAuth key / secret pair for the user @@ -178,7 +181,7 @@ function twitter_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= ''; - $s .= ''; + $s .= ''; } } $s .= ''; @@ -195,6 +198,11 @@ function twitter_post_hook(&$a,&$b) { if((local_user()) && (local_user() == $b['uid']) && (! $b['private']) && (! $b['parent']) ) { + // Twitter is not considered a private network + if($b['prvnets']) + return; + + load_pconfig(local_user(), 'twitter'); $ckey = get_config('twitter', 'consumerkey' ); @@ -208,6 +216,7 @@ function twitter_post_hook(&$a,&$b) { $twitter_enable = (($twitter_post && x($_POST,'twitter_enable')) ? intval($_POST['twitter_enable']) : 0); if($twitter_post && $twitter_enable) { + logger('Posting to Twitter', LOGGER_DEBUG); require_once('library/twitteroauth.php'); require_once('include/bbcode.php'); $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); @@ -241,3 +250,19 @@ function twitter_post_hook(&$a,&$b) { } } +function twitter_plugin_admin_post(&$a){ + $consumerkey = ((x($_POST,'consumerkey')) ? notags(trim($_POST['consumerkey'])) : ''); + $consumersecret = ((x($_POST,'consumersecret')) ? notags(trim($_POST['consumersecret'])): ''); + set_config('twitter','consumerkey',$consumerkey); + set_config('twitter','consumersecret',$consumersecret); + info( t('Settings updated.'). EOL ); +} +function twitter_plugin_admin(&$a, &$o){ + $t = file_get_contents( dirname(__file__). "/admin.tpl" ); + $o = replace_macros($t, array( + '$submit' => t('Submit'), + // name, label, value, help, [extra values] + '$consumerkey' => array('consumerkey', t('Consumer key'), get_config('twitter', 'consumerkey' ), ''), + '$consumersecret' => array('consumersecret', t('Consumer secret'), get_config('twitter', 'consumersecret' ), '') + )); +}