You are here

node_convert.install in Node Convert 7

Same filename and directory in other branches
  1. 6 node_convert.install

Installs necessary tables for node convert templates.

File

node_convert.install
View source
<?php

/**
 * @file
 * Installs necessary tables for node convert templates.
 */

/**
 * Node convert schema.
 */
function node_convert_schema() {
  $schema[NODE_CONVERT_TEMPLATE_TABLE] = array(
    // CTools export definitions.
    'export' => array(
      'key' => 'machine_name',
      'key name' => 'Machine name',
      'admin_title' => 'name',
      'primary key' => 'nctid',
      'identifier' => 'node_convert_template',
      'default hook' => 'default_node_convert_templates',
      // Function hook name.
      'delete callback' => 'node_convert_delete_template',
      'api' => array(
        'owner' => 'node_convert',
        'api' => 'node_convert',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'nctid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'no export' => TRUE,
      ),
      'machine_name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The unique string identifier for a conversion template.',
      ),
      'name' => array(
        'type' => 'text',
        'size' => 'small',
      ),
      'source_type' => array(
        'type' => 'text',
        'size' => 'small',
        'not null' => FALSE,
      ),
      'destination_type' => array(
        'type' => 'text',
        'size' => 'small',
        'not null' => TRUE,
      ),
      'data' => array(
        'type' => 'text',
        'size' => 'medium',
      ),
    ),
    'primary key' => array(
      'nctid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function node_convert_install() {
}

/**
 * Implements hook_uninstall().
 */
function node_convert_uninstall() {

  // Deleting node convert action.
  db_delete('actions')
    ->condition('callback', 'node_convert_convert_action')
    ->execute();
}

/**
 * Create machine names for all node conversion templates.
 */
function node_convert_update_7001() {

  // Load the node convert module, so we have access to constants and API.
  module_load_include('module', 'node_convert');
  if (!db_field_exists(NODE_CONVERT_TEMPLATE_TABLE, 'machine_name')) {

    // Add the new string machine name field for ctools.
    db_add_field(NODE_CONVERT_TEMPLATE_TABLE, 'machine_name', array(
      'type' => 'varchar',
      'length' => 255,
      'not null' => TRUE,
      'default' => '',
      'description' => 'The unique string identifier for a conversion template.',
    ));

    // Force drupal's schema to be rebuilt
    drupal_get_schema(NODE_CONVERT_TEMPLATE_TABLE, TRUE);
    _node_convert_recreate_identifiers();
  }
}

Functions

Namesort descending Description
node_convert_install Implements hook_install().
node_convert_schema Node convert schema.
node_convert_uninstall Implements hook_uninstall().
node_convert_update_7001 Create machine names for all node conversion templates.