how to let a node visible to all subdomains admins, but published only if a sub-domain editor choose to publish in his own site?

carvalhar - August 13, 2009 - 11:36
Project:Domain Access
Version:6.x-2.0-rc8
Component:Miscellaneous
Category:bug report
Priority:critical
Assigned:Unassigned
Status:patch (to be ported)
Description

Hi there,

I have a site with two profiles: one is a supervisor admin who can create nodes for a custom content type and them publish it to some affiliates.
The other profile is a local admin (responsible just for his sub-domain) who can pick up one of theses nodes and them publish it in his sub-domain.

So, i got one BIG problem:

The supervisor creates a node as unpublished and it's ok.
But when a local admin publish it in his site (I have marked Publish options in Node Settings->Domain node editing) all other sub-domains have the node published too.

So, how should i configure domain access to let each local admin decide if the node is published or not in his own site?
Any alternative?

Thanks!
Carlos

PS: Searching in other sub-domain also return the node, because once it's set as published by a local admin it is published in all sub-domains. Also, i don't want to let a sub-domain admin having access to Domain Access publishing options, to avoid the case of one sub-domain editor change the configuration of other sub-domain.

#1

agentrickard - August 13, 2009 - 13:59

You would need a custom module to enforce this rule, tracking the publication state of the node per domain and modifying it during node_load(). This might make a good stand-alone module.

Otherwise, you have to live with the options presented in section 3.1 of the README. You probably want to give sub-editors the 'publish to assigned domains' permission, which will _show_ them were a node is published, but only let them add/remove from their assigned domains.

One other option is to create a 'staging' domain. Publish all content to that domain, give all editors access to it, and then let them add content to their domain when they see fit.

#2

agentrickard - August 13, 2009 - 18:04

Well, let me amend that last comment.

You can't do this in Domain Access, because node access rules are not invoked for unpublished nodes. Only administrators or users with the 'edit XX nodes' can view/edit unpublished nodes, so a node access module has no way to enforce this logic.

See http://api.drupal.org/api/function/node_access/6

  // If the module did not override the access rights, use those set in the
  // node_access table.
  if ($op != 'create' && $node->nid && $node->status) {

So you would have to use the staging domain option, and set all nodes to 'published' and then assign them to domains as needed.

#3

carvalhar - August 17, 2009 - 13:15

Hi Rickard,

I'm trying to make this work as i need.

You talked about 'publish to assigned domains' but i see only 'publish from assigned domain'. I suppose it's the same, or i don't have this permission listed?

When a supervisor creates a new node, he sets the node published to all domains (DA publish option), but the node is set as "unpublished" (from the default Drupal's publish options, not the DA option). This is working fine, local admins can see the node as unpublished and if they want they can publish (the core option).

The problem goes when someone publish (core option) the node. I'd like to know where should i start to make this custom module interaction with node_load()...i confess i'm a bit lost :(

Any help or tip or clue is welcomed :)

thanks,
Carlos

#4

agentrickard - August 17, 2009 - 13:54
Priority:critical» normal

See section 3.1 on module permissions. There are both 'publish from assigned domain' and 'publish to any assigned domains' permissions.

You _cannot_ do what you want, as I explained in #2. Drupal's node access system will not let you, because only the node owner and users with the 'administer nodes' permission (or 'edit XXX type' permission) can edit an unpublished node. Domain Access cannot assert rights to unpublished nodes.

#5

carvalhar - August 17, 2009 - 16:54

Hi,

I'm trying the alternative at #1, but i got:
"The source affiliate must be selected as a publishing option."

Attached there is a print screen of my DA permissions. And the "Affiliate publishing options" in node/*/edit are:

Publish to
Sub-Domain 1
Select which affiliates can access this content.
Publishing status:
    * Domain
    * Sub-Domain 2
    *Sub-Domain 3
This content has also been published to these affiliates.

What is wrong?

Thanks,
Carlos

PS: i tried before the change at node_load "if ($op != 'create' && $node->nid && $node->status)" to "if ($op != 'create' && $node->nid)" but nothing different appeared.

AttachmentSize
Permissões | FGV_1250527815541.png 13.38 KB

#6

carvalhar - August 17, 2009 - 17:07

Just a note: the main admin has an option "Source domain" that doesn't exist with the editor set with only "publish to any assigned domains".
Is there a chance that the error "The source affiliate must be selected as a publishing option." is caused because Source Domain isn't editable, but doesn't pass the default source (eg: don't change them) ?

#7

agentrickard - August 17, 2009 - 17:30

Domain Source _does_ pass a default value if the editor doesn't have the proper permissions.

See lines 57-74 of domain_source.module.

Take a look inside domain_source_validate() to see if you can determine where the error is thrown.

And node_load() won't have any effect at all. We're looking at node_access(). Don't hack core; it will only cause problems and I will stop giving you support.

#8

carvalhar - August 17, 2009 - 18:02

Hi,

thanks for the fast answer :)

I found that this error was appearing at line 100 from domain source (function domain_source_nodeapi), so i commented the error and now it's working:
[...]
//form_set_error('domain_source', t('The source affiliate must be selected as a publishing option.'));
[...]

But this way the content can be visible if you access a direct url, as /node/14. Although, trough search it isn't detected.

I'm trying to apply a rule (Rules module) to detect if the node is publish to the domain, if it isn't, i'l l try to redirect it, as a 404.

Do you see a better solution?

How can i detect by PHP if the node is published (DA option) in the current domain?

thanks,
Carlos

#9

agentrickard - August 17, 2009 - 19:20

The question is _WHY_ is the error being thrown? Commenting out the error does not FIX the problem. Let's concentrate on that in this issue.

As for the PHP question, read the API or study the module. DA figures this out for you, so you shouldn't need to do anything. There is also a module somewhere in the queue that issues redirects. See #255711: Redirect search engines.

#10

carvalhar - August 17, 2009 - 20:43

i'm not sure why the error occurs, coudn't find a reason for it.

My solution with Rules is to detect if the node->domains list doesn't contain the id of the current domain:

global $_domain;
$redireciona = true;
foreach ($node->domains as $value) {
if ($value == $_domain['domain_id']) {
$redireciona = false;
break;
}
}
return $redireciona;

That's not a clean solution, but it's working.

thanks,
Carlos

#11

agentrickard - August 17, 2009 - 20:47

Let me see if I can reproduce.

#12

agentrickard - August 17, 2009 - 21:30

Bah. There is a bug in Domain Content.

I wonder if this helps? This patch has been committed to HEAD.

AttachmentSize
548140-dc.patch 1.29 KB

#13

agentrickard - August 17, 2009 - 22:03
Category:support request» bug report
Priority:normal» critical
Status:active» needs review

And a patch for the Domain Source error. We need to check AND not OR, in the error check.

AttachmentSize
548140-source-validate.patch 1.26 KB

#14

agentrickard - October 11, 2009 - 14:45

The patch in #13 is not right.

#15

agentrickard - October 11, 2009 - 15:19
Status:needs review» patch (to be ported)

THe patch failed because of errors in #601516: Inconsistent use of 'publish to any assigned domain'.

Here is an updated patch. Committed to HEAD.

AttachmentSize
548140-source-validate.patch 2.05 KB
 
 

Drupal is a registered trademark of Dries Buytaert.