# HG changeset patch # User Matti Hamalainen # Date 1446671577 -7200 # Node ID fd957c37fd8058514b7b5f3ba86e361efb2aba39 # Parent b7916209da833fcc0c9690ab476cd6704a5b6181 Add a new boolean reference variable to stValidateRequestUserData() arguments that returns if e-mail is required. diff -r b7916209da83 -r fd957c37fd80 admajax.php --- 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, diff -r b7916209da83 -r fd957c37fd80 msite.inc.php --- 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; diff -r b7916209da83 -r fd957c37fd80 pages/register.inc.php --- 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))