X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FContact.php;h=fe9869c6f88065386a8a918b11ac88e555e5096a;hb=bffdf96d8791db3f5c1aaede9b3f7416fb189f38;hp=4a6ddd52dbabdfbf6a7ef941859fa22861904ad0;hpb=ae8d7267a0596f7e238aeb87aadbd2d8860ad397;p=friendica.git diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 4a6ddd52db..fe9869c6f8 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -598,7 +598,7 @@ class Contact extends BaseObject if ($contact['uid'] != $uid) { if ($uid == 0) { - $profile_link = Profile::zrl($contact['url']); + $profile_link = self::magicLink($contact['url']); $menu = ['profile' => [L10n::t('View Profile'), $profile_link, true]]; return $menu; @@ -609,7 +609,7 @@ class Contact extends BaseObject if (DBM::is_result($contact_own)) { return self::photoMenu($contact_own, $uid); } else { - $profile_link = Profile::zrl($contact['url']); + $profile_link = self::magicLink($contact['url']); $connlnk = 'follow/?url=' . $contact['url']; $menu = [ 'profile' => [L10n::t('View Profile'), $profile_link, true], @@ -944,21 +944,36 @@ class Contact extends BaseObject 'name' => $data['name'], 'nick' => $data['nick']]; - // Only fill the pubkey if it was empty before. We have to prevent identity theft. - if (!empty($contact['pubkey'])) { - unset($contact['pubkey']); - } else { - $updated['pubkey'] = $data['pubkey']; - } - if ($data['keywords'] != '') { $updated['keywords'] = $data['keywords']; } if ($data['location'] != '') { $updated['location'] = $data['location']; } - if ($data['about'] != '') { - $updated['about'] = $data['about']; + + // Update the technical stuff as well - if filled + if ($data['notify'] != '') { + $updated['notify'] = $data['notify']; + } + if ($data['poll'] != '') { + $updated['poll'] = $data['poll']; + } + if ($data['batch'] != '') { + $updated['batch'] = $data['batch']; + } + if ($data['request'] != '') { + $updated['request'] = $data['request']; + } + if ($data['confirm'] != '') { + $updated['confirm'] = $data['confirm']; + } + if ($data['poco'] != '') { + $updated['poco'] = $data['poco']; + } + + // Only fill the pubkey if it had been empty before. We have to prevent identity theft. + if (empty($contact['pubkey'])) { + $updated['pubkey'] = $data['pubkey']; } if (($data["addr"] != $contact["addr"]) || ($data["alias"] != $contact["alias"])) { @@ -1040,24 +1055,26 @@ class Contact extends BaseObject } if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) { - $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = %d AND NOT `item`.`global`))"; + $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))"; } else { - $sql = "`item`.`uid` = %d"; + $sql = "`item`.`uid` = ?"; } $author_id = intval($r[0]["author-id"]); $contact = ($r[0]["contact-type"] == ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id'); - $r = q(item_query(local_user()) . " AND `item`.`" . $contact . "` = %d AND " . $sql . - " AND `item`.`verb` = '%s' ORDER BY `item`.`created` DESC LIMIT %d, %d", - intval($author_id), intval(local_user()), dbesc(ACTIVITY_POST), - intval($a->pager['start']), intval($a->pager['itemspage']) - ); + $condition = ["`$contact` = ? AND `gravity` IN (?, ?) AND " . $sql, + $author_id, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()]; + $params = ['order' => ['created' => true], + 'limit' => [$a->pager['start'], $a->pager['itemspage']]]; + $r = Item::selectForUser(local_user(), [], $condition, $params); + + $items = Item::inArray($r); - $o = conversation($a, $r, 'contact-posts', false); + $o = conversation($a, $items, 'contact-posts', false); - $o .= alt_pager($a, count($r)); + $o .= alt_pager($a, count($items)); return $o; } @@ -1697,9 +1714,9 @@ class Contact extends BaseObject */ public static function magicLink($contact_url, $url = '') { - $cid = self::getIdForURL($contact_url); + $cid = self::getIdForURL($contact_url, 0, true); if (empty($cid)) { - return ($url != '') ? $url : $contact_url; + return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url; } return self::magicLinkbyId($cid, $url); @@ -1715,12 +1732,19 @@ class Contact extends BaseObject */ public static function magicLinkbyId($cid, $url = '') { - // Direkt auf die URL verweisen, wenn die Host-Angaben unterschiedlich sind - - $contact = dba::selectFirst('contact', ['network', 'url'], ['id' => $cid]); + $contact = dba::selectFirst('contact', ['network', 'url', 'uid'], ['id' => $cid]); if ($contact['network'] != NETWORK_DFRN) { - return ($url != '') ? $url : $contact['url']; + return $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url']; + } + + // Only redirections to the same host do make sense + if (($url != '') && (parse_url($url, PHP_URL_HOST) != parse_url($contact['url'], PHP_URL_HOST))) { + return $url; + } + + if ($contact['uid'] != 0) { + return self::magicLink($contact['url'], $url); } $redirect = 'redir/' . $cid;