]> git.mxchange.org Git - friendica.git/commitdiff
Use the function from the contact template instead
authorMichael <heluecht@pirati.ca>
Fri, 31 Jul 2020 03:55:01 +0000 (03:55 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 31 Jul 2020 03:55:01 +0000 (03:55 +0000)
mod/common.php
mod/match.php
mod/suggest.php
src/Model/Contact.php
src/Module/AllFriends.php
src/Module/BaseSearch.php
src/Module/Contact.php

index 29b3a9432d68832db86154949b7a75ace33c6eb8..edcb81983fae6037be9a3d9dbac5e8b4c2ff210c 100644 (file)
  */
 
 use Friendica\App;
-use Friendica\Content\ContactSelector;
 use Friendica\Content\Pager;
 use Friendica\Core\Renderer;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model;
-use Friendica\Model\Contact;
 use Friendica\Module;
 use Friendica\Util\Strings;
 
@@ -123,9 +121,9 @@ function common_content(App $a)
 
        $entries = [];
        foreach ($common_friends as $common_friend) {
-               $contact = Model\Contact::getByURL($common_friend['url']);
+               $contact = Model\Contact::getByURLForUser($common_friend['url'], local_user());
                if (!empty($contact)) {
-                       $entries[] = Model\Contact::getTemplateData($contact, ++$id);
+                       $entries[] = Module\Contact::getContactTemplateVars($contact, ++$id);
                }
        }
 
index 75728b7043e9f28f49b4af769f15da31e7266da8..6a2e350bcc2a07f5615f464aa0dc0a8f991bf6ab 100644 (file)
@@ -27,6 +27,7 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
+use Friendica\Module\Contact as ModuleContact;
 
 /**
  * Controller for /match.
@@ -91,9 +92,9 @@ function match_content(App $a)
                                continue;
                        }
 
-                       $contact = Contact::getByURL($profile->url);
+                       $contact = Contact::getByURLForUser($profile->url, local_user());
                        if (!empty($contact)) {
-                               $entries[] = Contact::getTemplateData($contact, $i);
+                               $entries[] = ModuleContact::getContactTemplateVars($contact, $i);
                        }
                }
 
index c818bd010ec977fb4cd1c508c20644ee5b7d3d5c..03d0e77fc7f85225f79f3dde3921e7488b41a003 100644 (file)
  */
 
 use Friendica\App;
-use Friendica\Content\ContactSelector;
 use Friendica\Content\Widget;
 use Friendica\Core\Renderer;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
+use Friendica\Module\Contact as ModuleContact;
 
 function suggest_init(App $a)
 {
@@ -93,7 +93,7 @@ function suggest_content(App $a)
        $entries = [];
 
        foreach ($contacts as $contact) {
-               $entries[] = Contact::getTemplateData($contact, ++$id);
+               $entries[] = ModuleContact::getContactTemplateVars($contact, ++$id);
        }
 
        $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
index cceab3a02fc34c11a8ec3d74ca948f039f04c71c..7443d32a2efcb39958ae0a4c508ea41db16bddae 100644 (file)
@@ -3069,22 +3069,4 @@ class Contact
 
                return array_slice($contacts, $start, $limit);
        }
-
-       public static function getTemplateData(array $contact, int $id)
-       {
-               return [
-                       'url'          => self::magicLink($contact['url']),
-                       'itemurl'      => $contact['addr'] ?: $contact['url'],
-                       'name'         => $contact['name'],
-                       'thumb'        => self::getThumb($contact),
-                       'img_hover'    => $contact['url'],
-                       'details'      => $contact['location'],
-                       'tags'         => $contact['keywords'],
-                       'about'        => $contact['about'],
-                       'account_type' => self::getAccountType($contact),
-                       'network'      => ContactSelector::networkToName($contact['network'], $contact['url']),
-                       'photo_menu'   => self::photoMenu($contact),
-                       'id'           => $id,
-               ];
-       }
 }
index 10d33134654e593451a0dd037a598913d343269b..30418f5c2a4c56b749dc163c993b510d7ef76e15 100644 (file)
@@ -22,7 +22,6 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\Content\ContactSelector;
 use Friendica\Content\Pager;
 use Friendica\Core\Renderer;
 use Friendica\DI;
@@ -77,9 +76,9 @@ class AllFriends extends BaseModule
 
                $entries = [];
                foreach ($friends as $friend) {
-                       $contact = Model\Contact::getByURL($friend['url']);
+                       $contact = Model\Contact::getByURLForUser($friend['url'], local_user());
                        if (!empty($contact)) {
-                               $entries[] = Model\Contact::getTemplateData($contact, ++$id);
+                               $entries[] = Contact::getContactTemplateVars($contact, ++$id);
                        }
                }
 
index 594f5620554e66e44ae67ebcb733a55cc205fce4..5863a94050cdfc88288f552297510d7562216d2f 100644 (file)
@@ -22,7 +22,6 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\Content\ContactSelector;
 use Friendica\Content\Pager;
 use Friendica\Core\Renderer;
 use Friendica\Core\Search;
@@ -125,9 +124,9 @@ class BaseSearch extends BaseModule
 
                        // in case the result is a contact result, add a contact-specific entry
                        if ($result instanceof ContactResult) {
-                               $contact = Model\Contact::getByURL($result->getUrl());
+                               $contact = Model\Contact::getByURLForUser($result->getUrl(), local_user());
                                if (!empty($contact)) {
-                                       $entries[] = Model\Contact::getTemplateData($contact, ++$id);
+                                       $entries[] = Contact::getContactTemplateVars($contact, ++$id);
                                }
                        }
                }
index 3fa89cde916eb7aa64794f636429fd91a5643db0..2d06aa3240e7f26cc9d7cee119e8d88efb5f0ef2 100644 (file)
@@ -1009,7 +1009,14 @@ class Contact extends BaseModule
                return $o;
        }
 
-       public static function getContactTemplateVars(array $rr)
+       /**
+        * Return the fields for the contact template
+        *
+        * @param array $rr Contact array
+        * @param integer $id
+        * @return array Template fields
+        */
+       public static function getContactTemplateVars(array $rr, int $id = 0)
        {
                $dir_icon = '';
                $alt_text = '';
@@ -1069,12 +1076,16 @@ class Contact extends BaseModule
                        'thumb'     => Model\Contact::getThumb($rr),
                        'name'      => $rr['name'],
                        'username'  => $rr['name'],
+                       'details'   => $rr['location'],
+                       'tags'      => $rr['keywords'],
+                       'about'     => $rr['about'],
                        'account_type' => Model\Contact::getAccountType($rr),
                        'sparkle'   => $sparkle,
                        'itemurl'   => ($rr['addr'] ?? '') ?: $rr['url'],
                        'url'       => $url,
                        'network'   => ContactSelector::networkToName($rr['network'], $rr['url'], $rr['protocol']),
                        'nick'      => $rr['nick'],
+                       'id'        => $id,
                ];
        }