From 3e6088c6142d1dabbfdbb8b5df276ae942bd3554 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 27 Mar 2017 15:49:48 -0700 Subject: add 'author_is_pmable()' function with plugin hooks to control whether or not to display a 'send mail' link in the thread author menu. --- include/conversation.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'include/conversation.php') diff --git a/include/conversation.php b/include/conversation.php index b4f959afa..5b2d60583 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -917,6 +917,24 @@ function thread_action_menu($item,$mode = '') { } +function author_is_pmable($xchan) { + + $x = [ 'xchan' => $xchan, 'result' => 'unset' ]; + call_hooks('author_is_pmable',$x); + if($x['result'] !== 'unset') + return $x['result']; + + if($xchan['xchan_network'] === 'zot') + return true; + return false; + +} + + + + + + function thread_author_menu($item, $mode = '') { $menu = []; @@ -932,8 +950,6 @@ function thread_author_menu($item, $mode = '') { $profile_link = chanlink_hash($item['author_xchan']); - if($item['uid'] > 0) - $pm_url = z_root() . '/mail/new/?f=&hash=' . urlencode($item['author_xchan']); if(App::$contacts && array_key_exists($item['author_xchan'],App::$contacts)) $contact = App::$contacts[$item['author_xchan']]; @@ -941,6 +957,12 @@ function thread_author_menu($item, $mode = '') { if($local_channel && $item['author']['xchan_addr']) $follow_url = z_root() . '/follow/?f=&url=' . urlencode($item['author']['xchan_addr']); + + if($item['uid'] > 0 && author_is_pmable($item['author'])) + $pm_url = z_root() . '/mail/new/?f=&hash=' . urlencode($item['author_xchan']); + + + if($contact) { $poke_link = z_root() . '/poke/?f=&c=' . $contact['abook_id']; if (! intval($contact['abook_self'])) -- cgit v1.2.3