Index: mail_edit.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mail_edit/mail_edit.install,v
retrieving revision 1.1.4.3
diff -u -r1.1.4.3 mail_edit.install
--- mail_edit.install	10 Jul 2008 19:28:23 -0000	1.1.4.3
+++ mail_edit.install	9 Dec 2008 01:57:38 -0000
@@ -2,6 +2,15 @@
 // $Id: mail_edit.install,v 1.1.4.3 2008/07/10 19:28:23 litwol Exp $
 
 function mail_edit_install() {
+  if (db_table_exists('mail_edit') && !db_table_exists('mail_edit_registry')) {
+    // This must be a left-over from the (incompatible!) D5 version, see #318324.
+    // Move the old table out of the way:
+    $ret = array();
+    db_rename_table($ret, 'mail_edit', 'mail_edit_d5');
+    if ($ret[0]['success']) {
+      watchdog('mail_edit', 'The %mail_edit table has been renamed to %mail_edit_d5.', array('%mail_edit' => '{mail_edit}', '%mail_edit_d5' => '{mail_edit_d5}'), WATCHDOG_NOTICE);
+    }
+  }
   drupal_install_schema('mail_edit');
 }
 
@@ -45,10 +54,9 @@
         'description' => t(''),
       ),
     ),
+    'primary key' => array('id', 'language'),
     'indexes' => array(
-      '`unique entry`'        => array('`id`', '`language`'),
-      '`id`'        => array('`id`'),
-      '`language`'       => array('`language`'),
+      'language' => array('language'),
     ),
   );
   $schema['mail_edit_registry'] = array(
@@ -79,8 +87,109 @@
         'description' => t(''),
       ),      
     ),
-    '`primary key`' => array('`id`'),
+    'primary key' => array('id'),
   );  
   
   return $schema;
-}
\ No newline at end of file
+}
+
+/**
+ * Do one of two things to install on D6:
+ *  -- If this is an upgrade from a 5.x-1.x installation:
+ *     The D5 {mail_edit} table cannot be migrated to D6, so we move it away and do a full install.
+ *     Modules that have used Mail Editor under D5 can pick up their old records from {mail_edit_D5}.
+ *  -- If we already have an early 6.x-1.x installation, then fix the schema.
+ */
+function mail_edit_update_6000() {
+  $ret = array();
+  if (db_table_exists('mail_edit') && !db_table_exists('mail_edit_registry'))
+  {
+    // We have a D5 installation and need to move the old table out of the way:
+    db_rename_table($ret, 'mail_edit', 'mail_edit_d5');
+    if ($ret[0]['success']) {
+      watchdog('mail_edit', 'The %mail_edit table has been renamed to %mail_edit_d5.', array('%mail_edit' => '{mail_edit}', '%mail_edit_d5' => '{mail_edit_d5}'), WATCHDOG_NOTICE);
+    }
+
+    // Now install the D6 schema as of update_6000:
+    $schema['mail_edit'] = array(
+      'description' => t(''),
+      'fields' => array(
+        'description' => array(
+          'type' => 'varchar',
+          'length' => '255',
+          'not null' => TRUE,
+          'description' => t(''),
+        ),
+        'subject' => array(
+          'type' => 'varchar',
+          'length' => '255',
+          'not null' => TRUE,
+          'description' => t(''),
+        ),
+        'id' => array(
+          'type' => 'varchar',
+          'length' => '255',
+          'not null' => TRUE,
+          'description' => t(''),
+        ),
+        'language' => array(
+          'type' => 'varchar',
+          'length' => '10',
+          'not null' => TRUE,
+          'description' => t(''),
+        ),
+        'body' => array(
+          'type' => 'text',
+          'size' => 'normal',
+          'description' => t(''),
+        ),
+      ),
+      'primary key' => array('id', 'language'),
+      'indexes' => array(
+        'language' => array('language'),
+      ),
+    );
+    $schema['mail_edit_registry'] = array(
+      'description' => t(''),
+      'fields' => array(
+        'id' => array(
+          'type' => 'varchar',
+          'length' => '255',
+          'not null' => TRUE,
+          'description' => t(''),
+        ),
+        'module' => array(
+          'type' => 'varchar',
+          'length' => '255',
+          'not null' => TRUE,
+          'description' => t(''),
+        ),
+        'mailkey' => array(
+          'type' => 'varchar',
+          'length' => '255',
+          'not null' => TRUE,
+          'description' => t(''),
+        ),
+        'description' => array(
+          'type' => 'varchar',
+          'length' => '255',
+          'not null' => TRUE,
+          'description' => t(''),
+        ),      
+      ),
+      'primary key' => array('id'),
+    );  
+
+    db_create_table($ret, 'mail_edit', $schema['mail_edit']);
+    db_create_table($ret, 'mail_edit_registry', $schema['mail_edit_registry']);
+  }
+  else {
+    // Fix the schema of the 2008-Oct-08 snapshot release:
+    db_drop_index($ret, 'mail_edit', '`unique entry`');
+    db_drop_index($ret, 'mail_edit', '`id`');
+    db_add_primary_key($ret, 'mail_edit', array('id', 'language'));
+    db_add_primary_key($ret, 'mail_edit_registry', array('id'));
+  }
+  return $ret;
+}
+
Index: mail_edit.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mail_edit/mail_edit.module,v
retrieving revision 1.4.2.4
diff -u -r1.4.2.4 mail_edit.module
--- mail_edit.module	7 Oct 2008 19:24:39 -0000	1.4.2.4
+++ mail_edit.module	9 Dec 2008 01:57:38 -0000
@@ -13,7 +13,8 @@
   $items = array();
   $items['admin/build/mail-edit'] = array(
     'access arguments' => array('administer site configuration'),
-    'page callback' => 'mail_edit_list',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('mail_edit_list_form'),
     'description' => t('Edit mails being sent out by Drupal.'),
     'title' => t('Mail templates'),
   );
@@ -226,6 +227,16 @@
   }
 }
 
+function mail_edit_list_form() {
+  $form = array();
+  $form['mail_templates'] = array( 
+    '#type' => 'item',
+    '#value' => mail_edit_list(),
+    '#weight' => 0,
+  );
+  return $form;
+}
+
 function mail_edit_list() {
   _mail_edit_include();
   _mail_edit_key_registry_rebuild();      //update mail_edit_registry table
