X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FContact.php;h=cc4f4d9abedda01c6bca64dfee34eb96dff3c7fc;hb=5998c3995e745d0c2a3b60fab66c5ba9e2b9c27f;hp=5a4d0b1e86281b6ab9e4eb3bb9400e3fbd260219;hpb=3f77bf52f9969bd5821cfc12ecde4ea2954e44ef;p=friendica.git diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 5a4d0b1e86..cc4f4d9abe 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -32,16 +32,15 @@ use Friendica\Core\ACL; use Friendica\Core\Hook; use Friendica\Core\Protocol; use Friendica\Core\Renderer; +use Friendica\Core\Theme; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model; -use Friendica\Model\Contact as ModelContact; use Friendica\Module\Security\Login; use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\NotFoundException; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; /** @@ -49,6 +48,12 @@ use Friendica\Util\Strings; */ class Contact extends BaseModule { + const TAB_CONVERSATIONS = 1; + const TAB_POSTS = 2; + const TAB_PROFILE = 3; + const TAB_CONTACTS = 4; + const TAB_ADVANCED = 5; + private static function batchActions() { if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) { @@ -181,16 +186,13 @@ class Contact extends BaseModule private static function updateContactFromProbe($contact_id) { - $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]); + $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]); if (!DBA::isResult($contact)) { return; } // Update the entry in the contact table - Model\Contact::updateFromProbe($contact_id, '', true); - - // Update the entry in the gcontact table - Model\GContact::updateFromProbe($contact['url']); + Model\Contact::updateFromProbe($contact_id); } /** @@ -201,8 +203,8 @@ class Contact extends BaseModule */ private static function blockContact($contact_id) { - $blocked = !Model\Contact::isBlockedByUser($contact_id, local_user()); - Model\Contact::setBlockedForUser($contact_id, local_user(), $blocked); + $blocked = !Model\Contact\User::isBlocked($contact_id, local_user()); + Model\Contact\User::setBlocked($contact_id, local_user(), $blocked); } /** @@ -213,8 +215,8 @@ class Contact extends BaseModule */ private static function ignoreContact($contact_id) { - $ignored = !Model\Contact::isIgnoredByUser($contact_id, local_user()); - Model\Contact::setIgnoredForUser($contact_id, local_user(), $ignored); + $ignored = !Model\Contact\User::isIgnored($contact_id, local_user()); + Model\Contact\User::setIgnored($contact_id, local_user(), $ignored); } /** @@ -258,29 +260,32 @@ class Contact extends BaseModule $rel = Strings::escapeTags(trim($_GET['rel'] ?? '')); $group = Strings::escapeTags(trim($_GET['group'] ?? '')); - if (empty(DI::page()['aside'])) { - DI::page()['aside'] = ''; - } + $page = DI::page(); + + $page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js')); + $page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); - $contact_id = null; $contact = null; // @TODO: Replace with parameter from router if ($a->argc == 2 && intval($a->argv[1]) || $a->argc == 3 && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations']) ) { $contact_id = intval($a->argv[1]); - $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]); - if (!DBA::isResult($contact)) { - $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0, 'deleted' => false]); + // Ensure to use the user contact when the public contact was provided + $data = Model\Contact::getPublicAndUserContacID($contact_id, local_user()); + if (!empty($data['user']) && ($contact_id == $data['public'])) { + $contact_id = $data['user']; } + $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]); + // Don't display contacts that are about to be deleted if ($contact['network'] == Protocol::PHANTOM) { $contact = false; } - - $contact = ModelContact::checkAvatarCacheByArray($contact); } if (DBA::isResult($contact)) { @@ -318,7 +323,7 @@ class Contact extends BaseModule $vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [ '$name' => $contact['name'], - '$photo' => $contact['photo'], + '$photo' => Model\Contact::getPhoto($contact), '$url' => Model\Contact::magicLinkByContact($contact, $contact['url']), '$addr' => $contact['addr'] ?? '', '$network_link' => $network_link, @@ -391,16 +396,16 @@ class Contact extends BaseModule // NOTREACHED } - if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) { + if ($cmd === 'updateprofile') { self::updateContactFromProbe($contact_id); - DI::baseUrl()->redirect('contact/' . $contact_id . '/advanced/'); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } if ($cmd === 'block') { self::blockContact($contact_id); - $blocked = Model\Contact::isBlockedByUser($contact_id, local_user()); + $blocked = Model\Contact\User::isBlocked($contact_id, local_user()); info(($blocked ? DI::l10n()->t('Contact has been blocked') : DI::l10n()->t('Contact has been unblocked'))); DI::baseUrl()->redirect('contact/' . $contact_id); @@ -410,7 +415,7 @@ class Contact extends BaseModule if ($cmd === 'ignore') { self::ignoreContact($contact_id); - $ignored = Model\Contact::isIgnoredByUser($contact_id, local_user()); + $ignored = Model\Contact\User::isIgnored($contact_id, local_user()); info(($ignored ? DI::l10n()->t('Contact has been ignored') : DI::l10n()->t('Contact has been unignored'))); DI::baseUrl()->redirect('contact/' . $contact_id); @@ -431,17 +436,6 @@ class Contact extends BaseModule if ($cmd === 'drop' && ($orig_record['uid'] != 0)) { // Check if we should do HTML-based delete confirmation if (!empty($_REQUEST['confirm'])) { - //