diff options
author | habeascodice <habeascodice@federated.social> | 2014-11-01 03:04:11 -0700 |
---|---|---|
committer | habeascodice <habeascodice@federated.social> | 2014-11-01 03:04:11 -0700 |
commit | 31376de0665091f2dba04755562ccd238d57a13c (patch) | |
tree | ae59c8697b9fd20c33aeaf8acb3a698b63e9657b /mod/photos.php | |
parent | c854f8c238da2df08b52249142ad24ef66e422d1 (diff) | |
parent | 50c16c394fe2d966c62d30930600212a4e33303e (diff) | |
download | volse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.tar.gz volse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.tar.bz2 volse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'mod/photos.php')
-rw-r--r-- | mod/photos.php | 216 |
1 files changed, 111 insertions, 105 deletions
diff --git a/mod/photos.php b/mod/photos.php index dc593f22b..d1f2b4993 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -319,6 +319,7 @@ function photos_post(&$a) { $old_inform = $r[0]['inform']; } + // make sure the linked item has the same permissions as the photo regardless of any other changes $x = q("update item set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d where id = %d limit 1", @@ -380,6 +381,7 @@ function photos_post(&$a) { if($success['replaced']) { $tagged[] = $tag; + $post_tags[] = array( 'uid' => $a->profile['profile_uid'], 'type' => $success['termtype'], @@ -397,8 +399,14 @@ function photos_post(&$a) { ); if($r) { + $r = fetch_post_tags($r,true); $datarray = $r[0]; - $datarray['term'] = $post_tags; + if($post_tags) { + if((! array_key_exists('term',$datarray)) || (! is_array($datarray['term']))) + $datarray['term'] = $post_tags; + else + $datarray['term'] = array_merge($datarray['term'],$post_tags); + } item_store_update($datarray,$execflag); } @@ -468,11 +476,9 @@ function photos_content(&$a) { if(argc() > 3) { $datatype = argv(2); $datum = argv(3); - } - elseif((argc() > 2) && (argv(2) === 'upload')) - $datatype = 'upload'; - else + } else { $datatype = 'summary'; + } if(argc() > 4) $cmd = argv(4); @@ -495,7 +501,6 @@ function photos_content(&$a) { $can_post = perm_is_allowed($owner_uid,$observer['xchan_hash'],'post_photos'); $can_view = perm_is_allowed($owner_uid,$observer['xchan_hash'],'view_photos'); - if(! $can_view) { notice( t('Access to this item is restricted.') . EOL); return; @@ -521,34 +526,7 @@ function photos_content(&$a) { * Display upload form */ - if($datatype === 'upload') { - if(! ($can_post)) { - notice( t('Permission denied.')); - return; - } - - - - if(array_key_exists('albums', $a->data)) - $albums = get_app()->data['albums']; - else - $albums = photos_albums_list($a->data['channel'],$a->data['observer']); - - - $selname = (($datum) ? hex2bin($datum) : ''); - $albumselect = '<select id="photos-upload-album-select" name="album" size="4">'; - - $albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '> </option>'; - if(count($albums['albums'])) { - foreach($albums['albums'] as $album) { - if(! $album['text']) - continue; - $selected = (($selname === $album['text']) ? ' selected="selected" ' : ''); - $albumselect .= '<option value="' . $album['text'] . '"' . $selected . '>' . $album['text'] . '</option>'; - } - } - - $albumselect .= '</select>'; + if( $can_post) { $uploader = ''; @@ -556,12 +534,8 @@ function photos_content(&$a) { 'addon_text' => $uploader, 'default_upload' => true); - call_hooks('photo_upload_form',$ret); - $default_upload = '<input id="photos-upload-choose" type="file" name="userfile" /> <div class="photos-upload-submit-wrapper" > - <input type="submit" name="submit" value="' . t('Submit') . '" id="photos-upload-submit" /> </div>'; - /* Show space usage */ $r = q("select sum(size) as total from photo where aid = %d and scale = 0 ", @@ -571,10 +545,10 @@ function photos_content(&$a) { $limit = service_class_fetch($a->data['channel']['channel_id'],'photo_upload_limit'); if($limit !== false) { - $usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 ); + $usage_message = sprintf( t("%1$.2f MB of %2$.2f MB photo storage used."), $r[0]['total'] / 1024000, $limit / 1024000 ); } else { - $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 ); + $usage_message = sprintf( t('%1$.2f MB photo storage used.'), $r[0]['total'] / 1024000 ); } if($_is_owner) { @@ -588,28 +562,32 @@ function photos_content(&$a) { ); } - $albumselect_e = $albumselect; $aclselect_e = (($_is_owner) ? populate_acl($channel_acl,false) : ''); + $selname = (($datum) ? hex2bin($datum) : ''); + + $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer'])); + $tpl = get_markup_template('photos_upload.tpl'); - $o .= replace_macros($tpl,array( + $upload_form = replace_macros($tpl,array( '$pagename' => t('Upload Photos'), '$sessid' => session_id(), '$usage' => $usage_message, '$nickname' => $a->data['channel']['channel_address'], - '$newalbum' => t('New album name: '), - '$existalbumtext' => t('or existing album name: '), + '$newalbum_label' => t('Enter a new album name'), + '$newalbum_placeholder' => t('or select an existing one (doubleclick)'), '$nosharetext' => t('Do not show a status post for this upload'), - '$albumselect' => $albumselect_e, + '$albums' => $albums['albums'], + '$selname' => $selname, '$permissions' => t('Permissions'), '$aclselect' => $aclselect_e, '$uploader' => $ret['addon_text'], - '$default' => (($ret['default_upload']) ? $default_upload : ''), - '$uploadurl' => $ret['post_url'] + '$default' => (($ret['default_upload']) ? true : false), + '$uploadurl' => $ret['post_url'], + '$submit' => t('Submit') )); - return $o; } /* @@ -653,33 +631,27 @@ function photos_content(&$a) { intval($a->pager['itemspage']) ); - if($cmd === 'edit') { - if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { - if($can_post) { - if($a->get_template_engine() === 'internal') { - $album_e = template_escape($album); - } - else { - $album_e = $album; - } - - $edit_tpl = get_markup_template('album_edit.tpl'); - $o .= replace_macros($edit_tpl,array( - '$nametext' => t('New album name: '), - '$nickname' => $a->data['channel']['channel_address'], - '$album' => $album_e, - '$hexalbum' => bin2hex($album), - '$submit' => t('Submit'), - '$dropsubmit' => t('Delete Album') - )); + //edit album name + $album_edit = null; + if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { + if($can_post) { + if($a->get_template_engine() === 'internal') { + $album_e = template_escape($album); } - } - } - else { - if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { - if($can_post) { - $edit = array(t('Edit Album'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '/edit'); - } + else { + $album_e = $album; + } + $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer'])); + $edit_tpl = get_markup_template('album_edit.tpl'); + $album_edit = replace_macros($edit_tpl,array( + '$nametext' => t('New album name: '), + '$nickname' => $a->data['channel']['channel_address'], + '$album' => $album_e, + '$albums' => $albums['albums'], + '$hexalbum' => bin2hex($album), + '$submit' => t('Submit'), + '$dropsubmit' => t('Delete Album') + )); } } @@ -719,6 +691,7 @@ function photos_content(&$a) { 'desc'=> $desc_e, 'ext' => $ext, 'hash'=> $rr['resource_id'], + 'unknown' => t('Unknown') ); } } @@ -741,10 +714,12 @@ function photos_content(&$a) { $o .= replace_macros($tpl, array( '$photos' => $photos, '$album' => $album, + '$album_edit' => array(t('Edit Album'), $album_edit), '$can_post' => $can_post, '$upload' => array(t('Upload'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album)), '$order' => $order, - '$edit' => $edit + '$upload_form' => $upload_form, + '$usage' => $usage_message )); } @@ -855,16 +830,14 @@ function photos_content(&$a) { $tools = array( 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')), ); - - // lock - $lock = ( ( ($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) - || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) ) - ? t('Private Message') - : Null); - - } + // lock + $lock = ( ( (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) + || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) ) + ? t('Private Photo') + : Null); + $a->page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n"; if($prevlink) $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n"; @@ -873,7 +846,7 @@ function photos_content(&$a) { $a->page['htmlhead'] .= '});</script>'; if($prevlink) - $prevlink = array($prevlink, '<i class="icon-backward photo-icons""></i>') ; + $prevlink = array($prevlink, t('Previous')); $photo = array( 'href' => $a->get_baseurl() . '/photo/' . $hires['resource_id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], @@ -882,7 +855,7 @@ function photos_content(&$a) { ); if($nextlink) - $nextlink = array($nextlink, '<i class="icon-forward photo-icons"></i>'); + $nextlink = array($nextlink, t('Next')); // Do we have an item for this photo? @@ -912,21 +885,19 @@ function photos_content(&$a) { $r = conv_sort($r,'commented'); } - - $tags = array(); if($link_item['term']) { $cnt = 0; - foreach($link_item['term'] as $t) + foreach($link_item['term'] as $t) { $tags[$cnt] = array(0 => format_term_for_display($t)); if($can_post && ($ph[0]['uid'] == $owner_uid)) { - $tags[$cnt][1] = 'tagrm?f=&item=' . $link_item['id']; + $tags[$cnt][1] = 'tagrm/drop/' . $link_item['id'] . '/' . bin2hex($t['term']); //?f=&item=' . $link_item['id']; $tags[$cnt][2] = t('Remove'); } $cnt ++; + } } - if((local_user()) && (local_user() == $link_item['uid'])) { q("UPDATE `item` SET item_flags = (item_flags ^ %d) WHERE parent = %d and uid = %d and (item_flags & %d)", intval(ITEM_UNSEEN), @@ -945,18 +916,14 @@ function photos_content(&$a) { $edit = null; if($can_post) { - if(array_key_exists('albums', $a->data)) - $albums = get_app()->data['albums']; - else - $albums = photos_albums_list($a->data['channel'],$a->data['observer']); - $album_e = $ph[0]['album']; $caption_e = $ph[0]['description']; $aclselect_e = populate_acl($ph[0]); + $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer'])); $edit = array( 'edit' => t('Edit photo'), - 'id' => $ph[0]['id'], + 'id' => $link_item['id'], 'rotatecw' => t('Rotate CW (right)'), 'rotateccw' => t('Rotate CCW (left)'), 'albums' => $albums['albums'], @@ -969,7 +936,7 @@ function photos_content(&$a) { 'tag_label' => t('Add a Tag'), 'permissions' => t('Permissions'), 'aclselect' => $aclselect_e, - 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'), + 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'), 'item_id' => ((count($linked_items)) ? $link_item['id'] : 0), 'submit' => t('Submit'), 'delete' => t('Delete Photo') @@ -999,7 +966,7 @@ function photos_content(&$a) { $comments = ''; if(! count($r)) { if($can_post || $can_comment) { - $comments .= replace_macros($cmnt_tpl,array( + $commentbox = replace_macros($cmnt_tpl,array( '$return_path' => '', '$mode' => 'photos', '$jsreload' => $return_url, @@ -1025,7 +992,7 @@ function photos_content(&$a) { $like = ''; $dislike = ''; - // display comments + if($r) { foreach($r as $item) { @@ -1033,10 +1000,33 @@ function photos_content(&$a) { like_puller($a,$item,$dlike,'dislike'); } - $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : ''); - $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : ''); + $like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : ''); + $like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : ''); + if (count($like_list) > MAX_LIKERS) { + $like_list_part = array_slice($like_list, 0, MAX_LIKERS); + array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>'); + } else { + $like_list_part = ''; + } + $like_button_label = tt('Like','Likes',$like_count,'noun'); + + //if (feature_enabled($conv->get_profile_owner(),'dislike')) { + $dislike_count = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid']] : ''); + $dislike_list = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid'] . '-l'] : ''); + $dislike_button_label = tt('Dislike','Dislikes',$dislike_count,'noun'); + if (count($dislike_list) > MAX_LIKERS) { + $dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS); + array_push($dislike_list_part, '<a href="#" data-toggle="modal" data-target="#dislikeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>'); + } else { + $dislike_list_part = ''; + } + //} + + $like = ((isset($alike[$link_item['mid']])) ? format_like($alike[$link_item['mid']],$alike[$link_item['mid'] . '-l'],'like',$link_item['mid']) : ''); + $dislike = ((isset($dlike[$link_item['mid']])) ? format_like($dlike[$link_item['mid']],$dlike[$link_item['mid'] . '-l'],'dislike',$link_item['mid']) : ''); + // display comments foreach($r as $item) { $comment = ''; @@ -1070,7 +1060,7 @@ function photos_content(&$a) { $body_e = prepare_text($item['body'],$item['mimetype']); $comments .= replace_macros($template,array( - '$id' => $item['item_id'], + '$id' => $item['id'], '$mode' => 'photos', '$profile_url' => $profile_link, '$name' => $name_e, @@ -1079,7 +1069,7 @@ function photos_content(&$a) { '$title' => $title_e, '$body' => $body_e, '$ago' => relative_date($item['created']), - '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''), + '$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''), '$drop' => $drop, '$comment' => $comment )); @@ -1087,7 +1077,7 @@ function photos_content(&$a) { } if($can_post || $can_comment) { - $comments .= replace_macros($cmnt_tpl,array( + $commentbox = replace_macros($cmnt_tpl,array( '$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', @@ -1114,7 +1104,7 @@ function photos_content(&$a) { $photo_tpl = get_markup_template('photo_view.tpl'); $o .= replace_macros($photo_tpl, array( - '$id' => $ph[0]['id'], + '$id' => $link_item['id'], //$ph[0]['id'], '$album' => $album_e, '$tools' => $tools, '$lock' => $lock, @@ -1122,13 +1112,27 @@ function photos_content(&$a) { '$prevlink' => $prevlink, '$nextlink' => $nextlink, '$desc' => $ph[0]['description'], + '$filename' => $ph[0]['filename'], + '$unknown' => t('Unknown'), '$tag_hdr' => t('In This Photo:'), '$tags' => $tags, '$edit' => $edit, '$likebuttons' => $likebuttons, '$like' => $like_e, '$dislike' => $dislike_e, + '$like_count' => $like_count, + '$like_list' => $like_list, + '$like_list_part' => $like_list_part, + '$like_button_label' => $like_button_label, + '$like_modal_title' => t('Likes','noun'), + '$dislike_modal_title' => t('Dislikes','noun'), + '$dislike_count' => $dislike_count, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_count : ''), + '$dislike_list' => $dislike_list, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list : ''), + '$dislike_list_part' => $dislike_list_part, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list_part : ''), + '$dislike_button_label' => $dislike_button_label, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_button_label : ''), + '$modal_dismiss' => t('Close'), '$comments' => $comments, + '$commentbox' => $commentbox, '$paginate' => $paginate, )); @@ -1224,6 +1228,8 @@ function photos_content(&$a) { '$can_post' => $can_post, '$upload' => array(t('Upload'), $a->get_baseurl().'/photos/'.$a->data['channel']['channel_address'].'/upload'), '$photos' => $photos, + '$upload_form' => $upload_form, + '$usage' => $usage_message )); } |