X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=addon%2Ftwitter%2Ftwitter.php;h=1dce9d2f66a38b5b0b6b28f1ec55742504b33442;hb=8cc6e69705c40b942ff74f757d8db743c479646a;hp=3141cf0c94db666c58febb1c4c1d8ceb6b376d1e;hpb=23931ab719ca30ce0a5de4c04fd3bd83ecc9937f;p=friendica.git diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php index 3141cf0c94..1dce9d2f66 100644 --- a/addon/twitter/twitter.php +++ b/addon/twitter/twitter.php @@ -47,7 +47,6 @@ function twitter_install() { register_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); register_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook'); register_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); - register_hook('plugin_admin', 'addon/twitter/twitter.php', 'plugin_admin'); logger("installed twitter"); } @@ -57,7 +56,6 @@ function twitter_uninstall() { unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook'); unregister_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); - unregister_hook('plugin_admin', 'addon/twitter/twitter.php', 'plugin_admin'); } function twitter_jot_nets(&$a,&$b) { @@ -78,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 @@ -161,7 +162,7 @@ function twitter_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; - $s .= ''; + $s .= ''; } else { /*** * we have an OAuth key / secret pair for the user @@ -180,7 +181,7 @@ function twitter_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= ''; - $s .= ''; + $s .= ''; } } $s .= ''; @@ -197,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' ); @@ -210,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); @@ -242,14 +249,15 @@ function twitter_post_hook(&$a,&$b) { } } } -function plugin_admin_post(&$a){ + +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 plugin_admin(&$a, &$o){ +function twitter_plugin_admin(&$a, &$o){ $t = file_get_contents( dirname(__file__). "/admin.tpl" ); $o = replace_macros($t, array( '$submit' => t('Submit'),