provide option to block the public stream unless authenticated, since there could be legal issues with unmoderated content
This commit is contained in:
		| @@ -119,6 +119,7 @@ class Apps { | ||||
|  | ||||
|  | ||||
| 	static public function parse_app_description($f,$translate = true) { | ||||
|  | ||||
| 		$ret = array(); | ||||
|  | ||||
| 		$baseurl = z_root(); | ||||
| @@ -194,6 +195,10 @@ class Apps { | ||||
| 						if(! is_public_profile()) | ||||
| 							unset($ret); | ||||
| 						break; | ||||
| 					case 'public_stream': | ||||
| 						if(! can_view_public_stream()) | ||||
| 							unset($ret); | ||||
| 						break; | ||||
| 					case 'observer': | ||||
| 						if(! $observer) | ||||
| 							unset($ret); | ||||
| @@ -346,6 +351,10 @@ class Apps { | ||||
| 							if(! is_public_profile()) | ||||
| 								return ''; | ||||
| 							break; | ||||
| 						case 'public_stream': | ||||
| 							if(! can_view_public_stream()) | ||||
| 								return ''; | ||||
| 							break; | ||||
| 						case 'observer': | ||||
| 							$observer = \App::get_observer(); | ||||
| 							if(! $observer) | ||||
|   | ||||
| @@ -45,6 +45,7 @@ class Site { | ||||
| 		$force_publish		=	((x($_POST,'publish_all'))		? True	: False); | ||||
| 		$disable_discover_tab =	((x($_POST,'disable_discover_tab'))		? False	:	True); | ||||
| 		$site_firehose      =   ((x($_POST,'site_firehose')) ? True : False); | ||||
| 		$open_pubstream     =   ((x($_POST,'open_pubstream')) ? True : False); | ||||
| 		$login_on_homepage	=	((x($_POST,'login_on_homepage'))		? True	:	False); | ||||
| 		$enable_context_help = ((x($_POST,'enable_context_help'))		? True	:	False); | ||||
| 		$global_directory     = ((x($_POST,'directory_submit_url'))	? notags(trim($_POST['directory_submit_url']))	: ''); | ||||
| @@ -139,6 +140,7 @@ class Site { | ||||
| 		set_config('system','publish_all', $force_publish); | ||||
| 		set_config('system','disable_discover_tab', $disable_discover_tab); | ||||
| 		set_config('system','site_firehose', $site_firehose); | ||||
| 		set_config('system','open_pubstream', $open_pubstream); | ||||
| 		set_config('system','force_queue_threshold', $force_queue); | ||||
| 		if ($global_directory == '') { | ||||
| 			del_config('system', 'directory_submit_url'); | ||||
| @@ -319,7 +321,7 @@ class Site { | ||||
| 			'$force_publish'	=> array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")), | ||||
| 			'$disable_discover_tab'	=> array('disable_discover_tab', t('Import Public Streams'), $discover_tab, t('Import and allow access to public content pulled from other sites. Warning: this content is unmoderated.')), | ||||
| 			'$site_firehose'	=> array('site_firehose', t('Site only Public Streams'), get_config('system','site_firehose'), t('Allow access to public content originating only from this site if Imported Public Streams are disabled.')), | ||||
|  | ||||
| 			'$open_pubstream'	=> array('open_pubstream', t('Allow anybody on the internet to access the Public streams'), get_config('system','open_pubstream',1), t('Disable to require authentication before viewing. Warning: this content is unmoderated.')), | ||||
| 			'$login_on_homepage'	=> array('login_on_homepage', t("Login on Homepage"),((intval($homelogin) || $homelogin === false) ? 1 : '') , t("Present a login box to visitors on the home page if no other content has been configured.")), | ||||
| 			'$enable_context_help'	=> array('enable_context_help', t("Enable context help"),((intval($enable_context_help) === 1 || $enable_context_help === false) ? 1 : 0) , t("Display contextual help for the current page when the help button is pressed.")), | ||||
|  | ||||
|   | ||||
| @@ -12,9 +12,8 @@ class Pubstream extends \Zotlabs\Web\Controller { | ||||
| 		if($load) | ||||
| 			$_SESSION['loadtime'] = datetime_convert(); | ||||
|  | ||||
| 	 | ||||
| 		if(observer_prohibited(true)) { | ||||
| 				return login(); | ||||
| 		if((observer_prohibited(true)) || (! (intval(get_config('system','open_pubstream',1))) && get_observer_hash())) { | ||||
| 			return login(); | ||||
| 		} | ||||
|  | ||||
| 		$site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| version: 2 | ||||
| version: 2.2 | ||||
| url: $baseurl/pubstream | ||||
| requires: config:disable_discover_tab=0 | ||||
| requires: public_stream | ||||
| name: Public Stream | ||||
| photo: icon:globe | ||||
| categories: Social | ||||
| categories: Social, nav_featured_app | ||||
|   | ||||
							
								
								
									
										20
									
								
								boot.php
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								boot.php
									
									
									
									
									
								
							| @@ -1685,6 +1685,26 @@ function remote_channel() { | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
|  | ||||
| function can_view_public_stream() { | ||||
|  | ||||
| 	if((observer_prohibited(true))  | ||||
| 		|| (! (intval(get_config('system','open_pubstream',1))) && get_observer_hash())) { | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	$site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); | ||||
| 	$net_firehose  = ((get_config('system','disable_discover_tab',1)) ? false : true); | ||||
|  | ||||
| 	if(! ($site_firehose || $net_firehose)) { | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	return true; | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * @brief Show an error or alert text on next page load. | ||||
|  * | ||||
|   | ||||
| @@ -974,7 +974,7 @@ function author_is_pmable($xchan, $abook) { | ||||
| 	if($x['result'] !== 'unset') | ||||
| 		return $x['result']; | ||||
| 	 | ||||
| 	if($xchan['xchan_network'] === 'zot') | ||||
| 	if($xchan['xchan_network'] === 'zot' && get_observer_hash()) | ||||
| 		return true; | ||||
| 	return false; | ||||
|  | ||||
|   | ||||
| @@ -73,9 +73,7 @@ EOT; | ||||
| 	// nav links: array of array('href', 'text', 'extra css classes', 'title') | ||||
| 	$nav = []; | ||||
|  | ||||
| 	$disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false; | ||||
|  | ||||
| 	if(! $disable_discover_tab) | ||||
| 	if(can_view_public_stream()) | ||||
| 		$nav['pubs'] = true; | ||||
|  | ||||
| 	/** | ||||
|   | ||||
| @@ -84,6 +84,7 @@ | ||||
| 	{{include file="field_checkbox.tpl" field=$force_publish}} | ||||
| 	{{include file="field_checkbox.tpl" field=$disable_discover_tab}} | ||||
| 	{{include file="field_checkbox.tpl" field=$site_firehose}} | ||||
| 	{{include file="field_checkbox.tpl" field=$open_pubstream}} | ||||
| 	 | ||||
| 	<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div> | ||||
| 	 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user