[thirdparty-commits] jpeeler: mantis/trunk r44 - in /mantis/trunk: ./ core/

SVN commits to the Digium third-party software repository thirdparty-commits at lists.digium.com
Tue Jan 6 13:45:54 CST 2009


Author: jpeeler
Date: Tue Jan  6 13:45:53 2009
New Revision: 44

URL: http://svn.digium.com/view/thirdparty?view=rev&rev=44
Log:
This adds date of birth and country of nationality fields used for signing the online contribution license.

This branch will eventually be merged back over to the usual place in repotools.


Modified:
    mantis/trunk/core/license_api.php
    mantis/trunk/license_agreement.php

Modified: mantis/trunk/core/license_api.php
URL: http://svn.digium.com/view/thirdparty/mantis/trunk/core/license_api.php?view=diff&rev=44&r1=43&r2=44
==============================================================================
--- mantis/trunk/core/license_api.php (original)
+++ mantis/trunk/core/license_api.php Tue Jan  6 13:45:53 2009
@@ -83,15 +83,20 @@
 
 		$t_license = config_get( "license" );
 
+		// format date for database (YYYY-MM-DD)
+		$fulldob = "$p_dob_year-$p_dob_month-$p_dob_day";
+
 		$sql = sprintf("INSERT INTO mantis_license_table VALUES(''," .
-					   "'%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', TRUE, '%s', '',  NOW(), NULL)",
+					   "'%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', TRUE, '%s', '',  NOW(), NULL)",
 					   auth_get_current_user_id(),
 					   db_prepare_string( $p_name ),
+					   db_prepare_string( $fulldob ),
 					   db_prepare_string( $p_company ),
 					   db_prepare_string( $p_title ),
 					   db_prepare_string( $p_address_street ),
 					   db_prepare_string( $p_address_city ),
 					   db_prepare_string( $p_address_country ),
+					   db_prepare_string( $p_nationality_country ),
 					   db_prepare_string( $p_telephone ),
 					   db_prepare_string( $t_license["version"] ));
 
@@ -205,4 +210,13 @@
 
 		return $results;
 	}
+
+	function check_input_error( $p_key, &$p_input_array, $p_err_msg ) {
+		if(array_key_exists($p_key, $p_input_array)) {
+			echo "&nbsp;&nbsp;<font color=\"red\">$p_err_msg.</font>";
+			return 1;
+		}
+
+		return 0;
+	}
 ?>

Modified: mantis/trunk/license_agreement.php
URL: http://svn.digium.com/view/thirdparty/mantis/trunk/license_agreement.php?view=diff&rev=44&r1=43&r2=44
==============================================================================
--- mantis/trunk/license_agreement.php (original)
+++ mantis/trunk/license_agreement.php Tue Jan  6 13:45:53 2009
@@ -15,7 +15,7 @@
 		  <tr>
 		    <td class="news-body">
 			  <?php echo $reason; ?><br /><br />
-			  You will be redirected in <?php echo config_get("wait_time"); ?> seconds, or you can <a href="main_page.php">click here.</a>
+			  You will be redirected in <?php echo config_get("default_redirect_delay"); ?> seconds, or you can <a href="main_page.php">click here.</a>
 			</td>
 		  </tr>
 		</table>
@@ -49,9 +49,11 @@
 	$input_errors = array();
 
 	if (count($_POST) > 0 && isset($_SESSION["public_key"])) {
-		foreach(array("name", "address_street", "address_city", "address_country", "telephone") as $f)
-			if (!isset($_POST[$f]) || !strlen(trim($_POST[$f])))
+		foreach(array("name", "address_street", "address_city", "address_country", "nationality_country", "telephone", "dob_month", "dob_day", "dob_year") as $f)
+			if (!isset($_POST[$f]) || !strlen(trim($_POST[$f]))) {
+				//echo "DEBUG: setting error on $f<br>";
 				$input_errors[$f] = true;
+			}
 
 		if (strtolower($_POST["captcha"]) != strtolower(substr(md5(config_get('password_confirm_hash_magic_string') . $_SESSION["public_key"]), 1, 5)))
 			$input_errors["captcha"] = true;
@@ -125,31 +127,70 @@
     <td>
       <input type="text" name="name" 
       value="<?php echo ((isset($_POST["name"])) ? $_POST["name"] : user_get_realname(auth_get_current_user_id())); ?>"/>
-<?php 
-	if(array_key_exists("name", $input_errors)) 
-		echo "&nbsp;&nbsp;<font color=\"red\">You must enter your name...</font>"; 
-?>
+<?php check_input_error("name", $input_errors, "You must enter your name"); ?>
     </td>
   </tr>
   <tr class="row-2">
+    <td class="category" width="50%">Date of birth (you must be of at least 13 years of age):</td>
+    <td>
+<?php
+	echo "Month ";
+	echo "<select name=\"dob_month\" size=\"1\">";
+    echo "<option value=\"\"></option>\n";
+    for($i = 1; $i < 13; $i++) {
+		if ($i == $_POST[dob_month])
+      		echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
+		else
+      		echo "<option value=\"$i\">$i</option>\n";
+	}
+	echo "</select>&nbsp;";
+
+	echo "Day ";
+	echo "<select name=\"dob_day\" size=\"1\">";
+    echo "<option value=\"\"></option>\n";
+    for($i = 1; $i < 32; $i++) {
+		if ($i == $_POST[dob_day])
+      		echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
+		else
+      		echo "<option value=\"$i\">$i</option>\n";
+	}
+	echo "</select>&nbsp;";
+
+	$curyear = date("Y");
+	echo "Year ";
+	echo "<select name=\"dob_year\" size=\"1\">";
+    echo "<option value=\"\"></option>\n";
+    for($i = 1900; $i < $curyear - 12; $i++) {
+		if ($i == $_POST[dob_year])
+      		echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
+		else
+      		echo "<option value=\"$i\">$i</option>\n";
+	}
+	echo "</select>&nbsp;";
+    $ret = check_input_error("dob_month", $input_errors, "You must enter your date of birth");
+    if (!$ret)
+		$ret = check_input_error("dob_day", $input_errors, "You must enter your date of birth");
+	if (!$ret)
+    	check_input_error("dob_year", $input_errors, "You must enter your date of birth");
+?>
+    </td>
+  </tr>
+  <tr class="row-1">
     <td class="category">Company Name (if applicable):</td>
     <td>
       <input type="text" name="company"  
       value="<?php echo ((isset($_POST["company"])) ? $_POST["company"] : ""); ?>"/>
     </td>
   </tr>
-  <tr class="row-1">
+  <tr class="row-2">
     <td class="category">Job Title:</td>
     <td>
       <input type="text" name="title" 
       value="<?php echo ((isset($_POST["title"])) ? $_POST["title"] : ""); ?>"/>
-<?php 
-	if(array_key_exists("title", $input_errors)) 
-		echo "&nbsp;&nbsp;<font color=\"red\">You must enter a job title...</font>"; 
-?>
-    </td>
-  </tr>
-  <tr class="row-2">
+<?php check_input_error("title", $input_errors, "You must enter a job title"); ?>
+    </td>
+  </tr>
+  <tr class="row-1">
     <td class="category">
       <div class="address_category">Address:</div>
       <div class="address_text">
@@ -164,6 +205,7 @@
       <input type="text" name="address_city"
              value="<?php if(isset($_POST["address_city"])) echo $_POST["address_city"]; ?>" /><br />
       <select name="address_country">
+        <option value=""></option>
 <?php
 	foreach(get_country_list() as $c) {
 		echo str_repeat(" ", 8) . "<option value=\"{$c}\" ";
@@ -177,35 +219,44 @@
       </select><br />
 <?php 
 	foreach(array("street", "city", "country") as $k) {
-		if(array_key_exists("address_$k", $input_errors)) {
-			echo "      <font color=\"red\">You must enter all address fields...</font>\n"; 
+		if (check_input_error("address_$k", $input_errors, "You must enter all address fields"))
 			break;
-		}
-	}
-?>
-
-    </td>
-  </tr>
-  <tr class="row-1">
+	}
+?>
+    </td>
+  </tr>
+   <tr class="row-2">
+    <td class="category" width="50%">Country of Nationality:</td>
+    <td>
+      <select name="nationality_country">
+        <option value=""></option>
+<?php
+	foreach(get_country_list() as $c) {
+		echo str_repeat(" ", 8) . "<option value=\"{$c}\" ";
+
+		if(isset($_POST["nationality_country"]) && $_POST["nationality_country"] == $c)
+			echo "selected";
+
+		echo " />{$c}</option>\n";
+	}
+?>
+    </select><br />
+<?php check_input_error("nationality_country", $input_errors, "You must enter your nationality"); ?>
+    </td>
+  </tr>
+ <tr class="row-1">
     <td class="category">Telephone:</td>
     <td>
       <input type="text" name="telephone" 
       value="<?php echo ((isset($_POST["telephone"])) ? $_POST["telephone"] : ""); ?>"/>
-<?php 
-	if(array_key_exists("telephone", $input_errors)) 
-		echo "&nbsp;&nbsp;<font color=\"red\">You must enter your telephone number...</font>"; 
-?>
+<?php check_input_error("telephone", $input_errors, "You must enter your telephone number"); ?>
     </td>
   </tr>
   <tr class="row-2">
     <td class="category"><img src="make_captcha_img.php?public_key=<?php echo $_SESSION["public_key"]; ?>" /></td>
     <td>
       <input type="text" name="captcha" />
-<?php
-	if(array_key_exists("captcha", $input_errors)) {
-		echo "&nbsp;&nbsp;<font color=\"red\">The captcha image was incorrect...</font>";
-	}
-?>
+<?php check_input_error("captcha", $input_errors, "The captcha image was incorrect"); ?>
     </td>
   </tr>
   <tr>




More information about the thirdparty-commits mailing list