You are here

function _permissions_by_term_remove_disallowed_term_matches in Permissions by Term 7

Removes disallowed term matches by reference.

Parameters

array $term_matches The matched taxonomy terms.:

Return value

null

1 call to _permissions_by_term_remove_disallowed_term_matches()
permissions_by_term_autocomplete_terms in ./permissions_by_term.module
Page callback for views taxonomy autocomplete. This function has been copied from the Views module. It's nearly a duplicate from views_ajax_autocomplete_taxonomy(). It has the function _permissions_by_term_remove_disallowed_term_matches()…

File

./permissions_by_term.module, line 558
Allows access to terms in a vocabulary to be limited by user or role.

Code

function _permissions_by_term_remove_disallowed_term_matches(&$term_matches) {
  global $user;
  $updated_term_matches = array();
  foreach ($term_matches as $term_match) {
    $term = taxonomy_get_term_by_name($term_match);
    $term_id = key($term);
    if (!permissions_by_term_allowed($term_id, $user)) {
      unset($term_match);
    }
    else {
      $updated_term_matches[$term_match] = $term_match;
    }
  }
  $term_matches = $updated_term_matches;
}