View source
<?php
function kaltura_playlist_schema() {
$schema['node_kaltura_playlist'] = array(
'description' => t('The base table for Kaltura playlist nodes.'),
'fields' => array(
'vid' => array(
'description' => t('The current {node_revisions}.vid version identifier.'),
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'description' => t('The primary identifier for a node.'),
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
),
'playlist_view' => array(
'description' => t('none'),
'type' => 'varchar',
'length' => 255,
'default' => "",
'not null' => TRUE,
),
),
'primary key' => array(
'vid',
),
);
return $schema;
}
function kaltura_playlist_tables() {
$tables['node_kaltura_playlist'] = "CREATE TABLE `{node_kaltura_playlist}` (\n `vid` smallint(5) unsigned NOT NULL default '0',\n `nid` smallint(5) unsigned NOT NULL,\n `playlist_view` varchar(255) NOT NULL default '',\n PRIMARY KEY (`vid`)\n )";
return $tables;
}
function kaltura_playlist_install() {
$tables = kaltura_playlist_tables();
foreach ($tables as $table_name => $create_sql) {
db_query($create_sql);
}
if (module_exists('views')) {
kaltura_populate_nodes();
}
}
function kaltura_populate_nodes() {
if (!module_exists('views')) {
return;
}
include_once 'kaltura_playlist.module';
$views = kaltura_get_relevant_views();
$count = 0;
foreach ($views as $key => $view) {
$node = new stdClass();
$node->title = str_replace('_', ' ', $view);
$node->type = 'kaltura_playlist';
$node->playlist_view = $key;
$node->promote = 0;
$node->sticky = 0;
$node->status = 1;
$node->uid = 1;
$node->created = time();
$node->changed = time();
node_save($node);
kaltura_playlist_insert($node);
$count++;
}
drupal_set_message('Kaltura Playlist module has created ' . $count . ' playlist nodes based on your existing views.');
}
function kaltura_playlist_uninstall() {
$tables = kaltura_playlist_tables();
foreach ($tables as $table_name => $create_sql) {
db_query('DROP TABLE {' . $table_name . '}');
}
}