]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Contact.php
Fix tests
[friendica.git] / src / Module / Contact.php
index f82b7d3cc110606d1a615b682a346a25ab918c19..2609a5b8bfc3da6086516b24bf9d1b343bde159e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -413,6 +413,10 @@ class Contact extends BaseModule
                        }
 
                        if ($cmd === 'block') {
+                               if (public_contact() === $contact_id) {
+                                       throw new BadRequestException(DI::l10n()->t('You can\'t block yourself'));
+                               }
+
                                self::blockContact($contact_id);
 
                                $blocked = Model\Contact\User::isBlocked($contact_id, local_user());
@@ -423,6 +427,10 @@ class Contact extends BaseModule
                        }
 
                        if ($cmd === 'ignore') {
+                               if (public_contact() === $contact_id) {
+                                       throw new BadRequestException(DI::l10n()->t('You can\'t ignore yourself'));
+                               }
+
                                self::ignoreContact($contact_id);
 
                                $ignored = Model\Contact\User::isIgnored($contact_id, local_user());
@@ -518,7 +526,7 @@ class Contact extends BaseModule
 
                        $relation_text = sprintf($relation_text, $contact['name']);
 
-                       $url = Model\Contact::magicLink($contact['url']);
+                       $url = Model\Contact::magicLinkByContact($contact);
                        if (strpos($url, 'redir/') === 0) {
                                $sparkle = ' class="sparkle" ';
                        } else {
@@ -536,7 +544,7 @@ class Contact extends BaseModule
 
                        $poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
 
-                       $nettype = DI::l10n()->t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']));
+                       $nettype = DI::l10n()->t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol'], $contact['gsid']));
 
                        // tabs
                        $tab_str = self::getTabsHTML($contact, self::TAB_PROFILE);
@@ -642,11 +650,11 @@ class Contact extends BaseModule
                                '$profileurllabel'=> DI::l10n()->t('Profile URL'),
                                '$profileurl'     => $contact['url'],
                                '$account_type'   => Model\Contact::getAccountType($contact),
-                               '$location'       => BBCode::convert($contact['location']),
+                               '$location'       => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['location']),
                                '$location_label' => DI::l10n()->t('Location:'),
-                               '$xmpp'           => BBCode::convert($contact['xmpp']),
+                               '$xmpp'           => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['xmpp']),
                                '$xmpp_label'     => DI::l10n()->t('XMPP:'),
-                               '$about'          => BBCode::convert($contact['about'], false),
+                               '$about'          => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'], BBCode::EXTERNAL),
                                '$about_label'    => DI::l10n()->t('About:'),
                                '$keywords'       => $contact['keywords'],
                                '$keywords_label' => DI::l10n()->t('Tags:'),
@@ -1076,7 +1084,7 @@ class Contact extends BaseModule
                        }
                }
 
-               $url = Model\Contact::magicLink($contact['url']);
+               $url = Model\Contact::magicLinkByContact($contact);
 
                if (strpos($url, 'redir/') === 0) {
                        $sparkle = ' class="sparkle" ';
@@ -1103,7 +1111,7 @@ class Contact extends BaseModule
                        'url'          => $url,
                        'img_hover'    => DI::l10n()->t('Visit %s\'s profile [%s]', $contact['name'], $contact['url']),
                        'photo_menu'   => Model\Contact::photoMenu($contact),
-                       'thumb'        => Model\Contact::getThumb($contact),
+                       'thumb'        => Model\Contact::getThumb($contact, true),
                        'alt_text'     => $alt_text,
                        'name'         => $contact['name'],
                        'nick'         => $contact['nick'],
@@ -1113,7 +1121,7 @@ class Contact extends BaseModule
                        'account_type' => Model\Contact::getAccountType($contact),
                        'sparkle'      => $sparkle,
                        'itemurl'      => ($contact['addr'] ?? '') ?: $contact['url'],
-                       'network'      => ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']),
+                       'network'      => ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol'], $contact['gsid']),
                ];
        }