changeset 1012:fd957c37fd80

Add a new boolean reference variable to stValidateRequestUserData() arguments that returns if e-mail is required.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Nov 2015 23:12:57 +0200
parents b7916209da83
children 720078ca799e
files admajax.php msite.inc.php pages/register.inc.php
diffstat 3 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Wed Nov 04 22:11:21 2015 +0200
+++ b/admajax.php	Wed Nov 04 23:12:57 2015 +0200
@@ -1725,7 +1725,7 @@
       stExecSQLCond($sql, "OK, compo added.");
     }
     else
-    if ($type == "attendees" && stValidateRequestUserData(TRUE, FALSE))
+    if ($type == "attendees" && stValidateRequestUserData(TRUE, $emdummy, FALSE))
     {
       $sql = stGetAttendeeRegistrationSQL();
       stExecSQLCond($sql, "OK, attendee added.");
@@ -1777,7 +1777,7 @@
         stSetStatus(200, "Updated settings.");
       }
       else
-      if ($type == "attendees" && stValidateRequestUserData(TRUE, $id))
+      if ($type == "attendees" && stValidateRequestUserData(TRUE, $emdummy, $id))
       {
         $sql = stPrepareSQLUpdate("attendees",
           "WHERE id=".$id,
--- a/msite.inc.php	Wed Nov 04 22:11:21 2015 +0200
+++ b/msite.inc.php	Wed Nov 04 23:12:57 2015 +0200
@@ -600,11 +600,13 @@
 }
 
 
-function stValidateRequestUserData($admin, $id = FALSE)
+function stValidateRequestUserData($admin, &$requireEmail, $id = FALSE)
 {
   $res = TRUE;
   $chk = 0;
 
+  $requireEmail = stGetSetting("requireEMail") || stGetSetting("confirmEMail");
+
   if (stChkRequestItem("name", $name,
       array(CHK_ISGT, VT_STR, 0, "Handle / name not given."),
       array(CHK_LTEQ, VT_STR, SET_LEN_USERNAME, "Handle / name is too long, should be less than ".SET_LEN_USERNAME." characters.")))
@@ -623,7 +625,7 @@
     $res = FALSE;
 
   $email = stGetRequestItem("email");
-  if (!$admin && stGetSetting("requireEMail") && strlen($email) < 4)
+  if (!$admin && $requireEmail && strlen($email) < 4)
   {
     stError("E-mail address not given, or it is too short.");
     $res = FALSE;
--- a/pages/register.inc.php	Wed Nov 04 22:11:21 2015 +0200
+++ b/pages/register.inc.php	Wed Nov 04 23:12:57 2015 +0200
@@ -177,7 +177,7 @@
   stChkRequestItem("hash", $hash,
     array(CHK_GTEQ, VT_STR, 0, "Invalid data."));
 
-  stValidateRequestUserData(FALSE, FALSE);
+  stValidateRequestUserData(FALSE, $requireEmail, FALSE);
 
   $answer = stGetRequestItem("botcheck");
   if (hashToAnswer($hash) != intval($answer))