mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 03:15:19 +00:00
fix can_comment_on_post when viewing wall-to-wall
This commit is contained in:
parent
8fe5575469
commit
110974eb55
4 changed files with 35 additions and 15 deletions
|
@ -154,7 +154,10 @@ class Conversation extends BaseObject {
|
||||||
$item->set_commentable(false);
|
$item->set_commentable(false);
|
||||||
}
|
}
|
||||||
elseif(($this->observer) && (! $item->is_commentable())) {
|
elseif(($this->observer) && (! $item->is_commentable())) {
|
||||||
$item->set_commentable(can_comment_on_post($this->observer['xchan_hash'],$item->data));
|
if((array_key_exists('owner',$item->data)) && ($item->data['owner']['abook_flags'] & ABOOK_FLAG_SELF))
|
||||||
|
$item->set_commentable(perm_is_allowed($this->profile_owner,$this->observer['xchan_hash'],'post_comments'));
|
||||||
|
else
|
||||||
|
$item->set_commentable(can_comment_on_post($this->observer['xchan_hash'],$item->data));
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->set_conversation($this);
|
$item->set_conversation($this);
|
||||||
|
|
|
@ -83,9 +83,20 @@ function collect_recipients($item,&$private) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function can_comment_on_post($observer_xchan,$item);
|
||||||
|
*
|
||||||
|
* This function examines the comment_policy attached to an item and decides if the current observer has
|
||||||
|
* sufficient privileges to comment. This will normally be called on a remote site where perm_is_allowed()
|
||||||
|
* will not be suitable because the post owner does not have a local channel_id.
|
||||||
|
* Generally we should look at the item - in particular the author['book_flags'] and see if ABOOK_FLAG_SELF is set.
|
||||||
|
* If it is, you should be able to use perm_is_allowed( ... 'post_comments'), and if it isn't you need to call
|
||||||
|
* can_comment_on_post()
|
||||||
|
|
||||||
function can_comment_on_post($observer_xchan,$item) {
|
function can_comment_on_post($observer_xchan,$item) {
|
||||||
|
|
||||||
|
// logger('can_comment_on_post: comment_policy: ' . $item['comment_policy'], LOGGER_DEBUG);
|
||||||
|
|
||||||
if(! $observer_xchan)
|
if(! $observer_xchan)
|
||||||
return false;
|
return false;
|
||||||
if($item['comment_policy'] === 'none')
|
if($item['comment_policy'] === 'none')
|
||||||
|
@ -98,10 +109,10 @@ function can_comment_on_post($observer_xchan,$item) {
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case 'public':
|
case 'public':
|
||||||
# We don't allow public comments yet, until a policy
|
// We don't allow public comments yet, until a policy
|
||||||
# for dealing with anonymous comments is in place with
|
// for dealing with anonymous comments is in place with
|
||||||
# a means to moderate comments. Until that time, return
|
// a means to moderate comments. Until that time, return
|
||||||
# false.
|
// false.
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 'contacts':
|
case 'contacts':
|
||||||
|
|
22
mod/item.php
22
mod/item.php
|
@ -161,20 +161,26 @@ function item_post(&$a) {
|
||||||
|
|
||||||
if($parent) {
|
if($parent) {
|
||||||
logger('mod_item: item_post parent=' . $parent);
|
logger('mod_item: item_post parent=' . $parent);
|
||||||
if(! can_comment_on_post($observer['xchan_hash'],$parent_item)) {
|
$can_comment = false;
|
||||||
|
if((array_key_exists('owner',$parent_item)) && ($parent_item['owner']['abook_flags'] & ABOOK_FLAG_SELF))
|
||||||
|
$can_comment = perm_is_allowed($profile_uid,$observer['xchan_hash'],'post_comments');
|
||||||
|
else
|
||||||
|
$can_comment = can_comment_on_post($observer['xchan_hash'],$parent_item);
|
||||||
|
|
||||||
|
if(! $can_comment) {
|
||||||
notice( t('Permission denied.') . EOL) ;
|
notice( t('Permission denied.') . EOL) ;
|
||||||
if(x($_REQUEST,'return'))
|
if(x($_REQUEST,'return'))
|
||||||
goaway($a->get_baseurl() . "/" . $return_path );
|
goaway($a->get_baseurl() . "/" . $return_path );
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if(! perm_is_allowed($profile_uid,$observer['xchan_hash'],'post_wall')) {
|
||||||
if(! perm_is_allowed($profile_uid,$observer['xchan_hash'],(($parent) ? 'post_comments' : 'post_wall'))) {
|
notice( t('Permission denied.') . EOL) ;
|
||||||
notice( t('Permission denied.') . EOL) ;
|
if(x($_REQUEST,'return'))
|
||||||
if(x($_REQUEST,'return'))
|
goaway($a->get_baseurl() . "/" . $return_path );
|
||||||
goaway($a->get_baseurl() . "/" . $return_path );
|
killme();
|
||||||
killme();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
2013-09-26.448
|
2013-09-28.450
|
||||||
|
|
Loading…
Reference in a new issue