Replaced "getDetailsByURL" with "getByURL/getByURLForUser"

This commit is contained in:
Michael 2020-07-15 04:42:04 +00:00
parent 869f3cfec4
commit d9c6a46ffe
29 changed files with 78 additions and 285 deletions

View file

@ -63,7 +63,7 @@ class AllFriends extends BaseModule
}
DI::page()['aside'] = "";
Model\Profile::load($app, "", Model\Contact::getDetailsByURL($contact["url"]));
Model\Profile::load($app, "", Model\Contact::getByURL($contact["url"], 0, [], false));
$total = Model\GContact::countAllFriends(local_user(), $cid);
@ -79,7 +79,7 @@ class AllFriends extends BaseModule
$entries = [];
foreach ($friends as $friend) {
//get further details of the contact
$contactDetails = Model\Contact::getDetailsByURL($friend['url'], $uid, $friend);
$contactDetails = array_merge($friend, Model\Contact::getByURLForUser($friend['url'], $uid, [], false));
$connlnk = '';
// $friend[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photoMenu

View file

@ -971,7 +971,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) {
DI::page()['aside'] = '';
$profiledata = Model\Contact::getDetailsByURL($contact['url']);
$profiledata = Model\Contact::getByURL($contact['url'], 0, [], false);
Model\Profile::load($a, '', $profiledata, true);
@ -994,7 +994,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) {
DI::page()['aside'] = '';
$profiledata = Model\Contact::getDetailsByURL($contact['url']);
$profiledata = Model\Contact::getByURL($contact['url'], 0, [], false);
if (local_user() && in_array($profiledata['network'], Protocol::FEDERATED)) {
$profiledata['remoteconnect'] = DI::baseUrl() . '/follow?url=' . urlencode($profiledata['url']);

View file

@ -108,7 +108,7 @@ class Advanced extends BaseModule
throw new BadRequestException(DI::l10n()->t('Contact not found.'));
}
Model\Profile::load(DI::app(), "", Model\Contact::getDetailsByURL($contact["url"]));
Model\Profile::load(DI::app(), "", Model\Contact::getByURL($contact["url"], 0, [], false));
$warning = DI::l10n()->t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
$info = DI::l10n()->t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');

View file

@ -58,31 +58,16 @@ class Hovercard extends BaseModule
$contact = [];
// if it's the url containing https it should be converted to http
$contact_nurl = Strings::normaliseLink(GContact::cleanContactUrl($contact_url));
if (!$contact_nurl) {
if (!$contact_url) {
throw new HTTPException\BadRequestException();
}
// Search for contact data
// Look if the local user has got the contact
if (Session::isAuthenticated()) {
$contact = Contact::getDetailsByURL($contact_nurl, local_user());
}
// If not then check the global user
if (!count($contact)) {
$contact = Contact::getDetailsByURL($contact_nurl);
}
// Feeds url could have been destroyed through "cleanContactUrl", so we now use the original url
if (!count($contact) && Session::isAuthenticated()) {
$contact_nurl = Strings::normaliseLink($contact_url);
$contact = Contact::getDetailsByURL($contact_nurl, local_user());
}
if (!count($contact)) {
$contact_nurl = Strings::normaliseLink($contact_url);
$contact = Contact::getDetailsByURL($contact_nurl);
$contact = Contact::getByURLForUser($contact_url, local_user(), [], false);
} else {
$contact = Contact::getByURL($contact_url, 0, [], false);
}
if (!count($contact)) {
@ -110,7 +95,7 @@ class Hovercard extends BaseModule
'about' => $contact['about'],
'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']),
'tags' => $contact['keywords'],
'bd' => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'],
'bd' => $contact['bd'] <= DBA::NULL_DATE ? '' : $contact['bd'],
'account_type' => Contact::getAccountType($contact),
'actions' => $actions,
],

View file

@ -138,7 +138,7 @@ class Poke extends BaseModule
throw new HTTPException\NotFoundException();
}
Model\Profile::load(DI::app(), '', Model\Contact::getDetailsByURL($contact["url"]));
Model\Profile::load(DI::app(), '', Model\Contact::getByURL($contact["url"], 0, [], false));
$verbs = [];
foreach (DI::l10n()->getPokeVerbs() as $verb => $translations) {

View file

@ -103,7 +103,7 @@ class Contacts extends BaseProfile
continue;
}
$contact_details = Contact::getDetailsByURL($contact['url'], $a->profile['uid'], $contact);
$contact_details = array_merge($contact, Contact::getByURLForUser($contact['url'], $a->profile['uid'], [], false));
$contacts[] = [
'id' => $contact['id'],

View file

@ -350,7 +350,7 @@ class Acl extends BaseModule
continue;
}
$contact = Contact::getDetailsByURL($author);
$contact = Contact::getByURL($author, 0, ['micro', 'name', 'id', 'network', 'nick', 'addr', 'url', 'forum'], false);
if (count($contact) > 0) {
$unknown_contacts[] = [

View file

@ -237,13 +237,13 @@ class Index extends BaseSearch
} else {
// Cheaper local lookup for anonymous users, no probe
if ($isAddr) {
$contact = Contact::selectFirst(['id' => 'cid'], ['addr' => $search, 'uid' => 0]);
$contact = Contact::selectFirst(['id'], ['addr' => $search, 'uid' => 0]);
} else {
$contact = Contact::getDetailsByURL($search, 0, ['cid' => 0]);
$contact = array_merge(['id' => 0], Contact::getByURL($search, 0, ['id']));
}
if (DBA::isResult($contact)) {
$contact_id = $contact['cid'];
$contact_id = $contact['id'];
}
}