<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
}
// @TODO: Replace with parameter from router
- if ($a->argv[1] === 'batch') {
+ if (DI::args()->getArgv()[1] === 'batch') {
self::batchActions();
return;
}
// @TODO: Replace with parameter from router
- $contact_id = intval($a->argv[1]);
+ $contact_id = intval(DI::args()->getArgv()[1]);
if (!$contact_id) {
return;
}
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]);
- if (DBA::isResult($contact)) {
- $a->data['contact'] = $contact;
- }
-
return;
}
$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'])
+ if (DI::args()->getArgc() == 2 && intval(DI::args()->getArgv()[1])
+ || DI::args()->getArgc() == 3 && intval(DI::args()->getArgv()[1]) && in_array(DI::args()->getArgv()[2], ['posts', 'conversations'])
) {
- $contact_id = intval($a->argv[1]);
+ $contact_id = intval(DI::args()->getArgv()[1]);
// Ensure to use the user contact when the public contact was provided
- $data = Model\Contact::getPublicAndUserContacID($contact_id, local_user());
+ $data = Model\Contact::getPublicAndUserContactID($contact_id, local_user());
if (!empty($data['user']) && ($contact_id == $data['public'])) {
$contact_id = $data['user'];
}
if (DBA::isResult($contact)) {
if ($contact['self']) {
// @TODO: Replace with parameter from router
- if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) {
+ if ((DI::args()->getArgc() == 3) && intval(DI::args()->getArgv()[1]) && in_array(DI::args()->getArgv()[2], ['posts', 'conversations'])) {
DI::baseUrl()->redirect('profile/' . $contact['nick']);
} else {
DI::baseUrl()->redirect('profile/' . $contact['nick'] . '/profile');
}
}
- $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 = '';
return Login::form();
}
- if ($a->argc == 3) {
- $contact_id = intval($a->argv[1]);
+ if (DI::args()->getArgc() == 3) {
+ $contact_id = intval(DI::args()->getArgv()[1]);
if (!$contact_id) {
throw new BadRequestException();
}
// @TODO: Replace with parameter from router
- $cmd = $a->argv[2];
+ $cmd = DI::args()->getArgv()[2];
$orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]);
if (!DBA::isResult($orig_record)) {
}
if ($cmd === 'block') {
+ if (public_contact() === $contact_id) {
+ throw new BadRequestException(DI::l10n()->t('You can\'t block yourself'));
+ }
+
self::blockContact($contact_id);
$blocked = Model\Contact\User::isBlocked($contact_id, local_user());
}
if ($cmd === 'ignore') {
+ if (public_contact() === $contact_id) {
+ throw new BadRequestException(DI::l10n()->t('You can\'t ignore yourself'));
+ }
+
self::ignoreContact($contact_id);
$ignored = Model\Contact\User::isIgnored($contact_id, local_user());
$_SESSION['return_path'] = DI::args()->getQueryString();
- if (!empty($a->data['contact']) && is_array($a->data['contact'])) {
- $contact = $a->data['contact'];
-
+ if (!empty($contact)) {
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [
'$baseurl' => DI::baseUrl()->get(true),
]);
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')];
}
'$profileurllabel'=> DI::l10n()->t('Profile URL'),
'$profileurl' => $contact['url'],
'$account_type' => Model\Contact::getAccountType($contact),
- '$location' => BBCode::convert($contact['location']),
+ '$location' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['location']),
'$location_label' => DI::l10n()->t('Location:'),
- '$xmpp' => BBCode::convert($contact['xmpp']),
+ '$xmpp' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['xmpp']),
'$xmpp_label' => DI::l10n()->t('XMPP:'),
- '$about' => BBCode::convert($contact['about'], false),
+ '$about' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'], BBCode::EXTERNAL),
'$about_label' => DI::l10n()->t('About:'),
'$keywords' => $contact['keywords'],
'$keywords_label' => DI::l10n()->t('Tags:'),
$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];
$sql_values = [local_user()];
// @TODO: Replace with parameter from router
- $type = $a->argv[1] ?? '';
+ $type = DI::args()->getArgv()[1] ?? '';
switch ($type) {
case 'blocked':
public static function getTabsHTML(array $contact, int $active_tab)
{
$cid = $pcid = $contact['id'];
- $data = Model\Contact::getPublicAndUserContacID($contact['id'], local_user());
+ $data = Model\Contact::getPublicAndUserContactID($contact['id'], local_user());
if (!empty($data['user']) && ($contact['id'] == $data['public'])) {
$cid = $data['user'];
} elseif (!empty($data['public'])) {
}
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) {
$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']);
'url' => $url,
'img_hover' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact['name'], $contact['url']),
'photo_menu' => Model\Contact::photoMenu($contact),
- 'thumb' => Model\Contact::getThumb($contact, '', true),
+ 'thumb' => Model\Contact::getThumb($contact, true),
'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),