You are here

taxonomy_tools_role_access.install in Taxonomy Tools 8

Same filename and directory in other branches
  1. 7 taxonomy_tools_role_access/taxonomy_tools_role_access.install

Install, update and uninstall functions for the Taxonomy Role Access module.

File

taxonomy_tools_role_access/taxonomy_tools_role_access.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Taxonomy Role Access module.
 */

/**
 * Implements hook_schema().
 */
function taxonomy_tools_role_access_schema() {
  $schema['taxonomy_tools_role_access'] = array(
    'description' => 'The base table for Taxonomy Role Access records.',
    'fields' => array(
      'entry_id' => array(
        'description' => 'Table entry identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'auto_increment' => TRUE,
      ),
      'tid' => array(
        'description' => 'Taxonomy term identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'rid' => array(
        'description' => 'User role identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'indexes' => array(
      'taxonomy_tools_role_access_tid' => array(
        'tid',
      ),
      'taxonomy_tools_role_access_rid' => array(
        'rid',
      ),
    ),
    'primary key' => array(
      'entry_id',
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function taxonomy_tools_role_access_uninstall() {
  variable_del('taxonomy_tools_role_access_vocab_config');
  variable_del('taxonomy_tools_role_access_role_config');
}

/**
 * Use vocabulary machine names instead of IDs.
 */
function taxonomy_tools_role_access_update_7101() {
  $config = variable_get('taxonomy_tools_role_access_vocab_config', array());
  $new_config = array();
  foreach ($config as $key => $value) {
    $query = db_select('taxonomy_vocabulary', 'foo');
    $query
      ->addField('foo', 'machine_name');
    $query
      ->condition('foo.vid', $key);
    $machine_name = $query
      ->execute()
      ->fetchField();
    if ($key == $value) {
      $new_config[$machine_name] = $machine_name;
    }
    else {
      $new_config[$machine_name] = 0;
    }
  }
  variable_set('taxonomy_tools_role_access_vocab_config', $new_config);
}

Functions

Namesort descending Description
taxonomy_tools_role_access_schema Implements hook_schema().
taxonomy_tools_role_access_uninstall Implements hook_uninstall().
taxonomy_tools_role_access_update_7101 Use vocabulary machine names instead of IDs.