X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FContact.php;h=cc4f4d9abedda01c6bca64dfee34eb96dff3c7fc;hb=5998c3995e745d0c2a3b60fab66c5ba9e2b9c27f;hp=be6f16a5303725d4f87e5fb2ba0d41407a94cfb6;hpb=e80d68ba53776bed047d897f52db7e25b35a479d;p=friendica.git diff --git a/src/Module/Contact.php b/src/Module/Contact.php index be6f16a530..cc4f4d9abe 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -32,6 +32,7 @@ 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; @@ -40,7 +41,6 @@ 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; /** @@ -48,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'])) { @@ -112,7 +118,7 @@ class Contact extends BaseModule } if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false])) { - notice(DI::l10n()->t('Could not access contact record.') . EOL); + notice(DI::l10n()->t('Could not access contact record.')); DI::baseUrl()->redirect('contact'); return; // NOTREACHED } @@ -125,7 +131,7 @@ class Contact extends BaseModule $fetch_further_information = intval($_POST['fetch_further_information'] ?? 0); - $ffi_keyword_blacklist = Strings::escapeHtml(trim($_POST['ffi_keyword_blacklist'] ?? '')); + $ffi_keyword_denylist = Strings::escapeHtml(trim($_POST['ffi_keyword_denylist'] ?? '')); $priority = intval($_POST['poll'] ?? 0); if ($priority > 5 || $priority < 0) { @@ -140,14 +146,12 @@ class Contact extends BaseModule 'hidden' => $hidden, 'notify_new_posts' => $notify, 'fetch_further_information' => $fetch_further_information, - 'ffi_keyword_blacklist' => $ffi_keyword_blacklist], + 'ffi_keyword_denylist' => $ffi_keyword_denylist], ['id' => $contact_id, 'uid' => local_user()] ); - if (DBA::isResult($r)) { - info(DI::l10n()->t('Contact updated.') . EOL); - } else { - notice(DI::l10n()->t('Failed to update contact record.') . EOL); + if (!DBA::isResult($r)) { + notice(DI::l10n()->t('Failed to update contact record.')); } $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]); @@ -167,10 +171,9 @@ class Contact extends BaseModule return; } - $uid = $contact['uid']; - if ($contact['network'] == Protocol::OSTATUS) { - $result = Model\Contact::createFromProbe($uid, $contact['url'], false, $contact['network']); + $user = Model\User::getById($contact['uid']); + $result = Model\Contact::createFromProbe($user, $contact['url'], false, $contact['network']); if ($result['success']) { DBA::update('contact', ['subhub' => 1], ['id' => $contact_id]); @@ -183,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); } /** @@ -203,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); } /** @@ -215,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); } /** @@ -260,23 +260,28 @@ 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; @@ -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, @@ -367,7 +372,7 @@ class Contact extends BaseModule Nav::setSelected('contact'); if (!local_user()) { - notice(DI::l10n()->t('Permission denied.') . EOL); + notice(DI::l10n()->t('Permission denied.')); return Login::form(); } @@ -391,17 +396,17 @@ 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()); - info(($blocked ? DI::l10n()->t('Contact has been blocked') : DI::l10n()->t('Contact has been unblocked')) . EOL); + $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); // NOTREACHED @@ -410,8 +415,8 @@ class Contact extends BaseModule if ($cmd === 'ignore') { self::ignoreContact($contact_id); - $ignored = Model\Contact::isIgnoredByUser($contact_id, local_user()); - info(($ignored ? DI::l10n()->t('Contact has been ignored') : DI::l10n()->t('Contact has been unignored')) . EOL); + $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); // NOTREACHED @@ -421,7 +426,7 @@ class Contact extends BaseModule $r = self::archiveContact($contact_id, $orig_record); if ($r) { $archived = (($orig_record['archive']) ? 0 : 1); - info((($archived) ? DI::l10n()->t('Contact has been archived') : DI::l10n()->t('Contact has been unarchived')) . EOL); + info((($archived) ? DI::l10n()->t('Contact has been archived') : DI::l10n()->t('Contact has been unarchived'))); } 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'])) { - //