[twitter] Add addon config

This commit is contained in:
Hypolite Petovan 2018-06-27 23:21:24 -04:00
parent 9f0a441fe4
commit cb4f60c257
2 changed files with 28 additions and 4 deletions

View File

@ -0,0 +1,16 @@
<?php return <<<INI
; Warning: Don't change this file! It only holds the default config values for this addon.
; Instead overwrite these config values in config/local.ini.php in your Friendica directory
[twitter]
; consumerkey (String)
; OAuth Consumer Key provided by Twitter on registering an app at https://twitter.com/apps
consumerkey =
; consumersecret (String)
; OAuth Consumer Secret provided by Twitter on registering an app at https://twitter.com/apps
consumersecret =
INI;
//Keep this line

View File

@ -48,12 +48,13 @@
* we do not need "Twitter as login". When you've registered the app you get the * 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. * OAuth Consumer key and secret pair for your application/site.
* *
* Add this key pair to your global .htconfig.php or use the admin panel. * Add this key pair to your global config/local.ini.php or use the admin panel.
* *
* $a->config['twitter']['consumerkey'] = 'your consumer_key here'; * [twitter]
* $a->config['twitter']['consumersecret'] = 'your consumer_secret here'; * consumerkey = your consumer_key here
* consumersecret = your consumer_secret here
* *
* To activate the addon itself add it to the $a->config['system']['addon'] * To activate the addon itself add it to the [system] addon
* setting. After this, your user can configure their Twitter account settings * setting. After this, your user can configure their Twitter account settings
* from "Settings -> Addon Settings". * from "Settings -> Addon Settings".
* *
@ -94,6 +95,7 @@ define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
function twitter_install() function twitter_install()
{ {
// we need some hooks, for the configuration and for sending tweets // we need some hooks, for the configuration and for sending tweets
Addon::registerHook('load_config', 'addon/twitter/twitter.php', 'twitter_load_config');
Addon::registerHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings'); Addon::registerHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
Addon::registerHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); Addon::registerHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
Addon::registerHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local'); Addon::registerHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
@ -110,6 +112,7 @@ function twitter_install()
function twitter_uninstall() function twitter_uninstall()
{ {
Addon::unregisterHook('load_config', 'addon/twitter/twitter.php', 'twitter_load_config');
Addon::unregisterHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings'); Addon::unregisterHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
Addon::unregisterHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); Addon::unregisterHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
Addon::unregisterHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local'); Addon::unregisterHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
@ -128,6 +131,11 @@ function twitter_uninstall()
Addon::unregisterHook('addon_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); Addon::unregisterHook('addon_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
} }
function twitter_load_config(App $a)
{
$a->loadConfigFile(__DIR__. '/config/twitter.ini.php');
}
function twitter_check_item_notification(App $a, &$notification_data) function twitter_check_item_notification(App $a, &$notification_data)
{ {
$own_id = PConfig::get($notification_data["uid"], 'twitter', 'own_id'); $own_id = PConfig::get($notification_data["uid"], 'twitter', 'own_id');