? 6-validate.patch
? 6-x-conf-ignore.patch
? 683400-redirect.patch
? 710712-dc.patch
? 710712-domain-DRUPAL-6--2.patch
? 710712-domain-DRUPAL-6--2.v2.patch
? 752570-reset-domain-nid.patch
? 756162-domain-content.patch
Index: domain_content/domain_content.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_content/domain_content.admin.inc,v
retrieving revision 1.15.2.3
diff -u -p -r1.15.2.3 domain_content.admin.inc
--- domain_content/domain_content.admin.inc	10 Mar 2010 18:24:26 -0000	1.15.2.3
+++ domain_content/domain_content.admin.inc	29 Mar 2010 18:34:08 -0000
@@ -237,45 +237,7 @@ function domain_content_form($form_state
   }
   // Privileged users can make global changes to Domain Access permissions.
   if (user_access('set domain access')) {
-    $options = array();
-    $format = domain_select_format();
-    foreach (domain_domains() as $data) {
-      // Cannot pass zero in checkboxes.
-      ($data['domain_id'] == 0) ? $key = -1 : $key = $data['domain_id'];
-      // The domain must be valid.
-      if ($data['valid'] || user_access('access inactive domains')) {
-        // Filter checkboxes but not select lists.
-        $options[$key] = empty($format) ? check_plain($data['sitename']) : $data['sitename'];
-      }
-    }
-    $form['domain'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Affiliate publishing options'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-      '#prefix' => '<div class="description">'. t('If you select <em>Change affiliate publishing options</em> above, you should confirm the <em>Affiliate publishing options</em> settings below.') .'</div>'
-    );
-    $form['domain']['domain_site'] = array(
-      '#type' => 'checkbox',
-      '#prefix' => t('<p><b>Publishing options:</b>'),
-      '#suffix' => '</p>',
-      '#title' => t('Send to all affiliates'),
-      '#required' => FALSE,
-      '#description' => t('Select if this content can be shown to all affiliates.  This setting will override the options below.'),
-      '#default_value' => variable_get('domain_behavior', DOMAIN_INSTALL_RULE),
-    );
-    $form['domain']['domains'] = array(
-      '#type' => empty($format) ? 'checkboxes' : 'select',
-      '#title' => t('Publish to'),
-      '#options' => $options,
-      '#required' => FALSE,
-      '#description' => t('Select which affiliates can access this content.'),
-      '#default_value' => array(($_domain['domain_id'] == 0) ? -1 : $_domain['domain_id']), // Can't use 0 as a checkbox value.
-    );
-    if ($format) {
-      $form['domain']['domains']['#multiple'] = TRUE;
-      $form['domain']['domains']['#size'] = count($options) > 10 ? 10 : count($options);
-    }
+    domain_content_add_form_widget($form);
   }
   // Users must have passed at least one access check to have batch options.
   if ((user_access('administer nodes') || user_access('set domain access')) && !empty($nodes)) {
@@ -299,7 +261,7 @@ function domain_content_form($form_state
   $form['#theme'] = 'domain_content_admin_nodes';
   $form['#validate'][] = 'node_admin_nodes_validate';
   $form['#submit'][] = 'node_admin_nodes_submit';
-  $form['#submit'][] = 'domain_content_update_nodes';
+  $form['#submit'][] = 'domain_content_process_nodes';
   return $form;
 }
 
@@ -333,48 +295,6 @@ function domain_content_filter_operation
 }
 
 /**
- * FormAPI function that lets us update access rules.
- */
-function domain_content_update_nodes($form, &$form_state) {
-  // If our operation is flagged, then we have to manually change the
-  // {node_access} table.  The rest of the process will clear the cache,
-  // so this should be a safe operation.
-  if ($form_state['values']['operation'] == 'domain') {
-    if ($form_state['values']['domain_site']) {
-      $domain_site = TRUE;
-    }
-    $domains = array();
-    foreach ($form_state['values']['domains'] as $key => $value) {
-      // Cannot pass zero in checkboxes, so these are converted from -1.
-      if (abs($key) > 0 && $key == $value) {
-        ($key == -1) ? $id = 0 : $id = $value;
-        $domains[] = $id;
-      }
-    }
-    foreach ($form_state['values']['nodes'] as $nid) {
-      if ($nid > 0) {
-        // Delete anything not selected.
-        // We have to update both the {node_access} and {domain_access} tables.
-        db_query("DELETE FROM {node_access} WHERE nid = %d AND realm IN ('domain_id', 'domain_site')", $nid);
-        db_query("DELETE FROM {domain_access} WHERE nid = %d", $nid);
-        if (isset($domain_site)) {
-          db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", $nid, 0, 'domain_site', 1, 0, 0);
-          db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid, 0, 'domain_site');
-        }
-        if (!empty($domains)) {
-          foreach ($domains as $id) {
-            db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", $nid, $id, 'domain_id', 1, 1, 1);
-            db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid, $id, 'domain_id');
-          }
-        }
-      }
-    }
-  }
-  // Clear the cache.
-  cache_clear_all();
-}
-
-/**
  * Replaces the default theme function for the node administration form.
  *
  * @param $form
@@ -388,8 +308,8 @@ function theme_domain_content_admin_node
   // Overview table:
   $header = array(theme('table_select_header_cell'), t('Title'), t('Affiliates'), t('Type'), t('Author'), t('Status'), t('Operations'));
   $output = '';
-  $output .= drupal_render($form['options']);
   $output .= drupal_render($form['domain']);
+  $output .= drupal_render($form['options']);
   if (isset($form['title']) && is_array($form['title'])) {
     foreach (element_children($form['title']) as $key) {
       $row = array();
Index: domain_content/domain_content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_content/domain_content.module,v
retrieving revision 1.30.2.1
diff -u -p -r1.30.2.1 domain_content.module
--- domain_content/domain_content.module	18 Feb 2010 15:21:22 -0000	1.30.2.1
+++ domain_content/domain_content.module	29 Mar 2010 18:34:09 -0000
@@ -148,16 +148,28 @@ function domain_content_check($domain_id
 }
 
 /**
+ * Implement hook_domainlinks()
+ */
+function domain_content_domainlinks($domain) {
+  $links[] = array(
+    'title' => t('content'),
+    'path' => 'admin/domain/content/'. $domain['domain_id']
+  );
+  return $links;
+}
+
+/**
  * Implement hook_node_operations()
  */
 function domain_content_node_operations() {
   // Only privileged users can perform this operation.
   // Do not show this on the default node editing form.
-  if (arg(0) == 'admin' &&  arg(1) == 'domain' && user_access('set domain access')) {
+  if (user_access('set domain access')) {
     $operations = array(
       'domain' => array(
       'label' => t('Change affiliate publishing options'),
-      'callback' => 'domain_content_node_operations_access',
+      'callback' => 'domain_content_node_operations_process',
+      'configurable' => TRUE,
       )
     );
     return $operations;
@@ -169,8 +181,14 @@ function domain_content_node_operations(
  *
  * This callback is required, but we actually do our action inside
  * of domain_content_update_nodes().
+ *
+ * In the case of VBO, an actual form is passed here. Otherwise, we
+ * let our form submit handler process things.
  */
-function domain_content_node_operations_access($nodes) {
+function domain_content_node_operations_process($nodes, $form = array(), $form_state = array()) {
+  if (!empty($form_state['values'])) {
+    domain_content_node_operations_submit($form, $form_state);
+  }
 }
 
 /**
@@ -179,20 +197,177 @@ function domain_content_node_operations_
  *
  * @link http://drupal.org/node/336218
  */
-function domain_content_form_alter(&$form, &$form_state, $form_id) {
-  if ($form_id == 'node_multiple_delete_confirm') {
-    $form['#redirect'] = $_GET['q'];
+function domain_content_form_node_multiple_delete_confirm_alter(&$form, &$form_state) {
+  $form['#redirect'] = $_GET['q'];
+}
+
+/**
+ * Allow domain assignment to be made from the default content form.
+ */
+function domain_content_form_node_admin_content_alter(&$form, &$form_state) {
+  // Privileged users can make global changes to Domain Access permissions.
+  if (!user_access('set domain access')) {
+    return;
+  }
+
+  // Add our form elements.
+  domain_content_add_form_widget($form);
+  $form['domain']['#weight'] = -1;
+
+  // We cannot alter in a submit function to this form, so we fake it on post.
+  if (isset($form_state['post']['operation']) && $form_state['post']['operation'] == 'domain') {
+    $form_state['values'] = $form_state['post'];
+    domain_content_process_nodes($form, $form_state);
+    // Set this back to not confuse the form handler.
+    unset($form_state['values']);
   }
 }
 
 /**
- * Implement hook_domainlinks()
+ * Abstraction function for selecting domains for batch operations.
  */
-function domain_content_domainlinks($domain) {
-  $links[] = array(
-    'title' => t('content'),
-    'path' => 'admin/domain/content/'. $domain['domain_id']
+function domain_content_add_form_widget(&$form) {
+  global $_domain;
+  // We have different settings for the two form contexts.
+  // A blank form comes from VBO or core.
+  $prefix = '<div class="description">'. t('If you select <em>Change affiliate publishing options</em>, you should confirm the <em>Affiliate publishing options</em> settings below.') .'</div>';
+  $collapsed = TRUE;
+  if (empty($form)) {
+    $prefix = '';
+    $collapsed = FALSE;
+  }
+  $options = array();
+  $format = domain_select_format();
+  foreach (domain_domains() as $data) {
+    // Cannot pass zero in checkboxes.
+    $key = $data['domain_id'] == 0 ? -1 : $data['domain_id'];
+    // The domain must be valid.
+    if ($data['valid'] || user_access('access inactive domains')) {
+      // Filter checkboxes but not select lists.
+      $options[$key] = empty($format) ? check_plain($data['sitename']) : $data['sitename'];
+    }
+  }
+  $form['domain'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Affiliate publishing options'),
+    '#collapsible' => TRUE,
+    '#collapsed' => $collapsed,
+    '#prefix' => $prefix,
   );
-  return $links;
+  $form['domain']['domain_site'] = array(
+    '#type' => 'checkbox',
+    '#prefix' => t('<p><b>Publishing options:</b>'),
+    '#suffix' => '</p>',
+    '#title' => t('Send to all affiliates'),
+    '#required' => FALSE,
+    '#description' => t('Select if this content can be shown to all affiliates.  This setting will override the options below.'),
+    '#default_value' => variable_get('domain_behavior', DOMAIN_INSTALL_RULE),
+  );
+  $form['domain']['domains'] = array(
+    '#type' => empty($format) ? 'checkboxes' : 'select',
+    '#title' => t('Publish to'),
+    '#options' => $options,
+    '#required' => FALSE,
+    '#description' => t('Select which affiliates can access this content.'),
+    '#default_value' => array(($_domain['domain_id'] == 0) ? -1 : $_domain['domain_id']), // Can't use 0 as a checkbox value.
+  );
+  if ($format) {
+    $form['domain']['domains']['#multiple'] = TRUE;
+    $form['domain']['domains']['#size'] = count($options) > 10 ? 10 : count($options);
+  }
+}
 
+/**
+ * Process the form submission.
+ *
+ * This callback works for the normal operations callback, not VBO.
+ */
+function domain_content_process_nodes($form, &$form_state) {
+  if ($form_state['values']['operation'] != 'domain') {
+    return;
+  }
+  $options = array();
+  $options['domain_site'] = FALSE;
+  if ($form_state['values']['domain_site']) {
+    $options['domain_site'] = TRUE;
+  }
+  $options['domain_id'] = array_filter($form_state['values']['domains']);
+  $nids = array_filter($form_state['values']['nodes']);
+  domain_content_update_nodes($nids, $options);
+}
+
+/**
+ * Abstraction function that lets us update access rules.
+ */
+function domain_content_update_nodes($nids, $options) {
+  // If our operation is run, then we have to manually change the
+  // {node_access} table.  The rest of the process will clear the cache,
+  // so this should be a safe operation.
+  $domain_site = $options['domain_site'];
+  $domains = $options['domain_id'];
+  foreach ($nids as $nid) {
+    if ($nid > 0) {
+      // Delete anything not selected.
+      // We have to update both the {node_access} and {domain_access} tables.
+      db_query("DELETE FROM {node_access} WHERE nid = %d AND realm IN ('domain_id', 'domain_site')", $nid);
+      db_query("DELETE FROM {domain_access} WHERE nid = %d", $nid);
+      if (!empty($domain_site)) {
+        db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", $nid, 0, 'domain_site', 1, 0, 0);
+        db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid, 0, 'domain_site');
+      }
+      if (!empty($domains)) {
+        foreach ($domains as $id) {
+          $key = ($id == -1) ? 0 : $id;
+          db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", $nid, $key, 'domain_id', 1, 1, 1);
+          db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid, $key, 'domain_id');
+        }
+      }
+    }
+  }
+  // Clear the cache.
+  cache_clear_all();
+}
+
+/**
+ *  Custom form stage for Views Bulk Operations.
+ *
+ * @param $arguments
+ *   The Views arguments passed by VBO.
+ * @return
+ *   A custom form element for this multi-step process.
+ */
+function domain_content_node_operations_process_form($arguments) {
+  $form = array();
+  domain_content_add_form_widget($form);
+  if (isset($form['admin']['options']['operation'])) {
+    $form['admin']['options']['#weight'] = -10;
+  }
+  return $form;
+}
+
+/**
+ * Custom operation submit for Views Bulk Operations.
+ */
+function domain_content_node_operations_process_submit($form, &$form_state) {
+  // This is a three step form, and our action is on step three.
+  if ($form_state['values']['step'] == 2) {
+    return array($form, $form_state);
+  }
+  return domain_content_node_operations_submit($form, $form_state);
+}
+
+/**
+ * Submit handler for Views Bulk Operations.
+ *
+ * We need this because VBO processes nodes differently.
+ */
+function domain_content_node_operations_submit($form, &$form_state) {
+  $options = array();
+  $options['domain_site'] = FALSE;
+  if ($form_state['values']['domain_site']) {
+    $options['domain_site'] = TRUE;
+  }
+  $options['domain_id'] = array_filter($form_state['values']['domains']);
+  $nids = array_keys($form_state['storage'][1]['objects']['selection']);
+  domain_content_update_nodes($nids, $options);
 }
