I have made settings to allow users to publish a content only to the assigned domains:

- Set domain access status for all content: disabled
- Publish content to any assigned domain: enabled
- Publish content only from assigned domain: enabled

(all other Domain Access specific permissions are disabled)

but when the user creates a new content, even if he can see and choose to publish the content to one domain, indeed the content goes published to all affiliates.

I think this is because the default domain publishing options, for the given content type, include 'All domains', but the documentation says:

"Note also that the user is not given the ability to promote content to 'all affiliates'. Users who need this ability should be given the 'set domain access' permission instead."

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

A specific role should not have both permissions. (The "Publish content only from assigned domain" will trump the other permission.)

The All affiliates box is very clearly within a loop that only runs if you can set domain access. So make sure that you aren't testing as user 1 or another administrator.

It is also possible that some other module is altering the form.

valentin schmid’s picture

Is there already a solution available for this issue?
We also made settings to allow users to publish a content only to the assigned domains:

- Set domain access status for all content: disabled
- Publish content to any assigned domain: enabled
- Publish content only from assigned domain: disabled

All the new content is assigned to selected affiliates and additionally to "All affiliates".
I've found no way so far to prevent assigning to "All affiliates".

Any ideas?

PS: domain_access version is 7.x-3.11

valentin schmid’s picture

Hmm. I think that's an ugly bug in the file domain.module.

The (IMHO buggy) line ...
$defaults['domain_site'] = isset($settings['DOMAIN_ALL']) ? TRUE : FALSE;
... should be ...
$defaults['domain_site'] = (isset($settings['DOMAIN_ALL']) && $settings['DOMAIN_ALL']) ? TRUE : FALSE;

Please check the attached patch.

valentin schmid’s picture

Version: 7.x-3.10 » 7.x-3.11
Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Needs review
agentrickard’s picture

Status: Needs review » Postponed (maintainer needs more info)

No, because the array_flip() will remove the DOMAIN_ALL key if the value is 0.

valentin schmid’s picture

Not here.
var_dump(array_flip(array(0 => 'DOMAIN_ALL', 1 => 'DOMAIN_ACTIVE')))
... return ...

array(2) {
  ["DOMAIN_ALL"] => int(0)
  ["DOMAIN_ACTIVE"] => int(1)
}

php version is 5.3.2-1ubuntu4.22
Also tested with php 5.4.23. Still the same result.
array_flip wont remove the DOMAIN_ALL key if the value is 0.

PS: None of the versions in http://sandbox.onlinephpfunctions.com/ removes the DOMAIN_ALL key.

agentrickard’s picture

That's not how the array is formatted. You have it backwards.

agentrickard’s picture

Make sure you go here: admin/structure/domain/nodes and configure the settings, too.

valentin schmid’s picture

Hi Ken,

The settings in admin/structure/domain/nodes are configured.
Still have the same problem without the patch.

Let's take a look at the following code in the function domain_get_node_defaults:

  // We use array_flip for compatibility with node_type_form_submit().
  $settings = array_flip(domain_default_node_access_settings($type));

  $defaults['domain_site'] = isset($settings['DOMAIN_ALL']) ? TRUE : FALSE;

The instruction domain_default_node_access_settings($type) returns (var_dump output format):
array(2) { [0]=> string(10) "DOMAIN_ALL" [1]=> string(13) "DOMAIN_ACTIVE" }

The whole instruction array_flip(domain_default_node_access_settings($type)) returns (var_dump output format):
array(2) { ["DOMAIN_ALL"]=> int(0) ["DOMAIN_ACTIVE"]=> int(1) }

Consequently the variable $defaults['domain_site'] should be set this way:
$defaults['domain_site'] = (isset($settings['DOMAIN_ALL']) && $settings['DOMAIN_ALL']) ? TRUE : FALSE;

valentin schmid’s picture

Status: Postponed (maintainer needs more info) » Active

Please let me know if you need more information regarding this issue.

agentrickard’s picture

That is not the behavior I see. See attached.

What version of PHP are you using?

valentin schmid’s picture

Oops! I was completely wrong. Patch 1 was definitely the wrong place to fix the issue.

Let me do it better in the new patch 12.
User with limited permissions shoudn't be able to publish to 'all affiliates' (even this is default admin/structure/domain/nodes).

FreeAndEasy’s picture

Patch #12 works for me!

agentrickard’s picture

Category: Bug report » Feature request
Status: Active » Needs work

I disagree here. This is by design. What this logic says is "As a non-privileged user I cannot change the default publishing behavior set by my administrator."

It's worked this way since Drupal 5.

What the documentation says is that the user "is not given the ability". Perhaps the word "ability" should change to "choice."

FreeAndEasy’s picture

When I read 'Publish content to any assigned domain' I assumed immediately that this permission also means that users with this permission can only publish to their assigned domains.

A permission like that is strongly needed. Maybe there should be a new permission called 'Publish content only to assigned domains', that would be great.

FreeAndEasy’s picture

What is the purpose of giving the user the choice to publish to specific domains, if the content get published to all domains anyways???