From: rabuzarus <> Date: Thu, 28 May 2015 13:54:53 +0000 (+0200) Subject: better solution to exclude Contact Photos and include count of Photos X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=415a606a59cd68d7a2c85abaf8bae14fe76dbeef;p=friendica.git better solution to exclude Contact Photos and include count of Photos --- diff --git a/mod/photos.php b/mod/photos.php index 3ae5bbf392..1bb380696a 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -38,29 +38,29 @@ function photos_init(&$a) { $sql_extra = permissions_sql($a->data['user']['uid']); - $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc", - intval($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", + intval($a->data['user']['uid']), + dbesc('Contact Photos'), + dbesc( t('Contact Photos')) ); - - $ret = array('success' => false); + $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); - foreach($albums as $k => $album) { - if( $album['album'] === 'Contact Photos') { - unset ($albums[$k]['album']); - } - } - + // 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) { - if ($albums_visible) { + $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/' . $channel['channel_address'] . '/album/' . bin2hex($album['album']), + 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), 'urlencode' => urlencode($album['album']), 'bin2hex' => bin2hex($album['album']) ); @@ -68,62 +68,27 @@ function photos_init(&$a) { } } - /*return $ret;*/ - - $o = ''; - - if(! $albums) { - if(array_key_exists('albums', get_app()->data)) - $albums = get_app()->data['albums']; - else - $albums = $ret; - } - - $albums = $ret; - + $albums = $ret; + + if(local_user() && $a->data['user']['uid'] == local_user()) + $can_post = true; if($albums['success']) { - $o = replace_macros(get_markup_template('photo_albums.tpl'),array( + $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'),array( '$nick' => $a->data['user']['nickname'], '$title' => t('Photo Albums'), '$albums' => $albums['albums'], - '$baseurl' => z_root() + '$baseurl' => z_root(), + '$upload' => array( t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)), + '$can_post' => $can_post )); } -/* if(count($albums)) { - $a->data['albums'] = $albums; - - $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); - - if($albums_visible) { - $o .= '
'; - } - * - */ if(! x($a->page,'aside')) $a->page['aside'] = ''; $a->page['aside'] .= $o; + $a->page['aside'] .= $photo_albums_widget; $tpl = get_markup_template("photos_head.tpl"); diff --git a/view/templates/photo_albums.tpl b/view/templates/photo_albums.tpl index bbbf5c4a97..de8f2cd16c 100644 --- a/view/templates/photo_albums.tpl +++ b/view/templates/photo_albums.tpl @@ -1,13 +1,17 @@