You are here

fc.install in Field Complete 7

Field Complete - Provides field-based completeness for any entity - install.

File

fc.install
View source
<?php

/**
 * @file
 * Field Complete - Provides field-based completeness for any entity - install.
 */

/**
 * Implements hook_install().
 */
function fc_install() {

  // Set the default entity types
  variable_set('fc_entity_types', array(
    'node' => 'node',
    'user' => 'user',
  ));
  $args = array(
    '!href' => url('admin/config/content/fc/rebuild'),
  );
  drupal_set_message(t('You should now run the <a href="!href">Field Complete rebuild function</a>.', $args), 'warning');
}

/**
 * Implements hook_uninstall().
 */
function fc_uninstall() {
  variable_del('fc_entity_types');
  variable_del('fc_js_ids');
  variable_del('fc_tooltip');
}

/**
 * Implements hook_schema().
 */
function fc_schema() {
  return array(
    'fc' => array(
      'description' => 'Stores the completeness of entities.',
      'fields' => array(
        'entity_type' => array(
          'type' => 'varchar',
          'length' => 128,
          'not null' => TRUE,
          'default' => '',
          'description' => 'The entity type this field complete data is attached to.',
        ),
        'entity_id' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'description' => 'The entity id this data is attached to.',
        ),
        'revision_id' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => FALSE,
          'description' => 'The entity revision id this data is attached to, or NULL if the entity type is not versioned.',
        ),
        'complete' => array(
          'type' => 'int',
          'size' => 'tiny',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 1,
          'description' => 'The completeness of this entity as a boolean, true or false.',
        ),
        'percentage' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 100,
          'description' => 'The completeness of this entity as a percentage scale from 0 to 100.',
        ),
        'completeness' => array(
          'type' => 'blob',
          'size' => 'big',
          'not null' => FALSE,
          'serialize' => TRUE,
          'description' => 'The individual completeness of the fields of this entity.',
        ),
      ),
      'primary key' => array(
        'entity_type',
        'entity_id',
        'revision_id',
      ),
      'indexes' => array(
        'entity_type' => array(
          'entity_type',
        ),
        'entity_id' => array(
          'entity_id',
        ),
        'revision_id' => array(
          'revision_id',
        ),
        'complete' => array(
          'complete',
        ),
        'percentage' => array(
          'percentage',
        ),
      ),
    ),
  );
}

/**
 * Update the primary key for field complete.
 */
function fc_update_7001() {
  db_drop_primary_key('fc');
  db_add_primary_key('fc', array(
    'entity_type',
    'entity_id',
    'revision_id',
  ));
}

Functions

Namesort descending Description
fc_install Implements hook_install().
fc_schema Implements hook_schema().
fc_uninstall Implements hook_uninstall().
fc_update_7001 Update the primary key for field complete.