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 18:30:27 -0000 @@ -166,7 +166,7 @@ } } -function contact_admin_edit($category = NULL) { +function contact_admin_edit($cid = 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 cid = '%s'", $cid); + db_query("INSERT INTO {contact} (category, recipients, reply, weight) VALUES ('%s', '%s', '%s', '%s')", $edit['category'], $edit['recipients'], $edit['reply'], $edit['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 cid = '%s'", $cid)); + $edit['cid'] = $category->cid; + $edit['weight'] = $category->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'), 'weight', $edit['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($cid) { + $category = db_fetch_object(db_query("SELECT cid, category FROM {contact} WHERE cid = '%s'",$cid)); 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->cid, 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 cid = '%s'", $cid); drupal_goto('admin/contact'); } } function contact_admin() { - $result = db_query('SELECT category, recipients FROM {contact} ORDER BY category'); + $result = db_query('SELECT cid, weight, category, recipients FROM {contact} ORDER BY 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->cid)), l(t('delete'), 'admin/contact/delete/'. urlencode($category->cid) . '/')); } $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 cid, weight, category FROM {contact} ORDER BY weight'); $categories[] = '--'; while ($category = db_fetch_object($result)) { $categories[$category->category] = $category->category;