You are here

function taxonomy_access_enable in Taxonomy Access Control 5.2

Same name and namespace in other branches
  1. 5 taxonomy_access.module \taxonomy_access_enable()
  2. 6 taxonomy_access.module \taxonomy_access_enable()
  3. 7 taxonomy_access.install \taxonomy_access_enable()

Implementation of hook_enable().

Housekeeping: while we were away, did you delete any terms/vocabs/roles? 1: delete ta rows for missing terms 2: delete tad rows for missing vocabs 3: delete ta, tad rows for missing roles 4: rebuild node_access

File

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

Code

function taxonomy_access_enable() {
  global $db_type;
  switch ($db_type) {
    case 'mysql':
    case 'mysqli':
      db_query('DELETE ta FROM {term_access} ta LEFT JOIN {term_data} td ON ta.tid = td.tid WHERE ta.tid <> 0 AND ISNULL(td.tid)');
      db_query('DELETE tad FROM {term_access_defaults} tad LEFT JOIN {vocabulary} v ON tad.vid = v.vid WHERE tad.vid <> 0 AND ISNULL(v.vid)');
      db_query('DELETE ta FROM {term_access} ta LEFT JOIN {role} r ON ta.rid = r.rid WHERE ISNULL(r.rid)');
      db_query('DELETE tad FROM {term_access_defaults} tad LEFT JOIN {role} r ON tad.rid = r.rid WHERE ISNULL(r.rid)');
      break;
    case 'pgsql':
      db_query('DELETE FROM {term_access} ta LEFT JOIN {term_data} td ON ta.tid = td.tid WHERE ta.tid <> 0 AND ISNULL(td.tid)');
      db_query('DELETE FROM {term_access_defaults} tad LEFT JOIN {vocabulary} v ON tad.vid = v.vid WHERE tad.vid <> 0 AND ISNULL(v.vid)');
      db_query('DELETE FROM {term_access} ta LEFT JOIN {role} r ON ta.rid = r.rid WHERE ISNULL(r.rid)');
      db_query('DELETE FROM {term_access_defaults} tad LEFT JOIN {role} r ON tad.rid = r.rid WHERE ISNULL(r.rid)');
      break;
  }
  node_access_rebuild();
}