You are here

function taxonomy_access_restore_terms in Taxonomy Access Control 5

Same name and namespace in other branches
  1. 5.2 taxonomy_access.module \taxonomy_access_restore_terms()
  2. 6 taxonomy_access.module \taxonomy_access_restore_terms()

used to restore terms deleted by taxonomy_node_delete() that the user shouldn't have access to delete. see http://drupal.org/node/92355 and http://drupal.org/node/93086

Called by taxonomy_access_nodeapi()

1 call to taxonomy_access_restore_terms()
taxonomy_access_nodeapi in ./taxonomy_access.module
Implementation of hook_nodeapi().

File

./taxonomy_access.module, line 753
Allows administrators to specify how each category (in the taxonomy) can be used by various roles.

Code

function taxonomy_access_restore_terms($nid, $protected_terms) {
  if (isset($protected_terms)) {
    $terms = $protected_terms;
    if (count($terms)) {
      db_query('DELETE FROM {term_node} WHERE nid = %d AND tid IN (' . implode(',', $terms) . ')', $nid);
      foreach ($terms as $tid) {
        $replace_terms[] = '(' . $nid . ',' . $tid . ')';
      }
      db_query('INSERT INTO {term_node} (nid,tid) VALUES ' . implode(',', $replace_terms));
    }
  }
}