Index: admin/user.php =================================================================== --- admin/user.php (revision 1370) +++ admin/user.php (working copy) @@ -95,7 +95,10 @@ $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 @@ $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; + } } } }