From 5648581f4e4d6c8657db845e104652d23b5ce1f4 Mon Sep 17 00:00:00 2001 From: Michael Erdely Date: Wed, 9 Oct 2024 12:41:55 -0400 Subject: [PATCH] Reapply "use newuser_default_family to set a mandatory default family for new users" This reverts commit 0478c4f78c0121d208b3b23205ffcc8fdea7da07. --- src/includes/config.php | 6 ++++++ src/signup.php | 11 +++++++---- src/templates/signup.tpl | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/includes/config.php b/src/includes/config.php index 4db0795..6fa2494 100644 --- a/src/includes/config.php +++ b/src/includes/config.php @@ -39,6 +39,12 @@ function getGlobalOptions() { */ "newuser_requires_approval" => 1, + /* Do not allow new user to choose family + 0 = allow new user to choose family + 1 or more = default family + */ + "newuser_default_family" => 1, + /* Whether or not whom an item is reserved/bought by is hidden. */ "anonymous_purchasing" => 0, diff --git a/src/signup.php b/src/signup.php index c7e0174..778e7fb 100644 --- a/src/signup.php +++ b/src/signup.php @@ -19,10 +19,10 @@ $smarty = new MySmarty(); $opt = $smarty->opt(); if (isset($_POST["action"]) && $_POST["action"] == "signup") { - $username = $_POST["username"]; - $fullname = $_POST["fullname"]; - $email = $_POST["email"]; - $familyid = $_POST["familyid"]; + $username = isset($_REQUEST["username"]) ? $_POST["username"] : ""; + $fullname = isset($_REQUEST["fullname"]) ? $_POST["fullname"] : ""; + $email = isset($_REQUEST["email"]) ? $_POST["email"] : ""; + $familyid = isset($_REQUEST["familyid"]) ? $_POST["familyid"] : $opt['newuser_default_family']; // make sure that username isn't taken. $stmt = $smarty->dbh()->prepare("SELECT userid FROM {$opt["table_prefix"]}users WHERE username = ?"); @@ -101,6 +101,9 @@ if (count($families) == 1) { // default the family to the single family we have. $familyid = $families[0]["familyid"]; } +if (isset($opt['newuser_default_family']) && $opt['newuser_default_family'] != 0) { + $familyid = $opt['newuser_default_family']; +} $smarty->assign('families', $families); $smarty->assign('username', $username); $smarty->assign('fullname', $fullname); diff --git a/src/templates/signup.tpl b/src/templates/signup.tpl index e1b8abf..0a2351d 100644 --- a/src/templates/signup.tpl +++ b/src/templates/signup.tpl @@ -128,7 +128,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - {if $familycount > 1} + {if $familycount > 1 && $opt.newuser_default_family == 0}