From 82b12a29d41ecc058f07e286e360ee3764f79935 Mon Sep 17 00:00:00 2001 From: KFCSpike Date: Mon, 27 Jan 2014 13:30:45 +0000 Subject: [PATCH] Add checkbox for Beginner's Protection when creating Users in Admin Panel --- Admin/Templates/addUsers.tpl | 31 +++++++++++++++++++++++++++--- GameEngine/Admin/Mods/addUsers.php | 20 +++++++++++++++---- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/Admin/Templates/addUsers.tpl b/Admin/Templates/addUsers.tpl index 9ec415bf..b68eba97 100644 --- a/Admin/Templates/addUsers.tpl +++ b/Admin/Templates/addUsers.tpl @@ -74,6 +74,7 @@ $baseName = ($_GET['bn']); $amount = ($_GET['am']); $skipped = ($_GET['sk']); + $beginnersProtection = ($_GET['bp']); echo '

' . $amount . @@ -82,6 +83,28 @@ ' . $baseName . '
'; + + // Say if Beginners Protection was set for any Users created + if ($amount > 0) + { + $begMessage = 'Beginners Protection was '; + if (!$beginnersProtection) + { + $begMessage .= 'NOT '; + } + $begMessage .= 'set for '; + if ($amount > 1) + { + $begMessage .= 'these Users'; + } + else + { + $begMessage .= 'this User'; + } + + $begMessage .= '
'; + echo $begMessage; + } if ($skipped > 0) { echo '' @@ -90,7 +113,7 @@ Users not created as the user name already exists
'; } - echo 'Now would be a good time to ' + echo '
Now would be a good time to ' . 'Return to the server' . ' this will update rankings etc but will take a while!
' . ' Make sure max_execution_time is set to a high enough value in php.ini

' @@ -101,9 +124,11 @@ } ?>
- Base Name   + Base Name  

- How Many    + How Many    +

+ Beginners Protection   

diff --git a/GameEngine/Admin/Mods/addUsers.php b/GameEngine/Admin/Mods/addUsers.php index bb94697b..3b2be182 100644 --- a/GameEngine/Admin/Mods/addUsers.php +++ b/GameEngine/Admin/Mods/addUsers.php @@ -17,6 +17,7 @@ mysql_select_db(SQL_DB); $id = $_POST['id']; $baseName = $_POST['users_base_name']; $amount = (int) $_POST['users_amount']; +$beginnersProtection = $_POST['users_protection']; // Some basic error checking if (strlen($baseName) < 4) @@ -74,8 +75,6 @@ else /* * @TODO * - * Make beginners protection optional for Users created - * * Allow option to create (random) bigger villages, * upgrade fields, granary, warehouse, wall etc * @@ -85,11 +84,24 @@ else * where required */ - // Show beginners protection in User Profile - see TODOs + // Show the dove in User Profile - will show this even if + // beginners protection is not checked // Need a $database function for this // (assuming we don't already have one as creating Natars also updates this way) $q = "UPDATE " . TB_PREFIX . "users SET desc2 = '[#0]' WHERE id = $uid"; mysql_query($q) or die(mysql_error()); + + if (!$beginnersProtection) + { + // No beginners protection so set it to current time + // TODO create a $database function for this + // also used in editProtection.php so assuming no function + // already exists + $protection = time(); + mysql_query("UPDATE ".TB_PREFIX."users SET + protect = '".$protection."' + WHERE id = $uid") or die(mysql_error()); + } $database->updateUserField($uid,"act","",1); $wid = $database->generateBase($kid,0); @@ -108,6 +120,6 @@ else } } } - header("Location: ../../../Admin/admin.php?p=addUsers&g=OK&bn=$baseName&am=$created&sk=$skipped"); + header("Location: ../../../Admin/admin.php?p=addUsers&g=OK&bn=$baseName&am=$created&sk=$skipped&bp=$beginnersProtection"); } ?>