X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FContact.php;h=a76c2d89c9f8b58223a59eb3ab2786eee2c28eca;hb=e8bf74914b80884ccaf8d137366dea5d71215640;hp=36ec950519b2422985685466b59e49984d20fe79;hpb=39560218f8d47874ec2cb80be9ff3ba4fe32c777;p=friendica.git diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 36ec950519..a76c2d89c9 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -11,28 +11,25 @@ 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; use Friendica\Model; +use Friendica\Module\Security\Login; use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\NotFoundException; -use Friendica\Network\Probe; 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 { - private static function batchActions(App $a) + private static function batchActions() { if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) { return; @@ -69,15 +66,15 @@ 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)); } - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); } public static function post(array $parameters = []) { - $a = self::getApp(); + $a = DI::app(); if (!local_user()) { return; @@ -85,7 +82,7 @@ class Contact extends BaseModule // @TODO: Replace with parameter from router if ($a->argv[1] === 'batch') { - self::batchActions($a); + self::batchActions(); return; } @@ -96,21 +93,13 @@ 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); - $a->internalRedirect('contact'); + notice(DI::l10n()->t('Could not access contact record.') . EOL); + 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']); @@ -127,7 +116,6 @@ class Contact extends BaseModule $info = Strings::escapeHtml(trim($_POST['info'] ?? '')); $r = DBA::update('contact', [ - 'profile-id' => $profile_id, 'priority' => $priority, 'info' => $info, 'hidden' => $hidden, @@ -138,9 +126,9 @@ class Contact extends BaseModule ); if (DBA::isResult($r)) { - info(L10n::t('Contact updated.') . EOL); + info(DI::l10n()->t('Contact updated.') . EOL); } else { - notice(L10n::t('Failed to update contact record.') . EOL); + notice(DI::l10n()->t('Failed to update contact record.') . EOL); } $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]); @@ -246,13 +234,13 @@ class Contact extends BaseModule return Login::form($_SERVER['REQUEST_URI']); } - $a = self::getApp(); + $a = DI::app(); $nets = $_GET['nets'] ?? ''; $rel = $_GET['rel'] ?? ''; - if (empty($a->page['aside'])) { - $a->page['aside'] = ''; + if (empty(DI::page()['aside'])) { + DI::page()['aside'] = ''; } $contact_id = null; @@ -278,9 +266,9 @@ class Contact extends BaseModule if ($contact['self']) { // @TODO: Replace with parameter from router if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) { - $a->internalRedirect('profile/' . $contact['nick']); + DI::baseUrl()->redirect('profile/' . $contact['nick']); } else { - $a->internalRedirect('profile/' . $contact['nick'] . '?tab=profile'); + DI::baseUrl()->redirect('profile/' . $contact['nick'] . '?tab=profile'); } } @@ -313,13 +301,13 @@ class Contact extends BaseModule '$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, ]); @@ -346,11 +334,11 @@ class Contact extends BaseModule $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, [ - '$baseurl' => $a->getBaseURL(true), + DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [ + '$baseurl' => DI::baseUrl()->get(true), ]); $sort_type = 0; @@ -358,7 +346,7 @@ class Contact extends BaseModule Nav::setSelected('contact'); if (!local_user()) { - notice(L10n::t('Permission denied.') . EOL); + notice(DI::l10n()->t('Permission denied.') . EOL); return Login::form(); } @@ -373,18 +361,18 @@ 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)) { self::updateContactFromPoll($contact_id); - $a->internalRedirect('contact/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) { self::updateContactFromProbe($contact_id); - $a->internalRedirect('crepair/' . $contact_id); + DI::baseUrl()->redirect('crepair/' . $contact_id); // NOTREACHED } @@ -392,9 +380,9 @@ 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')) . EOL); - $a->internalRedirect('contact/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } @@ -402,9 +390,9 @@ 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')) . EOL); - $a->internalRedirect('contact/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } @@ -412,10 +400,10 @@ 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')) . EOL); } - $a->internalRedirect('contact/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } @@ -424,7 +412,7 @@ class Contact extends BaseModule if (!empty($_REQUEST['confirm'])) { //