? cvs_get_vanilla.sh Index: database/database.mysql =================================================================== RCS file: /cvs/drupal/drupal/database/database.mysql,v retrieving revision 1.196 diff -u -p -r1.196 database.mysql --- database/database.mysql 12 Sep 2005 18:26:59 -0000 1.196 +++ database/database.mysql 13 Sep 2005 16:19:39 -0000 @@ -204,10 +204,12 @@ CREATE TABLE comments ( -- CREATE TABLE contact ( + cid int(11) NOT NULL, category varchar(255) NOT NULL default '', recipients longtext NOT NULL default '', reply longtext NOT NULL default '', - PRIMARY KEY (category) + PRIMARY KEY (cid), + UNIQUE KEY category (category) ) TYPE=MyISAM; -- Index: database/database.pgsql =================================================================== RCS file: /cvs/drupal/drupal/database/database.pgsql,v retrieving revision 1.135 diff -u -p -r1.135 database.pgsql --- database/database.pgsql 12 Sep 2005 18:26:59 -0000 1.135 +++ database/database.pgsql 13 Sep 2005 16:19:39 -0000 @@ -200,11 +200,14 @@ CREATE INDEX comments_nid_idx ON comment -- CREATE TABLE contact ( + cid int NOT NULL, category varchar(255) NOT NULL default '', recipients text NOT NULL default '', reply text NOT NULL default '', - PRIMARY KEY (category) + PRIMARY KEY (cid), + UNIQUE (category) ); +CREATE SEQUENCE contact_cid_seq INCREMENT 1 START 1; -- -- Table structre for table 'node_comment_statistics' Index: database/updates.inc =================================================================== RCS file: /cvs/drupal/drupal/database/updates.inc,v retrieving revision 1.133 diff -u -p -r1.133 updates.inc --- database/updates.inc 12 Sep 2005 20:13:04 -0000 1.133 +++ database/updates.inc 13 Sep 2005 16:19:40 -0000 @@ -67,7 +67,8 @@ $sql_updates = array( "2005-08-15" => "update_145", "2005-08-25" => "update_146", "2005-09-07" => "update_147", - "2005-09-12" => "update_148" + "2005-09-12" => "update_148", + "2005-09-13" => "update_149" ); function update_110() { @@ -820,6 +821,29 @@ function update_148() { return $ret; } +function update_149() { + $ret = array(); + + switch($GLOBALS['db_type']){ + case "pgsql": + $ret[] = update_sql("ALTER TABLE {contact} DROP CONSTRAINT {contact}_pkey"); + $ret[] = update_sql("ALTER TABLE {contact} ADD COLUMN cid int"); + $ret[] = update_sql("CREATE SEQUENCE {contact}_cid_seq INCREMENT 1 START 1"); + $ret[] = update_sql("UPDATE contact SET cid = nextval('contact_cid_seq')"); + $ret[] = update_sql("ALTER TABLE {contact} ADD CONSTRAINT {contact}_category_pkey UNIQUE (category)"); + $ret[] = update_sql("ALTER TABLE {contact} ADD PRIMARY KEY (cid);"); + break; + case "mysql": + case "mysqli": + $ret[] = update_sql("ALTER TABLE {contact} DROP PRIMARY KEY"); + $ret[] = update_sql("ALTER TABLE {contact} ADD COLUMN cid int(11) NOT NULL PRIMARY KEY"); + $ret[] = update_sql("ALTER TABLE {contact} ADD UNIQUE KEY category (category)"); + break; + } + + return $ret; +} + function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql); Index: modules/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact.module,v retrieving revision 1.22 diff -u -p -r1.22 contact.module --- modules/contact.module 25 Aug 2005 21:14:16 -0000 1.22 +++ modules/contact.module 13 Sep 2005 16:19:46 -0000 @@ -166,7 +166,7 @@ function contact_mail_user() { } } -function contact_admin_edit($category = NULL) { +function contact_admin_edit($cid = NULL) { if (isset($_POST['edit'])) { $edit = $_POST['edit']; @@ -178,13 +178,14 @@ function contact_admin_edit($category = } 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 = '%d'", $cid); + db_query("INSERT INTO {contact} (cid, category, recipients, reply) VALUES ('%d', '%s', '%s', '%s')", db_next_id('{contact}_cid'), $edit['category'], $edit['recipients'], $edit['reply']); 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 = '%d'", $cid)); + $edit['cid'] = $category->cid; $edit['category'] = $category->category; $edit['recipients'] = $category->recipients; $edit['reply'] = $category->reply; @@ -198,27 +199,28 @@ function contact_admin_edit($category = 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 = '%d'",$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 = '%d'", $cid); drupal_goto('admin/contact'); } } function contact_admin() { - $result = db_query('SELECT category, recipients FROM {contact} ORDER BY category'); + $result = db_query('SELECT cid, category, recipients FROM {contact}'); $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 +314,7 @@ function contact_mail_page() { $edit['mail'] = $user->mail; } - $result = db_query('SELECT category FROM {contact} ORDER BY category'); + $result = db_query('SELECT cid, category FROM {contact}'); $categories[] = '--'; while ($category = db_fetch_object($result)) { $categories[$category->category] = $category->category;