X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=twitter%2Ftwitter.php;h=380121c2e2a40bc0d820e2417021b077a3bfda33;hb=9e9916a8d5518860fda327de2d2e87d878efc0d2;hp=8a80f471baf30749b48443827004d13467946cb8;hpb=a000f735f2666a2697594f481ba6514c1bd90e4e;p=friendica-addons.git
diff --git a/twitter/twitter.php b/twitter/twitter.php
old mode 100755
new mode 100644
index 8a80f471..380121c2
--- a/twitter/twitter.php
+++ b/twitter/twitter.php
@@ -64,7 +64,7 @@ define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
function twitter_install() {
// we need some hooks, for the configuration and for sending tweets
- register_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+ register_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
register_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
register_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
register_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
@@ -72,12 +72,14 @@ function twitter_install() {
register_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
register_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
register_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
+ register_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
+ register_hook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
logger("installed twitter");
}
function twitter_uninstall() {
- unregister_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+ unregister_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
unregister_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
unregister_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
unregister_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
@@ -85,10 +87,12 @@ function twitter_uninstall() {
unregister_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
unregister_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
unregister_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
+ unregister_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
+ unregister_hook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
// old setting - remove only
unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
- unregister_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+ unregister_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings');
unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
}
@@ -159,10 +163,10 @@ function twitter_settings_post ($a,$post) {
*/
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');
+ 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');
del_pconfig(local_user(), 'twitter', 'lastid');
del_pconfig(local_user(), 'twitter', 'mirror_posts');
del_pconfig(local_user(), 'twitter', 'import');
@@ -181,30 +185,30 @@ function twitter_settings_post ($a,$post) {
$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', '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');
+ 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','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');
+ if (!intval($_POST['twitter-mirror']))
+ del_pconfig(local_user(),'twitter','lastid');
- info(t('Twitter settings updated.') . EOL);
+ info(t('Twitter settings updated.') . EOL);
}}
}
function twitter_settings(&$a,&$s) {
- if(! local_user())
- return;
- $a->page['htmlhead'] .= '' . "\r\n";
+ if(! local_user())
+ return;
+ $a->page['htmlhead'] .= '' . "\r\n";
/***
* 1) Check that we have global consumer key & secret
* 2) If no OAuthtoken & stuff is present, generate button to get some
@@ -214,16 +218,16 @@ function twitter_settings(&$a,&$s) {
$csecret = get_config('twitter', 'consumersecret' );
$otoken = get_pconfig(local_user(), 'twitter', 'oauthtoken' );
$osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' );
- $enabled = get_pconfig(local_user(), 'twitter', 'post');
+ $enabled = get_pconfig(local_user(), 'twitter', 'post');
$checked = (($enabled) ? ' checked="checked" ' : '');
- $defenabled = get_pconfig(local_user(),'twitter','post_by_default');
+ $defenabled = get_pconfig(local_user(),'twitter','post_by_default');
$defchecked = (($defenabled) ? ' checked="checked" ' : '');
- $mirrorenabled = get_pconfig(local_user(),'twitter','mirror_posts');
- $mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
- $importenabled = get_pconfig(local_user(),'twitter','import');
- $importchecked = (($importenabled) ? ' checked="checked" ' : '');
- $create_userenabled = get_pconfig(local_user(),'twitter','create_user');
- $create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
+ $mirrorenabled = get_pconfig(local_user(),'twitter','mirror_posts');
+ $mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
+ $importenabled = get_pconfig(local_user(),'twitter','import');
+ $importchecked = (($importenabled) ? ' checked="checked" ' : '');
+ $create_userenabled = get_pconfig(local_user(),'twitter','create_user');
+ $create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
$css = (($enabled) ? '' : '-disabled');
@@ -252,7 +256,7 @@ function twitter_settings(&$a,&$s) {
* which the user can request a PIN to connect the account to a
* account at Twitter.
*/
- require_once('library/twitteroauth.php');
+ require_once('library/twitteroauth.php');
$connection = new TwitterOAuth($ckey, $csecret);
$request_token = $connection->getRequestToken();
$token = $request_token['oauth_token'];
@@ -266,50 +270,50 @@ function twitter_settings(&$a,&$s) {
$s .= '';
$s .= '';
$s .= '';
- $s .= '
';
- $s .= '';
+ $s .= '';
+ $s .= '';
} else {
/***
* we have an OAuth key / secret pair for the user
* so let's give a chance to disable the postings to Twitter
*/
- require_once('library/twitteroauth.php');
+ require_once('library/twitteroauth.php');
$connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
$details = $connection->get('account/verify_credentials');
$s .= '
'. t('If enabled all your public postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') .'
';
- if ($a->user['hidewall']) {
- $s .= '
'. t('Note: Due your privacy settings (Hide your profile details from unknown viewers?) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') .'
';
- }
+ if ($a->user['hidewall']) {
+ $s .= '
'. t('Note: Due your privacy settings (Hide your profile details from unknown viewers?) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') .'