]> git.mxchange.org Git - friendica.git/commitdiff
Use magicLink whenever possible
authorMichael <heluecht@pirati.ca>
Sat, 2 Jun 2018 08:05:06 +0000 (08:05 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 2 Jun 2018 08:05:06 +0000 (08:05 +0000)
23 files changed:
include/conversation.php
include/text.php
mod/allfriends.php
mod/contacts.php
mod/dfrn_request.php
mod/directory.php
mod/dirfind.php
mod/hovercard.php
mod/match.php
mod/message.php
mod/photos.php
mod/randprof.php
mod/suggest.php
mod/unfollow.php
mod/viewcontacts.php
src/Content/ForumManager.php
src/Core/NotificationsManager.php
src/Model/Contact.php
src/Model/Event.php
src/Model/Profile.php
src/Model/Term.php
src/Object/Post.php
view/theme/vier/theme.php

index 5f56723e2e361e47b84b15e7dc10439fc3e043ba..c7b581757a087f26376caef725b5cf31a778cb32 100644 (file)
@@ -14,7 +14,6 @@ use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
-use Friendica\Model\Profile;
 use Friendica\Object\Post;
 use Friendica\Object\Thread;
 use Friendica\Util\DateTimeFormat;
@@ -197,10 +196,10 @@ function localize_item(&$item) {
                        }
                }
 
-               $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
-               $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
+               $A = '[url=' . Contact::magicLink($Alink) . ']' . $Aname . '[/url]';
+               $B = '[url=' . Contact::magicLink($Blink) . ']' . $Bname . '[/url]';
                if ($Bphoto != "") {
-                       $Bphoto = '[url=' . Profile::zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
+                       $Bphoto = '[url=' . Contact::magicLink($Blink) . '][img]' . $Bphoto . '[/img][/url]';
                }
 
                $item['body'] = L10n::t('%1$s is now friends with %2$s', $A, $B)."\n\n\n".$Bphoto;
@@ -234,10 +233,10 @@ function localize_item(&$item) {
                        }
                }
 
-               $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
-               $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
+               $A = '[url=' . Contact::magicLink($Alink) . ']' . $Aname . '[/url]';
+               $B = '[url=' . Contact::magicLink($Blink) . ']' . $Bname . '[/url]';
                if ($Bphoto != "") {
-                       $Bphoto = '[url=' . Profile::zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
+                       $Bphoto = '[url=' . Contact::magicLink($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
                }
 
                /*
@@ -269,8 +268,8 @@ function localize_item(&$item) {
 
                $obj = $r[0];
 
-               $author  = '[url=' . Profile::zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
-               $objauthor =  '[url=' . Profile::zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]';
+               $author  = '[url=' . Contact::magicLink($item['author-link']) . ']' . $item['author-name'] . '[/url]';
+               $objauthor =  '[url=' . Contact::magicLink($obj['author-link']) . ']' . $obj['author-name'] . '[/url]';
 
                switch ($obj['verb']) {
                        case ACTIVITY_POST:
@@ -323,8 +322,8 @@ function localize_item(&$item) {
                                $target = $r[0];
                                $Bname = $target['author-name'];
                                $Blink = $target['author-link'];
-                               $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
-                               $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
+                               $A = '[url=' . Contact::magicLink($Alink) . ']' . $Aname . '[/url]';
+                               $B = '[url=' . Contact::magicLink($Blink) . ']' . $Bname . '[/url]';
                                $P = '[url=' . $target['plink'] . ']' . L10n::t('post/item') . '[/url]';
                                $item['body'] = L10n::t('%1$s marked %2$s\'s %3$s as favorite', $A, $B, $P)."\n";
                        }
@@ -334,7 +333,7 @@ function localize_item(&$item) {
        if (preg_match_all('/@\[url=(.*?)\]/is', $item['body'], $matches, PREG_SET_ORDER)) {
                foreach ($matches as $mtch) {
                        if (!strpos($mtch[1], 'zrl=')) {
-                               $item['body'] = str_replace($mtch[0], '@[url=' . Profile::zrl($mtch[1]) . ']', $item['body']);
+                               $item['body'] = str_replace($mtch[0], '@[url=' . Contact::magicLink($mtch[1]) . ']', $item['body']);
                        }
                }
        }
@@ -342,7 +341,7 @@ function localize_item(&$item) {
        // add zrl's to public images
        $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
        if (preg_match($photo_pattern, $item['body'])) {
-               $photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5'  . '[/img][/url]';
+               $photo_replace = '[url=' . Contact::magicLink('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5'  . '[/img][/url]';
                $item['body'] = BBCode::pregReplaceInTag($photo_pattern, $photo_replace, 'url', $item['body']);
        }
 
@@ -908,48 +907,6 @@ function conversation_add_children($parents, $block_authors, $order, $uid) {
        return $items;
 }
 
-function best_link_url($item, &$sparkle, $url = '') {
-
-       $best_url = '';
-       $sparkle  = false;
-
-       $clean_url = normalise_link($item['author-link']);
-
-       if (local_user()) {
-               $condition = [
-                       'network' => NETWORK_DFRN,
-                       'uid' => local_user(),
-                       'nurl' => normalise_link($clean_url),
-                       'pending' => false
-               ];
-               $contact = dba::selectFirst('contact', ['id'], $condition);
-               if (DBM::is_result($contact)) {
-                       $best_url = 'redir/' . $contact['id'];
-                       $sparkle = true;
-                       if ($url != '') {
-                               $hostname = get_app()->get_hostname();
-                               if (!strstr($url, $hostname)) {
-                                       $best_url .= "?url=".$url;
-                               } else {
-                                       $best_url = $url;
-                               }
-                       }
-               }
-       }
-       if (!$best_url) {
-               if ($url != '') {
-                       $best_url = $url;
-               } elseif (strlen($item['author-link'])) {
-                       $best_url = $item['author-link'];
-               } else {
-                       $best_url = $item['url'];
-               }
-       }
-
-       return $best_url;
-}
-
-
 function item_photo_menu($item) {
        $sub_link = '';
        $poke_link = '';
@@ -982,7 +939,7 @@ function item_photo_menu($item) {
                $photos_link = $profile_link . '?url=photos';
                $profile_link = $profile_link . '?url=profile';
        } else {
-               $profile_link = Profile::zrl($profile_link);
+               $profile_link = Contact::magicLink($profile_link);
        }
 
        if ($cid && !$item['self']) {
index 53eae1ff33924f7118df4c5f8beb3714743628c0..b982881287d2edfe3092d8a1102f4e29f5785d1b 100644 (file)
@@ -961,13 +961,9 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
        $redir = false;
 
        if ($redirect) {
-               $redirect_url = 'redir/' . $contact['id'];
-               if (local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) {
-                       $redir = true;
-                       $url = $redirect_url;
+               $url = Contact::magicLink($contact['url']);
+               if (strpos($url, 'redir/') === 0) {
                        $sparkle = ' sparkle';
-               } else {
-                       $url = Profile::zrl($url);
                }
        }
 
@@ -1300,11 +1296,7 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
        foreach ($matches as $mtch) {
                $mime = $mtch[3];
 
-               if ((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) {
-                       $the_url = 'redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1];
-               } else {
-                       $the_url = $mtch[1];
-               }
+               $the_url = Contact::magicLink($item['author-link'], $mtch[1]);
 
                if (strpos($mime, 'video') !== false) {
                        if (!$vhead) {
index bf852419d21f5cf27cb7dbcada9129ebad56853f..d85d3ec9b36938f015e3f197c154ed086d98c6f7 100644 (file)
@@ -70,7 +70,7 @@ function allfriends_content(App $a)
                } else {
                        $connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
                        $photo_menu = [
-                               'profile' => [L10n::t("View Profile"), Profile::zrl($rr['url'])],
+                               'profile' => [L10n::t("View Profile"), Contact::magicLink($rr['url'])],
                                'follow' => [L10n::t("Connect/Follow"), $connlnk]
                        ];
                }
index cd9021c17ec2cd4edde1b6c9b1997f92bb840f89..9ad7d09b57e40db3f41fa0022fc76a618fdd36ab 100644 (file)
@@ -65,7 +65,7 @@ function contacts_init(App $a)
                $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
                        '$name' => htmlentities($a->data['contact']['name']),
                        '$photo' => $a->data['contact']['photo'],
-                       '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/" . $a->data['contact']['id'] : $a->data['contact']['url'],
+                       '$url' => Contact::MagicLink($a->data['contact']['url']),
                        '$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
                        '$network_name' => $networkname,
                        '$network' => L10n::t('Network:'),
@@ -536,11 +536,10 @@ function contacts_content(App $a)
 
                $relation_text = sprintf($relation_text, htmlentities($contact['name']));
 
-               if (($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
-                       $url = "redir/{$contact['id']}";
+               $url = Contact::magicLink($contact['url']);
+               if (strpos($url, 'redir/') === 0) {
                        $sparkle = ' class="sparkle" ';
                } else {
-                       $url = $contact['url'];
                        $sparkle = '';
                }
 
@@ -940,11 +939,11 @@ function _contact_detail_for_template($rr)
                default:
                        break;
        }
-       if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
-               $url = "redir/{$rr['id']}";
+
+       $url = Contact::magicLink($rr['url']);
+       if (strpos($url, 'redir/') === 0) {
                $sparkle = ' class="sparkle" ';
        } else {
-               $url = $rr['url'];
                $sparkle = '';
        }
 
index ae6017d146e67a0ed907c691c19e1aa378848b59..6592bf901fbcebd38f8cbe3b9f5ed5272fcb9430 100644 (file)
@@ -189,7 +189,6 @@ function dfrn_request_post(App $a)
                                }
 
                                // (ignore reply, nothing we can do it failed)
-                               // Old: goaway(Profile::zrl($dfrn_url));
                                goaway($forwardurl);
                                return; // NOTREACHED
                        }
index 1179b6c53afbdc1c97c89192e423c4efca050f7c..90d7abcc0bfdca51fd2236585205df24c5c86821 100644 (file)
@@ -156,7 +156,7 @@ function directory_content(App $a)
                        $location_e = $location;
 
                        $photo_menu = [
-                               'profile' => [L10n::t("View Profile"), Profile::zrl($profile_link)]
+                               'profile' => [L10n::t("View Profile"), Contact::magicLink($profile_link)]
                        ];
 
                        $entry = [
index 14ceb6daee365077e1366060e10cd9c1c0f9102a..dc86f03a68f4c9cee27bd6e6f5d61efd92ae5dc8 100644 (file)
@@ -11,7 +11,6 @@ use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
-use Friendica\Model\Profile;
 use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\Network;
@@ -214,7 +213,7 @@ function dirfind_content(App $a, $prefix = "") {
                                        $connlnk = System::baseUrl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
                                        $conntxt = L10n::t('Connect');
                                        $photo_menu = [
-                                               'profile' => [L10n::t("View Profile"), Profile::zrl($jj->url)],
+                                               'profile' => [L10n::t("View Profile"), Contact::magicLink($jj->url)],
                                                'follow' => [L10n::t("Connect/Follow"), $connlnk]
                                        ];
                                }
@@ -223,7 +222,7 @@ function dirfind_content(App $a, $prefix = "") {
 
                                $entry = [
                                        'alt_text' => $alt_text,
-                                       'url' => Profile::magicLink($jj->url),
+                                       'url' => Contact::magicLink($jj->url),
                                        'itemurl' => $itemurl,
                                        'name' => htmlentities($jj->name),
                                        'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
index 01d9feb1e46fb4f1711e65e8d185e5b31293a5e1..2fb7b8cc7829140930f3f9373cae5ede3ac90199 100644 (file)
@@ -72,7 +72,7 @@ function hovercard_content()
                'nick'     => $contact['nick'],
                'addr'     => defaults($contact, 'addr', $contact['url']),
                'thumb'    => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
-               'url'      => $cid ? ('redir/' . $cid) : Profile::zrl($contact['url']),
+               'url'      => Contact::magicLink($contact['url']),
                'nurl'     => $contact['nurl'], // We additionally store the nurl as identifier
                'location' => $contact['location'],
                'gender'   => $contact['gender'],
index c5e35031f5aefcada8bba8db3d620c2b49466cff..b06007483554d9c6ae06a4d583a042ca90b50c57 100644 (file)
@@ -86,14 +86,14 @@ function match_content(App $a)
                                        $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
                                        $connlnk = System::baseUrl() . '/follow/?url=' . $jj->url;
                                        $photo_menu = [
-                                               'profile' => [L10n::t("View Profile"), Profile::zrl($jj->url)],
+                                               'profile' => [L10n::t("View Profile"), Contact::magicLink($jj->url)],
                                                'follow' => [L10n::t("Connect/Follow"), $connlnk]
                                        ];
 
                                        $contact_details = Contact::getDetailsByURL($jj->url, local_user());
 
                                        $entry = [
-                                               'url' => Profile::zrl($jj->url),
+                                               'url' => Contact::magicLink($jj->url),
                                                'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
                                                'name' => $jj->name,
                                                'details'       => $contact_details['location'],
index 6a48eb658e523317e7e7f681fb9f27e6a1b5cfd1..987babf74467b72b1111896d42e34198e9562ea9 100644 (file)
@@ -341,11 +341,8 @@ function message_content(App $a)
                        if ($message['from-url'] == $myprofile) {
                                $from_url = $myprofile;
                                $sparkle = '';
-                       } elseif ($message['contact-id'] != 0) {
-                               $from_url = 'redir/' . $message['contact-id'];
-                               $sparkle = ' sparkle';
                        } else {
-                               $from_url = $message['from-url'] . "?zrl=" . urlencode($myprofile);
+                               $from_url = Contact::magicLink($message['from-url']);
                                $sparkle = ' sparkle';
                        }
 
@@ -470,7 +467,7 @@ function render_messages(array $msg, $t)
                $rslt .= replace_macros($tpl, [
                        '$id' => $rr['id'],
                        '$from_name' => $participants,
-                       '$from_url' => (($rr['network'] === NETWORK_DFRN) ? 'redir/' . $rr['contact-id'] : $rr['url']),
+                       '$from_url' => Contact::magicLink($rr['url']),
                        '$from_addr' => $contact['addr'],
                        '$sparkle' => ' sparkle',
                        '$from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB),
index 45e713677abf18cd790a2e3768218ce75fec1f1e..9bc870ca13fe34265dac0fbf5d08071c1d7f33af 100644 (file)
@@ -1538,14 +1538,10 @@ function photos_content(App $a)
                                                continue;
                                        }
 
-                                       $redirect_url = 'redir/' . $item['cid'];
-
-                                       if (local_user() && ($item['contact-uid'] == local_user())
-                                               && ($item['network'] == NETWORK_DFRN) && !$item['self']) {
-                                               $profile_url = $redirect_url;
+                                       $profile_url = Contact::MagicLinkById($item['cid']);
+                                       if (strpos($profile_url, 'redir/') === 0) {
                                                $sparkle = ' sparkle';
                                        } else {
-                                               $profile_url = $item['url'];
                                                $sparkle = '';
                                        }
 
index c5154c12d0b1292ef39fced53c93ef88aadc3e66..18bcb236f8a98504e94acbe860b41c2d2ee82e08 100644 (file)
@@ -4,6 +4,7 @@
  */
 use Friendica\App;
 use Friendica\Core\System;
+use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 use Friendica\Model\Profile;
 
@@ -12,7 +13,7 @@ function randprof_init(App $a)
        $x = GContact::getRandomUrl();
 
        if ($x) {
-               goaway(Profile::zrl($x));
+               goaway(Contact::magicLink($x));
        }
 
        goaway(System::baseUrl() . '/profile');
index 5e8dcc5fb7325ec3cd66f2041752a62b438b2164..b1b6e83dac9476d6aa38cd3954307d5eb567ea40 100644 (file)
@@ -79,7 +79,7 @@ function suggest_content(App $a) {
                $connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
                $ignlnk = System::baseUrl() . '/suggest?ignore=' . $rr['id'];
                $photo_menu = [
-                       'profile' => [L10n::t("View Profile"), Profile::zrl($rr["url"])],
+                       'profile' => [L10n::t("View Profile"), Contact::magicLink($rr["url"])],
                        'follow' => [L10n::t("Connect/Follow"), $connlnk],
                        'hide' => [L10n::t('Ignore/Hide'), $ignlnk]
                ];
@@ -87,7 +87,7 @@ function suggest_content(App $a) {
                $contact_details = Contact::getDetailsByURL($rr["url"], local_user(), $rr);
 
                $entry = [
-                       'url' => Profile::zrl($rr['url']),
+                       'url' => Contact::magicLink($rr['url']),
                        'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
                        'img_hover' => $rr['url'],
                        'name' => $contact_details['name'],
index a26557a9a2157339a9ca70a0e95eb4a5747ca067..6059c27ab7e2403c0a05a657dd7b480ddc48b532 100644 (file)
@@ -118,7 +118,7 @@ function unfollow_content(App $a)
                        '$nickname' => "",
                        '$name' => $contact["name"],
                        '$url' => $contact["url"],
-                       '$zrl' => Profile::zrl($contact["url"]),
+                       '$zrl' => Contact::magicLink($contact["url"]),
                        '$url_label' => L10n::t("Profile URL"),
                        '$myaddr' => $myaddr,
                        '$request' => $request,
index 7763dc8bf7a9c4b88bbbaec9485218cf6dfbdfc4..af5ecd9d67011b5daaeace861600026cd7cd3975 100644 (file)
@@ -96,15 +96,6 @@ function viewcontacts_content(App $a)
                        continue;
                }
 
-               $url = $rr['url'];
-
-               // route DFRN profiles through the redirect
-               if ($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
-                       $url = 'redir/' . $rr['id'];
-               } else {
-                       $url = Profile::zrl($url);
-               }
-
                $contact_details = Contact::getDetailsByURL($rr['url'], $a->profile['uid'], $rr);
 
                $contacts[] = [
@@ -118,7 +109,7 @@ function viewcontacts_content(App $a)
                        'tags'          => $contact_details['keywords'],
                        'about'         => $contact_details['about'],
                        'account_type'  => Contact::getAccountType($contact_details),
-                       'url' => $url,
+                       'url' => Contact::magicLink($rr['url']),
                        'sparkle' => '',
                        'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
                        'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
index cfd083f9f8c3821010e1f61d3d77a78d1163f278..e45dd0c4215a5722638833190347894cfe4e6352 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\App;
 use Friendica\Content\Feature;
 use Friendica\Core\L10n;
 use Friendica\Core\System;
+use Friendica\Model\Contact;
 use Friendica\Database\DBM;
 use dba;
 
@@ -107,7 +108,7 @@ class ForumManager
 
                                $entry = [
                                        'url' => 'network?f=&cid=' . $contact['id'],
-                                       'external_url' => 'redir/' . $contact['id'],
+                                       'external_url' => Contact::magicLink($contact['url']),
                                        'name' => $contact['name'],
                                        'cid' => $contact['id'],
                                        'selected'      => $selected,
index 6a13c025c44db82d5610b6a797cb9184cf063bb0..6e9d469eb9778370aa9319f45c1ad3f70840a298 100644 (file)
@@ -828,7 +828,7 @@ class NotificationsManager extends BaseObject
                                        'contact_id' => $it['contact-id'],
                                        'photo' => ((x($it, 'fphoto')) ? proxy_url($it['fphoto'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
                                        'name' => $it['fname'],
-                                       'url' => Profile::zrl($it['furl']),
+                                       'url' => Contact::magicLink($it['furl']),
                                        'hidden' => $it['hidden'] == 1,
                                        'post_newfriend' => (intval(PConfig::get(local_user(), 'system', 'post_newfriend')) ? '1' : 0),
                                        'knowyou' => $knowyou,
@@ -862,7 +862,7 @@ class NotificationsManager extends BaseObject
                                        'hidden' => $it['hidden'] == 1,
                                        'post_newfriend' => (intval(PConfig::get(local_user(), 'system', 'post_newfriend')) ? '1' : 0),
                                        'url' => $it['url'],
-                                       'zrl' => Profile::zrl($it['url']),
+                                       'zrl' => Contact::magicLink($it['url']),
                                        'addr' => $it['gaddr'],
                                        'network' => $it['gnetwork'],
                                        'knowyou' => $it['knowyou'],
index 4a6ddd52dbabdfbf6a7ef941859fa22861904ad0..a2c9b48864e3efabdbd35ba374c200434f293214 100644 (file)
@@ -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],
@@ -1697,7 +1697,7 @@ 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;
                }
@@ -1717,12 +1717,16 @@ class Contact extends BaseObject
        {
                // 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'];
                }
 
+               if ($contact['uid'] != 0) {
+                       return self::magicLink($contact['url'], $url);
+               }
+
                $redirect = 'redir/' . $cid;
 
                if ($url != '') {
index db9e2b93034127cc85e1036571a8a3caea20899a..1f3259f228c246e5ab6cb5b208a6e5fdc4970b19 100644 (file)
@@ -868,12 +868,7 @@ class Event extends BaseObject
                $location = self::locationToArray($item['event-location']);
 
                // Construct the profile link (magic-auth).
-               $sp = false;
-               $profile_link = best_link_url($item, $sp);
-
-               if (!$sp) {
-                       $profile_link = Profile::zrl($profile_link);
-               }
+               $profile_link = Contact::magicLink($item['author-link']);
 
                $tpl = get_markup_template('event_stream_item.tpl');
                $return = replace_macros($tpl, [
index a2e374e51bdba73c9da6917dee2b26804ed360ba..39a89694a891c911a9a6c433bc12a224d7fe2d39 100644 (file)
@@ -496,7 +496,7 @@ class Profile
                        $p['photo'] = proxy_url($p['photo'], false, PROXY_SIZE_SMALL);
                }
 
-               $p['url'] = self::magicLink($p['url']);
+               $p['url'] = Contact::magicLink($p['url']);
 
                $tpl = get_markup_template('profile_vcard.tpl');
                $o .= replace_macros($tpl, [
@@ -594,12 +594,8 @@ class Profile
                                        $cids[] = $rr['cid'];
 
                                        $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
-                                       $url = $rr['url'];
-                                       if ($rr['network'] === NETWORK_DFRN) {
-                                               $url = System::baseUrl() . '/redir/' . $rr['cid'];
-                                       }
 
-                                       $rr['link'] = $url;
+                                       $rr['link'] = Contact::magicLink($rr['url']);
                                        $rr['title'] = $rr['name'];
                                        $rr['date'] = day_translate(DateTimeFormat::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . L10n::t('[today]') : '');
                                        $rr['startime'] = null;
@@ -1003,29 +999,6 @@ class Profile
                }
        }
 
-       /**
-        * @brief Returns a magic link to authenticate remote visitors
-        *
-        * @param string $contact_url The address of the contact profile
-        * @param integer $uid The user id, "local_user" is the default
-        *
-        * @return string with "redir" link
-        */
-       public static function magicLink($contact_url, $uid = -1)
-       {
-               if ($uid == -1) {
-                       $uid = local_user();
-               }
-               $condition = ['pending' => false, 'uid' => $uid,
-                               'nurl' => normalise_link($contact_url),
-                               'network' => NETWORK_DFRN, 'self' => false];
-               $contact = dba::selectFirst('contact', ['id'], $condition);
-               if (DBM::is_result($contact)) {
-                       return System::baseUrl() . '/redir/' . $contact['id'];
-               }
-               return self::zrl($contact_url);
-       }
-
        public static function zrl($s, $force = false)
        {
                if (!strlen($s)) {
index e5490fa7c6cc731a103d491e26d9bf30c4f2100a..1a4294c68a6cdf921c453bf62bf6a4fafdaa8575 100644 (file)
@@ -196,7 +196,7 @@ class Term
 
                        $orig_tag = $tag["url"];
 
-                       $tag["url"] = best_link_url($item, $sp, $tag["url"]);
+                       $tag["url"] = Contact::magicLink($item['author-link'], $tag['url']);
 
                        if ($tag["type"] == TERM_HASHTAG) {
                                if ($orig_tag != $tag["url"]) {
index 89f0d47f61e1387e7139e1e6924b27d89c65dacd..3895afa326c194e2176a4de16f5b286f0ebe9367 100644 (file)
@@ -13,7 +13,6 @@ use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
-use Friendica\Model\Profile;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Temporal;
 use dba;
@@ -71,7 +70,7 @@ class Post extends BaseObject
                }
 
                $this->writable = $this->getDataValue('writable') || $this->getDataValue('self');
-               $this->redirect_url = 'redir/' . $this->getDataValue('cid');
+               $this->redirect_url = Contact::magicLinkById($this->getDataValue('cid'));
 
                if (!$this->isToplevel()) {
                        $this->threaded = true;
@@ -840,7 +839,7 @@ class Post extends BaseObject
                                        // This will have been stored in $a->page_contact by our calling page.
                                        // Put this person as the wall owner of the wall-to-wall notice.
 
-                                       $this->owner_url = Profile::zrl($a->page_contact['url']);
+                                       $this->owner_url = Contact::magicLink($a->page_contact['url']);
                                        $this->owner_photo = $a->page_contact['thumb'];
                                        $this->owner_name = $a->page_contact['name'];
                                        $this->wall_to_wall = true;
@@ -862,14 +861,7 @@ class Post extends BaseObject
                                                $this->owner_photo = $this->getDataValue('owner-avatar');
                                                $this->owner_name = $this->getDataValue('owner-name');
                                                $this->wall_to_wall = true;
-                                               // If it is our contact, use a friendly redirect link
-                                               if ($this->getDataValue('network') === NETWORK_DFRN
-                                                       && link_compare($this->getDataValue('owner-link'), $this->getDataValue('url'))
-                                               ) {
-                                                       $this->owner_url = $this->getRedirectUrl();
-                                               } else {
-                                                       $this->owner_url = Profile::zrl($this->getDataValue('owner-link'));
-                                               }
+                                               $this->owner_url = Contact::magicLink($this->getDataValue('owner-link'));
                                        }
                                }
                        }
index c7525946535c48532b72c2cae86445e2bff12212..cc08a7d71fa442c39b8cf5de51bc0ee5de4f5217 100644 (file)
@@ -17,6 +17,7 @@ use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
+use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 use Friendica\Model\Profile;
 
@@ -153,7 +154,6 @@ function vier_community_info()
                        foreach ($r as $rr) {
                                $entry = replace_macros($tpl, [
                                        '$id' => $rr['id'],
-                                       //'$profile_link' => Profile::zrl($rr['url']),
                                        '$profile_link' => 'follow/?url='.urlencode($rr['url']),
                                        '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
                                        '$alt_text' => $rr['name'],
@@ -234,7 +234,7 @@ function vier_community_info()
 
                                $entry = [
                                        'url'          => 'network?f=&cid=' . $contact['id'],
-                                       'external_url' => 'redir/' . $contact['id'],
+                                       'external_url' => Contact::magicLink($contact['url']),
                                        'name'         => $contact['name'],
                                        'cid'          => $contact['id'],
                                        'selected'     => $selected,
@@ -285,7 +285,7 @@ function vier_community_info()
                }
 
                foreach ($r as $index => $helper) {
-                       $r[$index]["url"] = Profile::zrl($helper["url"]);
+                       $r[$index]["url"] = Contact::magicLink($helper["url"]);
                }
 
                $r[] = ["url" => "help/Quick-Start-guide", "name" => L10n::t("Quick Start")];