possible fixes for can_comment_on_post(), provide wiki_list on wiki sidebar
This commit is contained in:
parent
f4f610f1a3
commit
f230c07ba5
@ -196,7 +196,6 @@ class ThreadStream {
|
|||||||
$item->set_commentable(false);
|
$item->set_commentable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('include/channel.php');
|
|
||||||
|
|
||||||
$item->set_conversation($this);
|
$item->set_conversation($this);
|
||||||
$this->threads[] = $item;
|
$this->threads[] = $item;
|
||||||
|
@ -6,13 +6,17 @@ class Wiki_list {
|
|||||||
|
|
||||||
function widget($arr) {
|
function widget($arr) {
|
||||||
|
|
||||||
|
if(argc() < 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$channel = channelx_by_n(\App::$profile_uid);
|
$channel = channelx_by_n(\App::$profile_uid);
|
||||||
|
|
||||||
$wikis = \Zotlabs\Lib\NativeWiki::listwikis($channel,get_observer_hash());
|
$wikis = \Zotlabs\Lib\NativeWiki::listwikis($channel,get_observer_hash());
|
||||||
|
|
||||||
if($wikis) {
|
if($wikis) {
|
||||||
return replace_macros(get_markup_template('wikilist_widget.tpl'), array(
|
return replace_macros(get_markup_template('wikilist_widget.tpl'), array(
|
||||||
'$header' => t('Wiki List'),
|
'$header' => t('Wikis'),
|
||||||
'$channel' => $channel['channel_address'],
|
'$channel' => $channel['channel_address'],
|
||||||
'$wikis' => $wikis['wikis']
|
'$wikis' => $wikis['wikis']
|
||||||
));
|
));
|
||||||
|
@ -234,10 +234,11 @@ function can_comment_on_post($observer_xchan, $item) {
|
|||||||
// logger('Comment_policy: ' . $item['comment_policy'], LOGGER_DEBUG);
|
// logger('Comment_policy: ' . $item['comment_policy'], LOGGER_DEBUG);
|
||||||
|
|
||||||
$x = [
|
$x = [
|
||||||
'observer_hash' => $observer_xchan,
|
'observer_hash' => $observer_xchan,
|
||||||
'item' => $item,
|
'item' => $item,
|
||||||
'allowed' => 'unset'
|
'allowed' => 'unset'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hooks can_comment_on_post
|
* @hooks can_comment_on_post
|
||||||
* Called when deciding whether or not to present a comment box for a post.
|
* Called when deciding whether or not to present a comment box for a post.
|
||||||
@ -245,26 +246,34 @@ function can_comment_on_post($observer_xchan, $item) {
|
|||||||
* * \e array \b item
|
* * \e array \b item
|
||||||
* * \e boolean \b allowed - return value
|
* * \e boolean \b allowed - return value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
call_hooks('can_comment_on_post', $x);
|
call_hooks('can_comment_on_post', $x);
|
||||||
if($x['allowed'] !== 'unset')
|
|
||||||
|
if($x['allowed'] !== 'unset') {
|
||||||
return $x['allowed'];
|
return $x['allowed'];
|
||||||
|
}
|
||||||
|
|
||||||
if(! $observer_xchan)
|
if(! $observer_xchan) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if($item['comment_policy'] === 'none')
|
if($item['comment_policy'] === 'none') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(comments_are_now_closed($item))
|
if(comments_are_now_closed($item)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if($observer_xchan === $item['author_xchan'] || $observer_xchan === $item['owner_xchan'])
|
if($observer_xchan === $item['author_xchan'] || $observer_xchan === $item['owner_xchan']) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch($item['comment_policy']) {
|
switch($item['comment_policy']) {
|
||||||
case 'self':
|
case 'self':
|
||||||
if($observer_xchan === $item['author_xchan'] || $observer_xchan === $item['owner_xchan'])
|
if($observer_xchan === $item['author_xchan'] || $observer_xchan === $item['owner_xchan']) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'public':
|
case 'public':
|
||||||
case 'authenticated':
|
case 'authenticated':
|
||||||
@ -276,17 +285,22 @@ function can_comment_on_post($observer_xchan, $item) {
|
|||||||
case 'any connections':
|
case 'any connections':
|
||||||
case 'contacts':
|
case 'contacts':
|
||||||
case '':
|
case '':
|
||||||
if(array_key_exists('owner',$item) && get_abconfig($item['uid'],$item['owner']['abook_xchan'],'their_perms','post_comments')) {
|
if(local_channel() && get_abconfig(local_channel(),$item['owner_xchan'],'their_perms','post_comments')) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
if(intval($item['item_wall']) && perm_is_allowed($item['uid'],$observer_xchan,'post_comments')) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'red'))
|
if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'red')) {
|
||||||
return true;
|
return true;
|
||||||
if(strstr($item['comment_policy'],'site:') && strstr($item['comment_policy'],App::get_hostname()))
|
}
|
||||||
|
if(strstr($item['comment_policy'],'site:') && strstr($item['comment_policy'],App::get_hostname())) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
[region=aside]
|
[region=aside]
|
||||||
[widget=vcard][/widget]
|
[widget=vcard][/widget]
|
||||||
|
[widget=wiki_list][/widget]
|
||||||
[widget=wiki_pages][/widget]
|
[widget=wiki_pages][/widget]
|
||||||
[/region]
|
[/region]
|
||||||
[region=right_aside]
|
[region=right_aside]
|
||||||
|
Reference in New Issue
Block a user