kaltura.install in Kaltura 7.2
Same filename and directory in other branches
Installation process for kaltura core module
File
kaltura.installView source
<?php
/**
* @file
* Installation process for kaltura core module
*/
/**
* Implements hook_schema().
*
* Defines the tables and fields in each table that we add to the database
* to store kaltura data (nodes/notifications...).
*/
function kaltura_schema() {
$schema['node_kaltura'] = array(
'description' => 'The base table for Kaltura nodes.',
'fields' => array(
'kaltura_entryid' => array(
'description' => 'Kaltura entry id',
'type' => 'varchar',
'length' => 10,
'default' => '',
'not null' => TRUE,
),
'kaltura_tags' => array(
'description' => 'tags from kaltura CW',
'type' => 'text',
'default' => NULL,
'not null' => FALSE,
),
'kaltura_admin_tags' => array(
'description' => 'admin tags from kaltura CMS',
'type' => 'text',
'default' => NULL,
'not null' => FALSE,
),
'kstatus' => array(
'description' => 'The status of the entry/roughcut',
'type' => 'int',
'size' => 'small',
'default' => 0,
'not null' => TRUE,
),
'kaltura_media_type' => array(
'description' => 'Media type of the entry/mix. see kaltura API documentation for values',
'type' => 'int',
'size' => 'small',
'not null' => FALSE,
),
'kaltura_duration' => array(
'description' => 'The duration of the entry(msecs)/mix(secs) in seconds',
'type' => 'int',
'not null' => FALSE,
),
'kaltura_thumbnail_url' => array(
'description' => 'The url of the thumbnail for the entry',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'kaltura_partner_data' => array(
'description' => 'partner data that was sent in addentry',
'type' => 'varchar',
'length' => 4096,
'not null' => FALSE,
),
'kaltura_source' => array(
'description' => 'The source of the media (file,webcam,youtube etc.), see kaltura API documentation for values',
'type' => 'int',
'size' => 'small',
'not null' => FALSE,
),
'kaltura_source_id' => array(
'description' => 'The id of the media in the source (e.g. youtube video id)',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_source_link' => array(
'description' => 'The link of the media source',
'type' => 'varchar',
'length' => 1024,
'not null' => FALSE,
),
'kaltura_width' => array(
'description' => 'if item is image - the width of the image',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_height' => array(
'description' => 'if item is image - the height of the image',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_download_url' => array(
'description' => 'The direct download url for the entry/mix. available if item was flattened',
'type' => 'varchar',
'length' => 1024,
'not null' => FALSE,
),
'kaltura_media_date' => array(
'description' => 'Date of the image from exif data',
'type' => 'int',
'not null' => FALSE,
),
// A-sync data fields which should be updated by cron.
'kaltura_views' => array(
'description' => 'The number of times this item was viewed not necessarily played',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_plays' => array(
'description' => 'The number of times this item was played',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_votes' => array(
'description' => 'The number of votes on the entry/mix',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_rank' => array(
'description' => 'the calculated rank of the entry/mix - multiplied by 1000',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_total_rank' => array(
'description' => 'total rank of the entry/mix',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_entry_data' => array(
'description' => 'All the entry/kshow data (serialized) from kaltura received from notification or API call',
'type' => 'text',
'default' => NULL,
'not null' => FALSE,
),
'kaltura_video_comment' => array(
'description' => 'was the entry added as a comment for another node or not',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_created_date' => array(
'description' => 'The date and time the entry was created',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_updated_date' => array(
'description' => 'The date and time the entry was updated',
'type' => 'int',
'default' => 0,
'not null' => FALSE,
),
'kaltura_title' => array(
'description' => 'The entry title',
'type' => 'text',
'default' => NULL,
'not null' => FALSE,
),
'kaltura_description' => array(
'description' => 'The entry description',
'type' => 'text',
'default' => NULL,
'not null' => FALSE,
),
'kaltura_puser_id' => array(
'description' => 'Uploader user id',
'type' => 'int',
'default' => 1,
'not null' => TRUE,
),
),
'primary key' => array(
'kaltura_entryid',
),
'foreign keys' => array(
'owner' => array(
'table' => 'users',
'columns' => array(
'kaltura_puser_id' => 'uid',
),
),
),
);
$schema['kaltura_notifications'] = array(
'description' => 'table to "log" kaltura notifications, to ignore double notifications',
'fields' => array(
'notification_id' => array(
'description' => 'notification Id from kaltura',
'type' => 'bigint',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'data' => array(
'description' => 'notification REQUEST params',
'type' => 'text',
'default' => NULL,
'not null' => FALSE,
),
'received_at' => array(
'type' => 'int',
),
),
'primary key' => array(
'notification_id',
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function kaltura_install() {
$t = get_t();
if (!libraries_get_path('KalturaClient')) {
drupal_set_message($t('Kaltura client library is not detected. You have to download it to use the Kaltura module. You can do this using Drush command "drush kaltura-client".'), 'warning');
}
$link_path = 'admin/config/media/kaltura';
drupal_set_message($t('To !complete_link of the Kaltura Video Module installation, you must !partner_id_link', array(
'!complete_link' => l($t('complete installation'), $link_path),
'!partner_id_link' => l($t('associate it with a Kaltura Partner ID'), $link_path),
)));
}
/**
* Implemens hook_uninstall().
*/
function kaltura_uninstall() {
variable_del('kaltura_add_html5');
variable_del('kaltura_admin_secret');
variable_del('kaltura_last_update');
variable_del('kaltura_local_registration');
variable_del('kaltura_notification_status');
variable_del('kaltura_notification_type');
variable_del('kaltura_partner_cms_email');
variable_del('kaltura_partner_cms_password');
variable_del('kaltura_partner_id');
variable_del('kaltura_partner_url2');
variable_del('kaltura_secret');
variable_del('kaltura_server_url');
variable_del('kaltura_subp_id');
$t = get_t();
drupal_set_message($t('Kaltura module was successfully uninstalled.'));
}
/**
* Implements hook_requirements().
*/
function kaltura_requirements($phase) {
$requirements = array();
$t = get_t();
if ($phase == 'runtime') {
// First check if Libraries module exists
if (!drupal_get_path('module', 'libraries')) {
$requirements['kaltura'] = array(
'title' => t('Kaltura module'),
'severity' => REQUIREMENT_ERROR,
'value' => t('Libraries module missing'),
'description' => $t('Kaltura module requires the <a href="@url">Libraries module</a> to be installed.', array(
'@url' => 'http://drupal.org/project/libraries',
)),
);
}
else {
// Libraries module exists but may not be installed,
// even if it is listed as a dependency in .info file.
// For example, during installation from an installation profile
// Libraries will *not* be installed when hook_requirements gets called
if (!function_exists('libraries_get_path')) {
include_once drupal_get_path('module', 'libraries') . '/libraries.module';
}
if (!libraries_get_path('KalturaClient')) {
// KalturaClient is not installed
$requirements['kaltura_client'] = array(
'title' => $t('Kaltura client library'),
'value' => $t('Not detected'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('Kaltura module requires Kaltura client library to be installed. You can download it using Drush command "drush kaltura-client-install" or manually from !url.', array(
'!url' => l('this url', 'http://cdnbakmi.kaltura.com/content/clientlibs/php5_16-12-2014.tar.gz', array(
'attributes' => array(
'target' => '_blank',
),
)),
)),
);
}
else {
// KalturaClient is installed
$library = libraries_detect('KalturaClient');
$requirements['kaltura_client'] = array(
'title' => $t('Kaltura client library'),
'value' => $library['version'],
'severity' => REQUIREMENT_OK,
);
if (module_exists('kaltura')) {
// if modules enabled, check if it was configured yet
$status = variable_get('kaltura_partner_id');
if (!empty($status)) {
$requirements['kaltura'] = array(
'title' => $t('Kaltura module'),
'value' => $t('Configured'),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['kaltura'] = array(
'title' => $t('Kaltura module'),
'value' => $t('Not configured'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('You did not complete the module configuration. You must configure the module with valid kaltura partner details or perform registration. Go to @settings_link to complete configuration.', array(
'@settings_link' => l($t('kaltura module settings'), 'admin/config/media/kaltura'),
)),
);
}
}
}
}
}
return $requirements;
}
/*
* Alter notification ID field to bigint
*/
function kaltura_update_7201() {
db_drop_primary_key('kaltura_notifications');
db_add_primary_key('kaltura_notifications', array(
'notification_id',
));
}
Functions
Name![]() |
Description |
---|---|
kaltura_install | Implements hook_install(). |
kaltura_requirements | Implements hook_requirements(). |
kaltura_schema | Implements hook_schema(). |
kaltura_uninstall | Implemens hook_uninstall(). |
kaltura_update_7201 |