From 7652687692bffdc31a1b65ed4afce97addd2bbde Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 19 Apr 2013 02:35:08 -0400
Subject: [PATCH] Fix DB error when creating a new contact and a group is selected (#1489051)

---
 CHANGELOG                                |    1 +
 program/steps/addressbook/save.inc       |    2 +-
 program/lib/Roundcube/rcube_contacts.php |    4 ----
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index f4a9132..e82acfa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix DB error when creating a new contact and a group is selected (#1489051)
 - Fix handling of deprecated boolean value of reply_mode option (#1489052)
 - Fix parsing invalid date string (#1489035)
 - Add "with attachment" option to messages list filter (#1485382)
diff --git a/program/lib/Roundcube/rcube_contacts.php b/program/lib/Roundcube/rcube_contacts.php
index c66e986..e4fd7dc 100644
--- a/program/lib/Roundcube/rcube_contacts.php
+++ b/program/lib/Roundcube/rcube_contacts.php
@@ -626,10 +626,6 @@
             $insert_id = $this->db->insert_id($this->db_name);
         }
 
-        // also add the newly created contact to the active group
-        if ($insert_id && $this->group_id)
-            $this->add_to_group($this->group_id, $insert_id);
-
         $this->cache = null;
 
         return $insert_id;
diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc
index 8cab6e8..25bfbd4 100644
--- a/program/steps/addressbook/save.inc
+++ b/program/steps/addressbook/save.inc
@@ -192,7 +192,7 @@
         if (($maxnum = $RCMAIL->config->get('max_group_members', 0)) && ($counts->count + 1 > $maxnum))
           $OUTPUT->show_message('maxgroupmembersreached', 'warning', array('max' => $maxnum));
 
-        $CONTACTS->add_to_group($gid, $plugin['ids']);
+        $CONTACTS->add_to_group($plugin['group_id'], $plugin['ids']);
       }
     }
     else

--
Gitblit v1.9.1