You are here

function term_merge_access in Term Merge 7

Access callback for term merge action.

Decide whether to grant access to an account for an operation of merging terms in a vocabulary.

Parameters

object $vocabulary: Fully loaded vocabulary object inside of which term merge operation is requested for access granting

object $term: Fully loaded term object which belongs to the vocabulary inside of which term merge operation is requested for access granting. You are supposed only to provide either $vocabulary or $term. Depending on your context it might be more convenient for you to provide $term, and on other occasions it might be $vocabulary of more convenience

object $account: Fully loaded user object who is requesting access granting for the operation of term merging. You may provide nothing here, and the currently logged in user will be considered

Return value

bool Whether the access for term merging operation has been granted

1 string reference to 'term_merge_access'
term_merge_menu in ./term_merge.module
Implements hook_menu().

File

./term_merge.module, line 239
Provide functionality for merging taxonomy terms one into another.

Code

function term_merge_access($vocabulary = NULL, $term = NULL, $account = NULL) {
  if (is_null($vocabulary) && is_null($term)) {

    // This is no go, at least one of these 2 has to be provided.
    return FALSE;
  }
  if (is_null($account)) {

    // Falling back on currently logged in user.
    $account = $GLOBALS['user'];
  }
  if (is_null($vocabulary)) {
    $vocabulary = taxonomy_vocabulary_load($term->vid);
  }
  return user_access('merge terms', $account) || user_access('merge ' . $vocabulary->machine_name . ' terms', $account);
}