r1375: - Fix a SQL error on admin/user.php when adding a new user (bug://report/63)
authorRobert Sesek <rsesek@bluestatic.org>
Fri, 29 Dec 2006 21:21:12 +0000 (21:21 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Fri, 29 Dec 2006 21:21:12 +0000 (21:21 +0000)
- 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
docs/changes.txt

index e92a00eee4935ffca5c8373f05953487d451151e..99503c61b903f273453bbbb7d3e44a20d95848bd 100644 (file)
@@ -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;
+                                       }
                                }
                        }
                }
index e9d0bfbbc1005c9660af58dfdfee73b7f6dbcefa..9c247c651ae4d768322494ce24ae92238a8e9481 100644 (file)
@@ -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
 ===============================