You are here

janrain_capture.install in Janrain Registration 7.4

Uninstall functions for the janrain_capture module

File

janrain_capture.install
View source
<?php

/**
 * @file
 * Uninstall functions for the janrain_capture module
 */

/**
 * Implements hook_schema().
 */
function janrain_capture_schema() {
  $schema['janrain_capture_photos'] = array(
    'description' => 'Maps users to previously saved photo from Capture.',
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Primary Key: {users}.uid for user.',
      ),
      'uri' => array(
        'description' => 'The URI used to fetch the file.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'binary' => TRUE,
      ),
    ),
    'primary key' => array(
      'uid',
    ),
    'foreign keys' => array(
      'user' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  $schema['janrain_capture_countries'] = array(
    'description' => 'Maintains the records for janrain countries.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'Name of the janrain country.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'code' => array(
        'description' => 'Code of the janrain country.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'language' => array(
        'description' => 'Language of the janrain country.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}

/**
 * Programatically create a field (field_janrain_capture_uuid) on the User entity
 */
function janrain_capture_create_field() {

  // Check if our field is not already created.
  if (!field_info_field('field_janrain_capture_uuid')) {
    $field = array(
      'field_name' => 'field_janrain_capture_uuid',
      'type' => 'text',
      'translatable' => FALSE,
      'settings' => array(
        'max_length' => '255',
      ),
      'field_permissions' => array(
        'type' => '2',
      ),
    );
    field_create_field($field);

    // Create the instance on the bundle.
    $instance = array(
      'field_name' => 'field_janrain_capture_uuid',
      'entity_type' => 'user',
      'label' => 'Janrain Capture uuid',
      'bundle' => 'user',
      'required' => FALSE,
      'settings' => array(
        'text_processing' => '0',
        'user_register_form' => 0,
      ),
      'display' => array(
        'default' => array(
          'label' => 'above',
          'settings' => array(),
          'type' => 'hidden',
          'weight' => '3',
        ),
      ),
      'widget' => array(
        'active' => 1,
        'module' => 'text',
        'settings' => array(
          'size' => '60',
        ),
        'type' => 'text_textfield',
        'weight' => '2',
      ),
    );
    field_create_instance($instance);
  }
}

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

  // Create the UUID field.
  janrain_capture_create_field();

  // Set the default janrain_capture_screens_folder setting
  variable_set('janrain_capture_screens_folder', 'file:///sites/all/themes/janrain-capture-screens/');

  // Set the default version
  variable_set('janrain_capture_ver', JANRAIN_CAPTURE_VERSION_DEFAULT);
}

/**
 * Implements hook_uninstall().
 */
function janrain_capture_uninstall() {
  variable_del('janrain_capture_main');
  variable_del('janrain_capture_optional');
  variable_del('janrain_capture_fields');
  variable_del('janrain_capture_enforce');
  db_delete('variable')
    ->condition(db_or()
    ->condition('name', "janrain_capture_share%", 'LIKE'))
    ->execute();
}

Functions

Namesort descending Description
janrain_capture_create_field Programatically create a field (field_janrain_capture_uuid) on the User entity
janrain_capture_install Implements hook_install().
janrain_capture_schema Implements hook_schema().
janrain_capture_uninstall Implements hook_uninstall().