add 'author_is_pmable()' function with plugin hooks to control whether or not to display a 'send mail' link in the thread author menu.
This commit is contained in:
		
							
								
								
									
										14
									
								
								doc/hook/author_is_pmable.bb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								doc/hook/author_is_pmable.bb
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| [h2]author_is_pmable[/h2] | ||||
|  | ||||
| Called from thread action menu before returning a 'send mail' link for the post author. Not all authors will be able to receive private mail, for instance those on other networks with incompatible mail systems.  | ||||
|  | ||||
| By default author_is_pmable() returns true for 'zot' xchans, and false for all others. | ||||
|  | ||||
| The plugin is passed an array | ||||
|  | ||||
|   [ 'xchan' => $author_xchan, 'result' => 'unset' ] | ||||
|  | ||||
| A plugin which sets the 'result' to something besides 'unset' will over-ride the default behaviour. A value of true will enable the 'send mail' link and the private mail recipient will be set to the author's xchan_hash.  A value of false will disable the 'send mail' link.  | ||||
|  | ||||
|  | ||||
|  | ||||
| @@ -28,7 +28,7 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the | ||||
| [zrl=[baseurl]/help/hook/account_settings]account_settings[/zrl] | ||||
| 	Called when generating the account settings form | ||||
|  | ||||
| [zrl=[baseurl]/help/hook/settings_account]account_settings_post[/zrl] | ||||
| [zrl=[baseurl]/help/hook/account_settings_post]account_settings_post[/zrl] | ||||
| 	Called when posting from the account settings form | ||||
|  | ||||
| [zrl=[baseurl]/help/hook/activity_received]activity_received[/zrl] | ||||
| @@ -64,6 +64,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the | ||||
| [zrl=[baseurl]/help/hook/authenticate]authenticate[/zrl] | ||||
| 	Can provide alternate authentication mechanisms | ||||
|  | ||||
| [zrl=[baseurl]/help/hook/author_is_pmable]author_is_pmable[/zrl] | ||||
| 	Called from the thread action menu to determine if we can send private mail to the post author | ||||
|  | ||||
| [zrl=[baseurl]/help/hook/bb2diaspora]bb2diaspora[/zrl] | ||||
| 	called when converting bbcode to markdown | ||||
|  | ||||
|   | ||||
| @@ -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']))   | ||||
|   | ||||
		Reference in New Issue
	
	Block a user