]> git.mxchange.org Git - friendica.git/commitdiff
The magic link is added at more places
authorMichael <heluecht@pirati.ca>
Sun, 8 Apr 2018 19:17:50 +0000 (19:17 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 8 Apr 2018 19:17:50 +0000 (19:17 +0000)
mod/dirfind.php
src/Model/Profile.php

index a5b26a9193dbebc3974d50680818245e60ff081d..14ceb6daee365077e1366060e10cd9c1c0f9102a 100644 (file)
@@ -223,7 +223,7 @@ function dirfind_content(App $a, $prefix = "") {
 
                                $entry = [
                                        'alt_text' => $alt_text,
-                                       'url' => Profile::zrl($jj->url),
+                                       'url' => Profile::magicLink($jj->url),
                                        'itemurl' => $itemurl,
                                        'name' => htmlentities($jj->name),
                                        'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
index e493d82d53cfb36c4be9234bd093113211860909..ec53d064d6b83704d24ff2bd99f8a5b6c8f96640 100644 (file)
@@ -500,6 +500,8 @@ class Profile
                        $p['photo'] = proxy_url($p['photo'], false, PROXY_SIZE_SMALL);
                }
 
+               $p['url'] = self::magicLink($p['url']);
+
                $tpl = get_markup_template('profile_vcard.tpl');
                $o .= replace_macros($tpl, [
                        '$profile' => $p,
@@ -1005,6 +1007,29 @@ 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)) {