? 6-validate.patch ? 6-x-conf-ignore.patch ? 683400-redirect.patch ? 710712-domain-DRUPAL-6--2.patch ? 752570-static.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 26 Mar 2010 17:15:59 -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' => '
'. t('If you select Change affiliate publishing options above, you should confirm the Affiliate publishing options settings below.') .'
' - ); - $form['domain']['domain_site'] = array( - '#type' => 'checkbox', - '#prefix' => t('

Publishing options:'), - '#suffix' => '

', - '#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)) { @@ -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 26 Mar 2010 17:16:00 -0000 @@ -153,11 +153,12 @@ function domain_content_check($domain_id 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', + 'configurable' => TRUE, ) ); return $operations; @@ -171,6 +172,19 @@ function domain_content_node_operations( * of domain_content_update_nodes(). */ function domain_content_node_operations_access($nodes) { +dsm(func_get_args()); +} + +/** + * Custom form stage for Views Bulk Operations. + */ +function domain_content_node_operations_access_form($arr) { + $form = array(); + domain_content_add_form_widget($form); + if (isset($form['admin']['options']['operation'])) { + $form['admin']['options']['#weight'] = -10; + } + return $form; } /** @@ -179,9 +193,29 @@ 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_update_nodes($form, $form_state); + // Set this back to not confuse the form handler. + unset($form_state['values']); } } @@ -194,5 +228,140 @@ function domain_content_domainlinks($dom 'path' => 'admin/domain/content/'. $domain['domain_id'] ); return $links; +} +/** + * Abstraction function for selecting domains for batch operations. + */ +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 = '
'. t('If you select Change affiliate publishing options, you should confirm the Affiliate publishing options settings below.') .'
'; + $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, + ); + $form['domain']['domain_site'] = array( + '#type' => 'checkbox', + '#prefix' => t('

Publishing options:'), + '#suffix' => '

', + '#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); + } +} + +/** + * 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(); +} + +/** + * Custom operation submit for Views Bulk Operations. + */ +function domain_content_node_operations_access_submit($form, $form_values) { + if ($form_values['values']['domain_site']) { + $domain_site = TRUE; + } + $domains = array(); + foreach ($form_values['values']['domains'] as $key => $value) { + // Cannot pass zero in checkboxes, so these are converted from -1. + if (abs($key) > 0 && $key == $value) { + $id = $key == -1 ? 0 : $value; + $domains[] = $id; + } + } + $all_nodes = $form_values['storage'][1]['objects']['select_all']; + $nodes = $form_values['storage'][1]['objects']['selection']; + foreach ($nodes as $node) { + $nid = $node->nid; + if ($nid > 0) { + // Delete anything not selected. + // We have to update both the {node_access} and {domain_access} tables. + db_queryd("DELETE FROM {node_access} WHERE nid = %d AND realm IN ('domain_id', 'domain_site')", $nid); + db_queryd("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(); }