Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/CHANGELOG.txt,v
retrieving revision 1.16
diff -u -p -r1.16 CHANGELOG.txt
--- CHANGELOG.txt	2 Nov 2008 22:08:31 -0000	1.16
+++ CHANGELOG.txt	19 Jan 2009 19:50:35 -0000
@@ -4,7 +4,7 @@ Demo x.x-x.x, xxxx-xx-xx
 ------------------------
 
 
-Demo 6.x-1.x, xxxx-xx-xx
+Demo 7.x-1.x, xxxx-xx-xx
 ------------------------
 #329182 by sun: Moved menu items below admin/build.
 #299841 by sun: Fixed wrong function arguments for watchdog().
Index: database_mysql_dump.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/database_mysql_dump.inc,v
retrieving revision 1.9
diff -u -p -r1.9 database_mysql_dump.inc
--- database_mysql_dump.inc	28 Oct 2008 18:26:14 -0000	1.9
+++ database_mysql_dump.inc	20 Jan 2009 01:17:06 -0000
@@ -20,7 +20,7 @@ function demo_dump_db($filename, $exclud
     $header .= "-- http://drupal.org/project/demo\n";
     $header .= "--\n";
     $header .= "-- Database: ". _demo_get_database() ."\n";
-    $header .= "-- Date: ". format_date(time(), 'large') ."\n\n";
+    $header .= "-- Date: ". format_date(REQUEST_TIME, 'large') ."\n\n";
     // Avoid auto value for zero values (required for user id 0).
     $header .= "SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";\n";
     // Temporarily disable foreign key checks for the time of import.
@@ -65,8 +65,12 @@ function _demo_dump_table_structure($tab
   $output .= "-- Table structure for table '$table'\n";
   $output .= "--\n\n";
 
-  $data = db_fetch_array(db_query("SHOW CREATE TABLE %s", $table));
-  $output .= preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $data['Create Table']) .";\n";
+  $data = db_fetch_array(db_query("SHOW CREATE TABLE `$table`"));
+  $output .= preg_replace(
+    array('/^CREATE TABLE/', '/"/'),
+    array('CREATE TABLE IF NOT EXISTS', '`'),
+    $data['create table']
+  ) .";\n";
 
   return $output;
 }
@@ -83,7 +87,7 @@ function _demo_dump_table_data($table) {
   $output .= "--\n\n";
   
   // Dump table data
-  $result = db_query("SELECT * FROM %s", $table);
+  $result = db_query("SELECT * FROM $table");
 
   // Get table fields.
   if ($fields = _demo_get_fields($result)) {
@@ -168,28 +172,19 @@ function _demo_dump_table_data($table) {
 function _demo_get_fields($result) {
   $fields = array();
 
-  switch ($GLOBALS['db_type']) {
+  switch (db_driver()) {
     case 'mysql':
-      $num_fields = mysql_num_fields($result);
-      for ($i = 0; $i < $num_fields; $i++) {
-        $meta = mysql_fetch_field($result, $i);
-        // Enhance field definition with custom properties.
-        $meta->timestamp = (int)($meta->type == 'timestamp');
-        $flags = mysql_field_flags($result, $i);
-        $meta->binary = (int)(stristr($flags, 'binary') !== FALSE);
-        $fields[] = $meta;
-      }
-      break;
-
-    case 'mysqli':
-      while ($meta = mysqli_fetch_field($result)) {
+      $i = 0;
+      while ($meta = $result->getColumnMeta($i)) {
+        settype($meta, 'object');
         // Enhance the field definition for mysql-extension compatibilty.
-        $meta->numeric = (int)(bool)($meta->flags & MYSQLI_NUM_FLAG);
-        $meta->blob = (int)(bool)($meta->flags & MYSQLI_BLOB_FLAG);
+        $meta->numeric = (strtolower($meta->native_type) == 'short');
+        $meta->blob = (strtolower($meta->native_type) == 'blob');
         // Add custom properties.
-        $meta->timestamp = (int)($meta->type == MYSQLI_TYPE_TIMESTAMP);
-        $meta->binary = (int)(bool)($meta->flags & MYSQLI_BINARY_FLAG);
+        $meta->timestamp = (strtolower($meta->native_type) == 'long');
+        $meta->binary = (array_search('not_null', $meta->flags));
         $fields[] = $meta;
+        $i++;
       }
       break;
   }
Index: demo.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/demo.admin.inc,v
retrieving revision 1.3
diff -u -p -r1.3 demo.admin.inc
--- demo.admin.inc	2 Nov 2008 22:08:32 -0000	1.3
+++ demo.admin.inc	20 Jan 2009 01:17:28 -0000
@@ -127,8 +127,6 @@ function demo_dump() {
 }
 
 function demo_dump_submit($form, &$form_state) {
-  global $db_type;
-
   // Generate info file.
   $info = demo_set_info($form_state['values']);
   if (!$info) {
@@ -136,7 +134,7 @@ function demo_dump_submit($form, &$form_
   }
   
   // Include database specific functions.
-  $engine = ($db_type == 'mysqli' ? 'mysql' : $db_type);
+  $engine = db_driver();
   $inc_file = drupal_get_path('module', 'demo') .'/database_'. $engine .'_dump.inc';
   if (file_exists($inc_file)) {
     require_once $inc_file;
@@ -146,8 +144,8 @@ function demo_dump_submit($form, &$form_
   
     // Perform dump.
     $fileconfig = demo_get_fileconfig($info['filename']);
-    $exclude = array('{cache}', '{cache_content}', '{cache_filter}', '{cache_menu}', '{cache_page}', '{cache_views}', '{panels_object_cache}', '{watchdog}');
-    $exclude = array_map('db_prefix_tables', $exclude);
+    $exclude = array('{cache}', '{cache_block}', '{cache_content}', '{cache_filter}', '{cache_form}', '{cache_menu}', '{cache_page}', '{cache_path}', '{cache_registry}', '{cache_views}', '{panels_object_cache}', '{watchdog}');
+    $exclude = array_map(array('DatabaseConnection', 'prefixTables'), $exclude);
     demo_dump_db($fileconfig['sqlfile'], $exclude);
   }
   else {
@@ -174,7 +172,7 @@ function demo_reset_confirm_submit($form
   // Reset site to chosen snapshot.
   demo_reset($form_state['values']['filename']);
   // Save time of last reset.
-  variable_set('demo_reset_last', time());
+  variable_set('demo_reset_last', REQUEST_TIME);
   
   $form_state['redirect'] = isset($form_state['values']['redirect']) ? $form_state['values']['redirect'] : 'admin/build/demo';
 }
@@ -188,11 +186,11 @@ function demo_reset($filename = 'demo_si
 
   if (file_exists($fileconfig['sqlfile']) && $fp = fopen($fileconfig['sqlfile'], 'r')) {
     // Drop tables
-    $dt_watchdog = db_prefix_tables('{watchdog}');
+    $dt_watchdog = DatabaseConnection::prefixTables('{watchdog}');
     foreach (demo_enum_tables() as $table) {
       // Skip watchdog, except for legacy dumps that included the watchdog table
       if ($table != $dt_watchdog || $is_version_1_0_dump) {
-        db_query("DROP TABLE %s", $table);
+        db_query("DROP TABLE $table");
       }
     }
 
@@ -204,7 +202,13 @@ function demo_reset($filename = 'demo_si
       if ($line && $line != "\n" && strncmp($line, '--', 2) && strncmp($line, '#', 1)) {
         $query .= $line;
         if (substr($line, -2) == ";\n") {
-          if (!_db_query($query, FALSE)) {
+          $options = array(
+            'target' => 'default',
+            'return' => Database::RETURN_NULL,
+//            'throw_exception' => FALSE,
+          );
+          $stmt = Database::getActiveConnection($options['target'])->prepare($query);
+          if (!$stmt->execute(array(), $options)) {
             if ($verbose) {
               // Don't use t() here, as the locale_* tables might not (yet) exist.
               drupal_set_message(strtr('Query failed: %query', array('%query' => $query)), 'error');
@@ -279,7 +283,7 @@ function demo_get_dumps() {
   $fileconfig = demo_get_fileconfig();
   
   // Fetch list of available info files
-  $files = file_scan_directory($fileconfig['dumppath'], '.info$');
+  $files = file_scan_directory($fileconfig['dumppath'], '/.info$/');
 
   foreach ($files as $file => $object) {
     $files[$file]->filemtime = filemtime($file);
@@ -420,7 +424,7 @@ function demo_enum_tables() {
     $rx = '/^'. $db_prefix .'/';
   }
 
-  switch ($GLOBALS['db_type']) {
+  switch (db_driver()) {
     case 'mysql':
     case 'mysqli':
       $result = db_query("SHOW TABLES");
@@ -463,7 +467,7 @@ function demo_autocomplete($string = '')
   $matches = array();
   if ($string && $fileconfig = demo_get_fileconfig()) {
     $string = preg_quote($string);
-    $files = file_scan_directory($fileconfig['dumppath'], $string .'.*\.info$');
+    $files = file_scan_directory($fileconfig['dumppath'], '/'. $string .'.*\.info$/');
     foreach ($files as $file) {
       $matches[$file->name] = check_plain($file->name);
    }
Index: demo.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/demo.info,v
retrieving revision 1.7
diff -u -p -r1.7 demo.info
--- demo.info	2 Nov 2008 22:08:32 -0000	1.7
+++ demo.info	19 Jan 2009 19:52:17 -0000
@@ -2,4 +2,7 @@
 name = Demo Site
 description = Create snapshots and reset the site for demonstration or testing purposes.
 package = Development
-core = 6.x
+core = 7.x
+files[] = demo.module
+files[] = demo.admin.inc
+files[] = database_mysql_dump.inc
Index: demo.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/demo.module,v
retrieving revision 1.28
diff -u -p -r1.28 demo.module
--- demo.module	2 Nov 2008 22:08:32 -0000	1.28
+++ demo.module	19 Jan 2009 20:21:20 -0000
@@ -10,7 +10,12 @@
  * Implementation of hook_perm().
  */
 function demo_perm() {
-  return array('administer demo settings');
+  return array(
+    'administer demo settings' => array(
+      'title' => t('Administer demonstration site settings'),
+      'description' => t('Administer reset interval, create new dumps and manually reset this site.'),
+    ),
+  );
 }
 
 /**
@@ -26,7 +31,6 @@ function demo_menu() {
     'page callback' => 'drupal_get_form',
     'page arguments' => array('demo_admin_settings'),
     'access arguments' => $admin_access,
-    'file' => 'demo.admin.inc',
   );
   $items['admin/build/demo/maintenance'] = array(
     'title' => 'Status',
@@ -38,7 +42,6 @@ function demo_menu() {
     'page callback' => 'drupal_get_form',
     'page arguments' => array('demo_manage'),
     'access arguments' => $admin_access,
-    'file' => 'demo.admin.inc',
     'type' => MENU_LOCAL_TASK,
     'weight' => 1,
   );
@@ -47,7 +50,6 @@ function demo_menu() {
     'page callback' => 'drupal_get_form',
     'page arguments' => array('demo_dump'),
     'access arguments' => $admin_access,
-    'file' => 'demo.admin.inc',
     'type' => MENU_LOCAL_TASK,
     'weight' => 2,
   );
@@ -56,7 +58,6 @@ function demo_menu() {
     'page callback' => 'drupal_get_form',
     'page arguments' => array('demo_reset_confirm'),
     'access arguments' => $admin_access,
-    'file' => 'demo.admin.inc',
     'type' => MENU_LOCAL_TASK,
     'weight' => 3,
   );
@@ -64,7 +65,6 @@ function demo_menu() {
     'title' => 'Demo Site autocomplete',
     'page callback' => 'demo_autocomplete',
     'access arguments' => $admin_access,
-    'file' => 'demo.admin.inc',
     'type' => MENU_CALLBACK,
   );
   return $items;
@@ -109,7 +109,7 @@ function demo_reset_now() {
 }
 
 function demo_reset_now_submit($form, &$form_state) {
-  require_once drupal_get_path('module', 'demo') .'/demo.admin.inc';
+  module_load_include('inc', 'demo', 'demo.admin');
   demo_reset_confirm_submit($form, $form_state);
 }
 
@@ -119,10 +119,10 @@ function demo_reset_now_submit($form, &$
 function demo_cron() {
   if ($interval = variable_get('demo_reset_interval', 0)) {
     // See if it's time for a reset.
-    if ((time() - $interval) >= variable_get('demo_reset_last', 0)) {
-      require_once drupal_get_path('module', 'demo') .'/demo.admin.inc';
+    if ((REQUEST_TIME - $interval) >= variable_get('demo_reset_last', 0)) {
+      module_load_include('inc', 'demo', 'demo.admin');
       demo_reset(variable_get('demo_dump_cron', 'demo_site'), FALSE);
-      variable_set('demo_reset_last', time());
+      variable_set('demo_reset_last', REQUEST_TIME);
     }
   }
 }
