<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget;
-use Friendica\Core\ACL;
use Friendica\Core\Hook;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
const TAB_PROFILE = 3;
const TAB_CONTACTS = 4;
const TAB_ADVANCED = 5;
+ const TAB_MEDIA = 6;
private static function batchActions()
{
return;
}
- $contacts_id = $_POST['contact_batch'];
+ $redirectUrl = $_POST['redirect_url'] ?? 'contact';
- $stmt = DBA::select('contact', ['id', 'archive'], ['id' => $contacts_id, 'uid' => local_user(), 'self' => false, 'deleted' => false]);
- $orig_records = DBA::toArray($stmt);
+ self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'contact_batch_actions');
+
+ $orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]);
$count_actions = 0;
foreach ($orig_records as $orig_record) {
- $contact_id = $orig_record['id'];
- if (!empty($_POST['contacts_batch_update'])) {
- self::updateContactFromPoll($contact_id);
+ $cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], local_user());
+ if (empty($cdata) || public_contact() === $cdata['public']) {
+ // No action available on your own contact
+ continue;
+ }
+
+ if (!empty($_POST['contacts_batch_update']) && $cdata['user']) {
+ self::updateContactFromPoll($cdata['user']);
$count_actions++;
}
+
if (!empty($_POST['contacts_batch_block'])) {
- self::blockContact($contact_id);
+ self::toggleBlockContact($cdata['public'], local_user());
$count_actions++;
}
+
if (!empty($_POST['contacts_batch_ignore'])) {
- self::ignoreContact($contact_id);
- $count_actions++;
- }
- if (!empty($_POST['contacts_batch_archive'])
- && self::archiveContact($contact_id, $orig_record)
- ) {
- $count_actions++;
- }
- if (!empty($_POST['contacts_batch_drop'])) {
- self::dropContact($orig_record);
+ self::toggleIgnoreContact($cdata['public']);
$count_actions++;
}
}
info(DI::l10n()->tt('%d contact edited.', '%d contacts edited.', $count_actions));
}
- DI::baseUrl()->redirect('contact');
+ DI::baseUrl()->redirect($redirectUrl);
}
public static function post(array $parameters = [])
{
- $a = DI::app();
-
if (!local_user()) {
return;
}
// @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;
}
$info = Strings::escapeHtml(trim($_POST['info'] ?? ''));
- $r = DBA::update('contact', [
+ $r = Model\Contact::update([
'priority' => $priority,
'info' => $info,
'hidden' => $hidden,
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 actions */
- private static function updateContactFromPoll($contact_id)
+ /**
+ * @param int $contact_id Id of contact with uid != 0
+ * @throws NotFoundException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ private static function updateContactFromPoll(int $contact_id)
{
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]);
if (!DBA::isResult($contact)) {
}
if ($contact['network'] == Protocol::OSTATUS) {
- $user = Model\User::getById($contact['uid']);
- $result = Model\Contact::createFromProbe($user, $contact['url'], false, $contact['network']);
+ $result = Model\Contact::createFromProbeForUser($contact['uid'], $contact['url'], $contact['network']);
if ($result['success']) {
- DBA::update('contact', ['subhub' => 1], ['id' => $contact_id]);
+ Model\Contact::update(['subhub' => 1], ['id' => $contact_id]);
}
// pull feed and consume it, which should subscribe to the hub.
}
}
- private static function updateContactFromProbe($contact_id)
+ /**
+ * @param int $contact_id Id of the contact with uid != 0
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ private static function updateContactFromProbe(int $contact_id)
{
- $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]);
+ $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]);
if (!DBA::isResult($contact)) {
return;
}
/**
* Toggles the blocked status of a contact identified by id.
*
- * @param $contact_id
+ * @param int $contact_id Id of the contact with uid = 0
+ * @param int $owner_id Id of the user we want to block the contact for
* @throws \Exception
*/
- private static function blockContact($contact_id)
+ private static function toggleBlockContact(int $contact_id, int $owner_id)
{
- $blocked = !Model\Contact\User::isBlocked($contact_id, local_user());
- Model\Contact\User::setBlocked($contact_id, local_user(), $blocked);
+ $blocked = !Model\Contact\User::isBlocked($contact_id, $owner_id);
+ Model\Contact\User::setBlocked($contact_id, $owner_id, $blocked);
}
/**
* Toggles the ignored status of a contact identified by id.
*
- * @param $contact_id
+ * @param int $contact_id Id of the contact with uid = 0
* @throws \Exception
*/
- private static function ignoreContact($contact_id)
+ private static function toggleIgnoreContact(int $contact_id)
{
$ignored = !Model\Contact\User::isIgnored($contact_id, local_user());
Model\Contact\User::setIgnored($contact_id, local_user(), $ignored);
}
- /**
- * Toggles the archived status of a contact identified by id.
- * If the current status isn't provided, this will always archive the contact.
- *
- * @param $contact_id
- * @param $orig_record
- * @return bool
- * @throws \Exception
- */
- private static function archiveContact($contact_id, $orig_record)
- {
- $archived = empty($orig_record['archive']);
- $r = DBA::update('contact', ['archive' => $archived], ['id' => $contact_id, 'uid' => local_user()]);
-
- return DBA::isResult($r);
- }
-
- private static function dropContact($orig_record)
- {
- $owner = Model\User::getOwnerDataById(local_user());
- if (!DBA::isResult($owner)) {
- return;
- }
-
- Model\Contact::terminateFriendship($owner, $orig_record, true);
- Model\Contact::remove($orig_record['id']);
- }
-
public static function content(array $parameters = [], $update = 0)
{
if (!local_user()) {
$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'];
}
- $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]);
+ if (!empty($data)) {
+ $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;
+ // Don't display contacts that are about to be deleted
+ if (DBA::isResult($contact) && !empty($contact['network']) && $contact['network'] == Protocol::PHANTOM) {
+ $contact = false;
+ }
}
}
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)) {
throw new NotFoundException(DI::l10n()->t('Contact not found'));
}
- if ($cmd === 'update' && ($orig_record['uid'] != 0)) {
- self::updateContactFromPoll($contact_id);
- DI::baseUrl()->redirect('contact/' . $contact_id);
- // NOTREACHED
+ if ($cmd === 'posts') {
+ return self::getPostsHTML($contact_id);
}
- if ($cmd === 'updateprofile') {
- self::updateContactFromProbe($contact_id);
- DI::baseUrl()->redirect('contact/' . $contact_id);
- // NOTREACHED
+ if ($cmd === 'conversations') {
+ return self::getConversationsHMTL($a, $contact_id, $update);
}
- if ($cmd === 'block') {
- self::blockContact($contact_id);
+ self::checkFormSecurityTokenRedirectOnError('contact/' . $contact_id, 'contact_action', 't');
- $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')));
+ $cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], local_user());
+ if (empty($cdata)) {
+ throw new NotFoundException(DI::l10n()->t('Contact not found'));
+ }
- DI::baseUrl()->redirect('contact/' . $contact_id);
+ if ($cmd === 'update' && $cdata['user']) {
+ self::updateContactFromPoll($cdata['user']);
+ DI::baseUrl()->redirect('contact/' . $cdata['public']);
// NOTREACHED
}
- if ($cmd === 'ignore') {
- self::ignoreContact($contact_id);
-
- $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);
+ if ($cmd === 'updateprofile' && $cdata['user']) {
+ self::updateContactFromProbe($cdata['user']);
+ DI::baseUrl()->redirect('contact/' . $cdata['public']);
// NOTREACHED
}
- if ($cmd === 'archive' && ($orig_record['uid'] != 0)) {
- $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')));
+ if ($cmd === 'block') {
+ if (public_contact() === $cdata['public']) {
+ throw new BadRequestException(DI::l10n()->t('You can\'t block yourself'));
}
- DI::baseUrl()->redirect('contact/' . $contact_id);
+ self::toggleBlockContact($cdata['public'], 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/' . $cdata['public']);
// NOTREACHED
}
- if ($cmd === 'drop' && ($orig_record['uid'] != 0)) {
- // Check if we should do HTML-based delete confirmation
- if (!empty($_REQUEST['confirm'])) {
- DI::page()['aside'] = '';
-
- return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [
- '$header' => DI::l10n()->t('Drop contact'),
- '$contact' => self::getContactTemplateVars($orig_record),
- '$method' => 'get',
- '$message' => DI::l10n()->t('Do you really want to delete this contact?'),
- '$confirm' => DI::l10n()->t('Yes'),
- '$confirm_url' => DI::args()->getCommand(),
- '$confirm_name' => 'confirmed',
- '$cancel' => DI::l10n()->t('Cancel'),
- ]);
- }
- // Now check how the user responded to the confirmation query
- if (!empty($_REQUEST['canceled'])) {
- DI::baseUrl()->redirect('contact');
+ if ($cmd === 'ignore') {
+ if (public_contact() === $cdata['public']) {
+ throw new BadRequestException(DI::l10n()->t('You can\'t ignore yourself'));
}
- self::dropContact($orig_record);
- info(DI::l10n()->t('Contact has been removed.'));
+ self::toggleIgnoreContact($cdata['public']);
+
+ $ignored = Model\Contact\User::isIgnored($cdata['public'], local_user());
+ info(($ignored ? DI::l10n()->t('Contact has been ignored') : DI::l10n()->t('Contact has been unignored')));
- DI::baseUrl()->redirect('contact');
+ DI::baseUrl()->redirect('contact/' . $cdata['public']);
// NOTREACHED
}
- if ($cmd === 'posts') {
- return self::getPostsHTML($a, $contact_id);
- }
- if ($cmd === 'conversations') {
- return self::getConversationsHMTL($a, $contact_id, $update);
- }
}
$_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),
]);
$poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
- $nettype = DI::l10n()->t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']));
+ $nettype = DI::l10n()->t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol'], $contact['gsid']));
// tabs
$tab_str = self::getTabsHTML($contact, self::TAB_PROFILE);
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')];
}
$poll_interval = null;
- if ((($contact['network'] == Protocol::FEED) && !DI::config()->get('system', 'adjust_poll_frequency')) || ($contact['network']== Protocol::MAIL)) {
+ if ((($contact['network'] == Protocol::FEED) && !DI::config()->get('system', 'adjust_poll_frequency')) || ($contact['network'] == Protocol::MAIL)) {
$poll_interval = ContactSelector::pollInterval($contact['priority'], !$poll_enabled);
}
'$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),
+ '$matrix' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['matrix']),
+ '$matrix_label' => DI::l10n()->t('Matrix:'),
+ '$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':
'$submit' => DI::l10n()->t('Find'),
'$cmd' => DI::args()->getCommand(),
'$contacts' => $contacts,
- '$contact_drop_confirm' => DI::l10n()->t('Do you really want to delete this contact?'),
+ '$form_security_token' => BaseModule::getFormSecurityToken('contact_batch_actions'),
'multiselect' => 1,
'$batch_actions' => [
'contacts_batch_update' => DI::l10n()->t('Update'),
'contacts_batch_block' => DI::l10n()->t('Block') . '/' . DI::l10n()->t('Unblock'),
'contacts_batch_ignore' => DI::l10n()->t('Ignore') . '/' . DI::l10n()->t('Unignore'),
- 'contacts_batch_archive' => DI::l10n()->t('Archive') . '/' . DI::l10n()->t('Unarchive'),
- 'contacts_batch_drop' => DI::l10n()->t('Delete'),
],
'$h_batch_actions' => DI::l10n()->t('Batch Actions'),
'$paginate' => $pager->renderFull($total),
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'])) {
'id' => 'posts-tab',
'accesskey' => 'p',
],
+ [
+ 'label' => DI::l10n()->t('Media'),
+ 'url' => 'contact/' . $pcid . '/media',
+ 'sel' => (($active_tab == self::TAB_MEDIA) ? 'active' : ''),
+ 'title' => DI::l10n()->t('Posts containing media objects'),
+ 'id' => 'media-tab',
+ 'accesskey' => 'd',
+ ],
[
'label' => DI::l10n()->t('Profile'),
'url' => 'contact/' . $cid,
if (!$update) {
// We need the editor here to be able to reshare an item.
if (local_user()) {
- $x = [
- 'is_owner' => true,
- 'allow_location' => $a->user['allow_location'],
- 'default_location' => $a->user['default-location'],
- 'nickname' => $a->user['nickname'],
- 'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'),
- 'acl' => ACL::getFullSelectorHTML(DI::page(), $a->user, true),
- 'bang' => '',
- 'visitor' => 'block',
- 'profile_uid' => local_user(),
- ];
- $o = status_editor($a, $x, 0, true);
+ $o = DI::conversation()->statusEditor([], 0, true);
}
}
}
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) {
return $o;
}
- private static function getPostsHTML($a, $contact_id)
+ private static function getPostsHTML(int $contact_id)
{
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id, 'deleted' => false]);
$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),
+ '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),
'sparkle' => $sparkle,
'itemurl' => ($contact['addr'] ?? '') ?: $contact['url'],
- 'network' => ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']),
+ 'network' => ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol'], $contact['gsid']),
];
}
/**
* Gives a array with actions which can performed to a given contact
*
- * This includes actions like e.g. 'block', 'hide', 'archive', 'delete' and others
+ * This includes actions like e.g. 'block', 'hide', 'delete' and others
*
* @param array $contact Data about the Contact
* @return array with contact related actions
$poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
$contact_actions = [];
+ $formSecurityToken = self::getFormSecurityToken('contact_action');
+
// Provide friend suggestion only for Friendica contacts
if ($contact['network'] === Protocol::DFRN) {
$contact_actions['suggest'] = [
if ($poll_enabled) {
$contact_actions['update'] = [
'label' => DI::l10n()->t('Update now'),
- 'url' => 'contact/' . $contact['id'] . '/update',
+ 'url' => 'contact/' . $contact['id'] . '/update?t=' . $formSecurityToken,
'title' => '',
'sel' => '',
'id' => 'update',
if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
$contact_actions['updateprofile'] = [
'label' => DI::l10n()->t('Refetch contact data'),
- 'url' => 'contact/' . $contact['id'] . '/updateprofile',
+ 'url' => 'contact/' . $contact['id'] . '/updateprofile?t=' . $formSecurityToken,
'title' => '',
'sel' => '',
'id' => 'updateprofile',
$contact_actions['block'] = [
'label' => (intval($contact['blocked']) ? DI::l10n()->t('Unblock') : DI::l10n()->t('Block')),
- 'url' => 'contact/' . $contact['id'] . '/block',
+ 'url' => 'contact/' . $contact['id'] . '/block?t=' . $formSecurityToken,
'title' => DI::l10n()->t('Toggle Blocked status'),
'sel' => (intval($contact['blocked']) ? 'active' : ''),
'id' => 'toggle-block',
$contact_actions['ignore'] = [
'label' => (intval($contact['readonly']) ? DI::l10n()->t('Unignore') : DI::l10n()->t('Ignore')),
- 'url' => 'contact/' . $contact['id'] . '/ignore',
+ 'url' => 'contact/' . $contact['id'] . '/ignore?t=' . $formSecurityToken,
'title' => DI::l10n()->t('Toggle Ignored status'),
'sel' => (intval($contact['readonly']) ? 'active' : ''),
'id' => 'toggle-ignore',
];
- if ($contact['uid'] != 0) {
- $contact_actions['archive'] = [
- 'label' => (intval($contact['archive']) ? DI::l10n()->t('Unarchive') : DI::l10n()->t('Archive')),
- 'url' => 'contact/' . $contact['id'] . '/archive',
- 'title' => DI::l10n()->t('Toggle Archive status'),
- 'sel' => (intval($contact['archive']) ? 'active' : ''),
- 'id' => 'toggle-archive',
- ];
-
- $contact_actions['delete'] = [
- 'label' => DI::l10n()->t('Delete'),
- 'url' => 'contact/' . $contact['id'] . '/drop',
- 'title' => DI::l10n()->t('Delete contact'),
+ if ($contact['uid'] != 0 && Protocol::supportsRevokeFollow($contact['network']) && in_array($contact['rel'], [Model\Contact::FOLLOWER, Model\Contact::FRIEND])) {
+ $contact_actions['revoke_follow'] = [
+ 'label' => DI::l10n()->t('Revoke Follow'),
+ 'url' => 'contact/' . $contact['id'] . '/revoke',
+ 'title' => DI::l10n()->t('Revoke the follow from this contact'),
'sel' => '',
- 'id' => 'delete',
+ 'id' => 'revoke_follow',
];
}