X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=twitter%2Ftwitter.php;h=18625f8b8ff634ec684bca80f4433b4f1d3ae838;hb=2ca621a92a40fba62f8e9acf7eba3a47a5d2ed7b;hp=320c1cdec431e8b36168f16972d6079502ddee34;hpb=94ed7bf163e0b814afcc159ddaf00bf652e7387d;p=friendica-addons.git diff --git a/twitter/twitter.php b/twitter/twitter.php index 320c1cde..18625f8b 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -64,12 +64,13 @@ use Abraham\TwitterOAuth\TwitterOAuth; use Abraham\TwitterOAuth\TwitterOAuthException; +use Codebird\Codebird; use Friendica\App; use Friendica\Content\OEmbed; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Plaintext; -use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\PConfig; @@ -77,16 +78,17 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Conversation; -use Friendica\Model\GContact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\ItemContent; -use Friendica\Model\Queue; use Friendica\Model\User; -use Friendica\Object\Image; +use Friendica\Protocol\Activity; +use Friendica\Util\ConfigFileLoader; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Images; use Friendica\Util\Network; use Friendica\Util\Strings; @@ -97,47 +99,45 @@ define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes function twitter_install() { // we need some hooks, for the configuration and for sending tweets - Addon::registerHook('load_config' , __FILE__, 'twitter_load_config'); - Addon::registerHook('connector_settings' , __FILE__, 'twitter_settings'); - Addon::registerHook('connector_settings_post', __FILE__, 'twitter_settings_post'); - Addon::registerHook('hook_fork' , __FILE__, 'twitter_hook_fork'); - Addon::registerHook('post_local' , __FILE__, 'twitter_post_local'); - Addon::registerHook('notifier_normal' , __FILE__, 'twitter_post_hook'); - Addon::registerHook('jot_networks' , __FILE__, 'twitter_jot_nets'); - Addon::registerHook('cron' , __FILE__, 'twitter_cron'); - Addon::registerHook('queue_predeliver' , __FILE__, 'twitter_queue_hook'); - Addon::registerHook('follow' , __FILE__, 'twitter_follow'); - Addon::registerHook('expire' , __FILE__, 'twitter_expire'); - Addon::registerHook('prepare_body' , __FILE__, 'twitter_prepare_body'); - Addon::registerHook('check_item_notification', __FILE__, 'twitter_check_item_notification'); - Logger::log("installed twitter"); + Hook::register('load_config' , __FILE__, 'twitter_load_config'); + Hook::register('connector_settings' , __FILE__, 'twitter_settings'); + Hook::register('connector_settings_post', __FILE__, 'twitter_settings_post'); + Hook::register('hook_fork' , __FILE__, 'twitter_hook_fork'); + Hook::register('post_local' , __FILE__, 'twitter_post_local'); + Hook::register('notifier_normal' , __FILE__, 'twitter_post_hook'); + Hook::register('jot_networks' , __FILE__, 'twitter_jot_nets'); + Hook::register('cron' , __FILE__, 'twitter_cron'); + Hook::register('follow' , __FILE__, 'twitter_follow'); + Hook::register('expire' , __FILE__, 'twitter_expire'); + Hook::register('prepare_body' , __FILE__, 'twitter_prepare_body'); + Hook::register('check_item_notification', __FILE__, 'twitter_check_item_notification'); + Logger::info("installed twitter"); } function twitter_uninstall() { - Addon::unregisterHook('load_config' , __FILE__, 'twitter_load_config'); - Addon::unregisterHook('connector_settings' , __FILE__, 'twitter_settings'); - Addon::unregisterHook('connector_settings_post', __FILE__, 'twitter_settings_post'); - Addon::unregisterHook('hook_fork' , __FILE__, 'twitter_hook_fork'); - Addon::unregisterHook('post_local' , __FILE__, 'twitter_post_local'); - Addon::unregisterHook('notifier_normal' , __FILE__, 'twitter_post_hook'); - Addon::unregisterHook('jot_networks' , __FILE__, 'twitter_jot_nets'); - Addon::unregisterHook('cron' , __FILE__, 'twitter_cron'); - Addon::unregisterHook('queue_predeliver' , __FILE__, 'twitter_queue_hook'); - Addon::unregisterHook('follow' , __FILE__, 'twitter_follow'); - Addon::unregisterHook('expire' , __FILE__, 'twitter_expire'); - Addon::unregisterHook('prepare_body' , __FILE__, 'twitter_prepare_body'); - Addon::unregisterHook('check_item_notification', __FILE__, 'twitter_check_item_notification'); + Hook::unregister('load_config' , __FILE__, 'twitter_load_config'); + Hook::unregister('connector_settings' , __FILE__, 'twitter_settings'); + Hook::unregister('connector_settings_post', __FILE__, 'twitter_settings_post'); + Hook::unregister('hook_fork' , __FILE__, 'twitter_hook_fork'); + Hook::unregister('post_local' , __FILE__, 'twitter_post_local'); + Hook::unregister('notifier_normal' , __FILE__, 'twitter_post_hook'); + Hook::unregister('jot_networks' , __FILE__, 'twitter_jot_nets'); + Hook::unregister('cron' , __FILE__, 'twitter_cron'); + Hook::unregister('follow' , __FILE__, 'twitter_follow'); + Hook::unregister('expire' , __FILE__, 'twitter_expire'); + Hook::unregister('prepare_body' , __FILE__, 'twitter_prepare_body'); + Hook::unregister('check_item_notification', __FILE__, 'twitter_check_item_notification'); // old setting - remove only - Addon::unregisterHook('post_local_end' , __FILE__, 'twitter_post_hook'); - Addon::unregisterHook('addon_settings' , __FILE__, 'twitter_settings'); - Addon::unregisterHook('addon_settings_post', __FILE__, 'twitter_settings_post'); + Hook::unregister('post_local_end' , __FILE__, 'twitter_post_hook'); + Hook::unregister('addon_settings' , __FILE__, 'twitter_settings'); + Hook::unregister('addon_settings_post', __FILE__, 'twitter_settings_post'); } -function twitter_load_config(App $a) +function twitter_load_config(App $a, ConfigFileLoader $loader) { - $a->loadConfigFile(__DIR__ . '/config/twitter.config.php'); + $a->getConfigCache()->load($loader->loadAddonConfig('twitter')); } function twitter_check_item_notification(App $a, array &$notification_data) @@ -156,7 +156,7 @@ function twitter_check_item_notification(App $a, array &$notification_data) function twitter_follow(App $a, array &$contact) { - Logger::log("twitter_follow: Check if contact is twitter contact. " . $contact["url"], Logger::DEBUG); + Logger::info('Check if contact is twitter contact', ['url' => $contact["url"]]); if (!strstr($contact["url"], "://twitter.com") && !strstr($contact["url"], "@twitter.com")) { return; @@ -193,21 +193,25 @@ function twitter_follow(App $a, array &$contact) } } -function twitter_jot_nets(App $a, &$b) +function twitter_jot_nets(App $a, array &$jotnets_fields) { if (!local_user()) { return; } - $tw_post = PConfig::get(local_user(), 'twitter', 'post'); - if (intval($tw_post) == 1) { - $tw_defpost = PConfig::get(local_user(), 'twitter', 'post_by_default'); - $selected = ((intval($tw_defpost) == 1) ? ' checked="checked" ' : ''); - $b .= '
' . L10n::t('Currently connected to: ') . '' . $details->screen_name . '
@@ -359,6 +366,12 @@ function twitter_settings(App $a, &$s) ' . $details->description . 'Invalid Twitter info
+