]> git.mxchange.org Git - friendica-addons.git/blobdiff - pumpio/pumpio.php
Merge pull request #486 from MrPetovan/task/fix-scrutinizer-issues
[friendica-addons.git] / pumpio / pumpio.php
index 358a2257163e92a5fd0a07ce54644117016d9a62..3f6f8a87040da7da5f5e39b42b3619d4c19f3fb3 100644 (file)
@@ -5,17 +5,17 @@
  * Version: 0.2
  * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
  */
-
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\Worker;
-use Friendica\Model\GlobalContact;
-use Friendica\Object\Contact;
+use Friendica\Model\Contact;
+use Friendica\Model\GContact;
+use Friendica\Model\Group;
+use Friendica\Model\User;
 
 require 'addon/pumpio/oauth/http.php';
 require 'addon/pumpio/oauth/oauth_client.php';
 require_once 'include/enotify.php';
-require_once "include/Photo.php";
 require_once "mod/share.php";
 
 define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes
@@ -413,12 +413,13 @@ function pumpio_send(&$a,&$b) {
 
                logger("pumpio_send: receiver ".print_r($receiver, true));
 
-               if (!count($receiver) && ($b['private'] || !strstr($b['postopts'],'pumpio')))
+               if (!count($receiver) && ($b['private'] || !strstr($b['postopts'],'pumpio'))) {
                        return;
+               }
 
                // Dont't post if the post doesn't belong to us.
                // This is a check for forum postings
-               $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1));
+               $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
                if ($b['contact-id'] != $self['id']) {
                        return;
                }
@@ -976,7 +977,7 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
 
 function pumpio_get_contact($uid, $contact, $no_insert = false) {
 
-       GlobalContact::update(array("url" => $contact->url, "network" => NETWORK_PUMPIO, "generation" => 2,
+       GContact::update(array("url" => $contact->url, "network" => NETWORK_PUMPIO, "generation" => 2,
                        "photo" => $contact->image->url, "name" => $contact->displayName,  "hide" => true,
                        "nick" => $contact->preferredUsername, "location" => $contact->location->displayName,
                        "about" => $contact->summary, "addr" => str_replace("acct:", "", $contact->id)));
@@ -1024,14 +1025,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) {
 
                $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);
        } else {
                $contact_id = $r[0]["id"];
 
@@ -1046,8 +1040,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) {
                */
        }
 
-       if (function_exists("update_contact_avatar"))
-               update_contact_avatar($contact->image->url, $uid, $contact_id);
+       Contact::updateAvatar($contact->image->url, $uid, $contact_id);
 
        return($contact_id);
 }
@@ -1552,10 +1545,9 @@ function pumpio_getreceiver(&$a, $b) {
                        $gid = trim($gid, " <>");
 
                        $r = q("SELECT `contact`.`name`, `contact`.`nick`, `contact`.`url`, `contact`.`network` ".
-                               "FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d AND `group_member`.`uid` = %d ".
+                               "FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d ".
                                "AND `contact`.`id` = `group_member`.`contact-id` AND `contact`.`network` = '%s'",
                                        intval($gid),
-                                       intval($b["uid"]),
                                        dbesc(NETWORK_PUMPIO)
                                );