Problem/Motivation

Currently, the 'domain_site' grant is a global value that applies to all domains. If you have a case where 'send to all affiliates' should apply to 9 sites out of 10, you can't currently do that.

Proposed resolution

Let's make this configurable per domain, allowing sites to 'opt-out' of republishing content sent to 'all affiliates'. By default, sites would still opt-in.

Remaining tasks

Needs a hook_update_N(), a schema change {domain}.site_grant. and a test.

User interface changes

Adds a checkbox to the domain configuration form.

API changes

None that affect external modules.

Comments

gordon’s picture

Yes this is something we need at ecodirectory.com.au but I found this extremely difficult, because how site_grant is checked in domain_node_grants()

if (!empty($_domain['site_grant'])) {
  $grants['domain_site'][] = 0;
}

which means that to not set the domain_site grant you need to unset the site_grant var.

Too unset this you need to do the following.

function foo_domain_bootstrap_full($domain) {
  global $_domain;

  if ($domain['domain_id'] == 3) {
    unset($_domain['site_grant']);
  }
}

function foo_domain_load(&$domain) {  
  if ($domain['domain_id'] == 3) {
    unset($domain['site_grant']);
  }
}

Firstly we really need to change how domain_node_grants() treats site_grant. Maybe do something like

if (!isset($_domain['site_grant']) || $_domain['site_grant']) {
  $grants['domain_site'][] = 0;
}

Then we could implement something like...

function hook_domain_load(&$domain) {
  $domain['site_grant'] = 0;
}

which will turn off the site_grant for this domain.

Since I need this for a client, I am happy to provide a patch, but since this feature request is so old, I just want to make sure it will be accepted.

agentrickard’s picture

It needs to be fixed; it is a holdover from some very old Drupal 5 code. Another simple solution is to change the way the DEFINE is handled, which has been suggested elsewhere. Then you could set that variable in settings.php or elsewhere.

BTW: You shouldn't need to unset() the value, just set it to 0.

gordon’s picture

I would have loved to just set site_grant to 0 but the check is !empty()

gordon’s picture

Assigned: Unassigned » gordon
Status: Active » Needs review
StatusFileSize
new5.28 KB

Here is a patch which implements this.

agentrickard’s picture

Zero evaluates to empty. I don't get that part of the issue.

http://php.net/manual/en/function.empty.php

gordon’s picture

I have removed the empty() changes, and everything else is pretty much the same.

othermachines’s picture

Issue summary: View changes
StatusFileSize
new5.27 KB
new2.23 KB

I would like to see this feature. Thanks for the work on it.

There were a couple of issues with #6. I'm attaching a revised patch.

First, came across an issue related to this fix: Load $domain['site_grant'] earlier in the bootstrap process. Deleting the call to populate $_domain['site_grant'] in DOMAIN_BOOTSTRAP_FULL brought the problem back.

There were also missing single quotes around 'description' on lines 63 and 77 (see interdiff.txt).

A note that to test this patch you will need to comment out include DRUPAL_ROOT ... domain/settings.inc in settings.php, then run update.php.

bluegeek9’s picture

Status: Needs review » 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.