]> git.mxchange.org Git - friendica-addons.git/blobdiff - twitter/twitter.php
Merge branch 'apull'
[friendica-addons.git] / twitter / twitter.php
old mode 100644 (file)
new mode 100755 (executable)
index cf2c7ea..a6f73c8
@@ -6,7 +6,7 @@
  */
 
 
-/*   Twitter Plugin for Friendika
+/*   Twitter Plugin for Friendica
  *
  *   Author: Tobias Diekershoff
  *           tobias.diekershoff@gmx.net
  *     To use this plugin you need a OAuth Consumer key pair (key & secret)
  *     you can get it from Twitter at https://twitter.com/apps
  *
- *     Register your Friendika site as "Client" application with "Read & Write" access
+ *     Register your Friendica site as "Client" application with "Read & Write" access
  *     we do not need "Twitter as login". When you've registered the app you get the
  *     OAuth Consumer key and secret pair for your application/site.
  *
- *     Add this key pair to your global .htconfig.php
+ *     Add this key pair to your global .htconfig.php or use the admin panel.
  *
  *     $a->config['twitter']['consumerkey'] = 'your consumer_key here';
  *     $a->config['twitter']['consumersecret'] = 'your consumer_secret here';
@@ -91,10 +91,11 @@ function twitter_settings_post ($a,$post) {
                /***
                 * if the twitter-disconnect checkbox is set, clear the OAuth key/secret pair
                 * from the user configuration
-                * TODO can we revoke the access tokens at Twitter and do we need to do so?
                 */
                del_pconfig( local_user(), 'twitter', 'consumerkey'  );
                del_pconfig( local_user(), 'twitter', 'consumersecret' );
+                del_pconfig( local_user(), 'twitter', 'oauthtoken'  );  
+                del_pconfig( local_user(), 'twitter', 'oauthsecret'  );  
                 del_pconfig( local_user(), 'twitter', 'post' );
                 del_pconfig( local_user(), 'twitter', 'post_by_default' );
        } else {
@@ -114,7 +115,7 @@ function twitter_settings_post ($a,$post) {
                set_pconfig(local_user(),'twitter', 'oauthsecret', $token['oauth_token_secret']);
                 set_pconfig(local_user(),'twitter', 'post', 1);
                 //  reload the Addon Settings page, if we don't do it see Bug #42
-                goaway($a->get_baseurl().'/settings/addon');
+                goaway($a->get_baseurl().'/settings/connectors');
        } else {
                //  if no PIN is supplied in the POST variables, the user has changed the setting
                //  to post a tweet for every new __public__ posting to the wall
@@ -168,7 +169,7 @@ function twitter_settings(&$a,&$s) {
                        /***
                         *  make some nice form
                         */
-                       $s .= '<p>'. t('At this Friendika instance the Twitter plugin was enabled but you have not yet connected your account to your Twitter account. To do so click the button below to get a PIN from Twitter which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to Twitter.') .'</p>';
+                       $s .= '<p>'. t('At this Friendica instance the Twitter plugin was enabled but you have not yet connected your account to your Twitter account. To do so click the button below to get a PIN from Twitter which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to Twitter.') .'</p>';
                        $s .= '<a href="'.$connection->getAuthorizeURL($token).'" target="_twitter"><img src="addon/twitter/lighter.png" alt="'.t('Log in with Twitter').'"></a>';
                        $s .= '<div id="twitter-pin-wrapper">';
                        $s .= '<label id="twitter-pin-label" for="twitter-pin">'. t('Copy the PIN from Twitter here') .'</label>';
@@ -214,10 +215,10 @@ function twitter_post_local(&$a,&$b) {
        if((local_user()) && (local_user() == $b['uid']) && (! $b['private']) && (! $b['parent']) ) {
 
                $twitter_post = intval(get_pconfig(local_user(),'twitter','post'));
-               $twitter_enable = (($twitter_post && x($_POST,'twitter_enable')) ? intval($_POST['twitter_enable']) : 0);
+               $twitter_enable = (($twitter_post && x($_REQUEST,'twitter_enable')) ? intval($_REQUEST['twitter_enable']) : 0);
 
                // if API is used, default to the chosen settings
-               if($_POST['api_source'] && intval(get_pconfig(local_user(),'twitter','post_by_default')))
+               if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'twitter','post_by_default')))
                        $twitter_enable = 1;
 
         if(! $twitter_enable)