]> git.mxchange.org Git - friendica.git/blobdiff - include/Contact.php
Merge remote-tracking branch 'upstream/develop' into 1702-no-old_pager
[friendica.git] / include / Contact.php
index 845ee168cc77586dfa1542208f7633e3cf8107fb..3d4d6ded7fa64dfea6ab6972bf84a46523dbce0e 100644 (file)
@@ -534,19 +534,20 @@ function get_contact($url, $uid = 0, $no_update = false) {
        $data = array();
        $contact_id = 0;
 
-       // We first try the addr (nick@server.tld)
+       // We first try the nurl (http://server.tld/nick), most common case
        $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
-                               WHERE `addr` = '%s'
-                               AND `uid` = %d",
-               dbesc($url),
-               intval($uid));
+                                       WHERE `nurl` = '%s'
+                                       AND `uid` = %d",
+                       dbesc(normalise_link($url)),
+                       intval($uid));
+
 
-       // Then the nurl (http://server.tld/nick)
+       // Then the addr (nick@server.tld)
        if (! dbm::is_result($contacts)) {
                $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
-                                       WHERE `nurl` = '%s'
+                                       WHERE `addr` = '%s'
                                        AND `uid` = %d",
-                       dbesc(normalise_link($url)),
+                       dbesc($url),
                        intval($uid));
        }
 
@@ -576,14 +577,9 @@ function get_contact($url, $uid = 0, $no_update = false) {
 
        require_once('include/Probe.php');
        $data = Probe::uri($url);
-       if (!$data['url']) {
-               return 0;
-       }
-
-       $url = $data["url"];
 
-       // Does this address belongs to a valid network?
-       if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
+       // Last try in gcontact for unsupported networks
+       if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_PUMPIO))) {
                if ($uid != 0) {
                        return 0;
                }
@@ -598,6 +594,7 @@ function get_contact($url, $uid = 0, $no_update = false) {
                $data = $gcontacts[0];
        }
 
+       $url = $data["url"];
 
        if (!$contact_id) {
                q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
@@ -705,15 +702,6 @@ function posts_from_gcontact(App $a, $gcontact_id) {
        else
                $sql = "`item`.`uid` = %d";
 
-       if(get_config('system', 'old_pager')) {
-               $r = q("SELECT COUNT(*) AS `total` FROM `item`
-                       WHERE `gcontact-id` = %d and $sql",
-                       intval($gcontact_id),
-                       intval(local_user()));
-
-               $a->set_pager_total($r[0]['total']);
-       }
-
        $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
                        `author-name` AS `name`, `owner-avatar` AS `photo`,
                        `owner-link` AS `url`, `owner-avatar` AS `thumb`
@@ -729,11 +717,7 @@ function posts_from_gcontact(App $a, $gcontact_id) {
 
        $o = conversation($a,$r,'community',false);
 
-       if(!get_config('system', 'old_pager')) {
-               $o .= alt_pager($a,count($r));
-       } else {
-               $o .= paginate($a);
-       }
+       $o .= alt_pager($a,count($r));
 
        return $o;
 }
@@ -766,15 +750,6 @@ function posts_from_contact_url(App $a, $contact_url) {
 
        $author_id = intval($r[0]["author-id"]);
 
-       if (get_config('system', 'old_pager')) {
-               $r = q("SELECT COUNT(*) AS `total` FROM `item`
-                       WHERE `author-id` = %d and $sql",
-                       intval($author_id),
-                       intval(local_user()));
-
-               $a->set_pager_total($r[0]['total']);
-       }
-
        $r = q(item_query()." AND `item`.`author-id` = %d AND ".$sql.
                " ORDER BY `item`.`created` DESC LIMIT %d, %d",
                intval($author_id),
@@ -785,11 +760,7 @@ function posts_from_contact_url(App $a, $contact_url) {
 
        $o = conversation($a,$r,'community',false);
 
-       if (!get_config('system', 'old_pager')) {
-               $o .= alt_pager($a,count($r));
-       } else {
-               $o .= paginate($a);
-       }
+       $o .= alt_pager($a,count($r));
 
        return $o;
 }