I have a content type with a term reference field (drop down selection). Domain Taxonomy works fine when listing nodes (on any given domain I can see only nodes whose terms are assigned to the domain), however on node/add the vocabulary's drop-down select list shows all terms for all domains, irrespective of current domain. Expected behaviour: the drop-down list should be restricted to terms assigned to current domain, as in D6 version.

Comments

skizzo’s picture

Priority: Normal » Major
alan d.’s picture

I too just hit this on an administration page, but it is clearly by design for some reason:

function domain_taxonomy_query_term_access_alter($query) {
  if (path_is_admin(current_path()) && arg(0) != 'node') {
    return;
  }
   ...
}

However, my front end vocabs are being filtered. So is the content type edited on an administration path that does not start with 'node/'? If you have an admin theme enabled, then this would trigger on that page if the page is listed as an admin path.

Back to the query, shouldn't it be something like this, (and omg) what would break in doing so...

  if ($query->hasTag('term_access')) {
    // Do not filter if the user has permission to edit the terms.
    if (user_access('administer domains') || user_access('set domain access')) {
      return;
    }
  }
  elseif (path_is_admin(current_path()) && arg(0) != 'node') {
    // No access tags set, only enforce the restrictions on non-administration paths.
  }
alan d.’s picture

alan d.’s picture

OK, the core term lists (other than autocomplete) are generated with this:

function taxonomy_allowed_values($field) {
  $options = array();
  foreach ($field['settings']['allowed_values'] as $tree) {
    if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
      if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
        foreach ($terms as $term) {
          $options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
        }
      }
    }
  }
  return $options;
}

And the term query adds the access tags:

    $result = $query
      ->addTag('translatable')
      ->addTag('term_access')

This should result in the expected behaviour.

So testing radios & select lists:

The widgets

The resulting page without restrictions

Implemented restrictions by

a) Removing this domain from the list of non-restricted taxonomies

This is found under http://www.example.com/admin/structure/domain/taxonomy

b) Editing the terms to ensure that the terms were not assigned everywhere and that they only belonged to the correct domain

Custom term manager screenshot showing the settings: Screenshot

And the resulting widget on the Maritime site

The select list of both sites, Martime on the left, the HSA site on the right (this has all terms assigned)

OK, hopefully I have covered something that you missed, as this appears to be working perfectly.

skizzo’s picture

thank you for taking the time to go through your configuration and clarifying things. The only difference with my setup lies in the selection widget: I use the hierarchical select rather than the core select. Actually, I now recall that back in January I reported the problem in the hierarchical select issue queue but then, not being a programmer, I thought that the problem could not depend on a selection widget (false assumption?) and must lie in a lower layer, so I created this issue. Please feel free to close it, as it doesn't seem to be a Domain Taxonomy problem. Btw: where does the "term manager screenshot" in your response come from? can it be done with views or is it a special module? It looks like a convenient way of managing and verifying domain assignment for large taxonomies.

alan d.’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

hi skizzo, the "term manager screenshot" was a two day hack trying to normalise the damage that the tagging bug had exposed (another issue). It parses all of the term relationships from 3 field types and works out if there should be any domain settings applied to the terms. So I can update these 100 at a time, or merge duplicates etc. Handy but very messy in terms of the code, like it has no module checks etc and was designed to run with maybe 10 dependencies.

And I found the issue, posting in other thread reported to the appropriate users for action. This will probably be resolved in the next few weeks as this raises a fairly serious issue with that module.