}
}
- Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call']);
+ Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call', 'query' => $a->query_string]);
throw new NotImplementedException();
} catch (HTTPException $e) {
header("HTTP/1.1 {$e->getCode()} {$e->httpdesc}");
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
// get the tab navigation bar
- $tabs = Profile::getTabs($a, false, $a->data['user']['nickname']);
+ $tabs = Profile::getTabs($a, 'cal', false, $a->data['user']['nickname']);
// The view mode part is similiar to /mod/events.php
if ($mode == 'view') {
$tabs = '';
// tabs
if ($a->theme_events_in_profile) {
- $tabs = Profile::getTabs($a, true);
+ $tabs = Profile::getTabs($a, 'events', true);
}
$mode = 'view';
return;
}
- $o = Profile::getTabs($a, true);
+ $o = Profile::getTabs($a, 'notes', true);
if (!$update) {
$o .= '<h3>' . L10n::t('Personal Notes') . '</h3>';
// tabs
$is_owner = (local_user() && (local_user() == $owner_uid));
- $o .= Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
+ $o .= Profile::getTabs($a, 'photos', $is_owner, $a->data['user']['nickname']);
// Display upload form
if ($datatype === 'upload') {
// tabs
$_is_owner = (local_user() && (local_user() == $owner_uid));
- $o .= Profile::getTabs($a, $_is_owner, $a->data['user']['nickname']);
+ $o .= Profile::getTabs($a, 'videos', $_is_owner, $a->data['user']['nickname']);
//
// dispatch request
+++ /dev/null
-<?php
-/**
- * @file mod/viewcontacts.php
- */
-
-use Friendica\App;
-use Friendica\Content\ContactSelector;
-use Friendica\Content\Nav;
-use Friendica\Content\Pager;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
-use Friendica\Core\Protocol;
-use Friendica\Core\Renderer;
-use Friendica\Core\System;
-use Friendica\Database\DBA;
-use Friendica\Model\Contact;
-use Friendica\Model\Profile;
-use Friendica\Util\Proxy as ProxyUtils;
-
-function viewcontacts_init(App $a)
-{
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
- throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
- }
-
- if ($a->argc < 2) {
- throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
- }
-
- Nav::setSelected('home');
-
- $user = DBA::selectFirst('user', [], ['nickname' => $a->argv[1], 'blocked' => false]);
- if (!DBA::isResult($user)) {
- throw new \Friendica\Network\HTTPException\NotFoundException();
- }
-
- $a->data['user'] = $user;
- $a->profile_uid = $user['uid'];
-
- Profile::load($a, $a->argv[1]);
-}
-
-function viewcontacts_content(App $a)
-{
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
- notice(L10n::t('Public access denied.') . EOL);
- return;
- }
-
- $is_owner = $a->profile['profile_uid'] == local_user();
-
- // tabs
- $o = Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
-
- if (!count($a->profile) || $a->profile['hide-friends']) {
- notice(L10n::t('Permission denied.') . EOL);
- return $o;
- }
-
- $condition = [
- 'uid' => $a->profile['uid'],
- 'blocked' => false,
- 'pending' => false,
- 'hidden' => false,
- 'archive' => false,
- 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]
- ];
-
- $total = DBA::count('contact', $condition);
-
- $pager = new Pager($a->query_string);
-
- $params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
-
- $contacts_stmt = DBA::select('contact', [], $condition, $params);
-
- if (!DBA::isResult($contacts_stmt)) {
- info(L10n::t('No contacts.') . EOL);
- return $o;
- }
-
- $contacts = [];
-
- while ($contact = DBA::fetch($contacts_stmt)) {
- /// @TODO This triggers an E_NOTICE if 'self' is not there
- if ($contact['self']) {
- continue;
- }
-
- $contact_details = Contact::getDetailsByURL($contact['url'], $a->profile['uid'], $contact);
-
- $contacts[] = [
- 'id' => $contact['id'],
- 'img_hover' => L10n::t('Visit %s\'s profile [%s]', $contact_details['name'], $contact['url']),
- 'photo_menu' => Contact::photoMenu($contact),
- 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
- 'name' => substr($contact_details['name'], 0, 20),
- 'username' => $contact_details['name'],
- 'details' => $contact_details['location'],
- 'tags' => $contact_details['keywords'],
- 'about' => $contact_details['about'],
- 'account_type' => Contact::getAccountType($contact_details),
- 'url' => Contact::magicLink($contact['url']),
- 'sparkle' => '',
- 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $contact['url']),
- 'network' => ContactSelector::networkToName($contact['network'], $contact['url']),
- ];
- }
-
- DBA::close($contacts_stmt);
-
- $tpl = Renderer::getMarkupTemplate("viewcontact_template.tpl");
- $o .= Renderer::replaceMacros($tpl, [
- '$title' => L10n::t('Contacts'),
- '$contacts' => $contacts,
- '$paginate' => $pager->renderFull($total),
- ]);
-
- return $o;
-}
$this->routeCollector->addRoute(['GET'], '/probe', Module\Debug\Probe::class);
$this->routeCollector->addGroup('/profile', function (RouteCollector $collector) {
$collector->addRoute(['GET'], '/{nickname}', Module\Profile::class);
+ $collector->addRoute(['GET'], '/{nickname}/contacts[/{type}]', Module\Profile\Contacts::class);
$collector->addRoute(['GET'], '/{profile:\d+}/view', Module\Profile::class);
});
$this->routeCollector->addGroup('/proxy', function (RouteCollector $collector) {
}
/**
- * @param string $type
+ * Display a generic filter widget based on a list of options
+ *
+ * The options array must be the following format:
+ * [
+ * [
+ * 'ref' => {filter value},
+ * 'name' => {option name}
+ * ],
+ * ...
+ * ]
+ *
+ * @param string $type The filter query string key
* @param string $title
* @param string $desc
- * @param string $all
- * @param string $baseUrl
+ * @param string $all The no filter label
+ * @param string $baseUrl The full page request URI
* @param array $options
- * @param string $selected
+ * @param string $selected The currently selected filter option value
* @return string
* @throws \Exception
*/
- public static function filter($type, $title, $desc, $all, $baseUrl, array $options, $selected = null)
+ private static function filter($type, $title, $desc, $all, $baseUrl, array $options, $selected = null)
{
$queryString = parse_url($baseUrl, PHP_URL_QUERY);
$queryArray = [];
]);
}
+ /**
+ * Return networks widget
+ *
+ * @param string $baseurl baseurl
+ * @param string $selected optional, default empty
+ * @return string
+ * @throws \Exception
+ */
+ public static function contactRels($baseurl, $selected = '')
+ {
+ if (!local_user()) {
+ return '';
+ }
+
+ $options = [
+ ['ref' => 'followers', 'name' => L10n::t('Followers')],
+ ['ref' => 'following', 'name' => L10n::t('Following')],
+ ['ref' => 'mutuals', 'name' => L10n::t('Mutual friends')],
+ ];
+
+ return self::filter(
+ 'rel',
+ L10n::t('Relationships'),
+ '',
+ L10n::t('All Contacts'),
+ $baseurl,
+ $options,
+ $selected
+ );
+ }
+
/**
* Return networks widget
*
'pending' => false,
'hidden' => false,
'archive' => false,
- 'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA],
+ 'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::FEED],
]);
$contacts_title = L10n::t('No contacts');
return $contact;
}
- public static function addRelationship($importer, $contact, $datarray, $item = '', $sharing = false, $note = '') {
+ /**
+ * @param array $importer Owner (local user) data
+ * @param array $contact Existing owner-specific contact data we want to expand the relationship with. Optional.
+ * @param array $datarray An item-like array with at least the 'author-id' and 'author-url' keys for the contact. Mandatory.
+ * @param bool $sharing True: Contact is now sharing with Owner; False: Contact is now following Owner (default)
+ * @param string $note Introduction additional message
+ * @return bool|null True: follow request is accepted; False: relationship is rejected; Null: relationship is pending
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ public static function addRelationship(array $importer, array $contact, array $datarray, $sharing = false, $note = '')
+ {
// Should always be set
if (empty($datarray['author-id'])) {
- return;
+ return false;
}
- $fields = ['url', 'name', 'nick', 'photo', 'network'];
+ $fields = ['url', 'name', 'nick', 'photo', 'network', 'blocked'];
$pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]);
if (!DBA::isResult($pub_contact)) {
// Should never happen
- return;
+ return false;
+ }
+
+ // Contact is blocked at node-level
+ if (self::isBlocked($datarray['author-id'])) {
+ return false;
}
$url = defaults($datarray, 'author-link', $pub_contact['url']);
$nick = $pub_contact['nick'];
$network = $pub_contact['network'];
- if (is_array($contact)) {
+ if (!empty($contact)) {
+ // Contact is blocked at user-level
+ if (self::isBlockedByUser($contact['id'], $importer['id'])) {
+ return false;
+ }
+
// Make sure that the existing contact isn't archived
self::unmarkForArchival($contact);
- $protocol = self::getProtocol($url, $contact['network']);
-
if (($contact['rel'] == self::SHARING)
|| ($sharing && $contact['rel'] == self::FOLLOWER)) {
DBA::update('contact', ['rel' => self::FRIEND, 'writable' => true, 'pending' => false],
['id' => $contact['id'], 'uid' => $importer['uid']]);
}
- if ($protocol == Protocol::ACTIVITYPUB) {
- ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']);
- }
-
- // send email notification to owner?
+ return true;
} else {
- $protocol = self::getProtocol($url, $network);
-
+ // send email notification to owner?
if (DBA::exists('contact', ['nurl' => Strings::normaliseLink($url), 'uid' => $importer['uid'], 'pending' => true])) {
Logger::log('ignoring duplicated connection request from pending contact ' . $url);
- return;
+ return null;
}
+
// create contact record
- q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,
- `blocked`, `readonly`, `pending`, `writable`)
- VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, 1)",
- intval($importer['uid']),
- DBA::escape(DateTimeFormat::utcNow()),
- DBA::escape($url),
- DBA::escape(Strings::normaliseLink($url)),
- DBA::escape($name),
- DBA::escape($nick),
- DBA::escape($photo),
- DBA::escape($network),
- intval(self::FOLLOWER)
- );
+ DBA::insert('contact', [
+ 'uid' => $importer['uid'],
+ 'created' => DateTimeFormat::utcNow(),
+ 'url' => $url,
+ 'nurl' => Strings::normaliseLink($url),
+ 'name' => $name,
+ 'nick' => $nick,
+ 'photo' => $photo,
+ 'network' => $network,
+ 'rel' => self::FOLLOWER,
+ 'blocked' => 0,
+ 'readonly' => 0,
+ 'pending' => 1,
+ 'writable' => 1,
+ ]);
$contact_record = [
'id' => DBA::lastInsertId(),
'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW),
'otype' => 'intro'
]);
-
}
} elseif (DBA::isResult($user) && in_array($user['page-flags'], [User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE, User::PAGE_FLAGS_COMMUNITY])) {
$condition = ['uid' => $importer['uid'], 'url' => $url, 'pending' => true];
DBA::update('contact', ['pending' => false], $condition);
- $contact = DBA::selectFirst('contact', ['url', 'network', 'hub-verify'], ['id' => $contact_record['id']]);
- $protocol = self::getProtocol($contact['url'], $contact['network']);
-
- if ($protocol == Protocol::ACTIVITYPUB) {
- ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']);
- }
+ return true;
}
}
+
+ return null;
}
public static function removeFollower($importer, $contact, array $datarray = [], $item = "")
return '';
}
- public static function getTabs($a, $is_owner = false, $nickname = null)
+ /**
+ * @param App $a
+ * @param string $current
+ * @param bool $is_owner
+ * @param string $nickname
+ * @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ public static function getTabs(App $a, string $current, bool $is_owner, string $nickname = null)
{
if (is_null($nickname)) {
$nickname = $a->user['nickname'];
}
- $tab = false;
- if (!empty($_GET['tab'])) {
- $tab = Strings::escapeTags(trim($_GET['tab']));
- }
-
- $url = System::baseUrl() . '/profile/' . $nickname;
+ $baseProfileUrl = System::baseUrl() . '/profile/' . $nickname;
$tabs = [
[
'label' => L10n::t('Status'),
- 'url' => $url,
- 'sel' => !$tab && $a->argv[0] == 'profile' ? 'active' : '',
+ 'url' => $baseProfileUrl,
+ 'sel' => !$current ? 'active' : '',
'title' => L10n::t('Status Messages and Posts'),
'id' => 'status-tab',
'accesskey' => 'm',
],
[
'label' => L10n::t('Profile'),
- 'url' => $url . '/?tab=profile',
- 'sel' => $tab == 'profile' ? 'active' : '',
+ 'url' => $baseProfileUrl . '/?tab=profile',
+ 'sel' => $current == 'profile' ? 'active' : '',
'title' => L10n::t('Profile Details'),
'id' => 'profile-tab',
'accesskey' => 'r',
[
'label' => L10n::t('Photos'),
'url' => System::baseUrl() . '/photos/' . $nickname,
- 'sel' => !$tab && $a->argv[0] == 'photos' ? 'active' : '',
+ 'sel' => $current == 'photos' ? 'active' : '',
'title' => L10n::t('Photo Albums'),
'id' => 'photo-tab',
'accesskey' => 'h',
[
'label' => L10n::t('Videos'),
'url' => System::baseUrl() . '/videos/' . $nickname,
- 'sel' => !$tab && $a->argv[0] == 'videos' ? 'active' : '',
+ 'sel' => $current == 'videos' ? 'active' : '',
'title' => L10n::t('Videos'),
'id' => 'video-tab',
'accesskey' => 'v',
$tabs[] = [
'label' => L10n::t('Events'),
'url' => System::baseUrl() . '/events',
- 'sel' => !$tab && $a->argv[0] == 'events' ? 'active' : '',
+ 'sel' => $current == 'events' ? 'active' : '',
'title' => L10n::t('Events and Calendar'),
'id' => 'events-tab',
'accesskey' => 'e',
$tabs[] = [
'label' => L10n::t('Events'),
'url' => System::baseUrl() . '/cal/' . $nickname,
- 'sel' => !$tab && $a->argv[0] == 'cal' ? 'active' : '',
+ 'sel' => $current == 'cal' ? 'active' : '',
'title' => L10n::t('Events and Calendar'),
'id' => 'events-tab',
'accesskey' => 'e',
$tabs[] = [
'label' => L10n::t('Personal Notes'),
'url' => System::baseUrl() . '/notes',
- 'sel' => !$tab && $a->argv[0] == 'notes' ? 'active' : '',
+ 'sel' => $current == 'notes' ? 'active' : '',
'title' => L10n::t('Only You Can See This'),
'id' => 'notes-tab',
'accesskey' => 't',
];
}
- if (!$is_owner && empty($a->profile['hide-friends'])) {
+ if ($is_owner || empty($a->profile['hide-friends'])) {
$tabs[] = [
'label' => L10n::t('Contacts'),
- 'url' => System::baseUrl() . '/viewcontacts/' . $nickname,
- 'sel' => !$tab && $a->argv[0] == 'viewcontacts' ? 'active' : '',
+ 'url' => $baseProfileUrl . '/contacts',
+ 'sel' => $current == 'contacts' ? 'active' : '',
'title' => L10n::t('Contacts'),
'id' => 'viewcontacts-tab',
'accesskey' => 'k',
];
}
- $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab, 'tabs' => $tabs];
+ $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
Hook::callAll('profile_tabs', $arr);
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$a = self::getApp();
$nets = defaults($_GET, 'nets', '');
+ $rel = defaults($_GET, 'rel' , '');
if (empty($a->page['aside'])) {
$a->page['aside'] = '';
$findpeople_widget = '';
$follow_widget = '';
$networks_widget = '';
+ $rel_widget = '';
} else {
$vcard_widget = '';
$findpeople_widget = Widget::findPeople();
}
$networks_widget = Widget::networks($_SERVER['REQUEST_URI'], $nets);
+ $rel_widget = Widget::contactRels($_SERVER['REQUEST_URI'], $rel);
}
if ($contact['uid'] != 0) {
$groups_widget = null;
}
- $a->page['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $groups_widget . $networks_widget;
+ $a->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, [
$search = Strings::escapeTags(trim(defaults($_GET, 'search', '')));
$nets = Strings::escapeTags(trim(defaults($_GET, 'nets' , '')));
+ $rel = Strings::escapeTags(trim(defaults($_GET, 'rel' , '')));
$tabs = [
[
$sql_extra .= sprintf(" AND network = '%s' ", DBA::escape($nets));
}
+ switch ($rel) {
+ case 'followers': $sql_extra .= " AND `rel` IN (1, 3)"; break;
+ case 'following': $sql_extra .= " AND `rel` IN (2, 3)"; break;
+ case 'mutuals': $sql_extra .= " AND `rel` = 3"; break;
+ }
+
$sql_extra .= " AND NOT `deleted` ";
$sql_extra2 = ((($sort_type > 0) && ($sort_type <= Model\Contact::FRIEND)) ? sprintf(" AND `rel` = %d ", intval($sort_type)) : '');
}
}
+ switch ($rel) {
+ case 'followers': $header = L10n::t('Followers'); break;
+ case 'following': $header = L10n::t('Following'); break;
+ case 'mutuals': $header = L10n::t('Mutual friends'); break;
+ default: $header = L10n::t('Contacts');
+ }
+
switch ($type) {
case 'blocked': $header .= ' - ' . L10n::t('Blocked'); break;
case 'hidden': $header .= ' - ' . L10n::t('Hidden'); break;
}
if (!$update) {
- $tab = false;
- if (!empty($_GET['tab'])) {
- $tab = Strings::escapeTags(trim($_GET['tab']));
- }
+ $tab = Strings::escapeTags(trim(defaults($_GET, 'tab', '')));
- $o .= ProfileModel::getTabs($a, $is_owner, $a->profile['nickname']);
+ $o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);
if ($tab === 'profile') {
$o .= ProfileModel::getAdvanced($a);
--- /dev/null
+<?php
+
+namespace Friendica\Module\Profile;
+
+use Friendica\BaseModule;
+use Friendica\Content\ContactSelector;
+use Friendica\Content\Nav;
+use Friendica\Content\Pager;
+use Friendica\Core\Config;
+use Friendica\Core\L10n;
+use Friendica\Core\Protocol;
+use Friendica\Core\Renderer;
+use Friendica\Database\DBA;
+use Friendica\Model\Contact;
+use Friendica\Model\Profile;
+use Friendica\Util\Proxy as ProxyUtils;
+
+class Contacts extends BaseModule
+{
+ public static function content()
+ {
+ if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('User not found.'));
+ }
+
+ $a = self::getApp();
+
+ //@TODO: Get value from router parameters
+ $nickname = $a->argv[1];
+ $type = defaults($a->argv, 3, 'all');
+
+ Nav::setSelected('home');
+
+ $user = DBA::selectFirst('user', [], ['nickname' => $nickname, 'blocked' => false]);
+ if (!DBA::isResult($user)) {
+ throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('User not found.'));
+ }
+
+ $a->data['user'] = $user;
+ $a->profile_uid = $user['uid'];
+
+ Profile::load($a, $nickname);
+
+ $is_owner = $a->profile['profile_uid'] == local_user();
+
+ // tabs
+ $o = Profile::getTabs($a, 'contacts', $is_owner, $nickname);
+
+ if (!count($a->profile) || $a->profile['hide-friends']) {
+ notice(L10n::t('Permission denied.') . EOL);
+ return $o;
+ }
+
+ $condition = [
+ 'uid' => $a->profile['uid'],
+ 'blocked' => false,
+ 'pending' => false,
+ 'hidden' => false,
+ 'archive' => false,
+ 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED]
+ ];
+
+ switch ($type) {
+ case 'followers': $condition['rel'] = [1, 3]; break;
+ case 'following': $condition['rel'] = [2, 3]; break;
+ case 'mutuals': $condition['rel'] = 3; break;
+ }
+
+ $total = DBA::count('contact', $condition);
+
+ $pager = new Pager($a->query_string);
+
+ $params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
+
+ $contacts_stmt = DBA::select('contact', [], $condition, $params);
+
+ if (!DBA::isResult($contacts_stmt)) {
+ info(L10n::t('No contacts.') . EOL);
+ return $o;
+ }
+
+ $contacts = [];
+
+ while ($contact = DBA::fetch($contacts_stmt)) {
+ if ($contact['self']) {
+ continue;
+ }
+
+ $contact_details = Contact::getDetailsByURL($contact['url'], $a->profile['uid'], $contact);
+
+ $contacts[] = [
+ 'id' => $contact['id'],
+ 'img_hover' => L10n::t('Visit %s\'s profile [%s]', $contact_details['name'], $contact['url']),
+ 'photo_menu' => Contact::photoMenu($contact),
+ 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
+ 'name' => substr($contact_details['name'], 0, 20),
+ 'username' => $contact_details['name'],
+ 'details' => $contact_details['location'],
+ 'tags' => $contact_details['keywords'],
+ 'about' => $contact_details['about'],
+ 'account_type' => Contact::getAccountType($contact_details),
+ 'url' => Contact::magicLink($contact['url']),
+ 'sparkle' => '',
+ 'itemurl' => $contact_details['addr'] ? : $contact['url'],
+ 'network' => ContactSelector::networkToName($contact['network'], $contact['url']),
+ ];
+ }
+
+ DBA::close($contacts_stmt);
+
+ switch ($type) {
+ case 'followers': $title = L10n::tt('Follower (%s)', 'Followers (%s)', $total); break;
+ case 'following': $title = L10n::tt('Following (%s)', 'Following (%s)', $total); break;
+ case 'mutuals': $title = L10n::tt('Mutual friend (%s)', 'Mutual friends (%s)', $total); break;
+
+ case 'all': default: $title = L10n::tt('Contact (%s)', 'Contacts (%s)', $total); break;
+ }
+
+ $tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
+ $o .= Renderer::replaceMacros($tpl, [
+ '$title' => $title,
+ '$nickname' => $nickname,
+ '$type' => $type,
+
+ '$all_label' => L10n::t('All contacts'),
+ '$followers_label' => L10n::t('Followers'),
+ '$following_label' => L10n::t('Following'),
+ '$mutuals_label' => L10n::t('Mutual friends'),
+
+ '$contacts' => $contacts,
+ '$paginate' => $pager->renderFull($total),
+ ]);
+
+ return $o;
+ }
+}
DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
$contact = DBA::selectFirst('contact', [], ['id' => $cid, 'network' => Protocol::NATIVE_SUPPORT]);
} else {
- $contact = false;
+ $contact = [];
}
$item = ['author-id' => Contact::getIdForURL($activity['actor']),
// Ensure that the contact has got the right network type
self::switchContact($item['author-id']);
- Contact::addRelationship($owner, $contact, $item, '', false, $note);
+ $result = Contact::addRelationship($owner, $contact, $item, false, $note);
+ if ($result === true) {
+ ActivityPub\Transmitter::sendContactAccept($item['author-link'], $item['author-id'], $owner['uid']);
+ }
+
$cid = Contact::getIdForURL($activity['actor'], $uid);
if (empty($cid)) {
return;
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Accept',
'actor' => $owner['url'],
- 'object' => ['id' => $id, 'type' => 'Follow',
+ 'object' => [
+ 'id' => (string)$id,
+ 'type' => 'Follow',
'actor' => $profile['url'],
- 'object' => $owner['url']],
+ 'object' => $owner['url']
+ ],
'instrument' => self::getService(),
'to' => [$profile['url']]];
- Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
+ Logger::debug('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id);
$signed = LDSignature::sign($data, $owner);
HTTPSignature::transmit($signed, $profile['inbox'], $uid);
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Reject',
'actor' => $owner['url'],
- 'object' => ['id' => $id, 'type' => 'Follow',
+ 'object' => [
+ 'id' => (string)$id,
+ 'type' => 'Follow',
'actor' => $profile['url'],
- 'object' => $owner['url']],
+ 'object' => $owner['url']
+ ],
'instrument' => self::getService(),
'to' => [$profile['url']]];
- Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
+ Logger::debug('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id);
$signed = LDSignature::sign($data, $owner);
HTTPSignature::transmit($signed, $profile['inbox'], $uid);
// The functions below are partly used by ostatus.php as well - where we have this variable
$r = q("SELECT * FROM `contact` WHERE `id` = %d", intval($importer["id"]));
$contact = $r[0];
- $nickname = $contact["nick"];
// Big question: Do we need these functions? They were part of the "consume_feed" function.
// This function once was responsible for DFRN and OStatus.
if (activity_match($item["verb"], ACTIVITY_FOLLOW)) {
Logger::log("New follower");
- Contact::addRelationship($importer, $contact, $item, $nickname);
+ Contact::addRelationship($importer, $contact, $item);
return false;
}
if (activity_match($item["verb"], ACTIVITY_UNFOLLOW)) {
}
if (activity_match($item["verb"], ACTIVITY_REQ_FRIEND)) {
Logger::log("New friend request");
- Contact::addRelationship($importer, $contact, $item, $nickname, true);
+ Contact::addRelationship($importer, $contact, $item, true);
return false;
}
if (activity_match($item["verb"], ACTIVITY_UNFRIEND)) {
$author = self::fetchAuthor($xpath, $entry, $importer, $contact, $stored);
}
- $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:preferredUsername/text()', $entry);
- if ($value != "") {
- $nickname = $value;
- } else {
- $nickname = $author["author-name"];
- }
-
$item = array_merge($header, $author);
$item["uri"] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry);
}
if ($item["verb"] == ACTIVITY_FOLLOW) {
- Contact::addRelationship($importer, $contact, $item, $nickname);
+ Contact::addRelationship($importer, $contact, $item);
continue;
}
$author->appendChild($urls);
}
- XML::addElement($doc, $author, "followers", "", ["url" => System::baseUrl()."/viewcontacts/".$owner["nick"]]);
+ XML::addElement($doc, $author, "followers", "", ["url" => System::baseUrl() . "/profile/" . $owner["nick"] . "/contacts/followers"]);
XML::addElement($doc, $author, "statusnet:profile_info", "", ["local_id" => $owner["uid"]]);
if ($profile["publish"]) {
}
catch (Exception $e) {
$normalized = false;
- Logger::error('normalise error');
- // Sooner or later we should log some details as well - but currently this leads to memory issues
- // Logger::log('normalise error:' . substr(print_r($e, true), 0, 10000), Logger::DEBUG);
+ $messages = [];
+ $currentException = $e;
+ do {
+ $messages[] = $currentException->getMessage();
+ } while($currentException = $currentException->getPrevious());
+
+ Logger::warning('JsonLD normalize error');
+ Logger::notice('JsonLD normalize error', ['messages' => $messages]);
+ Logger::info('JsonLD normalize error', ['trace' => $e->getTraceAsString()]);
+ Logger::debug('JsonLD normalize error', ['jsonobj' => $jsonobj]);
}
return $normalized;
--- /dev/null
+<div class="generic-page-wrapper">
+ {{include file="section_title.tpl"}}
+
+ <ul role="menubar" class="tabs">
+ <li role="menuitem"><a href="profile/{{$nickname}}/contacts" class="tab button{{if !$type || $type == 'all'}} active{{/if}}">{{$all_label}}</a></li>
+ <li role="menuitem"><a href="profile/{{$nickname}}/contacts/followers" class="tab button{{if $type == 'followers'}} active{{/if}}">{{$followers_label}}</a></li>
+ <li role="menuitem"><a href="profile/{{$nickname}}/contacts/following" class="tab button{{if $type == 'following'}} active{{/if}}">{{$following_label}}</a></li>
+ <li role="menuitem"><a href="profile/{{$nickname}}/contacts/mutuals" class="tab button{{if $type == 'mutuals'}} active{{/if}}">{{$mutuals_label}}</a></li>
+ </ul>
+
+ <div id="viewcontact_wrapper-{{$id}}">
+{{foreach $contacts as $contact}}
+ {{include file="contact_template.tpl"}}
+{{/foreach}}
+ </div>
+ <div class="clear"></div>
+ <div id="view-contact-end"></div>
+
+ {{$paginate nofilter}}
+</div>
clear: both;
}
-
-#viewcontacts {
- margin-top: 15px;
-}
#profile-edit-default-desc {
color: #FF0000;
border: 1px solid #FF8888;
.manage-content-wrapper, .notes-content-wrapper,
.message-content-wrapper, .apps-content-wrapper,
#adminpage, .delegate-content-wrapper, .uexport-content-wrapper,
-.viewcontacts-content-wrapper, .dfrn_request-content-wrapper,
+.dfrn_request-content-wrapper,
.friendica-content-wrapper, .credits-content-wrapper, .nogroup-content-wrapper,
.profperm-content-wrapper, .invite-content-wrapper, .tos-content-wrapper,
.fsuggest-content-wrapper {
right: 10px;
}
- .generic-page-wrapper, .profile_photo-content-wrapper, .videos-content-wrapper, .suggest-content-wrapper, .common-content-wrapper, .help-content-wrapper, .allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, .directory-content-wrapper, .manage-content-wrapper, .notes-content-wrapper, .message-content-wrapper, .apps-content-wrapper, #adminpage, .delegate-content-wrapper, .uexport-content-wrapper, .viewcontacts-content-wrapper, .dfrn_request-content-wrapper, .friendica-content-wrapper, .credits-content-wrapper, .nogroup-content-wrapper, .profperm-content-wrapper, .invite-content-wrapper, .tos-content-wrapper, .fsuggest-content-wrapper {
+ .generic-page-wrapper, .profile_photo-content-wrapper, .videos-content-wrapper, .suggest-content-wrapper, .common-content-wrapper, .help-content-wrapper, .allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, .directory-content-wrapper, .manage-content-wrapper, .notes-content-wrapper, .message-content-wrapper, .apps-content-wrapper, #adminpage, .delegate-content-wrapper, .uexport-content-wrapper, .dfrn_request-content-wrapper, .friendica-content-wrapper, .credits-content-wrapper, .nogroup-content-wrapper, .profperm-content-wrapper, .invite-content-wrapper, .tos-content-wrapper, .fsuggest-content-wrapper {
border-radius: 0;
padding: 10px;
}
--- /dev/null
+<div class="generic-page-wrapper">
+ {{include file="section_title.tpl"}}
+
+ <ul class="nav nav-tabs">
+ <li role="presentation"{{if !$type || $type == 'all'}} class="active"{{/if}}><a href="profile/{{$nickname}}/contacts">{{$all_label}}</a></li>
+ <li role="presentation"{{if $type == 'followers'}} class="active"{{/if}}><a href="profile/{{$nickname}}/contacts/followers">{{$followers_label}}</a></li>
+ <li role="presentation"{{if $type == 'following'}} class="active"{{/if}}><a href="profile/{{$nickname}}/contacts/following">{{$following_label}}</a></li>
+ <li role="presentation"{{if $type == 'mutuals'}} class="active"{{/if}}><a href="profile/{{$nickname}}/contacts/mutuals">{{$mutuals_label}}</a></li>
+ </ul>
+
+ <ul id="viewcontact_wrapper{{if $id}}-{{$id}}{{/if}}" class="viewcontact_wrapper media-list">
+{{foreach $contacts as $contact}}
+ <li>{{include file="contact_template.tpl"}}</li>
+{{/foreach}}
+ </ul>
+ <div class="clear"></div>
+ <div id="view-contact-end"></div>
+
+ {{$paginate nofilter}}
+</div>
clear: both;
}
-#viewcontacts {
- margin-top: 15px;
-}
-
.contact-entry-wrapper .contact-entry-photo-wrapper {
float: left;
margin-right: 10px;