You are here

video.install in Video 7

Provides installation schema for video.module @author Heshan Wanigasooriya <heshan@heidisoft.com>

File

video.install
View source
<?php

/**
 * @file
 * Provides installation schema for video.module
 * @author Heshan Wanigasooriya <heshan@heidisoft.com>
 * 
 */

/**
 * Implementation of hook_schema().
 */
function video_schema() {

  // video files
  $schema['video_files'] = array(
    'description' => 'Store video transcoding queue.',
    'fields' => array(
      'vid' => array(
        'description' => t('Video id, the primary identifier'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'fid' => array(
        'description' => 'The {file_managed}.fid being referenced in this field.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => 'The {node}.nid being referenced in this field.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'Status of the transcoding, possible values are 1, 5, 10, 20',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'dimensions' => array(
        'description' => 'The dimensions of the output video.',
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
      ),
      'started' => array(
        'description' => t('Start timestamp of transcodings'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'completed' => array(
        'description' => 'Transcoding completed timestamp',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of converted files.
          Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
      ),
    ),
    'indexes' => array(
      'status' => array(
        'status',
      ),
      'file' => array(
        'fid',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
  );

  // video preset
  $schema['video_preset'] = array(
    'description' => 'The preset table.',
    'fields' => array(
      'pid' => array(
        'description' => 'The primary identifier for a video preset.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The name of this preset.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'A brief description of this preset.',
        'type' => 'text',
        'size' => 'medium',
        'translatable' => TRUE,
      ),
      'settings' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'Serialized preset settings that do not warrant a dedicated column.
          Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
      ),
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
    'primary key' => array(
      'pid',
    ),
  );

  // video thumbnails
  $schema['video_thumbnails'] = array(
    'description' => 'The video thumbnails table.',
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Foreign Key {video_files}.fid.',
      ),
      'thumbnails' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'Serialized array of thumbnails data.
          Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
      ),
    ),
    'indexes' => array(
      'thumbnail' => array(
        'vid',
      ),
    ),
    'foreign keys' => array(
      'thumbnails' => array(
        'table' => 'video_files',
        'columns' => array(
          'vid' => 'vid',
        ),
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_field_schema().
 */
function video_field_schema($field) {
  return array(
    'columns' => array(
      'fid' => array(
        'description' => 'The {file_managed}.fid being referenced in this field.',
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
      ),
      'thumbnail' => array(
        'description' => 'The {file_managed}.fid being referenced for video thumbanil.',
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
      ),
      'player_dimensions' => array(
        'description' => "Video dimention for the video player.",
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ),
    ),
    'indexes' => array(
      'fid' => array(
        'fid',
      ),
    ),
    'foreign keys' => array(
      'fid' => array(
        'table' => 'file_managed',
        'columns' => array(
          'fid' => 'fid',
        ),
      ),
    ),
  );
}

/**
 * Implementation of hook_install().
 */
function video_install() {

  // Create the videos directory and ensure it's writable.
  $directory = file_default_scheme() . '://videos';
  file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
}

/**
 * Implementation of hook_uninstall().
 */
function video_uninstall() {
  drupal_uninstall_schema('video');

  // remove variables
  db_query("DELETE FROM {variable} WHERE name LIKE 'video_%'");

  // Remove the video directory and generated images.
  file_unmanaged_delete_recursive(file_default_scheme() . '://videos');
}

Functions

Namesort descending Description
video_field_schema Implements hook_field_schema().
video_install Implementation of hook_install().
video_schema Implementation of hook_schema().
video_uninstall Implementation of hook_uninstall().