X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fhovercard.php;h=0e8cc80f27ae962453b57988f4d005d037c3e890;hb=54707dd4c815b6bf9aec5d8cb9231a1646aaa65a;hp=29dfd268913eded5834f89877b0c3d3dd4906f3c;hpb=f7165156f1d049e110226dbd25730e44d5c550ba;p=friendica.git diff --git a/mod/hovercard.php b/mod/hovercard.php index 29dfd26891..0e8cc80f27 100644 --- a/mod/hovercard.php +++ b/mod/hovercard.php @@ -9,8 +9,10 @@ */ use Friendica\App; use Friendica\Core\Config; +use Friendica\Core\System; use Friendica\Model\Contact; use Friendica\Model\GContact; +use Friendica\Model\Profile; function hovercard_init(App $a) { @@ -25,7 +27,7 @@ function hovercard_content() // Get out if the system doesn't have public access allowed if (intval(Config::get('system', 'block_public'))) { - http_status_exit(401); + System::httpExit(401); } // Return the raw content of the template. We use this to make templates usable for js functions. @@ -42,10 +44,10 @@ function hovercard_content() // the contact. So we strip out the contact id from the internal url and look in the contact table for // the real url (nurl) $cid = 0; - if (local_user() && strpos($profileurl, 'redir/') === 0) { + if (strpos($profileurl, 'redir/') === 0) { $cid = intval(substr($profileurl, 6)); - $r = dba::select('contact', array('nurl'), array('id' => $cid), array('limit' => 1)); - $profileurl = defaults($r, 'nurl', ''); + $remote_contact = dba::selectFirst('contact', ['nurl'], ['id' => $cid]); + $profileurl = defaults($remote_contact, 'nurl', ''); } $contact = []; @@ -65,12 +67,12 @@ function hovercard_content() } // Move the contact data to the profile array so we can deliver it to - $profile = array( + $profile = [ 'name' => $contact['name'], 'nick' => $contact['nick'], 'addr' => defaults($contact, 'addr', $contact['url']), 'thumb' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB), - 'url' => $cid ? ('redir/' . $cid) : zrl($contact['url']), + 'url' => Contact::magicLink($contact['url']), 'nurl' => $contact['nurl'], // We additionally store the nurl as identifier 'location' => $contact['location'], 'gender' => $contact['gender'], @@ -80,16 +82,16 @@ function hovercard_content() 'bd' => $contact['birthday'] <= '0001-01-01' ? '' : $contact['birthday'], 'account_type' => Contact::getAccountType($contact), 'actions' => $actions, - ); + ]; if ($datatype == 'html') { $tpl = get_markup_template('hovercard.tpl'); - $o = replace_macros($tpl, array( + $o = replace_macros($tpl, [ '$profile' => $profile, - )); + ]); return $o; } else { - json_return_and_die($profile); + System::jsonExit($profile); } }