Index: emf.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/emf/emf.install,v
retrieving revision 1.11
diff -u -p -r1.11 emf.install
--- emf.install	9 Nov 2009 15:00:33 -0000	1.11
+++ emf.install	8 Oct 2010 15:40:47 -0000
@@ -48,6 +48,19 @@ function emf_schema() {
       'language'           => array('type' => 'varchar', 'length' => '12', 'not null' => TRUE, 'default' => ''),
     ),
     'primary key' => array('lid'),
+    // CTools export support.
+    'export' => array(
+      'key' => 'lid',
+      'key name' => 'name',
+      // 'identifier' => 'emf_list',
+      'default hook' => 'default_emf_lists',  // Function hook name.
+      'api' => array(
+        'owner' => 'emf',
+        'api' => 'emf_lists',  // Base name for api include files.
+        'minimum_version' => 1,
+        'current_version' => 1,
+      ),
+    ),
   );
 
   // requests
@@ -64,6 +77,20 @@ function emf_schema() {
       'timestamp' => array('timestamp'),
       'type' => array('type'),
     ),
+    // CTools export support.
+    // @TODO: Finish. Doesn't work yet.
+    'export' => array(
+      'key' => 'mail',
+      'key name' => 'name',
+      // 'identifier' => 'emf_request',
+      'default hook' => 'default_emf_requests',  // Function hook name.
+      'api' => array(
+        'owner' => 'emf',
+        'api' => 'emf_requests',  // Base name for api include files.
+        'minimum_version' => 1,
+        'current_version' => 1,
+      ),
+    ),
   );
 
   // subscriptions
@@ -73,10 +100,39 @@ function emf_schema() {
       'lid'    => array('type' => 'varchar', 'length' => '64', 'not null' => TRUE),
     ),
     'primary key' => array('mail', 'lid'),
+    // CTools export support.
+    // No CTools export support, this table gets too large.
+    // 'export' => array(
+    //   'key' => 'mail',
+    //   'key name' => 'name',
+    //   // 'identifier' => 'emf_subscription',
+    //   'default hook' => 'default_emf_subscriptions',  // Function hook name.
+    //   'api' => array(
+    //     'owner' => 'emf',
+    //     'api' => 'emf_subscriptions',  // Base name for api include files.
+    //     'minimum_version' => 1,
+    //     'current_version' => 1,
+    //   ),
+    // ),
   );
 
   // list roles
-  $schema['emf_list_roles'] = _emf_schema_list_roles();
+  $schema['emf_list_roles'] = array_merge(_emf_schema_list_roles(), array(
+    // CTools export support.
+    // @TODO: Finish. Exporting works, need to finish importing.
+    'export' => array(
+      'key' => 'lid',
+      'key name' => 'lid',
+      // 'identifier' => 'emf_list_roles',
+      'default hook' => 'default_emf_list_roles',  // Function hook name.
+      'api' => array(
+        'owner' => 'emf',
+        'api' => 'emf_list_roles',  // Base name for api include files.
+        'minimum_version' => 1,
+        'current_version' => 1,
+      ),
+    ),
+  ));
 
   return $schema;
 }
Index: emf.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/emf/emf.module,v
retrieving revision 1.14
diff -u -p -r1.14 emf.module
--- emf.module	9 Nov 2009 15:00:33 -0000	1.14
+++ emf.module	8 Oct 2010 15:40:47 -0000
@@ -354,4 +354,104 @@ function emf_get_plugin() {
     return $plugins[0];
   }
   return FALSE;
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_[table]_list().
+ *
+ * Provide a list of records that can be exported.
+ */
+function emf_emf_list_list($item, $indent) {
+  $list = array();
+  $table = 'emf_list';
+
+  // Get all of the table records.
+  $items = ctools_export_crud_load_all($table);
+
+  foreach ($items as $item) {
+    $list[$item->lid] = check_plain($item->name_api);
+  }
+  return $list;
+}
+
+/**
+ * Implementation of hook_[table]_list().
+ *
+ * Provide a list of records that can be exported.
+ */
+function emf_emf_request_list($item, $indent) {
+  $list = array();
+  $table = 'emf_request';
+
+  // Get all of the table records.
+  $items = ctools_export_crud_load_all($table);
+
+  foreach ($items as $item) {
+    $list[$item->mail] = check_plain($item->mail);
+  }
+  return $list;
+}
+
+/**
+ * Implementation of hook_[table]_list().
+ *
+ * Provide a list of records that can be exported.
+ */
+function emf_emf_list_roles_list($item, $indent) {
+  $list = array();
+  $table = 'emf_roles';
+
+  // Get all of the table records.
+  $q = db_query("SELECT
+      elr.lid,
+      elr.rid,
+      el.name_api name,
+      r.name role
+    FROM
+      {emf_list_roles} elr
+      INNER JOIN {emf_list} el
+        ON elr.lid=el.lid
+      INNER JOIN {role} r
+        ON r.rid=elr.rid
+    ORDER BY
+      el.name_api,
+      r.rid");
+
+  while ($item = db_fetch_object($q)) {
+    $list[$item->lid .':'. $item->rid] = check_plain($item->name .' -> '. $item->role);
+  }
+  return $list;
+}
+
+/**
+ * Implementation of hook_[table]_to_hook_code().
+ *
+ * Provide the exported objects.
+ */
+function emf_emf_list_roles_to_hook_code($names = array(), $name = 'foo') {
+  $schema = drupal_get_schema('emf_list_roles');
+  $export = $schema['export'];
+  $output = '';
+  if (!empty($names)) {
+    $output = "/**\n";
+    $output .= " * Implementation of hook_{$export['default hook']}()\n";
+    $output .= " */\n";
+    $output .= "function " . $name . "_{$export['default hook']}() {\n";
+    $output .= "  \${$export['identifier']}s = array();\n\n";
+    foreach ($names as $x => $record) {
+      $keys = explode(':', $record);
+      $name = $names[$x];
+      $output .= "  \${$export['identifier']} = new stdClass;\n";
+      $output .= "  \${$export['identifier']}->disabled = FALSE; /* Edit this to true to make a default context disabled initially */\n";
+      $output .= "  \${$export['identifier']}->api_version = 3;\n";
+      foreach ($keys as $pos => $key) {
+        $output .= "  \${$export['identifier']}->{$schema['primary key'][$pos]} = ". ctools_var_export($key) .";\n";
+      }
+      $output .= "  \${$export['identifier']}s['" . check_plain($name) . "'] = \${$export['identifier']};\n\n";
+    }
+    $output .= "  return \${$export['identifier']}s;\n";
+    $output .= "}\n";
+  }
+
+  return $output;
+}
