You are here

video_embed_field.install in Video Embed Field 7

Same filename and directory in other branches
  1. 7.2 video_embed_field.install

File

video_embed_field.install
View source
<?php

/**
 *  Install file for video_embed_field module
 *  @author jcaldwell
 */

/**
 *  Implementation of hook_field_schema
 *  Define the schema for the field
 */
function video_embed_field_field_schema($field) {
  switch ($field['type']) {
    case 'video_embed_field':
      $columns = array(
        'video_url' => array(
          'type' => 'varchar',
          'length' => 512,
          'default' => '',
        ),
        'embed_code' => array(
          'type' => 'varchar',
          'length' => 1024,
          'default' => '',
        ),
        'description' => array(
          'type' => 'text',
          'not null' => FALSE,
        ),
      );
      $indexes = array();
      break;
  }
  return array(
    'columns' => $columns,
    'indexes' => $indexes,
  );
}
function video_embed_field_uninstall() {

  //do nothing right now - should eventually remove all the variables
}

/**
 *  Add an optional description form
 */
function video_embed_field_update_7000() {

  // Get the list of fields of type 'video_embed_field'.
  $video_embed_fields = array();
  foreach (field_info_fields() as $field_name => $field_info) {
    if ($field_info['type'] == 'video_embed_field') {
      $video_embed_fields[$field_name] = field_read_field($field_name);
    }
  }
  foreach ($video_embed_fields as $field) {
    if ($field['deleted']) {
      $table = "field_deleted_data_{$field['id']}";
      $revision_table = "field_deleted_revision_{$field['id']}";
    }
    else {
      $table = "field_data_{$field['field_name']}";
      $revision_table = "field_revision_{$field['field_name']}";
    }
    $column = $field['field_name'] . '_' . 'description';
    db_add_field($table, $column, array(
      'type' => 'text',
      'not null' => FALSE,
    ));
    db_add_field($revision_table, $column, array(
      'type' => 'text',
      'not null' => FALSE,
    ));
  }
  return t('Additional columns added.');
}

Functions

Namesort descending Description
video_embed_field_field_schema Implementation of hook_field_schema Define the schema for the field
video_embed_field_uninstall
video_embed_field_update_7000 Add an optional description form