]> git.mxchange.org Git - friendica-addons.git/blobdiff - twitter/twitter.php
Merge pull request #483 from MrPetovan/task/fix-scrutinizer-issues
[friendica-addons.git] / twitter / twitter.php
index f88d4542b41a0c1a9f695216b3f9badbb7615b33..dbd0bab87892857501517f65f14658f941bcf448 100644 (file)
  */
 
 use Friendica\App;
+use Friendica\Content\OEmbed;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\Worker;
 use Friendica\Model\GContact;
+use Friendica\Model\Group;
 use Friendica\Model\Photo;
+use Friendica\Model\User;
 use Friendica\Object\Image;
 
 require_once 'include/enotify.php';
@@ -222,7 +225,7 @@ function twitter_settings_post(App $a, $post)
                        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($a->get_baseurl() . '/settings/connectors');
+                       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
@@ -520,7 +523,7 @@ function twitter_post_hook(App $a, &$b)
 
                $max_char = 280;
                require_once "include/plaintext.php";
-               $msgarr = plaintext($a, $b, $max_char, true, 8);
+               $msgarr = plaintext($b, $max_char, true, 8);
                $msg = $msgarr["text"];
 
                if (($msg == "") && isset($msgarr["title"])) {
@@ -589,7 +592,7 @@ function twitter_post_hook(App $a, &$b)
 // -----------------
                        $max_char = 280;
                        require_once "include/plaintext.php";
-                       $msgarr = plaintext($a, $b, $max_char, true, 8);
+                       $msgarr = plaintext($b, $max_char, true, 8);
                        $msg = $msgarr["text"];
 
                        if (($msg == "") && isset($msgarr["title"])) {
@@ -786,7 +789,7 @@ function twitter_prepare_body(App $a, &$b)
                        }
                }
 
-               $msgarr = plaintext($a, $item, $max_char, true, 8);
+               $msgarr = plaintext($item, $max_char, true, 8);
                $msg = $msgarr["text"];
 
                if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
@@ -1055,14 +1058,7 @@ function twitter_fetch_contact($uid, $contact, $create_user)
 
                $contact_id = $r[0]['id'];
 
-               $g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
-                       intval($uid)
-               );
-
-               if ($g && intval($g[0]['def_gid'])) {
-                       require_once 'include/group.php';
-                       group_add_member($uid, '', $contact_id, $g[0]['def_gid']);
-               }
+               Group::addMember(User::getDefaultGroup($uid), $contact_id);
 
                $photos = Photo::importProfilePhoto($avatar, $uid, $contact_id, true);
 
@@ -1177,7 +1173,6 @@ function twitter_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
 
 function twitter_expand_entities(App $a, $body, $item, $no_tags = false, $picture)
 {
-       require_once "include/oembed.php";
        require_once "include/network.php";
 
        $tags = "";
@@ -1196,7 +1191,7 @@ function twitter_expand_entities(App $a, $body, $item, $no_tags = false, $pictur
                        if ($url->url && $url->expanded_url && $url->display_url) {
                                $expanded_url = original_url($url->expanded_url);
 
-                               $oembed_data = oembed_fetch_url($expanded_url);
+                               $oembed_data = OEmbed::fetchURL($expanded_url);
 
                                // Quickfix: Workaround for URL with "[" and "]" in it
                                if (strpos($expanded_url, "[") || strpos($expanded_url, "]")) {