- if (isset($_POST['twitter-pin'])) {
- // if the user supplied us with a PIN from Twitter, let the magic of OAuth happen
- logger('got a Twitter PIN');
- require_once('library/twitteroauth.php');
- $ckey = get_config('twitter', 'consumerkey');
- $csecret = get_config('twitter', 'consumersecret');
- // the token and secret for which the PIN was generated were hidden in the settings
- // form as token and token2, we need a new connection to Twitter using these token
- // and secret to request a Access Token with the PIN
- $connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
- $token = $connection->getAccessToken( $_POST['twitter-pin'] );
- // ok, now that we have the Access Token, save them in the user config
- set_pconfig(local_user(),'twitter', 'oauthtoken', $token['oauth_token']);
- 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/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
- set_pconfig(local_user(),'twitter','post',intval($_POST['twitter-enable']));
- set_pconfig(local_user(),'twitter','post_by_default',intval($_POST['twitter-default']));
- set_pconfig(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
- set_pconfig(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
- set_pconfig(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
-
- if (!intval($_POST['twitter-mirror']))
- del_pconfig(local_user(),'twitter','lastid');
-
- info(t('Twitter settings updated.') . EOL);
- }}
+ if (isset($_POST['twitter-pin'])) {
+ // if the user supplied us with a PIN from Twitter, let the magic of OAuth happen
+ logger('got a Twitter PIN');
+ require_once 'library/twitteroauth.php';
+ $ckey = Config::get('twitter', 'consumerkey');
+ $csecret = Config::get('twitter', 'consumersecret');
+ // the token and secret for which the PIN was generated were hidden in the settings
+ // form as token and token2, we need a new connection to Twitter using these token
+ // and secret to request a Access Token with the PIN
+ $connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
+ $token = $connection->getAccessToken($_POST['twitter-pin']);
+ // ok, now that we have the Access Token, save them in the user config
+ PConfig::set(local_user(), 'twitter', 'oauthtoken', $token['oauth_token']);
+ PConfig::set(local_user(), 'twitter', 'oauthsecret', $token['oauth_token_secret']);
+ PConfig::set(local_user(), 'twitter', 'post', 1);
+ // reload the Addon Settings page, if we don't do it see Bug #42
+ goaway('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
+ PConfig::set(local_user(), 'twitter', 'post', intval($_POST['twitter-enable']));
+ PConfig::set(local_user(), 'twitter', 'post_by_default', intval($_POST['twitter-default']));
+ PConfig::set(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
+ PConfig::set(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
+ PConfig::set(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
+
+ if (!intval($_POST['twitter-mirror'])) {
+ PConfig::delete(local_user(), 'twitter', 'lastid');
+ }
+
+ info(t('Twitter settings updated.') . EOL);
+ }
+ }