You are here

video.install in Video 6.4

Provides installation functions for video.module.

@author Heshan Wanigasooriya <heshan at heidisoft dot com> <heshanmw at gmail dot com> @todo

File

video.install
View source
<?php

/**
 * @file
 * Provides installation functions for video.module.
 *
 * @author Heshan Wanigasooriya <heshan at heidisoft dot com>
 *                              <heshanmw at gmail dot com>
 * @todo
 */

/**
 * Implementation of hook_schema().
 */
function video_schema() {
  $schema['video_files'] = array(
    'description' => t('Store video transcoding queue'),
    'fields' => array(
      'vid' => array(
        'description' => t('Video id'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'fid' => array(
        'description' => t('Original file id'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => t('Node id'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => t('Status of the transcoding'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'dimensions' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => t('The dimensions of the video.'),
      ),
      'started' => array(
        'description' => t('Started transcodings'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'completed' => array(
        'description' => t('Transcoding completed'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        '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',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function video_install() {
  drupal_install_schema('video');
}

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

  // Delete all variables that begin with the namespaced "video_*"
  $result = db_query('SELECT name FROM {variable} WHERE name LIKE "video_%%"');
  while ($var = db_fetch_array($result)) {
    variable_del($var['name']);
  }
  variable_del('vid_filesystem');
  variable_del('vid_convertor');
  variable_del('vid_metadata');
  variable_del('vid_preset');
}

/**
* Implementation of hook_requirements().
*/
function video_requirements($phase) {
  $t = get_t();
  $requirements = array();
  $fs = variable_get('vid_filesystem', 'drupal');
  $downloads = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC);
  if ($downloads == FILE_DOWNLOADS_PRIVATE && $fs == 'drupal') {
    $requirements['video_filesystem'] = array(
      'title' => $t('Video module settings'),
      'description' => $t('Storing videos in the Drupal file system is not supported when using <a href="@filesystem">private downloads</a>.', array(
        '@filesystem' => url('admin/settings/file-system'),
      )),
      'value' => l($t('Change setting'), 'admin/settings/video/filesystem'),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}

/**
 * Update 6405
 * dropping video_rendering table and creating video_files
 * @return <type>
 */
function video_update_6405() {
  $ret = array();
  if (db_table_exists('video_rendering')) {
    db_drop_table($ret, 'video_rendering');
  }
  if (db_table_exists('video_files')) {
    db_drop_table($ret, 'video_files');
  }
  $table = array(
    'description' => t('Store video transcoding queue'),
    'fields' => array(
      'vid' => array(
        'description' => t('Video id'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'fid' => array(
        'description' => t('Original file id'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => t('Node id'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'filename' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => t('The filename of the video.'),
      ),
      'filepath' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => t('The filepath of the video.'),
      ),
      'filemime' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => t('The filemime of the video.'),
      ),
      'filesize' => array(
        'description' => t('Filesize of the video.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'dimensions' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => t('The dimensions of the video.'),
      ),
      'status' => array(
        'description' => t('Status of the transcoding'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'started' => array(
        'description' => t('Started transcodings'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'completed' => array(
        'description' => t('Transcoding completed'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'status' => array(
        'status',
      ),
      'file' => array(
        'fid',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
  );
  db_create_table($ret, 'video_files', $table);
  return $ret;
}

/**
 * Update 6406
 * @return <type>
 */
function video_update_6406() {
  drupal_set_message('The system has reset your thumbnail and ffmpeg command settings to their original state.  If you made adjustments to these commands, you will have to reset them up.');

  //lets reset our ffmpeg system command variables.
  variable_set('video_ffmpeg_thumbnailer_options', '-i !videofile -an -y -f mjpeg -ss !seek -vframes 1 !thumbfile');
  variable_set('video_ffmpeg_helper_auto_cvr_options', '-y -i !videofile -f flv -ar 22050 -ab !audiobitrate -s !size -b !videobitrate -qscale 1 !convertfile');
  return array();
}

/**
 * Update 6407
 */
function video_update_6407() {
  $ret = array();

  // drop un wanted fields in video files
  db_drop_field($ret, 'video_files', 'filesize');
  db_drop_field($ret, 'video_files', 'filename');
  db_drop_field($ret, 'video_files', 'filepath');
  db_drop_field($ret, 'video_files', 'filemime');
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_add_column($ret, 'video_files', 'data', 'longtext', array(
        'null' => TRUE,
      ));
      break;
    case 'pgsql':
      db_add_column($ret, 'video_files', 'data', 'text', array(
        'null' => TRUE,
      ));
      break;
  }
  return $ret;
}

Functions

Namesort descending Description
video_install Implementation of hook_install().
video_requirements Implementation of hook_requirements().
video_schema Implementation of hook_schema().
video_uninstall Implementation of hook_uninstall().
video_update_6405 Update 6405 dropping video_rendering table and creating video_files
video_update_6406 Update 6406
video_update_6407 Update 6407