- // $item['contact-uid'] is only set on profile page and indicates the uid of the user who owns the profile.
-
- $profile_owner = ((x($item,'contact-uid')) && intval($item['contact-uid']) ? intval($item['contact-uid']) : 0);
-
- // So we are checking that this is a logged in user on some page that *isn't* a profile page
- // OR a profile page where the viewer owns the profile.
- // Then check if we can use a sparkle (redirect) link to the profile by virtue of it being our contact
- // or a friend's contact that we both have a connection to.
-
- if((local_user() && ($profile_owner == 0))
- || ($profile_owner && $profile_owner == local_user())) {
-
- if(strlen($item['author-link']) && link_compare($item['author-link'],$item['url'])) {
- $redir = $redirect_url;
- $cid = $item['cid'];
- }
- elseif(isset($a->authors[$item['author-link']])) {
- $redir = $a->get_baseurl() . '/redir/' . $a->authors[$item['author-link']]['id'];
- $cid = $a->authors[$item['author-link']]['id'];
- }
- if($item['author-link'] === 'mailbox')
- $cid = $item['cid'];
-
- if((isset($cid)) && (! $item['self'])) {
- $contact_url = $a->get_baseurl() . '/contacts/' . $cid;
- $posts_link = $a->get_baseurl() . '/network/?cid=' . $cid;
- if($item['network'] === 'dfrn') {
- $status_link = $redir . "?url=status";
- $profile_link = $redir . "?url=profile";
- $photos_link = $redir . "?url=photos";
- $pm_url = $a->get_baseurl() . '/message/new/' . $cid;
- }
+ if($sparkle) {
+ $cid = intval(basename($profile_link));
+ $status_link = $profile_link . "?url=status";
+ $photos_link = $profile_link . "?url=photos";
+ $profile_link = $profile_link . "?url=profile";
+ $pm_url = $a->get_baseurl() . '/message/new/' . $cid;
+ }
+ else {
+ if(local_user() && local_user() == $item['uid'] && link_compare($item['url'],$item['author-link'])) {
+ $cid = $item['contact-id'];
+ }
+ else {
+ $cid = 0;