Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev
This commit is contained in:
		| @@ -1,17 +1,31 @@ | ||||
| <?php | ||||
| namespace Zotlabs\Module; | ||||
|  | ||||
|  | ||||
| require_once('include/security.php'); | ||||
|  | ||||
| class Lockview extends \Zotlabs\Web\Controller { | ||||
|  | ||||
| 	function get() { | ||||
|  | ||||
| 		$atokens = array(); | ||||
|  | ||||
| 		if(local_channel()) { | ||||
| 			$at = q("select * from atoken where atoken_uid = %d", | ||||
| 				intval(local_channel()) | ||||
| 			); | ||||
| 			if($at) { | ||||
| 				foreach($at as $t) { | ||||
| 					$atokens[] = atoken_xchan($t); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	   | ||||
| 		$type = ((argc() > 1) ? argv(1) : 0); | ||||
| 		if (is_numeric($type)) { | ||||
| 			$item_id = intval($type); | ||||
| 			$type='item'; | ||||
| 		} else { | ||||
| 		}  | ||||
| 		else { | ||||
| 			$item_id = ((argc() > 2) ? intval(argv(2)) : 0); | ||||
| 		} | ||||
| 	   | ||||
| @@ -98,6 +112,13 @@ class Lockview extends \Zotlabs\Web\Controller { | ||||
| 			if($r) | ||||
| 				foreach($r as $rr)  | ||||
| 					$l[] = '<li>' . $rr['xchan_name'] . '</li>'; | ||||
| 			if($atokens) { | ||||
| 				foreach($atokens as $at) { | ||||
| 					if(in_array("'" . $at['xchan_hash'] . "'",$allowed_users)) {	 | ||||
| 						$l[] = '<li>' . $at['xchan_name'] . '</li>'; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		if(count($deny_groups)) { | ||||
| 			$r = q("SELECT gname FROM `groups` WHERE hash IN ( " . implode(', ', $deny_groups) . " )"); | ||||
| @@ -110,6 +131,16 @@ class Lockview extends \Zotlabs\Web\Controller { | ||||
| 			if($r) | ||||
| 				foreach($r as $rr)  | ||||
| 					$l[] = '<li><strike>' . $rr['xchan_name'] . '</strike></li>'; | ||||
|  | ||||
| 			if($atokens) { | ||||
| 				foreach($atokens as $at) { | ||||
| 					if(in_array("'" . $at['xchan_hash'] . "'",$deny_users)) {	 | ||||
| 						$l[] = '<li><strike>' . $at['xchan_name'] . '</strike></li>'; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
|  | ||||
| 		} | ||||
| 	 | ||||
| 		echo $o . implode($l); | ||||
|   | ||||
| @@ -121,17 +121,24 @@ class Settings extends \Zotlabs\Web\Controller { | ||||
|  | ||||
| 		if((argc() > 1) && (argv(1) == 'tokens')) { | ||||
| 			check_form_security_token_redirectOnErr('/settings/tokens', 'settings_tokens'); | ||||
| 			 | ||||
| 			$atoken_id = (($_POST['atoken_id']) ? intval($_POST['atoken_id']) : 0); | ||||
| 			$name = trim(escape_tags($_POST['name'])); | ||||
| 			$token = trim($_POST['token']); | ||||
| 			if(trim($_POST['expires'])) | ||||
| 				$expires = datetime_convert(date_default_timezone_get(),'UTC',$_POST['expires']); | ||||
| 			else | ||||
| 				$expires = NULL_DATE; | ||||
|  | ||||
| 			$token_errs = 0; | ||||
| 			if(array_key_exists('token',$_POST)) { | ||||
| 				$atoken_id = (($_POST['atoken_id']) ? intval($_POST['atoken_id']) : 0); | ||||
| 				$name = trim(escape_tags($_POST['name'])); | ||||
| 				$token = trim($_POST['token']); | ||||
| 				if((! $name) || (! $token)) | ||||
| 						$token_errs ++; | ||||
| 				if(trim($_POST['expires'])) | ||||
| 					$expires = datetime_convert(date_default_timezone_get(),'UTC',$_POST['expires']); | ||||
| 				else | ||||
| 					$expires = NULL_DATE; | ||||
| 			} | ||||
| 			if($token_errs) { | ||||
| 				notice( t('Name and Password are required.') . EOL); | ||||
| 				return; | ||||
| 			} | ||||
| 			if($atoken_id) { | ||||
| 				$r = q("update atoken set atoken_name = '%s', atoken_token = '%s' atoken_expire = '%s'  | ||||
| 				$r = q("update atoken set atoken_name = '%s', atoken_token = '%s' atoken_expires = '%s'  | ||||
| 					where atoken_id = %d and atoken_uid = %d", | ||||
| 					dbesc($name), | ||||
| 					dbesc($token), | ||||
| @@ -141,7 +148,7 @@ class Settings extends \Zotlabs\Web\Controller { | ||||
| 				); | ||||
| 			} | ||||
| 			else { | ||||
| 				$r = q("insert into atoken ( atoken_aid, atoken_uid, atoken_name, atoken_token, atoken_expire ) | ||||
| 				$r = q("insert into atoken ( atoken_aid, atoken_uid, atoken_name, atoken_token, atoken_expires ) | ||||
| 					values ( %d, %d, '%s', '%s', '%s' ) ", | ||||
| 					intval($channel['channel_account_id']), | ||||
| 					intval($channel['channel_id']), | ||||
| @@ -767,10 +774,13 @@ class Settings extends \Zotlabs\Web\Controller { | ||||
| 				intval(local_channel()) | ||||
| 			);			 | ||||
|  | ||||
| 			$desc = t('Use this form to create temporary access identifiers to share things with non-members. These identities may be used in Access Control Lists and visitors may login using these credentials to access the private content.'); | ||||
|  | ||||
| 			$tpl = get_markup_template("settings_tokens.tpl"); | ||||
| 			$o .= replace_macros($tpl, array( | ||||
| 				'$form_security_token' => get_form_security_token("settings_tokens"), | ||||
| 				'$title'	=> t('Guest Access Tokens'), | ||||
| 				'$desc'     => $desc, | ||||
| 				'$tokens' => $t, | ||||
| 				'$atoken' => $atoken, | ||||
| 				'$name' => array('name', t('Login Name'), (($atoken) ? $atoken['atoken_name'] : ''),''), | ||||
|   | ||||
							
								
								
									
										4231
									
								
								util/hmessages.po
									
									
									
									
									
								
							
							
						
						
									
										4231
									
								
								util/hmessages.po
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -2036,3 +2036,14 @@ dl.bb-dl > dd > li { | ||||
|     border-style: solid; | ||||
|     border-width: 5px; | ||||
| } | ||||
|  | ||||
| .atoken-list { | ||||
| 	margin-right: 5px; | ||||
| 	list-style-type: none; | ||||
| } | ||||
| .atoken-list li { | ||||
| 	margin-bottom: 10px; | ||||
| } | ||||
| .atoken-text { | ||||
| 	margin: 5px 10px 5px 10px; | ||||
| } | ||||
| @@ -3,6 +3,7 @@ | ||||
| 		<h2>{{$title}}</h2> | ||||
| 		<div class="clear"></div> | ||||
| 	</div> | ||||
| 	<div class="atoken-text descriptive-text">{{$desc}}</div> | ||||
| 	<form action="settings/tokens" id="settings-account-form" method="post" autocomplete="off" > | ||||
| 		<input type='hidden' name='form_security_token' value='{{$form_security_token}}'> | ||||
| 		{{if $atoken}}<input type="hidden" name="atoken_id" value="{{$atoken.atoken_id}}" />{{/if}} | ||||
| @@ -17,9 +18,9 @@ | ||||
| 	</form> | ||||
| 	{{if $tokens}} | ||||
| 	<div> | ||||
| 	<ul> | ||||
| 	<ul class="atoken-list"> | ||||
| 	{{foreach $tokens as $t}} | ||||
| 	<li><a href="settings/tokens/{{$t.atoken_id}}">{{$t.atoken_name}}</a> <a href="settings/tokens/{{$t.atoken_id}}/drop"><i class="fa fa-remove btn btn-xs btn-default pull-right"></i></a></li> | ||||
| 	<li><span class="pull-right atoken-drop"><a href="settings/tokens/{{$t.atoken_id}}/drop"><i class="fa fa-trash btn btn-xs btn-default"></i></a></span><a href="settings/tokens/{{$t.atoken_id}}">{{$t.atoken_name}}</a></li> | ||||
| 	{{/foreach}} | ||||
| 	</ul> | ||||
| 	</div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user