diff --git a/mod/photos.php b/mod/photos.php index cf924f399..8d13f859a 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1054,8 +1054,13 @@ function photos_content(&$a) { $a->set_pager_itemspage(20); } + if($_GET['order'] === 'posted') + $order = 'ASC'; + else + $order = 'DESC'; + $r = q("SELECT `resource-id`, `id`, `filename`, type, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s' - AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", + AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` $order LIMIT %d , %d", intval($owner_uid), dbesc($album), intval($a->pager['start']), @@ -1089,10 +1094,17 @@ function photos_content(&$a) { } } + if($_GET['order'] === 'posted') + $o .= '
'; + else + $o .= ''; + + if($can_post) { $o .= ''; } + $tpl = get_markup_template('photo_album.tpl'); if(count($r)) $twist = 'rotright'; @@ -1107,7 +1119,8 @@ function photos_content(&$a) { $o .= replace_macros($tpl,array( '$id' => $rr['id'], '$twist' => ' ' . $twist . rand(2,4), - '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'], + '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'] + . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''), '$phototitle' => t('View Photo'), '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext, '$imgalt' => template_escape($rr['filename']), @@ -1152,8 +1165,14 @@ function photos_content(&$a) { $prevlink = ''; $nextlink = ''; + if($_GET['order'] === 'posted') + $order = 'ASC'; + else + $order = 'DESC'; + + $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0 - $sql_extra ORDER BY `created` DESC ", + $sql_extra ORDER BY `created` $order ", dbesc($ph[0]['album']), intval($owner_uid) ); @@ -1171,8 +1190,8 @@ function photos_content(&$a) { } } $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : ''); - $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix; - $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix; + $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); }