From da05b9736ec0f2712d1a6828ff819aa12dd9e391 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 2 Jul 2013 16:37:33 -0700 Subject: some work on issue #62 (comments collapsing on liveupdate), but still a work in progress some work on photo consolidated "view/edit", but still a work in progress --- mod/photos.php | 134 ++++++++++++++++++++++++--------------------------------- 1 file changed, 57 insertions(+), 77 deletions(-) (limited to 'mod') diff --git a/mod/photos.php b/mod/photos.php index 65bf866f1..f0b2b882e 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -633,6 +633,9 @@ function photos_content(&$a) { // dispatch request // + /** + * Display upload form + */ if($datatype === 'upload') { if(! ($can_post)) { @@ -640,12 +643,8 @@ function photos_content(&$a) { return; } - $selname = (($datum) ? hex2bin($datum) : ''); - - $albumselect = '
'; + /* Show space usage */ $r = q("select sum(size) as total from photo where uid = %d and scale = 0 ", intval($a->data['channel']['channel_id']) @@ -687,15 +687,8 @@ function photos_content(&$a) { $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 ); } - - if($a->get_template_engine() === 'internal') { - $albumselect_e = template_escape($albumselect); - $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))); - } - else { - $albumselect_e = $albumselect; - $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); - } + $albumselect_e = $albumselect; + $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); $tpl = get_markup_template('photos_upload.tpl'); $o .= replace_macros($tpl,array( @@ -718,6 +711,10 @@ function photos_content(&$a) { return $o; } + /* + * Display a single photo album + */ + if($datatype === 'album') { $album = hex2bin($datum); @@ -793,6 +790,7 @@ function photos_content(&$a) { if(count($r)) $twist = 'rotright'; foreach($r as $rr) { + if($twist == 'rotright') $twist = 'rotleft'; else @@ -839,12 +837,12 @@ function photos_content(&$a) { } + /** + * Display one photo + */ if($datatype === 'image') { - - - //$o = ''; // fetch image, item containing image, then comments $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' @@ -853,13 +851,16 @@ function photos_content(&$a) { dbesc($datum) ); - if(! count($ph)) { + if(! $ph) { + + /* Check again - this time without specifying permissions */ + $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' LIMIT 1", intval($owner_uid), dbesc($datum) ); - if(count($ph)) + if($ph) notice( t('Permission denied. Access to this item may be restricted.')); else notice( t('Photo not available') . EOL ); @@ -893,9 +894,9 @@ function photos_content(&$a) { break; } } - $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : ''); - $prevlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); - $nextlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + + $prevlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + $nextlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); } @@ -918,7 +919,6 @@ function photos_content(&$a) { if($can_post && ($ph[0]['uid'] == $owner_uid)) { $tools = array( - 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')), ); @@ -931,7 +931,7 @@ function photos_content(&$a) { } - if(! $cmd !== 'edit') { + if(! $can_post) { $a->page['htmlhead'] .= '