Comments

agentrickard’s picture

Domain Content already lets you do 50 at a time.

The D6 version is closed to new feature requests. A small helper module would probably achieve this integration.

agentrickard’s picture

Category: support » feature
Status: Active » Needs review

Here's a small pseudo-patch that I might consider. This is in Domain Content module, and should open its node operations to other modules.

/**
 * Implement hook_node_operations()
 */
function domain_content_node_operations() {
  // Only privileged users can perform this operation.
  if (user_access('set domain access')) {
    $operations = array(
      'domain' => array(
      'label' => t('Change affiliate publishing options'),
      'callback' => 'domain_content_node_operations_access',
      )
    );
    return $operations;
  }
}
fizk’s picture

With this patch, I don't see domain content's operations show up under /admin/content/node2. I'll try to help with this.

agentrickard’s picture

/admin/content/node2 ?? What module sets that path?

Note that you still need the 'set domain access' permission for the form element to appear.

agentrickard’s picture

Status: Needs review » Needs work

Oh, that patch just adds the operation. You would still need the form selection element, and it is not clear to me how to add that to any form.

And this is why we already provide this feature in Domain Content.

fizk’s picture

Status: Needs work » Needs review

To make the operation show up under Bulk Operations drop down list, I had to edit the view:

Style -> Bulk Operations (configuration wheel) -> scroll down to "Selected operations" -> check "Change affiliate publishing options (domain_content_node_operations_access)"

Edit:
Need to add the domain content form and we'll be done.

agentrickard’s picture

Status: Needs review » Needs work

Yes, but how? Is that form (from VBO) consistently named?

Just having the operation doesn't do anything.

agentrickard’s picture

StatusFileSize
new33.37 KB

I can't make VBO work. I get this stupid error when trying to add the new operation.

agentrickard’s picture

Status: Needs work » Needs review
StatusFileSize
new5.37 KB

Even so, give this a shot. Apply from the domain root dir.

agentrickard’s picture

StatusFileSize
new6.69 KB

Last patch forgot to set option properly.

fizk’s picture

Nice! The publishing options are empty though:

Publishing options:
[x] Send to all affiliates

Select if this content can be shown to all affiliates. This setting will override the options below.




Publish to:

Select which affiliates can access this content.

agentrickard’s picture

Try the second patch, in #10.

fizk’s picture

1 rows processed in about 5 ms:

* Performed aggregate Change affiliate publishing options on node 1956.

Seems like it's not saving the changes, though.

1. I'm trying to make all my content affiliated with the main page, and nothing else. Hence, "Content for all affiliate sites" page should be empty. I thought I could do this by unchecking "Send to all affiliates" and checking "Publish to: ", but it didn't work in either VBO _or_ the "Content for all affiliate sites" page.

2. Changing a single node to non-main site X doesn't show up under /admin/domain/content/3

fizk’s picture

As I suspected, the normal /admin/domain/content pages work just fine.

fizk’s picture

I think the problem is that domain_content_update_nodes(...) isn't being called. VBO calls domain_content_node_operations_access(...), and that's it.

domain_content_update_nodes() is supposed to be called by #submit when domain_content_form(...) returns a form.

fizk’s picture

Does #submit survive the confirmation step? VBO's confirmation step looks like:

Are you sure you want to perform 'Change affiliate publishing options' on selected rows?

You selected the following 1 rows:

* my test node

[ Confirm ] Cancel

fizk’s picture

Here's more info

If I add $form['#submit'][] = 'domain_content_test'; to the end of domain_content_add_form_widget(...), the test function is called on the _confirmation page_, not after the confirmation page has been submitted.

fizk’s picture

If you're on IRC, let's talk in Freenode #drupal, I'm fizk_.

agentrickard’s picture

I think your point in #15 is correct. In our normal usage, that callback is all we need. In VBO cases, we probably need a different callback.

Of course, I can't get VBO to _work_ with Views 6.x.2.8...

agentrickard’s picture

Status: Needs review » Needs work
fizk’s picture

Are you running Firefox? The screenshot looks like Safari, maybe that page is broken in Safari.

agentrickard’s picture

Firefox (3.5 on OS X). It's a form element thing. It says to edit the fields, but no fields are shown.

fizk’s picture

fizk’s picture

Maybe try adding the widget form to the confirmation page instead of the selection page?

agentrickard’s picture

Maybe... Can you try?

fizk’s picture

Done! Will upload the patch in a few minutes :)

fizk’s picture

Status: Needs work » Needs review
StatusFileSize
new8.35 KB

Patched against unmodified 6.x-2.1

agentrickard’s picture

Issue tags: +favorite

Tagging.

nonsie’s picture

Status: Needs review » Needs work

I'm getting the following error with the patch in #28:
Parameter 1 to domain_content_node_operations_access_submit() expected to be a reference, value given in views_bulk_operations\views_bulk_operations.module on line 901.

Also I cannot make any changes to affiliates using VBO.

fizk’s picture

What version of VBO are you running? I have 6.x-1.9.

domain_content_node_operations_access_submit() processes the submission. When we fix this, your changes to affiliates will be saved.

nonsie’s picture

I have 6.x-1.9 as well.
The line 901 in VBO is

return call_user_func($action_submit, $form, $form_values);

while domain_content_node_operations_access_submit uses &$form and &$form_values.

fizk’s picture

If you have devel module, can you dpm($form), or just var_dump($form).

nonsie’s picture

Status: Needs work » Needs review
StatusFileSize
new7.81 KB

Patch against DRUPAL-6--2 attached.

fizk’s picture

What was the problem?

nonsie’s picture

domain_content_node_operations_access_submit was using reference while it needs to use value.

fizk’s picture

It's faster to use references, and why isn't it breaking for me?

nonsie’s picture

Which PHP version are you running? Mine is 5.3.1

fizk’s picture

Ah, I have 5.2.12....maybe that's why.

agentrickard’s picture

Let's be sure that none of this breaks Domain Content. I also wonder if we can expose this to VBO directly in domain.module, so people wouldn't need to use Domain Content unless they wanted to.

Silicon.Valet’s picture

ack... broken again in 6.24 why was this not added to HEAD?

agentrickard’s picture

DID YOU REVIEW THE PATCH?

NO. YOU DIDN'T.

So you have no grounds to complain. And you're being offensive.

Read the thread. The two maintainers cannot make VBO work properly, so we cannot commit the patch, because we can't even verify that it works.

And it's not broken "again". The functionality does not currently exist. Domain Content _predates_ VBO.

Either help or leave.

fizk’s picture

Like I said before, the patch works for me.

nonsie had a problem and fixed it in #34.

agentrickard: can you find a nice soul to test this patch and tell us if there are problems?

agentrickard’s picture

And the questions in #40?

agentrickard’s picture

Status: Needs review » Needs work

The function domain_content_node_operations_access_submit() is just plain wrong. It processes when the confirm form is loaded, not when it is submitted.

agentrickard’s picture

Version: 6.x-2.1 » 6.x-2.4
StatusFileSize
new14.01 KB

Here's the current patch against 6--2, which fixes everything (?) except the error in domain_content_node_operations_access_submit().

Works with Domain Content, the normal Node admin form, and VBO. Though the VBO confirm operation is broken.

agentrickard’s picture

I would also greatly prefer to _remove_ the broken intermediate step in the VBO process and simply add the DA form elements directly to the selection form, as it's done in the other two cases.

agentrickard’s picture

StatusFileSize
new14.01 KB

And why are the arguments wrong? domain_content_node_operations_access_submit($form, $form_values)? That's D5 syntax.

This was a very sloppy patch.

domain_content_node_operations_access_submit needs to be removed and made to work with domain_content_update_nodes(). The duplicate code is painful.

Silicon.Valet’s picture

wow, hit a nerve here. Didn't mean to be offensive. The patch above DID work for me in 6.21 without any trouble. I was not being accusatory, merely asking why it wasn't added in. As I said, it does work for me in 6.21, just not in 6.24. I'm sorry for coming off badly.

agentrickard’s picture

Well, the patch has known bugs in it, and is not ready for production. The patch in #48 should apply to 6.x.2.4, so give it a try.

Watch what happens, however, if you hit 'Cancel' on a VBO operation. The changes still get saved. That's a bad oversight.

Part of my frustration here is that 6.x is essentially closed to new features. I'm considering an exception here, and doing extra work. So hollow complaints just don't cut it.

fizk’s picture

rickard, how do you generate your patches? "710712-domain-DRUPAL-6--2.patch" sounds like it was autogenerated

fizk’s picture

The problem with the Cancel button is that we have already changed the domain by the time the user lands on the confirmation page.

We should relying on _views_bulk_operations_action_submit to call our callback function, domain_content_node_operations_access_form.

http://drupalcontrib.org/api/function/_views_bulk_operations_action_subm...

fizk’s picture

waiting for reply here: http://drupal.org/node/712912

nonsie’s picture

re #51 - most developers create patches in issue_number + module_name + branch_version format to keep track of the patches - which results in filename like 710712-domain-DRUPAL-6--2.patch. This way it's easy to find all module or version specific patches.

Or at least that's how I've understood/used it;)

fizk’s picture

To add to the Cancel button bug, there really is no Form API Cancel button, its' just a HTML link pointing back to VBO's first page.

fizk’s picture

StatusFileSize
new13.77 KB

OK, this works for me! :)

Please try to break it.

fizk’s picture

Status: Needs work » Needs review
agentrickard’s picture

Status: Needs review » Needs work

I'd still like to see the code duplication between domain_content_node_operations_access_submit_process and domain_content_update_nodes removed.

I also just noticed that this method will not work properly IFF another module uses hook_domainrecords(). We are deliberately writing to the {node_access} table, and in some cases, that will not be desired. We may need to invoke node_access_needs_rebuild() if hook_domainrecords() is present.

fizk’s picture

I'd still like to see the code duplication between domain_content_node_operations_access_submit_process and domain_content_update_nodes removed.

Unless you can do this very quickly, let's make this a separate issue after the patch is included in HEAD.

I also just noticed that this method will not work properly IFF another module uses hook_domainrecords(). We are deliberately writing to the {node_access} table, and in some cases, that will not be desired. We may need to invoke node_access_needs_rebuild() if hook_domainrecords() is present.

Why not just invoke hook_domainrecords every time? Please update the patch if we need to add this.

fizk’s picture

Also, did you test the patch in #56?

agentrickard’s picture

1. No. I'm not putting redundant code in HEAD. You want the feature? Write the code better.

2. We have to refactor domain_content_update_nodes() to incorporate hook_domainrecords(). That's part of the work to be done. That _could_ however, be split to a new issue.

3. No. It's not ready. So I didn't test it.

fizk’s picture

1. No. I'm not putting redundant code in HEAD. You want the feature? Write the code better.
You wrote it, actually. I don't know how the domain system works, so I can't change this.

2. We have to refactor domain_content_update_nodes() to incorporate hook_domainrecords(). That's part of the work to be done. That _could_ however, be split to a new issue.
Thanks, link back to here for reference.

3. No. It's not ready. So I didn't test it.
Please test. If it's broken, that is something I can help with.

agentrickard’s picture

6.x is bugfix only. This is not a bug. It's a feature. And, no, I didn't write domain_content_node_operations_access_submit_process().

I'm busy with the D7 port.

agentrickard’s picture

agentrickard’s picture

StatusFileSize
new14.7 KB

Here's a better patch.

I _still_ don't like the VBO workflow, but am willing to let that go.

@fizk I need you to _document_ the VBO functions in this code. It's a black box, and I don't like those. In particular, I don't know what domain_content_node_operations_process_submit is doing with the 'step' value.

When testing, be aware that there are 3 separate use cases for this functionality. Your last patch broke two of them because it was entirely focused on VBO.

agentrickard’s picture

Status: Needs work » Needs review

This will also be easy to integrate with #756162: Domain Content ignores hook_domainrecords() when ready.

fizk’s picture

I'll add the documentation.

What use cases did it break/not break? I tested single step mode (no confirmation page), confirmation page mode, and Batch mode.

agentrickard’s picture

admin/build/content -- the normal batch editing screen. Triggered a form submit when no values were passed.

Same for admin/domain/content/0.

As I said, the cases you discuss are only VBO operations. hook_node_operations() is also fired by core and by Domain Content. Note the argument changes required in function domain_content_node_operations_process() to make this work.

This patch is _not_ VBO-specific. It adds VBO support and extends generic node_operations.

fizk’s picture

Oh, I thought hook_node_operations() was for VBO only.

agentrickard’s picture

Nope. It's a core hook. One that we used to implement only on the Domain Content pages. Now we're opening it up to all three.

See http://api.drupal.org/api/function/hook_node_operations

This is why I keep saying that I don't like how VBO handles the form. It's different from the other two uses.

fizk’s picture

rickard, what do you think using Drupal actions instead of node_operations?

http://drupal.org/node/712912#comment-2783974

> What's the benefit to creating an action instead of node_operation?
Nothing much, except that the fact that VBO supports 'configurable' for node_operations is a hack, whereas actions are designed to work with 'configurable'.

Also, the patch that you refer to indicates that you process the nodes when VBO calls your action's submit function. The actions guide explains that the action submit form should not execute the action, but just prepare the parameters that will be passed to the action function. Again, looking at the existing actions in VBO should clarify this.

agentrickard’s picture

The D6 version of DA is bugfix only, so if we're taking any approach other than this, it needs to be addressed in a separate module.

I would be ok with removing the VBO portions of this patch, committing the other changes, and letting VBO support happen somewhere else.

There is an existing module for this functionality: http://drupal.org/project/domain_actions

The purpose of the core DA suite is to support Drupal core. VBO is a special case that I do not feel compelled to support.

fizk’s picture

Status: Needs review » Closed (fixed)

Everyone that needs VBO support, head over to http://drupal.org/project/domain_actions.

agentrickard’s picture

I was a little surprised to see this closed. Note the changes here, if looking at how actions might work.

#757746: please add different way for "Change affiliate publishing options"

agentrickard’s picture

Status: Closed (fixed) » Fixed
StatusFileSize
new18.35 KB

I committed this version of the patch to 6.x.2 and HEAD.

agentrickard’s picture

StatusFileSize
new1.51 KB

Accidentally left in some VBO-specific cruft.

fizk’s picture

Aweseome, can you describe how the patch in #75 fixes this bug?

agentrickard’s picture

It doesn't "fix" anything. There was never a bug. Domain Content just doesn't support VBO.

The code refactor makes it easier for other modules to abstract some of the functions for use. See domain_content_add_form_widget() and domain_content_update_nodes() specifically.

Any actions should leverage these functions.

fizk’s picture

Status: Fixed » Closed (fixed)

Ah, ok.

Alrighty, when someone, maybe me, actually fixes this issue "How to change content affiliation for 1000+ nodes", we'll come back here and mark this issue as fixed.

Thanks for including the patch in #75 into HEAD.

drvdt’s picture

Version: 6.x-2.4 » 7.x-3.10
Issue summary: View changes
Status: Closed (fixed) » Active

How to do this with Drupal 7. VBO does not have.
Thanks

agentrickard’s picture

Domain Content can still do this.

drvdt’s picture

@ agentrickard
Yes, but that page can not fill by all field.
I have a solution for this issue:
- Step 1. Use VBO, can use any fill condition, change all nodes you want to "Stick"
- Step 2. Use admin/content use stick filter, change all node you have to domain you want
- Step 3. Use VBO, use stick filter, change back to Un-Stick

UksusoFF’s picture

Issue summary: View changes
UksusoFF’s picture

bluegeek9’s picture

Status: Active » Closed (outdated)

Drupal 7 in End of Life and no longer supported. We encourage you to upgrade to a supported version of Drupal. For more information, see https://www.drupal.org/upgrade.

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support of this project makes other volunteer contributions more sustainable.
There are multiple ways to show appreciation for the work contributed to this project, including:
  • Triaging issues and adding more context to existing issues.
  • Writing documentation or patches for this project.