From 17f43e81173dfdaa242a56eb11ef2a5189afc678 Mon Sep 17 00:00:00 2001
From: Juan Pablo Novillo <juampy72@gmail.com>
Date: Thu, 9 Feb 2012 12:25:07 +0100
Subject: [PATCH] Issue #1430130 by greg.1.anderson: Enable development
 modules after syncing from @live to @dev

Added an option to disable modules.
---
 examples/sync_enable.drush.inc |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/examples/sync_enable.drush.inc b/examples/sync_enable.drush.inc
index 1d26cfa..e370cea 100644
--- a/examples/sync_enable.drush.inc
+++ b/examples/sync_enable.drush.inc
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Sync_enable adds an "enable" option to sql-sync to enable
+ * Sync_enable adds options to sql-sync to enable and disable
  * modules after an sql-sync operation.  One use case for this
  * is to use Drush site aliases to automatically enable your 
  * development modules whenever you sync from your live site to
@@ -13,8 +13,9 @@
  *   'root' => '/srv/www/drupal',
  *   'uri' => 'site.com',
  *   'target-command-specific' => array(
- *     'sql-sync' => array(
- *       'enable' => array('devel', 'hacked'),
+ *     'sql-sync'  => array(
+ *       'enable'  => array('devel', 'hacked'),
+ *       'disable' => array('securepages'),
  *     ),
  *   ),
  * );
@@ -40,7 +41,8 @@
  */
 function sync_enable_drush_help_alter(&$command) {
   if ($command['command'] == 'sql-sync') {
-    $command['options']['enable'] = "Enable the specified modules in the target database after the sync operation has completed.";
+    $command['options']['enable']  = "Enable the specified modules in the target database after the sync operation has completed.";
+    $command['options']['disable'] = "Disable the specified modules in the target database after the sync operation has completed.";
   }
 }
 
@@ -49,7 +51,7 @@ function sync_enable_drush_help_alter(&$command) {
  *
  * The post hook is only called if the sql-sync operation completes
  * without an error.  When called, we check to see if the user specified
- * any modules to enable.  If so, we will call pm-enable on each module.
+ * any modules to enable/disable.  If so, we will call pm-enable/pm-disable on each module.
  */
 function drush_sync_enable_post_sql_sync($source = NULL, $destination = NULL) {
   $modules_to_enable = drush_get_option_list('enable');
@@ -57,4 +59,9 @@ function drush_sync_enable_post_sql_sync($source = NULL, $destination = NULL) {
     drush_log(dt("Enable !modules post-sql-sync", array('!modules' => implode(',', $modules_to_enable))), 'ok');
     drush_invoke_process($destination, 'pm-enable', $modules_to_enable, array('yes' => TRUE));
   }
+  $modules_to_disable = drush_get_option_list('disable');
+  if (!empty($modules_to_disable)) {
+    drush_log(dt("Disable !modules post-sql-sync", array('!modules' => implode(',', $modules_to_disable))), 'ok');
+    drush_invoke_process($destination, 'pm-disable', $modules_to_disable, array('yes' => TRUE));
+  }
 }
-- 
1.7.5.4

