I'm not sure if this is a bug or if I'm misusing Domain Access. My use case is a newspaper website, where anonymous users can submit obituaries to one or more of four affiliated newspapers. I've assigned anonymous users the "view domain publishing" privilege, and I'm using the "show checkboxes of available domains" option for the node form. However, because the anonymous $user object doesn't have any domain_user data, domain_form_alter returns drupal_access_denied on line 1127. Should there be a way to specify which domains are available to anonymous users submitting content? If so, I'm happy to write a patch.

Comments

agentrickard’s picture

This is related to #311398: domain_form_alter fails for anonymous user. The 'view domain publishing' permission was never designed for use with anonymous users, since anon users usually can't submit content.

You need a means to control where anonymous uses post. One option is a small module that uses hook_user() to add domain information to the anon user object (user 0):

custom_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'load') {
   $account->domain_user = array(
    -1 => -1, // the primary domain
     2 => 2, // domain_id #2
   );
  }
}

The array here should be in the form $key = $value, where both $key and $value are the domain_id, and -1 indicates the primary domain.

I would also be willing to review a patch that lets you set domain privlieges for user 0, which would need to be a separate admin page or fieldset on Admin > Build > Domains.

ksenzee’s picture

Assigned:Unassigned» ksenzee

Great. Working on a patch now.

agentrickard’s picture

Simple checkboxes that save to the user 0 row in the db should be fine. We're actually lazy right now and just store this data as a serialized array in the 'data' column of {users}.

ksenzee’s picture

StatusFileSize
new3.32 KB

We're actually lazy right now and just store this data as a serialized array in the 'data' column of {users}.

It's not laziness, it's database denormalization for greater efficiency! OSLT.

I'm attaching a patch that adds the info on user load -- I had that part done before I saw your reply. Let me know if it's okay or if you'd rather I cooked one up that saves to the users table.

agentrickard’s picture

Status:Active» Needs review

The use of the variables table is fine, and may be preferred by some folks, in fact.

I think my only complaint is the fieldset title.

'Domains that accept anonymous content'

I would just use 'Anonymous user settings' --> note that this would also apply to Domain Strict, which is a bonus for this patch.

ksenzee’s picture

StatusFileSize
new3.28 KB

"Anonymous user settings" sounds better to me too. New patch attached.

Summit’s picture

Subscribing, greetings, Martijn

agentrickard’s picture

I am probably going to break this out to a separate page, where you can add default assignments per role.

agentrickard’s picture

Also note, I am about to put this into 6.x.2. Then it will get backported.

agentrickard’s picture

Status:Needs review» Patch (to be ported)

Committed to HEAD.

agentrickard’s picture

StatusFileSize
new58.63 KB

Attached is a screenshot of the new admin interface, for D6.

agentrickard’s picture

Version:5.x-1.8» 6.x-2.0-rc5

Releases in 6.x.2.0-rc5.

agentrickard’s picture

Category:bug» feature
shushu’s picture

Status:Patch (to be ported)» Closed (fixed)

Can't this bug be closed ?

stevebab’s picture

@agentrickard - Brilliant module, useful update.

How might I add "anonymous" to each domain automatically when the domain is created? Is there a check we can put in a custom module that would grant anonymous "create" privileges on whatever domain they are browsing?

stevebab’s picture

Status:Closed (fixed)» Active

Reopening to see if we could have User Default patterns always set for new domains.

That is, how can we set new domains to always assign anonymous, authenticated (and whatever other roles) by default when a new domain is created.

As it is now, I believe the only way to apply user defaults is to go into the User Defaults menu manually. It would be very helpful if a pattern of User Defaults were automatically applied to each new domain upon creation.

Any ideas as to how to do this @agentrickard ?

agentrickard’s picture

Status:Active» Closed (fixed)

File a new feature request against 7.x.3. Or implement hook_domainupdate().

stevebab’s picture

Status:Closed (fixed)» Active

@agentrickard

I appreciate the suggestion. Unfortunately, I'm stuck using D6 for this particular project. I would greatly appreciate a few pointers on how to use hook_domainupdate() to auto-assign anonymous users to each domain.

Thank you very much for the awesome module.

agentrickard’s picture

Status:Active» Closed (fixed)