]> git.mxchange.org Git - friendica-addons.git/blobdiff - twitter/twitter.php
Merge pull request #496 from zeroadam/bugFix-Twitter
[friendica-addons.git] / twitter / twitter.php
index 1b4758018c0b359d12333e5ab8f81f3709ffca05..0a831800ad7e2aeb63e5062e4989caa914954357 100644 (file)
@@ -33,7 +33,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
-/*   Twitter Plugin for Friendica
+/*   Twitter Addon for Friendica
  *
  *   Author: Tobias Diekershoff
  *           tobias.diekershoff@gmx.net
@@ -41,7 +41,7 @@
  *   License:3-clause BSD license
  *
  *   Configuration:
- *     To use this plugin you need a OAuth Consumer key pair (key & secret)
+ *     To use this addon you need a OAuth Consumer key pair (key & secret)
  *     you can get it from Twitter at https://twitter.com/apps
  *
  *     Register your Friendica site as "Client" application with "Read & Write" access
@@ -53,9 +53,9 @@
  *     $a->config['twitter']['consumerkey'] = 'your consumer_key here';
  *     $a->config['twitter']['consumersecret'] = 'your consumer_secret here';
  *
- *     To activate the plugin itself add it to the $a->config['system']['addon']
+ *     To activate the addon itself add it to the $a->config['system']['addon']
  *     setting. After this, your user can configure their Twitter account settings
- *     from "Settings -> Plugin Settings".
+ *     from "Settings -> Addon Settings".
  *
  *     Requirements: PHP5, curl [Slinky library]
  */
@@ -69,6 +69,7 @@ use Friendica\Core\Worker;
 use Friendica\Model\GContact;
 use Friendica\Model\Group;
 use Friendica\Model\Photo;
+use Friendica\Model\Queue;
 use Friendica\Model\User;
 use Friendica\Object\Image;
 
@@ -109,8 +110,8 @@ function twitter_uninstall()
 
        // old setting - remove only
        Addon::unregisterHook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
-       Addon::unregisterHook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings');
-       Addon::unregisterHook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
+       Addon::unregisterHook('addon_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
 }
 
 function twitter_check_item_notification(App $a, &$notification_data)
@@ -301,7 +302,7 @@ function twitter_settings(App $a, &$s)
                        /*                       * *
                         *  make some nice form
                         */
-                       $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 .= '<p>' . t('At this Friendica instance the Twitter addon 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>';
@@ -627,8 +628,9 @@ function twitter_post_hook(App $a, &$b)
                                }
 
                                $s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $post]);
-                               require_once 'include/queue_fn.php';
-                               add_to_queue($a->contact, NETWORK_TWITTER, $s);
+                               
+                               Queue::add($a->contact, NETWORK_TWITTER, $s);
+
                                notice(t('Twitter post failed. Queued for retry.') . EOL);
                        } elseif ($iscomment) {
                                logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
@@ -641,7 +643,7 @@ function twitter_post_hook(App $a, &$b)
        }
 }
 
-function twitter_plugin_admin_post(App $a)
+function twitter_addon_admin_post(App $a)
 {
        $consumerkey     = x($_POST, 'consumerkey')     ? notags(trim($_POST['consumerkey']))     : '';
        $consumersecret  = x($_POST, 'consumersecret')  ? notags(trim($_POST['consumersecret']))  : '';
@@ -650,7 +652,7 @@ function twitter_plugin_admin_post(App $a)
        info(t('Settings updated.') . EOL);
 }
 
-function twitter_plugin_admin(App $a, &$o)
+function twitter_addon_admin(App $a, &$o)
 {
        $t = get_markup_template("admin.tpl", "addon/twitter/");
 
@@ -925,8 +927,6 @@ function twitter_queue_hook(App $a, &$b)
                return;
        }
 
-       require_once 'include/queue_fn.php';
-
        foreach ($qi as $x) {
                if ($x['network'] !== NETWORK_TWITTER) {
                        continue;
@@ -972,7 +972,7 @@ function twitter_queue_hook(App $a, &$b)
                                logger('twitter_queue: Send to Twitter failed: "' . print_r($result->errors, true) . '"');
                        } else {
                                $success = true;
-                               remove_queue_item($x['id']);
+                               Queue::removeItem($x['id']);
                        }
                } else {
                        logger("twitter_queue: Error getting tokens for user " . $user['uid']);
@@ -980,7 +980,7 @@ function twitter_queue_hook(App $a, &$b)
 
                if (!$success) {
                        logger('twitter_queue: delayed');
-                       update_queue_time($x['id']);
+                       Queue::updateTime($x['id']);
                }
        }
 }