For usability, the domain path fields should only be visible for domains that are selected as being "Published to" in the domain access options section.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

crashtest_’s picture

Assigned: crashtest_ » Unassigned
Status: Active » Needs review
FileSize
2.9 KB

Here is a patch that accomplishes this by hiding or showing the path fields depending upon the corresponding access options. Also, if the "Publish to all" option is selected, they all show, and if not, then it defaults to the checkboxes under access.

agentrickard’s picture

Status: Needs review » Needs work

The patch failed to apply against the latest dev branch.

Shouldn't we be using #attached here?

Base functionality looks fine. Need to test for a user with limited permissions.

Les Lim’s picture

Status: Needs work » Needs review
FileSize
3.19 KB

Updated CrashTest's approach to work against the latest dev and to use #attached, and reworked the js a little for simplicity.

I've tested it on a user with limited permissions, but only with patches already applied from #1337500: Restrict user to only set path on assigned domains and #1425292: domain_path_node_insert() should update existing records rather than deleting/recreating them.

grndlvl’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.88 KB

Patch re-roll. Applies cleanly to 7.x-1.x.

Tested limited access content creation.

Added: an over encapsulating hide on first run, to account for domains not listed in the "Publish to:" checkboxes.
(Don't think this will be needed once #1337500: Restrict user to only set path on assigned domains
&& #1425292: domain_path_node_insert() should update existing records rather than deleting/recreating them are applied.)

All seems to work.

agentrickard’s picture

Is any of this testable? I suspect not.

agentrickard’s picture

Status: Reviewed & tested by the community » Needs work

This approach does not work as expected when the user has the limited permissions "Publish content only from assigned domain " or "Publish content only from the default domain". In both cases, the domain form element is suppressed, so the JS never fires.

We should address that. I suspect by setting a preselected JS variable in this case. e.g. in this code:

  if // ... logic for user_access() {
    drupal_add_js('setting', SOME VALUE);
  }
  $form['domain_path'] = array(
    '#tree' => TRUE,
    '#title' => t('Domain-specific paths'),
    '#type' => 'fieldset',
    '#group' => 'additional_settings',
    '#access' => user_access('edit domain paths'),
    '#attached' => array(
      'js' => array(drupal_get_path('module', 'domain_path') . '/domain_path.js'),
    ),
  );
grndlvl’s picture

Now when the user does not have access to the domain field then a domain id js variable is created and the js will display that path field when set. Otherwise, it will look at the domain field.

Also cleaned up the js implementation and remove "$default_domain = domain_default();" which wasn't being used anywhere.

grndlvl’s picture

Status: Needs work » Needs review
grndlvl’s picture

Minor grammatical corrections.

grndlvl’s picture

agentrickard’s picture

Seems to work, except an editor with limited domain permissions can still wipe all domain-specific paths for a node.

Do we need a separate permission for that?

grndlvl’s picture

Status: Needs review » Closed (fixed)

Commited http://drupal.org/commitlog/commit/17364/35a7f0af5d06ab606ae8f8788f86af1...

Thanks all!

Also I have created a new ticket for the suggestion from #11 #1675896: Delete domain-specific aliases should not be visible by restricted permissions so lets continue discussion there.

jca’s picture

Issue summary: View changes

If in 'admin/structure/domain/settings' we have selected the option 'Select list' this patch doesn't work (the edit form does not show any textbox for aliases).
Only works for 'Checkboxes' option.

oldspot’s picture

@jca - there is a patch for that here: https://www.drupal.org/node/2173291
It checks whether you are using select list or checkboxes.