From fbeb80e9f6c866c865c96860d1fda981451b42ef Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 29 Dec 2006 21:21:12 +0000 Subject: [PATCH] r1375: - Fix a SQL error on admin/user.php when adding a new user (bug://report/63) - When adding new users from the admin section, email options are not saved right because post_insert() also sets options, mixing with the admin-set ones --- admin/user.php | 20 +++++++++++++------- docs/changes.txt | 2 ++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/admin/user.php b/admin/user.php index e92a00e..99503c6 100644 --- a/admin/user.php +++ b/admin/user.php @@ -95,7 +95,10 @@ if ($_POST['do'] == 'insert') $user->set('defaultsortas', $bugsys->in['defaultsortas']); $user->insert(); - $bugsys->input_clean('emailopts', TYPE_INT); + // post_insert will set the email options... so we now have to dump them + $db->query("DELETE FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $user->insertid); + + $bugsys->input_clean('emailopts', TYPE_INT); foreach ($bugsys->in['emailopts'] AS $relation => $bitarr) { $bitmask = 0; @@ -220,16 +223,19 @@ if ($_REQUEST['do'] == 'edit' OR $_REQUEST['do'] == 'add') $admin->table_start(false); $admin->table_head(_('Email Options'), 6); - $options = $db->query("SELECT * FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $user->objdata['userid']); - while ($opt = $db->fetch_array($options)) + if ($user->objdata['userid']) { - foreach ($bugsys->emailoptions['notifications'] AS $name => $notif) + $options = $db->query("SELECT * FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $user->objdata['userid']); + while ($opt = $db->fetch_array($options)) { - foreach ($bugsys->emailoptions['relations'] AS $name => $relation) + foreach ($bugsys->emailoptions['notifications'] AS $name => $notif) { - if ($opt['mask'] & $notif AND $opt['relation'] == $relation) + foreach ($bugsys->emailoptions['relations'] AS $name => $relation) { - $checked["$relation"]["$notif"] = HTML_CHECKED; + if ($opt['mask'] & $notif AND $opt['relation'] == $relation) + { + $checked["$relation"]["$notif"] = HTML_CHECKED; + } } } } diff --git a/docs/changes.txt b/docs/changes.txt index e9d0bfb..9c247c6 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -2,6 +2,8 @@ =============================== - Fixed a potential SQL error on search.php because no results were found (bug://report/62) +- Fixed a SQL error on admin/user.php when adding a new user from the admin section (bug://report/63) +- When adding a new user from the admin section, email options were not saved properly 1.1.4 =============================== -- 2.22.5