Another stab at cleaning up the photos module. This should make permissions behave a bit better and show the "this is you" photo for commenting and get rid of most of the old "visitor and "contact" cruft.
This commit is contained in:
parent
f371e3ce8c
commit
3fa6737726
@ -616,36 +616,28 @@ function photos_content(&$a) {
|
|||||||
|
|
||||||
$can_post = false;
|
$can_post = false;
|
||||||
$visitor = 0;
|
$visitor = 0;
|
||||||
$contact = null;
|
|
||||||
$remote_contact = false;
|
|
||||||
$contact_id = 0;
|
|
||||||
|
|
||||||
$owner_uid = $a->data['channel']['channel_id'];
|
$owner_uid = $a->data['channel']['channel_id'];
|
||||||
$owner_aid = $a->data['channel']['channel_account_id'];
|
$owner_aid = $a->data['channel']['channel_account_id'];
|
||||||
|
|
||||||
$community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
|
$observer = $a->get_observer();
|
||||||
|
|
||||||
if((local_user()) && (local_user() == $owner_uid))
|
$can_post = perm_is_allowed($owner_uid,$observer['xchan_hash'],'post_photos');
|
||||||
$can_post = true;
|
$can_view = perm_is_allowed($owner_uid,$observer['xchan_hash'],'view_photos');
|
||||||
|
|
||||||
// FIXME
|
|
||||||
if(! $remote_contact) {
|
|
||||||
if(local_user()) {
|
|
||||||
$contact_id = $_SESSION['cid'];
|
|
||||||
$contact = $a->contact;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
|
if(! $can_view) {
|
||||||
notice( t('Access to this item is restricted.') . EOL);
|
notice( t('Access to this item is restricted.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
|
$sql_extra = permissions_sql($owner_uid);
|
||||||
|
|
||||||
$o = "";
|
$o = "";
|
||||||
|
|
||||||
// tabs
|
// tabs
|
||||||
|
|
||||||
$_is_owner = (local_user() && (local_user() == $owner_uid));
|
$_is_owner = (local_user() && (local_user() == $owner_uid));
|
||||||
$o .= profile_tabs($a,$_is_owner, $a->data['channel']['channel_address']);
|
$o .= profile_tabs($a,$_is_owner, $a->data['channel']['channel_address']);
|
||||||
|
|
||||||
@ -708,7 +700,7 @@ function photos_content(&$a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$albumselect_e = $albumselect;
|
$albumselect_e = $albumselect;
|
||||||
$aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb));
|
$aclselect_e = (($_is_owner) ? populate_acl($a->get_channel(), false) : '');
|
||||||
|
|
||||||
$tpl = get_markup_template('photos_upload.tpl');
|
$tpl = get_markup_template('photos_upload.tpl');
|
||||||
$o .= replace_macros($tpl,array(
|
$o .= replace_macros($tpl,array(
|
||||||
@ -963,16 +955,12 @@ function photos_content(&$a) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $can_post) {
|
$a->page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n";
|
||||||
$a->page['htmlhead'] .= '<script>
|
if($prevlink)
|
||||||
$(document).keydown(function(event) {' . "\n";
|
$a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
|
||||||
|
if($nextlink)
|
||||||
if($prevlink)
|
$a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
|
||||||
$a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
|
$a->page['htmlhead'] .= '});</script>';
|
||||||
if($nextlink)
|
|
||||||
$a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
|
|
||||||
$a->page['htmlhead'] .= '});</script>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if($prevlink)
|
if($prevlink)
|
||||||
$prevlink = array($prevlink, '<i class="icon-backward photo-icons""></i>') ;
|
$prevlink = array($prevlink, '<i class="icon-backward photo-icons""></i>') ;
|
||||||
@ -1085,9 +1073,9 @@ function photos_content(&$a) {
|
|||||||
'$id' => $link_item['id'],
|
'$id' => $link_item['id'],
|
||||||
'$parent' => $link_item['id'],
|
'$parent' => $link_item['id'],
|
||||||
'$profile_uid' => $owner_uid,
|
'$profile_uid' => $owner_uid,
|
||||||
'$mylink' => $contact['url'],
|
'$mylink' => $observer['xchan_url'],
|
||||||
'$mytitle' => t('This is you'),
|
'$mytitle' => t('This is you'),
|
||||||
'$myphoto' => $contact['thumb'],
|
'$myphoto' => $observer['xchan_photo_s'],
|
||||||
'$comment' => t('Comment'),
|
'$comment' => t('Comment'),
|
||||||
'$submit' => t('Submit'),
|
'$submit' => t('Submit'),
|
||||||
'$preview' => t('Preview'),
|
'$preview' => t('Preview'),
|
||||||
@ -1137,7 +1125,7 @@ function photos_content(&$a) {
|
|||||||
|
|
||||||
$drop = '';
|
$drop = '';
|
||||||
|
|
||||||
if(($item['contact-id'] == $contact_id) || ($item['uid'] == local_user()))
|
if($observer['xchan_hash'] === $item['author_xchan'] || $observer['xchan_hash'] === $item['owner_xchan'])
|
||||||
$drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
|
$drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
|
||||||
|
|
||||||
|
|
||||||
@ -1171,9 +1159,9 @@ function photos_content(&$a) {
|
|||||||
'$id' => $link_item['id'],
|
'$id' => $link_item['id'],
|
||||||
'$parent' => $link_item['id'],
|
'$parent' => $link_item['id'],
|
||||||
'$profile_uid' => $owner_uid,
|
'$profile_uid' => $owner_uid,
|
||||||
'$mylink' => $contact['url'],
|
'$mylink' => $observer['xchan_url'],
|
||||||
'$mytitle' => t('This is you'),
|
'$mytitle' => t('This is you'),
|
||||||
'$myphoto' => $contact['thumb'],
|
'$myphoto' => $observer['xchan_photo_s'],
|
||||||
'$comment' => t('Comment'),
|
'$comment' => t('Comment'),
|
||||||
'$submit' => t('Submit'),
|
'$submit' => t('Submit'),
|
||||||
'$ww' => ''
|
'$ww' => ''
|
||||||
|
Reference in New Issue
Block a user