]> git.mxchange.org Git - friendica.git/commitdiff
Simplified functionality to load the profile in the sidebar
authorMichael <heluecht@pirati.ca>
Fri, 23 Jul 2021 12:39:37 +0000 (12:39 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 23 Jul 2021 12:39:37 +0000 (12:39 +0000)
15 files changed:
include/conversation.php
mod/display.php
mod/follow.php
mod/unfollow.php
src/Content/Widget/VCard.php [new file with mode: 0644]
src/Model/Item.php
src/Model/Profile.php
src/Module/Contact.php
src/Module/Contact/Advanced.php
src/Module/Contact/Contacts.php
src/Module/Contact/Poke.php
src/Protocol/Feed.php
src/Worker/UpdateContacts.php
view/templates/widget/vcard.tpl
view/theme/frio/templates/widget/vcard.tpl

index cd9e098990f10e5ae29d5ea53fbafacaacf1d5f3..c46aeff992621b22393948864af4c05f51d061a2 100644 (file)
@@ -272,7 +272,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
 
        $ssl_state = (local_user() ? true : false);
 
-       $profile_owner = 0;
        $live_update_div = '';
 
        $blocklist = conv_get_blocklist();
@@ -281,7 +280,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
 
        if ($mode === 'network') {
                $items = conversation_add_children($items, false, $order, $uid);
-               $profile_owner = local_user();
                if (!$update) {
                        /*
                         * The special div is needed for liveUpdate to kick in for this page.
@@ -308,7 +306,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                }
        } elseif ($mode === 'profile') {
                $items = conversation_add_children($items, false, $order, $uid);
-               $profile_owner = $a->profile['uid'];
 
                if (!$update) {
                        $tab = 'posts';
@@ -322,13 +319,12 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                 */
 
                                $live_update_div = '<div id="live-profile"></div>' . "\r\n"
-                                       . "<script> var profile_uid = " . $a->profile['uid']
+                                       . "<script> var profile_uid = " . $uid
                                        . "; var netargs = '?f='; </script>\r\n";
                        }
                }
        } elseif ($mode === 'notes') {
                $items = conversation_add_children($items, false, $order, local_user());
-               $profile_owner = local_user();
 
                if (!$update) {
                        $live_update_div = '<div id="live-notes"></div>' . "\r\n"
@@ -337,7 +333,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                }
        } elseif ($mode === 'display') {
                $items = conversation_add_children($items, false, $order, $uid);
-               $profile_owner = $a->profile['uid'];
 
                if (!$update) {
                        $live_update_div = '<div id="live-display"></div>' . "\r\n"
@@ -346,7 +341,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                }
        } elseif ($mode === 'community') {
                $items = conversation_add_children($items, true, $order, $uid);
-               $profile_owner = 0;
 
                if (!$update) {
                        $live_update_div = '<div id="live-community"></div>' . "\r\n"
@@ -357,7 +351,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                }
        } elseif ($mode === 'contacts') {
                $items = conversation_add_children($items, false, $order, $uid);
-               $profile_owner = 0;
 
                if (!$update) {
                        $live_update_div = '<div id="live-contact"></div>' . "\r\n"
@@ -368,7 +361,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                $live_update_div = '<div id="live-search"></div>' . "\r\n";
        }
 
-       $page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
+       $page_dropping = ((local_user() && local_user() == $uid) ? true : false);
 
        if (!$update) {
                $_SESSION['return_path'] = DI::args()->getQueryString();
index 7a8bca45731107d88fc11a8eec391a859063de3f..5bcf30faa03dbbc4b11fc86c120fb753f1b07e85 100644 (file)
@@ -21,7 +21,7 @@
 
 use Friendica\App;
 use Friendica\Content\Text\BBCode;
-use Friendica\Content\Text\HTML;
+use Friendica\Content\Widget;
 use Friendica\Core\ACL;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
@@ -32,8 +32,7 @@ use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
-use Friendica\Model\Profile;
-use Friendica\Module\Objects;
+use Friendica\Module\ActivityPub\Objects;
 use Friendica\Network\HTTPException;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Protocol\DFRN;
@@ -126,7 +125,7 @@ function display_init(App $a)
                }
        }
 
-       Profile::load($a, $nick, $profiledata);
+       DI::page()['aside'] = Widget\VCard::getHTML($profiledata);
 }
 
 function display_fetchauthor($a, $item)
@@ -257,6 +256,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
 
        $is_remote_contact = false;
        $item_uid = local_user();
+       $page_uid = 0;
 
        $parent = null;
        if (!empty($parent_uri_id)) {
@@ -264,21 +264,21 @@ function display_content(App $a, $update = false, $update_uid = 0)
        }
 
        if (DBA::isResult($parent)) {
-               $a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid'];
-               $is_remote_contact = Session::getRemoteContactID($a->profile['uid']);
+               $page_uid = ($page_uid ?? 0) ?: $parent['uid'];
+               $is_remote_contact = Session::getRemoteContactID($page_uid);
                if ($is_remote_contact) {
                        $item_uid = $parent['uid'];
                }
        } else {
-               $a->profile = ['uid' => intval($item['uid'])];
+               $page_uid = $item['uid'];
        }
 
-       $page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]);
+       $page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $page_uid]);
        if (DBA::isResult($page_contact)) {
                $a->page_contact = $page_contact;
        }
 
-       $is_owner = (local_user() && (in_array($a->profile['uid'], [local_user(), 0])) ? true : false);
+       $is_owner = (local_user() && (in_array($page_uid, [local_user(), 0])) ? true : false);
 
        if (!empty($a->profile['hidewall']) && !$is_owner && !$is_remote_contact) {
                throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
@@ -299,9 +299,9 @@ function display_content(App $a, $update = false, $update_uid = 0)
                ];
                $o .= status_editor($a, $x, 0, true);
        }
-       $sql_extra = Item::getPermissionsSQLByUserId($a->profile['uid']);
+       $sql_extra = Item::getPermissionsSQLByUserId($page_uid);
 
-       if (local_user() && (local_user() == $a->profile['uid'])) {
+       if (local_user() && (local_user() == $page_uid)) {
                $condition = ['parent-uri-id' => $parent_uri_id, 'uid' => local_user(), 'unseen' => true];
                $unseen = Post::exists($condition);
        } else {
@@ -314,7 +314,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
 
        $condition = ["`uri-id` = ? AND `uid` IN (0, ?) " . $sql_extra, $uri_id, $item_uid];
        $fields = ['parent-uri-id', 'body', 'title', 'author-name', 'author-avatar', 'plink', 'author-id', 'owner-id', 'contact-id'];
-       $item = Post::selectFirstForUser($a->profile['uid'], $fields, $condition);
+       $item = Post::selectFirstForUser($page_uid, $fields, $condition);
 
        if (!DBA::isResult($item)) {
                throw new HTTPException\NotFoundException(DI::l10n()->t('The requested item doesn\'t exist or has been deleted.'));
index ac74d217bc4d816f09a952d0180d417d93bf7afa..86f72671269184f062ba79af6716c38440381770 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 use Friendica\App;
+use Friendica\Content\Widget;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\DI;
@@ -75,7 +76,7 @@ function follow_content(App $a)
 
        // Don't try to add a pending contact
        $user_contact = DBA::selectFirst('contact', ['pending'], ["`uid` = ? AND ((`rel` != ?) OR (`network` = ?)) AND
-               (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", 
+               (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
                $uid, Contact::FOLLOWER, Protocol::DFRN, Strings::normaliseLink($url),
                Strings::normaliseLink($url), $url, Protocol::STATUSNET]);
 
@@ -157,7 +158,7 @@ function follow_content(App $a)
        DI::page()['aside'] = '';
 
        if ($protocol != Protocol::PHANTOM) {
-               Profile::load($a, '', $contact, false);
+               DI::page()['aside'] = Widget\VCard::getHTML(Contact::getByURL($contact['url'], false));
 
                $o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'),
                        ['$title' => DI::l10n()->t('Status Messages and Posts')]
index 97cb0e1a327ab998d160f8c3f5c60d5c55ffe338..f07522cab5520151324ee68eef5536ab8e4e3091 100644 (file)
  */
 
 use Friendica\App;
+use Friendica\Content\Widget;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
-use Friendica\Model\Profile;
 use Friendica\Model\User;
 use Friendica\Util\Strings;
 
@@ -105,7 +105,7 @@ function unfollow_content(App $a)
        ]);
 
        DI::page()['aside'] = '';
-       Profile::load($a, '', Contact::getByURL($contact['url'], false));
+       DI::page()['aside'] = Widget\VCard::getHTML(Contact::getByURL($contact['url'], false));
 
        $o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), ['$title' => DI::l10n()->t('Status Messages and Posts')]);
 
diff --git a/src/Content/Widget/VCard.php b/src/Content/Widget/VCard.php
new file mode 100644 (file)
index 0000000..a7d7d8c
--- /dev/null
@@ -0,0 +1,99 @@
+<?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Content\Widget;
+
+use Friendica\Content\Text\BBCode;
+use Friendica\Core\Protocol;
+use Friendica\Core\Renderer;
+use Friendica\DI;
+use Friendica\Model\Contact;
+use Friendica\Util\Strings;
+
+/**
+ * VCard widget
+ *
+ * @author Michael Vogel
+ */
+class VCard
+{
+       /**
+        * Get HTML for vcard block
+        *
+        * @template widget/vcard.tpl
+        * @return string
+        */
+       public static function getHTML(array $contact)
+       {
+               if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) {
+                       $network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
+               } else {
+                       $network_link = '';
+               }
+
+               $follow_link = '';
+               $unfollow_link = '';
+               $wallmessage_link = '';
+
+               if (local_user()) {
+                       if ($contact['uid']) {
+                               $id      = $contact['id'];
+                               $rel     = $contact['rel'];
+                               $pending = $contact['pending'];
+                       } else {
+                               $pcontact = Contact::selectFirst(['id', 'rel', 'pending'], ['uid' => local_user(), 'uri-id' => $contact['uri-id']]);
+                               $id      = $pcontact['id'] ?? 0;
+                               $rel     = $pcontact['rel'] ?? Contact::NOTHING;
+                               $pending = $pcontact['pending'] ?? false;
+                       }
+
+                       if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
+                               if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) {
+                                       $unfollow_link = 'unfollow?url=' . urlencode($contact['url']) . '&auto=1';
+                               } elseif(!$pending) {
+                                       $follow_link = 'follow?url=' . urlencode($contact['url']) . '&auto=1';
+                               }
+                       }
+
+                       if (in_array($rel, [Contact::FOLLOWER, Contact::FRIEND]) && Contact::canReceivePrivateMessages($contact)) {
+                               $wallmessage_link = 'message/new/' . $id;
+                       }
+               }
+
+               return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [
+                       '$contact'          => $contact,
+                       '$photo'            => Contact::getPhoto($contact),
+                       '$url'              => Contact::magicLinkByContact($contact, $contact['url']),
+                       '$about'            => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'] ?? ''),
+                       '$xmpp'             => DI::l10n()->t('XMPP:'),
+                       '$location'         => DI::l10n()->t('Location:'),
+                       '$network_link'     => $network_link,
+                       '$network'          => DI::l10n()->t('Network:'),
+                       '$account_type'     => Contact::getAccountType($contact),
+                       '$follow'           => DI::l10n()->t('Follow'),
+                       '$follow_link'      => $follow_link,
+                       '$unfollow'         => DI::l10n()->t('Unfollow'),
+                       '$unfollow_link'    => $unfollow_link,
+                       '$wallmessage'      => DI::l10n()->t('Message'),
+                       '$wallmessage_link' => $wallmessage_link,
+               ]);
+       }
+}
index 5a0c1066cbe18cdb5164afbbfd89451d9613e4ab..cbac14a11b7c15e3312ff212ce1d74ca688fa65b 100644 (file)
@@ -468,18 +468,14 @@ class Item
                // Checking if there is already an item with the same guid
                $condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']];
                if (Post::exists($condition)) {
-                       Logger::notice('Found already existing item', [
-                               'guid' => $item['guid'],
-                               'uid' => $item['uid'],
-                               'network' => $item['network']
-                       ]);
+                       Logger::notice('Found already existing item', $condition);
                        return true;
                }
 
                $condition = ['uri-id' => $item['uri-id'], 'uid' => $item['uid'],
                        'network' => [$item['network'], Protocol::DFRN]];
                if (Post::exists($condition)) {
-                       Logger::notice('duplicated item with the same uri found.', $item);
+                       Logger::notice('duplicated item with the same uri found.', $condition);
                        return true;
                }
 
@@ -487,7 +483,7 @@ class Item
                if (in_array($item['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
                        $condition = ['guid' => $item['guid'], 'uid' => $item['uid']];
                        if (Post::exists($condition)) {
-                               Logger::notice('duplicated item with the same guid found.', $item);
+                               Logger::notice('duplicated item with the same guid found.', $condition);
                                return true;
                        }
                } elseif ($item['network'] == Protocol::OSTATUS) {
index b3345eb63fb547ba0c46df7596f339c7801d1c81..4ff34d4684969bc7949125c670bfbc25ebc01b20 100644 (file)
@@ -211,40 +211,14 @@ class Profile
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function load(App $a, $nickname, array $profiledata = [], $show_connect = true)
+       public static function load(App $a, $nickname)
        {
-               $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]);
-
-               if (!DBA::isResult($user) && empty($profiledata)) {
-                       Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
-                       return;
-               }
-
-               if (count($profiledata) > 0) {
-                       // Ensure to have a "nickname" field
-                       if (empty($profiledata['nickname']) && !empty($profiledata['nick'])) {
-                               $profiledata['nickname'] = $profiledata['nick'];
-                       }
-
-                       // Add profile data to sidebar
-                       DI::page()['aside'] .= self::sidebar($a, $profiledata, true, $show_connect);
-
-                       if (!DBA::isResult($user)) {
-                               return;
-                       }
-               }
-
-               $profile = !empty($user['uid']) ? User::getOwnerDataById($user['uid'], false) : [];
-
-               if (empty($profile) && empty($profiledata)) {
+               $profile = User::getOwnerDataByNick($nickname);
+               if (empty($profile)) {
                        Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
                        return;
                }
 
-               if (empty($profile)) {
-                       $profile = ['uid' => 0, 'name' => $nickname];
-               }
-
                $a->profile = $profile;
                $a->profile_uid = $profile['uid'];
 
@@ -253,7 +227,7 @@ class Profile
 
                DI::page()['title'] = $a->profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
 
-               if (!$profiledata && !DI::pConfig()->get(local_user(), 'system', 'always_my_theme')) {
+               if (!DI::pConfig()->get(local_user(), 'system', 'always_my_theme')) {
                        $a->setCurrentTheme($a->profile['theme']);
                        $a->setCurrentMobileTheme($a->profile['mobile-theme']);
                }
@@ -269,16 +243,14 @@ class Profile
                        require_once $theme_info_file;
                }
 
-               $block = ((DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) ? true : false);
+               $block = (DI::config()->get('system', 'block_public') && !Session::isAuthenticated());
 
                /**
                 * @todo
                 * By now, the contact block isn't shown, when a different profile is given
                 * But: When this profile was on the same server, then we could display the contacts
                 */
-               if (!$profiledata) {
-                       DI::page()['aside'] .= self::sidebar($a, $a->profile, $block, $show_connect);
-               }
+               DI::page()['aside'] .= self::sidebar($a, $a->profile, $block);
 
                return;
        }
@@ -304,7 +276,7 @@ class Profile
         * @hooks 'profile_sidebar'
         *      array $arr
         */
-       private static function sidebar(App $a, array $profile, $block = 0, $show_connect = true)
+       private static function sidebar(App $a, array $profile, $block = 0)
        {
                $o = '';
                $location = false;
@@ -374,7 +346,7 @@ class Profile
                        || in_array($profile_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND]);
                $visitor_base_path = self::getMyURL() ? preg_replace('=/profile/(.*)=ism', '', self::getMyURL()) : '';
 
-               if (!$local_user_is_self && $show_connect) {
+               if (!$local_user_is_self) {
                        if (!$visitor_is_authenticated) {
                                // Remote follow is only available for local profiles
                                if (!empty($profile['nickname']) && strpos($profile_url, DI::baseUrl()->get()) === 0) {
@@ -495,7 +467,7 @@ class Profile
 
                $p['photo'] = Contact::getAvatarUrlForId($cid, ProxyUtils::SIZE_SMALL);
 
-               $p['url'] = Contact::magicLinkById($cid);
+               $p['url'] = Contact::magicLinkById($cid, $profile['url']);
 
                $tpl = Renderer::getMarkupTemplate('profile/vcard.tpl');
                $o .= Renderer::replaceMacros($tpl, [
index 47f244a9191755212ab32d645506d4a7863f305c..89051f27dc8608595fd0890d386cb377d67c2007 100644 (file)
@@ -308,42 +308,7 @@ class Contact extends BaseModule
 
                        $a->data['contact'] = $contact;
 
-                       if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) {
-                               $network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
-                       } else {
-                               $network_link = '';
-                       }
-
-                       $follow_link = '';
-                       $unfollow_link = '';
-                       if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
-                               if ($contact['uid'] && in_array($contact['rel'], [Model\Contact::SHARING, Model\Contact::FRIEND])) {
-                                       $unfollow_link = 'unfollow?url=' . urlencode($contact['url']) . '&auto=1';
-                               } elseif(!$contact['pending']) {
-                                       $follow_link = 'follow?url=' . urlencode($contact['url']) . '&auto=1';
-                               }
-                       }
-
-                       $wallmessage_link = '';
-                       if ($contact['uid'] && Model\Contact::canReceivePrivateMessages($contact)) {
-                               $wallmessage_link = 'message/new/' . $contact['id'];
-                       }
-
-                       $vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [
-                               '$name'         => $contact['name'],
-                               '$photo'        => Model\Contact::getPhoto($contact),
-                               '$url'          => Model\Contact::magicLinkByContact($contact, $contact['url']),
-                               '$addr'         => $contact['addr'] ?? '',
-                               '$network_link' => $network_link,
-                               '$network'      => DI::l10n()->t('Network:'),
-                               '$account_type' => Model\Contact::getAccountType($contact),
-                               '$follow'       => DI::l10n()->t('Follow'),
-                               '$follow_link'   => $follow_link,
-                               '$unfollow'     => DI::l10n()->t('Unfollow'),
-                               '$unfollow_link' => $unfollow_link,
-                               '$wallmessage'  => DI::l10n()->t('Message'),
-                               '$wallmessage_link' => $wallmessage_link,
-                       ]);
+                       $vcard_widget = Widget\VCard::getHTML($contact);
 
                        $findpeople_widget = '';
                        $follow_widget = '';
@@ -578,14 +543,14 @@ class Contact extends BaseModule
                                        Model\Contact::MIRROR_FORWARDED => DI::l10n()->t('Mirror as forwarded posting'),
                                        Model\Contact::MIRROR_OWN_POST => DI::l10n()->t('Mirror as my own posting')];
                        } elseif (in_array($contact['network'], [Protocol::ACTIVITYPUB])) {
-                               $remote_self_options = [Model\Contact::MIRROR_DEACTIVATED => DI::l10n()->t('No mirroring'), 
+                               $remote_self_options = [Model\Contact::MIRROR_DEACTIVATED => DI::l10n()->t('No mirroring'),
                                Model\Contact::MIRROR_NATIVE_RESHARE => DI::l10n()->t('Native reshare')];
                        } elseif (in_array($contact['network'], [Protocol::DFRN])) {
-                               $remote_self_options = [Model\Contact::MIRROR_DEACTIVATED => DI::l10n()->t('No mirroring'), 
+                               $remote_self_options = [Model\Contact::MIRROR_DEACTIVATED => DI::l10n()->t('No mirroring'),
                                Model\Contact::MIRROR_OWN_POST => DI::l10n()->t('Mirror as my own posting'),
                                Model\Contact::MIRROR_NATIVE_RESHARE => DI::l10n()->t('Native reshare')];
                        } else {
-                               $remote_self_options = [Model\Contact::MIRROR_DEACTIVATED => DI::l10n()->t('No mirroring'), 
+                               $remote_self_options = [Model\Contact::MIRROR_DEACTIVATED => DI::l10n()->t('No mirroring'),
                                        Model\Contact::MIRROR_OWN_POST => DI::l10n()->t('Mirror as my own posting')];
                        }
 
@@ -669,7 +634,7 @@ class Contact extends BaseModule
                                        $contact['remote_self'],
                                        DI::l10n()->t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
                                        $remote_self_options
-                               ],      
+                               ],
                        ]);
 
                        $arr = ['contact' => $contact, 'output' => $o];
@@ -1002,11 +967,11 @@ class Contact extends BaseModule
                }
 
                if (DBA::isResult($contact)) {
-                       DI::page()['aside'] = '';
-
                        if (!$update) {
                                $profiledata = Model\Contact::getByURLForUser($contact['url'], local_user());
-                               Model\Profile::load($a, '', $profiledata, true);
+                               DI::page()['aside'] = Widget\VCard::getHTML($profiledata);
+                       } else {
+                               DI::page()['aside'] = '';
                        }
 
                        if ($contact['uid'] == 0) {
@@ -1026,15 +991,13 @@ class Contact extends BaseModule
                $o = self::getTabsHTML($contact, self::TAB_POSTS);
 
                if (DBA::isResult($contact)) {
-                       DI::page()['aside'] = '';
-
                        $profiledata = Model\Contact::getByURLForUser($contact['url'], local_user());
 
                        if (local_user() && in_array($profiledata['network'], Protocol::FEDERATED)) {
                                $profiledata['remoteconnect'] = DI::baseUrl() . '/follow?url=' . urlencode($profiledata['url']);
                        }
 
-                       Model\Profile::load($a, '', $profiledata, true);
+                       DI::page()['aside'] = Widget\VCard::getHTML($profiledata);
 
                        if ($contact['uid'] == 0) {
                                $o .= Model\Contact::getPostsFromId($contact['id']);
@@ -1115,7 +1078,7 @@ class Contact extends BaseModule
                        'alt_text'     => $alt_text,
                        'name'         => $contact['name'],
                        'nick'         => $contact['nick'],
-                       'details'      => $contact['location'], 
+                       'details'      => $contact['location'],
                        'tags'         => $contact['keywords'],
                        'about'        => $contact['about'],
                        'account_type' => Model\Contact::getAccountType($contact),
index d287daed8f64a7dde5fb87437c00e20201e52f34..29de7bd6febc2b0b0875333b3fdf11890253e15f 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module\Contact;
 
 use Friendica\BaseModule;
+use Friendica\Content\Widget;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\Core\Session;
@@ -104,7 +105,7 @@ class Advanced extends BaseModule
                        throw new BadRequestException(DI::l10n()->t('Contact not found.'));
                }
 
-               Model\Profile::load(DI::app(), "", Model\Contact::getByURL($contact["url"], false));
+               DI::page()['aside'] = Widget\VCard::getHTML($contact);
 
                $warning = DI::l10n()->t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
                $info    = DI::l10n()->t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
index e38d7acfce942a9c7f2bfb83c571491a59ac17d5..b75dea43db25d04c597ce63e9bafb6370293cd37 100644 (file)
@@ -38,7 +38,7 @@ class Contacts extends BaseModule
 
                $localContactId = Model\Contact::getPublicIdByUserId(local_user());
 
-               Model\Profile::load($app, '', $contact);
+               DI::page()['aside'] = Widget\VCard::getHTML($contact);
 
                $condition = [
                        'blocked' => false,
index 96c0e3fea5fb66099ce8f85c84214f088d9d2a64..6e8920c5cf36cfd13ea402b4b69568587af798d3 100644 (file)
@@ -3,6 +3,7 @@
 namespace Friendica\Module\Contact;
 
 use Friendica\BaseModule;
+use Friendica\Content\Widget;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
@@ -135,7 +136,7 @@ class Poke extends BaseModule
                        throw new HTTPException\NotFoundException();
                }
 
-               Model\Profile::load(DI::app(), '', Model\Contact::getByURL($contact["url"], false));
+               DI::page()['aside'] = Widget\VCard::getHTML(Model\Contact::getByURL($contact["url"], false));
 
                $verbs = [];
                foreach (DI::l10n()->getPokeVerbs() as $verb => $translations) {
index c155e9e3d250b326074ccac8236a08d1b97fe0cc..a1b77f8bd5e4628e9c05f8f0039f87446b44d77f 100644 (file)
@@ -878,8 +878,8 @@ class Feed
                        Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA];
 
                if ($filter === 'comments') {
-                       $condition[0] .= " AND `object-type` = ? ";
-                       $condition[] = Activity\ObjectType::COMMENT;
+                       $condition[0] .= " AND `gravity` = ? ";
+                       $condition[] = GRAVITY_COMMENT;
                }
 
                if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
index 0c211aa93908ee4b1d8b4ae455e4b80810d06785..b5ac862bda89706833458fe6fa2b6edd43cf0eeb 100644 (file)
@@ -55,9 +55,9 @@ class UpdateContacts
                $ids = self::getContactsToUpdate($condition, [], $limit);
                Logger::info('Fetched federated user contacts', ['count' => count($ids)]);
 
-               $conditions = ["`id` IN (SELECT `author-id` FROM `post-user` WHERE `author-id` = `contact`.`id`)",
-                       "`id` IN (SELECT `owner-id` FROM `post-user` WHERE `owner-id` = `contact`.`id`)",
-                       "`id` IN (SELECT `causer-id` FROM `post-user` WHERE `causer-id` = `contact`.`id`)",
+               $conditions = ["`id` IN (SELECT `author-id` FROM `post` WHERE `author-id` = `contact`.`id`)",
+                       "`id` IN (SELECT `owner-id` FROM `post` WHERE `owner-id` = `contact`.`id`)",
+                       "`id` IN (SELECT `causer-id` FROM `post` WHERE `causer-id` = `contact`.`id`)",
                        "`id` IN (SELECT `cid` FROM `post-tag` WHERE `cid` = `contact`.`id`)",
                        "`id` IN (SELECT `cid` FROM `user-contact` WHERE `cid` = `contact`.`id`)"];
 
index 2cd8d9bb7bb2d5b06c8fadd0c239917821508e8e..4eedb9b7ac3bfe062b168265ded535d10212c68a 100644 (file)
@@ -1,14 +1,27 @@
-
 <div class="vcard h-card">
-       <div class="fn p-name" dir="auto">{{$name}}</div>
-       {{if $addr}}<div class="p-addr">{{$addr}}</div>{{/if}}
-       {{if $about}}<div class="title p-about" dir="auto">{{$about nofilter}}</div>{{/if}}
+       <div class="fn p-name" dir="auto">{{$contact.name}}</div>
+       {{if $contact.addr}}<div class="p-addr">{{$contact.addr}}</div>{{/if}}
        {{if $url}}
        <div id="profile-photo-wrapper"><a href="{{$url}}"><img class="vcard-photo photo u-photo" style="width: 175px; height: 175px;" src="{{$photo}}" alt="{{$name}}" /></a></div>
        {{else}}
        <div id="profile-photo-wrapper"><img class="vcard-photo photo u-photo" style="width: 175px; height: 175px;" src="{{$photo}}" alt="{{$name}}" /></div>
        {{/if}}
        {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
+       {{if $about}}<div class="title p-about" dir="auto">{{$about nofilter}}</div>{{/if}}
+       {{if $contact.xmpp}}
+               <dl class="xmpp">
+               <dt class="xmpp-label">{{$xmpp}}</dt>
+               <dd class="xmpp-data">{{$contact.xmpp}}</dd>
+               </dl>
+       {{/if}}
+       {{if $contact.location}}
+               <dl class="location" dir="auto">
+                       <dt class="location-label">{{$location}}</dt>
+                       <dd class="adr h-adr">
+                               <p class="p-location">{{$contact.location}}</p>
+                       </dd>
+               </dl>
+       {{/if}}
        {{if $network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$network_link nofilter}}</dd></dl>{{/if}}
 
        <div id="profile-extra-links">
index 9c89ace8c2769e9a80801e73af55e761764052ef..69fb4d4afdff16549e34c788bd35f4a599432cf3 100644 (file)
@@ -2,9 +2,9 @@
 
        <div id="profile-photo-wrapper">
                {{if $url}}
-               <a href="{{$url}}"><img class="photo u-photo" src="{{$photo}}" alt="{{$name}}" /></a>
+               <a href="{{$url}}"><img class="photo u-photo" src="{{$photo}}" alt="{{$contact.name}}" /></a>
                {{else}}
-               <img class="photo u-photo" src="{{$photo}}" alt="{{$name}}" />
+               <img class="photo u-photo" src="{{$photo}}" alt="{{$contact.name}}" />
                {{/if}}
        </div>
 
        <div id="vcard-short-info-wrapper" style="display: none;">
                <div id="vcard-short-info" class="media" style="display: none">
                        <div id="vcard-short-photo-wrapper" class="pull-left">
-                               <img class="media-object" src="{{$photo}}" alt="{{$name}}" />
+                               <img class="media-object" src="{{$photo}}" alt="{{$contact.name}}" />
                        </div>
 
                        <div id="vcard-short-desc" class="media-body">
-                               <h4 class="media-heading" dir="auto">{{$name}}</h4>
-                               {{if $addr}}<div class="vcard-short-addr">{{$addr}}</div>{{/if}}
+                               <h4 class="media-heading" dir="auto">{{$contact.name}}</h4>
+                               {{if $contact.addr}}<div class="vcard-short-addr">{{$contact.addr}}</div>{{/if}}
                        </div>
                </div>
        </div>
 
        <div class="panel-body">
                <div class="profile-header">
-                       <h3 class="fn p-name" dir="auto">{{$name}}</h3>
+                       <h3 class="fn p-name" dir="auto">{{$contact.name}}</h3>
 
-                       {{if $addr}}<div class="p-addr">{{$addr}}</div>{{/if}}
+                       {{if $contact.addr}}<div class="p-addr">{{$contact.addr}}</div>{{/if}}
 
                        {{if $account_type}}<div class="account-type">({{$account_type}})</div>{{/if}}
 
                        {{if $about}}<div class="title" dir="auto">{{$about nofilter}}</div>{{/if}}
-
-                       {{if $network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$network_link nofilter}}</dd></dl>{{/if}}
                </div>
 
                <div id="profile-extra-links">
                                </div>
                        {{/if}}
                </div>
+
+               <div class="clear"></div>
+
+               {{if $contact.location}}
+               <div class="location detail">
+                       <span class="location-label icon"><i class="fa fa-map-marker"></i></span>
+                       <span class="adr">
+                               <p class="p-location">{{$contact.location}}</p>
+                       </span>
+               </div>
+               {{/if}}
+
+               {{if $contact.xmpp}}
+               <div class="xmpp">
+                       <span class="xmpp-label icon"><i class="fa fa-comments"></i></span>
+                       <span class="xmpp-data"><a href="xmpp:{{$contact.xmpp}}" rel="me" target="_blank" rel="noopener noreferrer">{{include file="sub/punct_wrap.tpl" text=$contact.xmpp}}</a></span>
+               </div>
+               {{/if}}
+
+               {{if $network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$network_link nofilter}}</dd></dl>{{/if}}
        </div>
 </div>