--- contact.module	2005-11-30 20:57:11.000000000 +0530
+++ contact.module.new	2005-12-01 20:20:56.000000000 +0530
@@ -48,9 +48,12 @@
     $items[] = array('path' => 'admin/contact/list', 'title' => t('list'),
       'callback' => 'contact_admin', 'access' => user_access('administer site configuration'),
       'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1);
-    $items[] = array('path' => 'admin/contact/edit', 'title' => t('add category'),
+    $items[] = array('path' => 'admin/contact/add', 'title' => t('add category'),
       'callback' => 'contact_admin_edit', 'access' => user_access('administer site configuration'),
       'type' => MENU_LOCAL_TASK);
+    $items[] = array('path' => 'admin/contact/edit', 'title' => t('edit category'),
+      'callback' => 'contact_admin_edit', 'access' => user_access('administer site configuration'),
+      'type' => MENU_CALLBACK);
     $items[] = array('path' => 'admin/contact/delete', 'title' => t('delete contact'),
       'callback' => 'contact_admin_delete', 'access' => user_access('administer site configuration'),
       'type' => MENU_CALLBACK);
@@ -186,8 +189,16 @@
     }
 
     if (!form_get_errors()) {
-      db_query("DELETE FROM {contact} WHERE cid = %d", $cid);
-      db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected) VALUES ('%s', '%s', '%s', %d, %d)", $edit['category'], $edit['recipients'], $edit['reply'], $edit['weight'], $edit['selected']);
+      if ($edit['selected']) {
+        //Unselect all other contact categories
+        db_query("UPDATE {contact} SET selected = 0");
+      }
+      if (arg(2) == "add") {
+        db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected) VALUES ('%s', '%s', '%s', %d, %d)", $edit['category'], $edit['recipients'], $edit['reply'], $edit['weight'], $edit['selected']);
+      }
+      else {
+        db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d WHERE cid=%d", $edit['category'], $edit['recipients'], $edit['reply'], $edit['weight'], $edit['selected'], $cid);
+      }
       drupal_set_message(t('Category %category has been updated.', array('%category' => theme('placeholder', $edit['category']))));
       drupal_goto('admin/contact');
     }
