'notify' => DI::baseUrl() . '/dfrn_notify/' . $user['nickname'],
'poll' => DI::baseUrl() . '/dfrn_poll/' . $user['nickname'],
'confirm' => DI::baseUrl() . '/dfrn_confirm/' . $user['nickname'],
- 'poco' => DI::baseUrl() . '/poco/' . $user['nickname'],
'name-date' => DateTimeFormat::utcNow(),
'uri-date' => DateTimeFormat::utcNow(),
'avatar-date' => DateTimeFormat::utcNow(),
'notify' => DI::baseUrl() . '/dfrn_notify/' . $user['nickname'],
'poll' => DI::baseUrl() . '/dfrn_poll/'. $user['nickname'],
'confirm' => DI::baseUrl() . '/dfrn_confirm/' . $user['nickname'],
- 'poco' => DI::baseUrl() . '/poco/' . $user['nickname'],
];
self::clearFollowerFollowingEndpointCache($contact['uid']);
// Archive the contact
- self::update(['archive' => true, 'network' => Protocol::PHANTOM, 'deleted' => true], ['id' => $id]);
+ self::update(['archive' => true, 'network' => Protocol::PHANTOM, 'rel' => self::NOTHING, 'deleted' => true], ['id' => $id]);
if (!DBA::exists('contact', ['uri-id' => $contact['uri-id'], 'deleted' => false])) {
Avatar::deleteCache($contact);
$sparkle = false;
if (($contact['network'] === Protocol::DFRN) && !$contact['self'] && empty($contact['pending'])) {
$sparkle = true;
- $profile_link = DI::baseUrl() . '/redir/' . $contact['id'];
+ $profile_link = 'contact/redir/' . $contact['id'];
} else {
$profile_link = $contact['url'];
}
if ($sparkle) {
$status_link = $profile_link . '/status';
- $photos_link = str_replace('/profile/', '/photos/', $profile_link);
+ $photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
if (self::canReceivePrivateMessages($contact) && empty($contact['pending'])) {
- $pm_url = DI::baseUrl() . '/message/new/' . $contact['id'];
+ $pm_url = 'message/new/' . $contact['id'];
}
- $contact_url = DI::baseUrl() . '/contact/' . $contact['id'];
+ $contact_url = 'contact/' . $contact['id'];
- $posts_link = DI::baseUrl() . '/contact/' . $contact['id'] . '/conversations';
+ $posts_link = 'contact/' . $contact['id'] . '/conversations';
$follow_link = '';
$unfollow_link = '';
if (!$contact['self'] && Protocol::supportsFollow($contact['network'])) {
if ($contact['uid'] && in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
- $unfollow_link = 'unfollow?url=' . urlencode($contact['url']) . '&auto=1';
+ $unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
} elseif(!$contact['pending']) {
- $follow_link = 'follow?url=' . urlencode($contact['url']) . '&auto=1';
+ $follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1';
}
}
'network' => [DI::l10n()->t('Network Posts') , $posts_link , false],
'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true],
- 'unfollow'=> [DI::l10n()->t('UnFollow') , $unfollow_link, true],
+ 'unfollow'=> [DI::l10n()->t('Unfollow') , $unfollow_link, true],
];
} else {
$menu = [
'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
'pm' => [DI::l10n()->t('Send PM') , $pm_url , false],
'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true],
- 'unfollow'=> [DI::l10n()->t('UnFollow') , $unfollow_link , true],
+ 'unfollow'=> [DI::l10n()->t('Unfollow') , $unfollow_link , true],
];
if (!empty($contact['pending'])) {
'writable' => 1,
'blocked' => 0,
'readonly' => 0,
- 'pending' => 0];
+ 'pending' => 0,
+ ];
- $condition = ['nurl' => Strings::normaliseLink($data["url"]), 'uid' => $uid, 'deleted' => false];
+ $condition = ['nurl' => Strings::normaliseLink($data['url']), 'uid' => $uid, 'deleted' => false];
// Before inserting we do check if the entry does exist now.
$contact = DBA::selectFirst('contact', ['id'], $condition, ['order' => ['id']]);
return $destination;
}
- $redirect = 'redir/' . $contact['id'];
+ $redirect = 'contact/redir/' . $contact['id'];
if (($url != '') && !Strings::compareLink($contact['url'], $url)) {
$redirect .= '?url=' . $url;
* @param string $search Name or nick
* @param string $mode Search mode (e.g. "community")
* @param int $uid User ID
+ * @param int $limit Maximum amount of returned values
+ * @param int $offset Limit offset
*
* @return array with search results
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function searchByName(string $search, string $mode = '', int $uid = 0): array
+ public static function searchByName(string $search, string $mode = '', int $uid = 0, int $limit = 0, int $offset = 0): array
{
if (empty($search)) {
return [];
if ($uid == 0) {
$condition['blocked'] = false;
+ } else {
+ $condition['rel'] = [Contact::SHARING, Contact::FRIEND];
}
// check if we search only communities or every contact
$search .= '%';
+ $params = [];
+
+ if (!empty($limit) && !empty($offset)) {
+ $params['limit'] = [$offset, $limit];
+ } elseif (!empty($limit)) {
+ $params['limit'] = $limit;
+ }
+
$condition = DBA::mergeConditions($condition,
["(NOT `unsearchable` OR `nurl` IN (SELECT `nurl` FROM `owner-view` WHERE `publish` OR `net-publish`))
AND (`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?)", $search, $search, $search]);
- $contacts = self::selectToArray([], $condition);
+ $contacts = self::selectToArray([], $condition, $params);
return $contacts;
}
return [];
}
+
+ /**
+ * Checks, if contacts with the given condition exists
+ *
+ * @param array $condition
+ *
+ * @return bool
+ * @throws \Exception
+ */
+ public static function exists(array $condition): bool
+ {
+ return DBA::exists('contact', $condition);
+ }
}