X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FContact.php;h=bf22470ed4babce42aaa88cc81e171da1335db95;hb=0c73531da1d93f218a47c798ae5db1d00144a7be;hp=f7c6680ed4592ccccb2356e378e0aa695175471b;hpb=e944d7bed6b971494bff82396960d280e6a82cca;p=friendica.git diff --git a/src/Module/Contact.php b/src/Module/Contact.php index f7c6680ed4..bf22470ed4 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Module; @@ -11,10 +30,8 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Widget; use Friendica\Core\ACL; use Friendica\Core\Hook; -use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\Renderer; -use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -23,13 +40,10 @@ 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; /** * Manages and show Contacts and their content - * - * @brief manages contacts */ class Contact extends BaseModule { @@ -70,7 +84,7 @@ class Contact extends BaseModule } } if ($count_actions > 0) { - info(L10n::tt('%d contact edited.', '%d contacts edited.', $count_actions)); + info(DI::l10n()->tt('%d contact edited.', '%d contacts edited.', $count_actions)); } DI::baseUrl()->redirect('contact'); @@ -97,28 +111,20 @@ class Contact extends BaseModule } if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false])) { - notice(L10n::t('Could not access contact record.') . EOL); + notice(DI::l10n()->t('Could not access contact record.')); DI::baseUrl()->redirect('contact'); return; // NOTREACHED } Hook::callAll('contact_edit_post', $_POST); - $profile_id = intval($_POST['profile-assign'] ?? 0); - if ($profile_id) { - if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) { - notice(L10n::t('Could not locate selected profile.') . EOL); - return; - } - } - $hidden = !empty($_POST['hidden']); $notify = !empty($_POST['notify']); $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) { @@ -128,20 +134,17 @@ class Contact extends BaseModule $info = Strings::escapeHtml(trim($_POST['info'] ?? '')); $r = DBA::update('contact', [ - 'profile-id' => $profile_id, 'priority' => $priority, 'info' => $info, '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(L10n::t('Contact updated.') . EOL); - } else { - notice(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]); @@ -161,10 +164,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]); @@ -184,9 +186,6 @@ class Contact extends BaseModule // 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']); } /** @@ -249,11 +248,13 @@ class Contact extends BaseModule $a = DI::app(); - $nets = $_GET['nets'] ?? ''; - $rel = $_GET['rel'] ?? ''; + $search = Strings::escapeTags(trim($_GET['search'] ?? '')); + $nets = Strings::escapeTags(trim($_GET['nets'] ?? '')); + $rel = Strings::escapeTags(trim($_GET['rel'] ?? '')); + $group = Strings::escapeTags(trim($_GET['group'] ?? '')); - if (empty($a->page['aside'])) { - $a->page['aside'] = ''; + if (empty(DI::page()['aside'])) { + DI::page()['aside'] = ''; } $contact_id = null; @@ -281,7 +282,7 @@ class Contact extends BaseModule if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) { DI::baseUrl()->redirect('profile/' . $contact['nick']); } else { - DI::baseUrl()->redirect('profile/' . $contact['nick'] . '?tab=profile'); + DI::baseUrl()->redirect('profile/' . $contact['nick'] . '/profile'); } } @@ -310,17 +311,17 @@ 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, - '$network' => L10n::t('Network:'), + '$network' => DI::l10n()->t('Network:'), '$account_type' => Model\Contact::getAccountType($contact), - '$follow' => L10n::t('Follow'), + '$follow' => DI::l10n()->t('Follow'), '$follow_link' => $follow_link, - '$unfollow' => L10n::t('Unfollow'), + '$unfollow' => DI::l10n()->t('Unfollow'), '$unfollow_link' => $unfollow_link, - '$wallmessage' => L10n::t('Message'), + '$wallmessage' => DI::l10n()->t('Message'), '$wallmessage_link' => $wallmessage_link, ]); @@ -328,6 +329,12 @@ class Contact extends BaseModule $follow_widget = ''; $networks_widget = ''; $rel_widget = ''; + + if ($contact['uid'] != 0) { + $groups_widget = Model\Group::sidebarWidget('contact', 'group', 'full', 'everyone', $contact_id); + } else { + $groups_widget = ''; + } } else { $vcard_widget = ''; $findpeople_widget = Widget::findPeople(); @@ -339,27 +346,21 @@ class Contact extends BaseModule $networks_widget = Widget::networks($_SERVER['REQUEST_URI'], $nets); $rel_widget = Widget::contactRels($_SERVER['REQUEST_URI'], $rel); + $groups_widget = Widget::groups($_SERVER['REQUEST_URI'], $group); } - if ($contact['uid'] != 0) { - $groups_widget = Model\Group::sidebarWidget('contact', 'group', 'full', 'everyone', $contact_id); - } else { - $groups_widget = null; - } - - $a->page['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $groups_widget . $networks_widget . $rel_widget; + DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $groups_widget . $networks_widget . $rel_widget; $tpl = Renderer::getMarkupTemplate('contacts-head.tpl'); - $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ + DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [ '$baseurl' => DI::baseUrl()->get(true), ]); - $sort_type = 0; $o = ''; Nav::setSelected('contact'); if (!local_user()) { - notice(L10n::t('Permission denied.') . EOL); + notice(DI::l10n()->t('Permission denied.')); return Login::form(); } @@ -374,7 +375,7 @@ class Contact extends BaseModule $orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]); if (!DBA::isResult($orig_record)) { - throw new NotFoundException(L10n::t('Contact not found')); + throw new NotFoundException(DI::l10n()->t('Contact not found')); } if ($cmd === 'update' && ($orig_record['uid'] != 0)) { @@ -385,7 +386,7 @@ class Contact extends BaseModule if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) { self::updateContactFromProbe($contact_id); - DI::baseUrl()->redirect('crepair/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id . '/advanced/'); // NOTREACHED } @@ -393,7 +394,7 @@ class Contact extends BaseModule self::blockContact($contact_id); $blocked = Model\Contact::isBlockedByUser($contact_id, local_user()); - info(($blocked ? L10n::t('Contact has been blocked') : L10n::t('Contact has been unblocked')) . EOL); + info(($blocked ? DI::l10n()->t('Contact has been blocked') : DI::l10n()->t('Contact has been unblocked'))); DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED @@ -403,7 +404,7 @@ class Contact extends BaseModule self::ignoreContact($contact_id); $ignored = Model\Contact::isIgnoredByUser($contact_id, local_user()); - info(($ignored ? L10n::t('Contact has been ignored') : L10n::t('Contact has been unignored')) . EOL); + info(($ignored ? DI::l10n()->t('Contact has been ignored') : DI::l10n()->t('Contact has been unignored'))); DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED @@ -413,7 +414,7 @@ class Contact extends BaseModule $r = self::archiveContact($contact_id, $orig_record); if ($r) { $archived = (($orig_record['archive']) ? 0 : 1); - info((($archived) ? L10n::t('Contact has been archived') : 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); @@ -425,7 +426,7 @@ class Contact extends BaseModule if (!empty($_REQUEST['confirm'])) { //