You are here

function taxonomy_access_restore_terms in Taxonomy Access Control 6

Same name and namespace in other branches
  1. 5.2 taxonomy_access.module \taxonomy_access_restore_terms()
  2. 5 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

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

File

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

Code

function taxonomy_access_restore_terms($nid, $vid, $protected_terms) {
  if (isset($protected_terms)) {
    $terms = $protected_terms;
    if (count($terms)) {
      $args = array(
        $nid,
        $vid,
      );
      $args = array_merge($args, $terms);
      db_query('DELETE FROM {term_node} WHERE nid = %d AND vid = %d
                  AND tid IN (' . db_placeholders($terms, 'int') . ')', $args);
      foreach ($terms as $tid) {

        // Create row for Schema API.
        $row = new stdClass();
        $row->nid = $nid;
        $row->vid = $vid;
        $row->tid = $tid;
        drupal_write_record('term_node', $row);
      }
    }
  }
}