From 52997255819c8117bbb4fe2f081001bd2333fce5 Mon Sep 17 00:00:00 2001
From: Steve Karsch <skarsch@skarsch-unumtu.(none)>
Date: Sat, 26 Feb 2011 10:31:03 -0500
Subject: [PATCH] Issue #1073946 by karschsp: If the variable_changes module is enabled, an extra option is added on the variable_dump page to allow for exporting of variables that have changed since the last backup.

---
 variable_dump.module |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/variable_dump.module b/variable_dump.module
index ce56d35..9313794 100644
--- a/variable_dump.module
+++ b/variable_dump.module
@@ -53,6 +53,9 @@ function variable_dump_export_form(&$form_state) {
         ),
         '#description' => t('The type of search to perform.'),
       );
+      if (module_exists('variable_changes')) {
+        $form['operation']['#options']['variable_changes'] = t('Variable Changes');
+      }
       $form['type'] = array(
         '#title' => t('Type of export'),
         '#type' => 'radios',
@@ -226,6 +229,17 @@ function _variable_dump_get_vars($text, $type) {
     case 'ends_with':
       $result = db_query("SELECT * FROM {variable} WHERE name LIKE('%$text') ORDER BY name");
       break;
+    case 'variable_changes':
+      $r = db_query("SELECT v.name name, v.value AS current_value, vc.value AS old_value FROM {variable} v LEFT JOIN {variable_copy} vc ON v.name = vc.name");
+      while ($row = db_fetch_object($r)) {
+        if ($row->current_value == $row->old_value) {
+          // do nothing
+        } else {
+          $vals[] = "'" . $row->name . "'";
+        }
+      }
+      $result = db_query("SELECT * FROM {variable} WHERE name IN (" . implode(', ',  $vals) . ") ORDER BY name");
+      break;
     default:
       $result = db_query("SELECT * FROM {variable} WHERE name LIKE('$text%') ORDER BY name");
       break;  
-- 
1.7.1

