X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphotos.php;h=6d147a6f55a694f9696650828a2cbb0730ebd5ad;hb=389b7de451eb8e684b48e2c96598f1d12c1465d9;hp=3ed8e9984c315f0e20deb4a42ff5b04fcb637db4;hpb=a982320ba902edc11e8cd16e08b3c2d3f0eb6946;p=friendica.git diff --git a/mod/photos.php b/mod/photos.php index 3ed8e9984c..6d147a6f55 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -17,6 +17,8 @@ function photos_init(&$a) { return; } + nav_set_selected('home'); + $o = ''; if($a->argc > 1) { @@ -29,71 +31,76 @@ function photos_init(&$a) { return; $a->data['user'] = $r[0]; + $a->profile_uid = $r[0]['uid']; + $is_owner = (local_user() && (local_user() == $a->profile_uid)); - $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg'); + $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg'); - $tpl = get_markup_template("vcard-widget.tpl"); + $tpl = get_markup_template("vcard-widget.tpl"); $vcard_widget .= replace_macros($tpl, array( - '$name' => $a->data['user']['username'], - '$photo' => $profilephoto - )); + '$name' => $a->data['user']['username'], + '$photo' => $profilephoto + )); $sql_extra = permissions_sql($a->data['user']['uid']); $albums = q("SELECT count(distinct `resource-id`) AS `total`, `album` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' - $sql_extra group by album order by created desc", + $sql_extra group by album order by created desc", intval($a->data['user']['uid']), - dbesc('Contact Photos'), - dbesc( t('Contact Photos')) + dbesc('Contact Photos'), + dbesc( t('Contact Photos')) ); - $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); - - // add various encodings to the array so we can just loop through and pick them out in a template - $ret = array('success' => false); - - if($albums) { - $a->data['albums'] = $albums; - if ($albums_visible) - $ret['success'] = true; - - $ret['albums'] = array(); - foreach($albums as $k => $album) { - $entry = array( - 'text' => $album['album'], - 'total' => $album['total'], - 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), - 'urlencode' => urlencode($album['album']), - 'bin2hex' => bin2hex($album['album']) - ); - $ret['albums'][] = $entry; - } - } - - $albums = $ret; - - if(local_user() && $a->data['user']['uid'] == local_user()) - $can_post = true; - - if($albums['success']) { - $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'),array( - '$nick' => $a->data['user']['nickname'], - '$title' => t('Photo Albums'), - 'recent' => t('Recent Photos'), - '$albums' => $albums['albums'], - '$baseurl' => z_root(), - '$upload' => array( t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload'), - '$can_post' => $can_post - )); - } + $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); + + // add various encodings to the array so we can just loop through and pick them out in a template + $ret = array('success' => false); + + if($albums) { + $a->data['albums'] = $albums; + if ($albums_visible) + $ret['success'] = true; + + $ret['albums'] = array(); + foreach($albums as $k => $album) { + //hide profile photos to others + if((! $is_owner) && (! remote_user()) && ($album['album'] == t('Profile Photos'))) + continue; + $entry = array( + 'text' => $album['album'], + 'total' => $album['total'], + 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), + 'urlencode' => urlencode($album['album']), + 'bin2hex' => bin2hex($album['album']) + ); + $ret['albums'][] = $entry; + } + } + + $albums = $ret; + + if(local_user() && $a->data['user']['uid'] == local_user()) + $can_post = true; + + if($albums['success']) { + $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'),array( + '$nick' => $a->data['user']['nickname'], + '$title' => t('Photo Albums'), + 'recent' => t('Recent Photos'), + '$albums' => $albums['albums'], + '$baseurl' => z_root(), + '$upload' => array( t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload'), + '$can_post' => $can_post + )); + } if(! x($a->page,'aside')) $a->page['aside'] = ''; - $a->page['aside'] .= $vcard_widget; - $a->page['aside'] .= $photo_albums_widget; + $a->page['aside'] .= $vcard_widget; + $a->page['aside'] .= $photo_albums_widget; $tpl = get_markup_template("photos_head.tpl"); @@ -533,12 +540,12 @@ function photos_post(&$a) { if(count($links)) { foreach($links as $link) { if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') - $profile = $link['@attributes']['href']; + $profile = $link['@attributes']['href']; if($link['@attributes']['rel'] === 'salmon') { $salmon = '$url:' . str_replace(',','%sc',$link['@attributes']['href']); if(strlen($inform)) $inform .= ','; - $inform .= $salmon; + $inform .= $salmon; } } } @@ -1058,8 +1065,8 @@ function photos_content(&$a) { $o = ""; // tabs - $_is_owner = (local_user() && (local_user() == $owner_uid)); - $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']); + $is_owner = (local_user() && (local_user() == $owner_uid)); + $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']); // // dispatch request @@ -1089,8 +1096,6 @@ function photos_content(&$a) { } } - $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); - $uploader = ''; $ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'], @@ -1139,11 +1144,11 @@ function photos_content(&$a) { if($a->theme['template_engine'] === 'internal') { $albumselect_e = template_escape($albumselect); - $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))); + $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user))); } else { $albumselect_e = $albumselect; - $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); + $aclselect_e = (($visitor) ? '' : populate_acl($a->user)); } $o .= replace_macros($tpl,array( @@ -1800,6 +1805,10 @@ function photos_content(&$a) { if(count($r)) { $twist = 'rotright'; foreach($r as $rr) { + //hide profile photos to others + if((! $is_owner) && (! remote_user()) && ($rr['album'] == t('Profile Photos'))) + continue; + if($twist == 'rotright') $twist = 'rotleft'; else @@ -1816,8 +1825,8 @@ function photos_content(&$a) { } $photos[] = array( - 'id' => $rr['id'], - 'twist' => ' ' . $twist . rand(2,4), + 'id' => $rr['id'], + 'twist' => ' ' . $twist . rand(2,4), 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'], 'title' => t('View Photo'), 'src' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,