X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=addon%2Ftwitter%2Ftwitter.php;h=1dce9d2f66a38b5b0b6b28f1ec55742504b33442;hb=8cc6e69705c40b942ff74f757d8db743c479646a;hp=678da9388a3c8e2865fa3a5dd33694a8202f7b4b;hpb=8fea19dd38cf9c43bb6f6fa1a4f349555cbe90f8;p=friendica.git
diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php
index 678da9388a..1dce9d2f66 100644
--- a/addon/twitter/twitter.php
+++ b/addon/twitter/twitter.php
@@ -1,4 +1,10 @@
+ */
+
/* Twitter Plugin for Friendika
*
@@ -59,7 +65,7 @@ function twitter_jot_nets(&$a,&$b) {
$tw_post = get_pconfig(local_user(),'twitter','post');
if(intval($tw_post) == 1) {
$tw_defpost = get_pconfig(local_user(),'twitter','post_by_default');
- $selected = ((intval($tw_defpost == 1)) ? ' selected="selected" ' : '');
+ $selected = ((intval($tw_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '
'
. t('Post to Twitter') . '
';
}
@@ -70,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
@@ -153,7 +162,7 @@ function twitter_settings(&$a,&$s) {
$s .= '';
$s .= '';
$s .= '';
- $s .= '';
+ $s .= '';
} else {
/***
* we have an OAuth key / secret pair for the user
@@ -172,7 +181,7 @@ function twitter_settings(&$a,&$s) {
$s .= '';
$s .= '';
$s .= '';
- $s .= '';
+ $s .= '';
}
}
$s .= '';
@@ -189,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' );
@@ -202,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);
@@ -235,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' ), '')
+ ));
+}