]> git.mxchange.org Git - friendica.git/commitdiff
Move the plink functionality to the right function
authorMichael <heluecht@pirati.ca>
Thu, 5 May 2022 07:57:52 +0000 (07:57 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 5 May 2022 07:57:52 +0000 (07:57 +0000)
src/Content/Item.php
src/Model/Item.php

index 9136396ed1c26c9d3cb683fa36324d6d0838545d..d36112865127e737a952c001c1eb9dac82db6f91 100644 (file)
@@ -355,23 +355,7 @@ class Item
                                $item['body'] = $this->l10n->t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag);
                        }
                }
-/*
-               $matches = null;
-               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=' . Contact::magicLink($mtch[1]) . ']', $item['body']);
-                               }
-                       }
-               }
-*/
-               // add sparkle links to appropriate permalinks
-               // Only create a redirection to a magic link when logged in
-               if (!empty($item['plink']) && Session::isAuthenticated() && $item['private'] == ModelItem::PRIVATE) {
-                       $author = ['uid' => 0, 'id' => $item['author-id'],
-                               'network' => $item['author-network'], 'url' => $item['author-link']];
-                       $item['plink'] = Contact::magicLinkByContact($author, $item['plink']);
-               }
+
                $this->profiler->stopRecording();
        }
 
index d57700c33d077712af750baefab62833916df5e6..496757910ae367a43a006b32513d1606fbdfd06c 100644 (file)
@@ -3200,6 +3200,12 @@ class Item
                                'orig_title' => DI::l10n()->t('View on separate page'),
                        ];
 
+                       if (!empty($plink) && ($item['private'] == self::PRIVATE)) {
+                               $author = ['uid' => 0, 'id' => $item['author-id'],
+                                       'network' => $item['author-network'], 'url' => $item['author-link']];
+                               $plink = Contact::magicLinkByContact($author, $plink);
+                       }
+
                        if (!empty($plink)) {
                                $ret['href'] = DI::baseUrl()->remove($plink);
                                $ret['title'] = DI::l10n()->t('Link to source');