-if(! function_exists('extract_item_authors')) {
-function extract_item_authors($arr,$uid) {
-
- if((! $uid) || (! is_array($arr)) || (! count($arr)))
- return array();
- $urls = array();
- foreach($arr as $rr) {
- if(! in_array("'" . dbesc($rr['author-link']) . "'",$urls))
- $urls[] = "'" . dbesc($rr['author-link']) . "'";
- }
-
- // pre-quoted, don't put quotes on %s
- if(count($urls)) {
- $r = q("SELECT `id`,`url` FROM `contact` WHERE `uid` = %d AND `url` IN ( %s ) AND `network` = 'dfrn' AND `self` = 0 AND `blocked` = 0 ",
- intval($uid),
- implode(',',$urls)
- );
- if(count($r)) {
- $ret = array();
- foreach($r as $rr)
- $ret[$rr['url']] = $rr['id'];
- return $ret;
- }
- }
- return array();
-}}
-
-if(! function_exists('item_photo_menu')){
-function item_photo_menu($item){
- $a = get_app();
-
- if (!isset($a->authors)){
- $rr = q("SELECT id, network, url FROM contact WHERE uid=%d AND self!=1", intval(local_user()));
- $authors = array();
- foreach($rr as $r) $authors[$r['url']]= $r;
- $a->authors = $authors;
- }
-
- $contact_url="";
- $pm_url="";
-
- $status_link="";
- $photo_link="";
- $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
- $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
-
- // $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;
- 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['network'] === 'dfrn' && (! $item['self'])) {
- $status_link = $redir . "?url=status";
- $profile_link = $redir . "?url=profile";
- $photos_link = $redir . "?url=photos";
- $pm_url = $a->get_baseurl() . '/message/new/' . $cid;
- }
-
- $contact_url = $item['self']?"":$a->get_baseurl() . '/contacts/' . (($item['cid']) ? $item['cid'] : $cid);
- }
-
-
- $menu = Array(
- t("View status") => $status_link,
- t("View profile") => $profile_link,
- t("View photos") => $photos_link,
- t("Edit contact") => $contact_url,
- t("Send PM") => $pm_url,
- );
-
-
- $args = array($item, &$menu);
-
- call_hooks('item_photo_menu', $args);
-
- $o = "";
- foreach($menu as $k=>$v){
- if ($v!="") $o .= "<li><a href='$v'>$k</a></li>\n";
- }
- return $o;
-}}