Hello,

I'm using Image module 6.x-1.2 with image_import plugin.
When I import images, nodes are created correctly, but I realised that the reason why I couldn't see the nodes listed in the Administer > List Content section was because the "Publish to" field was blank : none of my affiliates domains was selected : nor the current one, neither the default one.

I have to edit each node, and select the "Publish to" affiliate...as you can imagine, I'm loosing the interest of image_import.
In my nodes_settings section, domain_node_types sub section, I have nothing checked, and I want that to stay as is, since I don't want any content type to be published to all affiliates by default upon creation.

That being said, I'm pretty sure I have a problem on my system, and not with Domain features, because I read here or there persons having a similar issue, but at least, the field was populated with something (their issue was that it wasn't the correct value).
In my case, I have no value at all !

Any idea how to correct this ?
Thanks for your suggestion,

Comments

agentrickard’s picture

Not much you can do here except write the code that is missing from image_import to deal with proper domain assignments.

See the developer notes in the documentation for information about how to construct $node->domain information. The function domain_form_devel_generate_content_form_alter() can also give you some examples.

agentrickard’s picture

These all should, however, at least be assigned to the default domain.

l_arbalette’s picture

Thanks for your reply.
I indeed see that in the image_create_node_from function, from image_import module, the created node does not build any domain related variable.
From what I understand from your #1 reply, I should modify this function to add a section to construct $node->domain information. I read, as suggested, http://drupal.org/node/1096988 and even http://drupal.org/node/1096982, but it didn't help me that much. I will keep studying it.

But let me please come back on your #2 reply first : from what I understand (I'm not sure I got your point), even if I don't construct $node>domain information in the image_create_node_from function, the node should anyway acquire the default domain ?

Running the code step by step showed me that, in image_create_node_from function :
- before node_save($node); call, nothing is related to domain in $node
- after a call to node_save($node);, 2 new variables have been added (domain_source = 0 and domain_site = 0) and 1 array (domains, with one value [0] = 0)
(I have 4 affiliates, 0 being the default one I assume)
And then, the node is still saved without any "Publish to" selected affiliate.
Is something's missing ? If yes, why ?
If no, then my confusion is even greater !

l_arbalette’s picture

ok, got it.
First : I succeeded in making the whole thing work by adding the following code to the function :

global $_domain
// Domain Access features
  if (isset($_domain['domain_id'])) {
    $node->domain_site = FALSE; // Sets "Send to all affiliates" off
    $node->domain_source = $_domain['domain_id']; // Sets the "Source domain"
    if ($_domain['domain_id'] == 0){  // If the active domain is the default domain, have to replace 0 by -1 since checkboxes cannot accept 0
          $node->domains = array(-1 => -1); // Sets the domains node is published to.
    }
    else {
          $node->domains = array($_domain['domain_id'] => $_domain['domain_id']); // Sets the domains node is published to.
    }
  }

Secondly, I guess I figured out why the "default" behaviour is not working : as mentionned, domains array was populated with one value : [0] => 0, after the call of node_save function.
But as you mentionned it here http://drupal.org/node/1343980, 0 is not accepted with checkboxes, and has to be replaced by -1.
But the default behaviour seems to populate the domains array with 0 instead of -1.
Am I correct that it is the cause of the issue ? What do we have to change to make it work properly ? (without switching to D7 of course ! ;-) )

agentrickard’s picture

The issue is that domain_node_access_records() should assign the node to the default domain for you if none of the domain properties are set on the node. Passing 0 or -1 to that function should have the same effect. We only have to massage it when using a form.

l_arbalette’s picture

According to you, it should work properly by default ?
What's wrong then on my setup ? (unless I'm missing your point ?)

agentrickard’s picture

I can't debug your setup. If the hack from comment #4 works, then use it.

What I don't understand is why domain_node_access_records() isn't firing properly without that code. There are some things to check:

1) Is DA installed and running correctly before starting the import?
2) What, if any, data gets saved in the {node_access} table on import?
3) What, if any, data gets saved in the {domain_access} table on import?

l_arbalette’s picture

yes, hack is working and I'm using it.
Anyway, I would be happy to understand why it's not working the way it should.
To answer your questions, I just tested the importation of 1 picture after having removed the hack :
One node has been created in node, type = image
1/ DA is installed and working
2/ node_access table has been populated with the following value :

  • gid = 2
  • realm = content_access_id
  • grant_view = 1
  • grant_update = 0
  • grant_delete = 0

3/domain_access has not been populated with anything related to this node.

I'm wondering if maybe Content Access module may conflict with Domain Access ?
I have it installed on my drupal...

agentrickard’s picture

Very likely, yes. I wish you had mentioned that module earlier.

I suspect Content Access is setting a grants "priority" > 0 in it's hook_node_access_records(). Doing so destroys the grants set by Domain Access, which is why you have no records.

You really can't run both modules together without writing custom bridge code.

agentrickard’s picture

And your hack wouldn't really "work" in that case, because you won't have any domain access records in the {node_access} table. Without those, the module doesn't work. The {domain_access} table is really just for rebuilding the {node_access} table when required.

l_arbalette’s picture

ok, sorry not to have mentionned it sooner. It did not come to my mind at all that there could be conflicts !
I don't get your point regarding my hack not working...since it is working ?

but anyway, I understand having both Domain Access and Content Access on my drupal is the cause of the unexpected behaviour and that custom bridges have to be developped if I want it to work differently.

Thanks for your time, and for your wonderfull module !

agentrickard’s picture

Status: Active » Closed (works as designed)

In D6, you likely need to implement hook_domainrecords() to make this work. See the API.php document in the download.