Reapply "use newuser_default_family to set a mandatory default family for new users"

This reverts commit 0478c4f78c.
This commit is contained in:
Michael Erdely 2024-10-09 12:41:55 -04:00
parent 0478c4f78c
commit 5648581f4e
3 changed files with 14 additions and 5 deletions

View file

@ -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,

View file

@ -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);

View file

@ -128,7 +128,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<input id="email" name="email" type="text" class="input-xlarge" value="{$email|escape:'htmlall'}" placeholder="you@somewhere.com">
</div>
</div>
{if $familycount > 1}
{if $familycount > 1 && $opt.newuser_default_family == 0}
<div class="control-group">
<label class="control-label" for="familyid">Family</label>
<div class="controls">