Index: modules/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact.module,v retrieving revision 1.22 diff -u -r1.22 contact.module --- modules/contact.module 25 Aug 2005 21:14:16 -0000 1.22 +++ modules/contact.module 31 Aug 2005 16:36:21 -0000 @@ -166,7 +166,7 @@ } } -function contact_admin_edit($category = NULL) { +function contact_admin_edit($contact_id = NULL) { if (isset($_POST['edit'])) { $edit = $_POST['edit']; @@ -178,19 +178,22 @@ } if (!form_get_errors()) { - db_query("DELETE FROM {contact} WHERE category = '%s'", $category); - db_query("INSERT INTO {contact} (category, recipients, reply) VALUES ('%s', '%s', '%s')", $edit['category'], $edit['recipients'], $edit['reply']); + db_query("DELETE FROM {contact} WHERE contact_id = '%s'", $contact_id); + db_query("INSERT INTO {contact} (category, recipients, reply, contact_weight) VALUES ('%s', '%s', '%s', '%s')", $edit['category'], $edit['recipients'], $edit['reply'], $edit['contact_weight']); drupal_goto('admin/contact'); } } else { - $category = db_fetch_object(db_query("SELECT * FROM {contact} WHERE category = '%s'", $category)); + $category = db_fetch_object(db_query("SELECT * FROM {contact} WHERE contact_id = '%s'", $contact_id)); + $edit['contact_id'] = $category->contact_id; + $edit['contact_weight'] = $category->contact_weight; $edit['category'] = $category->category; $edit['recipients'] = $category->recipients; $edit['reply'] = $category->reply; } $form = form_textfield(t('Category'), 'category', $edit['category'], 60, 255, t("Example: 'website feedback' or 'product information'."), NULL, TRUE); + $form .= form_textfield(t('Weight'), 'contact_weight', $edit['contact_weight'], 3, 255, t("Higher number will make this contact appear higher on the list."), NULL, TRUE); $form .= form_textarea(t('Recipients'), 'recipients', $edit['recipients'], 60, 5, t("Example: 'webmaster@yoursite.com' or 'sales@yoursite.com'. To specify multiple repecients, separate each e-mail address with a comma."), NULL, TRUE); $form .= form_textarea(t('Auto-reply'), 'reply', $edit['reply'], 60, 5, t("Optional auto-reply. Leave empty if you don't want to send the user an auto-reply message.")); $form .= form_submit(t('Submit')); @@ -198,27 +201,28 @@ return form($form); } -function contact_admin_delete($category) { +function contact_admin_delete($contact_id) { + $category = db_fetch_object(db_query("SELECT contact_id, category FROM {contact} WHERE contact_id = '%s'",$contact_id)); if ($_POST['op'] != t('Delete')) { return theme('confirm', - t('Are you sure you want to delete %category?', array('%category' => theme('placeholder', $category))), - 'admin/contact/delete/'. $category, + t('Are you sure you want to delete %category?', array('%category' => theme('placeholder', $category->category))), + 'admin/contact/delete/'. $category->category, t('This action cannot be undone.'), t('Delete'), t('Cancel')); } else { - db_query("DELETE FROM {contact} WHERE category = '%s'", $category); + db_query("DELETE FROM {contact} WHERE contact_id = '%s'", $contact_id); drupal_goto('admin/contact'); } } function contact_admin() { - $result = db_query('SELECT category, recipients FROM {contact} ORDER BY category'); + $result = db_query('SELECT contact_id, contact_weight, category, recipients FROM {contact} ORDER BY contact_weight DESC'); $rows = array(); while ($category = db_fetch_object($result)) { - $rows[] = array($category->category, $category->recipients, l(t('edit'), 'admin/contact/edit/'. urlencode($category->category)), l(t('delete'), 'admin/contact/delete/'. urlencode($category->category))); + $rows[] = array($category->category, $category->recipients, l(t('edit'), 'admin/contact/edit/'. urlencode($category->contact_id)), l(t('delete'), 'admin/contact/delete/'. urlencode($category->contact_id) . '/')); } $header = array(t('Category'), t('Recipients'), array('data' => t('Operations'), 'colspan' => 2)); return theme('table', $header, $rows); @@ -312,7 +316,7 @@ $edit['mail'] = $user->mail; } - $result = db_query('SELECT category FROM {contact} ORDER BY category'); + $result = db_query('SELECT contact_id, contact_weight, category FROM {contact} ORDER BY contact_weight'); $categories[] = '--'; while ($category = db_fetch_object($result)) { $categories[$category->category] = $category->category;