浏览代码

Fixed access rights for admin and datetime picker

Fixed access rights for admin in game monitor and restored datetime picker user input checks.
DieFeM 9 年之前
父节点
当前提交
2629c671db

+ 2 - 0
includes/database_mysql.php

@@ -1383,6 +1383,7 @@ class OGPDatabaseMySQL extends OGPDatabase
 				$user_group_expiration_dates = $this->listQuery($query3);
 				foreach($servers as $key => $server)
 				{
+					$servers[$key]['access_rights'] = "ufpetc";
 					if($user_expiration_dates)
 					{
 						foreach($user_expiration_dates as $user_expiration_date)
@@ -1755,6 +1756,7 @@ class OGPDatabaseMySQL extends OGPDatabase
 				$user_group_expiration_dates = $this->listQuery($query3);
 				foreach($servers as $key => $server)
 				{
+					$servers[$key]['access_rights'] = "ufpetc";
 					if($user_expiration_dates)
 					{
 						foreach($user_expiration_dates as $user_expiration_date)

+ 2 - 0
includes/database_mysqli.php

@@ -1380,6 +1380,7 @@ class OGPDatabaseMySQL extends OGPDatabase
 				$user_group_expiration_dates = $this->listQuery($query3);
 				foreach($servers as $key => $server)
 				{
+					$servers[$key]['access_rights'] = "ufpetc";
 					if($user_expiration_dates)
 					{
 						foreach($user_expiration_dates as $user_expiration_date)
@@ -1752,6 +1753,7 @@ class OGPDatabaseMySQL extends OGPDatabase
 				$user_group_expiration_dates = $this->listQuery($query3);
 				foreach($servers as $key => $server)
 				{
+					$servers[$key]['access_rights'] = "ufpetc";
 					if($user_expiration_dates)
 					{
 						foreach($user_expiration_dates as $user_expiration_date)

+ 59 - 3
js/modules/user_games.js

@@ -165,9 +165,65 @@ $(document).ready(function() {
 			}, "json");
 		}
 	});
+	
+	var datePickerInput = $("input[name=expiration_date]");
+	if(datePickerInput)
+	{
+		var now_str = datePickerInput.attr('data-today').split(' '),
+			date = now_str[0].split('/'),
+			time = now_str[1].split(':'),
+			now  = new Date(date[2], date[1]-1, date[0], time[0], time[1], time[2], 0);
+		$('#datetimepicker').datetimepicker({
+			format: 'd/m/Y h:m:s',
+			startDate: now,
+			onChangeDateTime: function(e, obj) {
+				if(e == null)
+				{
+					datePickerInput.val("X");
+				}
+				else
+				{
+					var now_str = $( "input[name=expiration_date]" ).attr('data-today').split(' '),
+					date = now_str[0].split('/'),
+					time = now_str[1].split(':'),
+					now  = new Date(date[2], date[1]-1, date[0], time[0], time[1], time[2], 0);
+					var selected = new Date(e);
+					if( selected <= now )
+					{
+						alert('The selected date has already passed.');
+						datePickerInput.val("X");
+					}
+					else
+					{
+						datePickerInput.val(obj.val());
+					}
+				}
+				if("edit" == GetURLParameter('p'))
+				{
+					datePickerInput.css("background", "#fe9cb1");
+				}
+			}
+		});
+		
+		datePickerInput.on('change', function() {
+			if(this.value.match(/^\d{1,2}\/\d{1,2}\/\d{4}\s\d{1,2}:\d{1,2}:\d{1,2}$/g) == null || this.value == "X")
+			{
+				this.value = "";
+			}
+			else
+			{
+				var sel_str = this.value.split(' '),
+					date = sel_str[0].split('/'),
+					time = sel_str[1].split(':'),
+					selected  = new Date(date[2], date[1]-1, date[0], time[0], time[1], time[2], 0);
+				if( selected <= now )
+				{
+					alert('The selected date has already passed.');
+					this.value = "";
+				}
+			}
+		});
+	}
 
 });
 
-$(window).load(function(){
-	$('input[name="expiration_date"]').datetimepicker();
-});

+ 22 - 22
modules/user_games/assign_home.php

@@ -41,23 +41,23 @@ function exec_ogp_module()
 	if(isset($_REQUEST['user_id'])){
 		if(empty($_REQUEST['user_id']) || $db->getUserById($_REQUEST['user_id']) == null)
 		{
-			print_failure(get_lang('valid_user'));
+			print_failure(valid_user);
 			return;
 		}
 	}else if(isset($_REQUEST['group_id'])){
 		if(empty($_REQUEST['group_id']) || $db->getGroupById($_REQUEST['group_id']) == null)
 		{
-			print_failure(get_lang('valid_group'));
+			print_failure(valid_group);
 			return;
 		}
 	}else{
-		print_failure(get_lang('invalid_url'));
+		print_failure(invalid_url);
 		return;
 	}
 	
 	if ( isset( $_REQUEST['user_id'] ) && !$isAdmin )
 	{
-		echo "<p class='note'>".get_lang('not_available')."</p>";
+		echo "<p class='note'>".not_available."</p>";
 		return;
 	}
 	
@@ -75,7 +75,7 @@ function exec_ogp_module()
 	
 	if( !$isAdmin && !isset($own_group) ) 
 	{
-		echo "<p class='note'>".get_lang('not_available')."</p>";
+		echo "<p class='note'>".not_available."</p>";
 		return;
 	}
 
@@ -172,7 +172,7 @@ function exec_ogp_module()
 	if ( empty($remote_servers) )
 	{
 		print_failure(get_lang("no_remote_servers_available_please_add_at_least_one"));
-		echo "<p><a href='?m=server'>".get_lang('add_remote_server')."</a></p>";
+		echo "<p><a href='?m=server'>".add_remote_server."</a></p>";
 		return;
 	}
 
@@ -186,7 +186,7 @@ function exec_ogp_module()
 		echo "<h2>".get_lang_f('assign_new_home_to_'.$id_type,$assign_name)."</h2>";
 		echo "<form action='?m=user_games&amp;p=assign' method='post'>";
 		echo "<input name='".$id_type."_id' value='".$assign_id."' type='hidden' />\n";
-		echo "<table class='center'><tr><td align='right'><label for='home_id'>".get_lang('select_home').":</label></td>";
+		echo "<table class='center'><tr><td align='right'><label for='home_id'>".select_home.":</label></td>";
 		echo '<td align="left"><select id="home_id" name="home_id" onchange="this.form.submit();">';
 		echo "<option></option>\n";
 		foreach ( $available_homes as $home )
@@ -218,15 +218,15 @@ function exec_ogp_module()
 			{
 				echo create_selection($selection,$flag,$access_rights);
 			}
-			echo "<tr><td class='right'>".get_lang('assign_expiration_date').":</td>\n".
+			echo "<tr><td class='right'>".assign_expiration_date.":</td>\n".
 				 "<td class='left'>\n".
-				 "<tr><td class='right'>".get_lang('server_expiration_date').":</td>\n".
+				 "<tr><td class='right'>".server_expiration_date.":</td>\n".
 				 "<td class='left'>".
 				 "<div id='datetimepicker' class='input-append date'>".
-				 "<input name='expiration_date' placeholder='dd/MM/yyyy hh:mm:ss' type='text' value='X'>".
+				 "<input name='expiration_date' placeholder='dd/MM/yyyy hh:mm:ss' type='text' value='X' data-today='".date('d/m/Y H:i:s')."' >\n".
 				 "</div></td></tr>\n".
 				 "<tr><td  colspan='2' class='info'>". assign_expiration_date_info ."</td></tr>\n";
-			echo "<tr><td colspan='2'><input type='submit' name='assign' value='".get_lang('assign')."' /></td></tr>\n";
+			echo "<tr><td colspan='2'><input type='submit' name='assign' value='".assign."' /></td></tr>\n";
 		}
 		echo "</table></form>\n";
 	}
@@ -234,9 +234,9 @@ function exec_ogp_module()
 	{
 		echo "<h2>".get_lang("no_more_homes_available_that_can_be_assigned_for_this_$id_type")."</h2>";
 		//print_lang('you_can_add_a_new_game_server_from');
-		//echo "<a href='?m=user_games'>".get_lang('game_servers')."</a>.</p>";
+		//echo "<a href='?m=user_games'>".game_servers."</a>.</p>";
 		if( $isAdmin )
-			echo get_lang_f("you_can_add_a_new_game_server_from","<a href='?m=user_games'>".get_lang('game_servers')."</a>")."</p>";
+			echo get_lang_f("you_can_add_a_new_game_server_from","<a href='?m=user_games'>".game_servers."</a>")."</p>";
 	}
 	// View servers for use if there are any.
 	$game_homes = $db->getHomesFor($id_type,$assign_id);
@@ -247,14 +247,14 @@ function exec_ogp_module()
 	}
 	else
 	{
-		echo "<h2>".get_lang('assigned_homes')."</h2>";
+		echo "<h2>".assigned_homes."</h2>";
 		echo '<table class="center">';
-		echo "<tr><th>".get_lang('home_id')."</th><th>".get_lang('game_server')."</th>
-			<th>".get_lang('game_type')."</th>
-			<th align='center'>".get_lang('game_home')."</th>
-			<th>".get_lang('game_home_name')."</th><th>".get_lang('access_rights')."</th>
-			<th>".get_lang('assign_expiration_date')."</th>
-			<th>".get_lang('actions')."</th></tr>";
+		echo "<tr><th>".home_id."</th><th>".game_server."</th>
+			<th>".game_type."</th>
+			<th align='center'>".game_home."</th>
+			<th>".game_home_name."</th><th>".access_rights."</th>
+			<th>".assign_expiration_date."</th>
+			<th>".actions."</th></tr>";
 		foreach( $game_homes as $row )
 		{
 			$access_rights = empty($row['access_rights']) ? "-" : $row['access_rights'];
@@ -271,7 +271,7 @@ function exec_ogp_module()
 				<form action='?m=user_games&amp;p=assign' method='post'>
 				<input name='".$id_type."_id' value='$assign_id' type='hidden' />
 				<input name='home_id' value='".$row['home_id']."' type='hidden' />
-				<input type='submit' name='unassign' value='".get_lang('unassign')."' /></form></td>
+				<input type='submit' name='unassign' value='".unassign."' /></form></td>
 				</tr>";
 		}
 		echo "</table>";
@@ -283,4 +283,4 @@ function exec_ogp_module()
 	else 
 		echo create_back_button('user_admin');
 }
-?>
+?>

+ 2 - 15
modules/user_games/edit_home.php

@@ -574,20 +574,6 @@ function exec_ogp_module()
 	<script src="js/datetimepicker/jquery.datetimepicker.full.min.js"></script>
 	<script type="text/javascript" src="js/modules/user_games.js"></script>
 	<?php
-	if($isAdmin){
-		$expiration_date = $home_info['server_expiration_date'] == "X" ? "X" : date('d/m/Y H:i:s', $home_info['server_expiration_date']);
-	?>
-	<script>
-	$(window).load(function(){
-		$('input[name="expiration_date"]').datetimepicker({
-			value: '<?php echo $expiration_date;?>',
-			format: 'd/m/Y H:i:s'
-		});
-	});
-	</script>
-	<?php
-	}
-
 	echo "<h2>". editing_home_called ." \"".htmlentities($home_info['home_name'])."\"</h2><div id='result' >";
 	if(isset($result))
 	{
@@ -746,7 +732,8 @@ function exec_ogp_module()
 		echo "<tr><td class='right'>".get_lang('server_expiration_date').":</td>\n".
 			 "<td class='left'><form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>".
 			 "<div id='datetimepicker' class='input-append date'>".
-			 "<input name='expiration_date' placeholder='dd/MM/yyyy hh:mm:ss' type='text' value='".$expiration_date."'>".
+			 "<input name='expiration_date' placeholder='dd/MM/yyyy hh:mm:ss' type='text' value='".$expiration_date.
+			 "' data-today='".date('d/m/Y H:i:s')."' >\n".
 			 "</div>".
 			 "<input type='submit' name='set_expiration_date' value='". set_expiration_date ."' />".
 			 "</form></td></tr>\n".