Skip to content

Commit

Permalink
more kaltura stuff for 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
natepixel committed Jan 31, 2013
1 parent 7f1df1c commit 670a687
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* A module that offers the download links for a kaltura-integrated media work.
* @package reason
* @subpackage admin
*/

/**
* Include dependencies
*/
reason_include_once('classes/admin/modules/default.php');
reason_include_once('classes/entity_selector.php');
reason_include_once('classes/kaltura_shim.php');
reason_include_once( 'function_libraries/url_utils.php' );
reason_include_once('classes/media_work_helper.php');


/**
* This module checks to see if the current user has access to the given media work. It the user has access,
* All possible download links are displayed.
*
* This module is only compatible with kaltura-integrated Media Works.
*
* @author Marcus Huderle
*/
class mediaWorkDownloadLinksModule extends DefaultModule
{

var $media_work;
var $kaltura_shim;
var $user;
var $media_length;
var $media_files;

function init()
{
parent::init();

$this->admin_page->title = 'Download Links for Media Work';
$this->media_work = new entity($this->admin_page->id);

if ($this->media_work->get_value('integration_library') == 'kaltura')
{
$this->kaltura_shim = new KalturaShim();
$this->user = new entity($this->admin_page->user_id);

// Grab the associated media files
$es = new entity_selector();
$es->add_type(id_of('av_file'));
$es->add_right_relationship($this->media_work->id(), relationship_id_of('av_to_av_file'));
$this->media_files = $es->run_one();
}
}

function run()
{
if ($this->media_work->get_value('integration_library') == 'kaltura')
{
// Kill the module if the user doesn't have access to the video
$mwh = new media_work_helper($this->media_work);
if ( !$mwh->user_has_access_to_media() )
{
die('<p>You do not have permission to view the download links for this media work.</p>');
}

echo '<p>All download links for "'.$this->media_work->get_value('name').'" are displayed below.</p>'."\n";

echo '<ul>'."\n";
echo '<li><a href="'.$this->kaltura_shim->get_original_data_url($this->media_work->get_value('entry_id')).'">Original</a></li>'."\n";
foreach ($this->media_files as $file)
{
echo '<li><a href="'.$file->get_value('download_url').'">'.$file->get_value('name').'</a></li>'."\n";
}
echo '</ul>'."\n";

}
else
{
die('<p>This module only applies to kaltura-integrated Media Works.</p>');
}
}
}
?>
37 changes: 25 additions & 12 deletions reason_4.0/lib/core/classes/kaltura_shim.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,9 @@ public function add_flavor_param($params, $netid)
$client = $this->_get_kaltura_client($netid, true);
if (!$client) return false;

$list = $client->flavorParams->listAction();
$pager = new KalturaFilterPager();
$pager->pageSize = -1;
$list = $client->flavorParams->listAction(null, $pager);
$objects = $list->objects;
foreach ($objects as $param)
{
Expand All @@ -450,51 +452,62 @@ public function add_flavor_param($params, $netid)
$flavor_param = new KalturaFlavorParams();
foreach ($params as $key => $val) $flavor_param->$key = $val;

return $client->flavorParams->add($flavor_param);
$client->flavorParams->add($flavor_param);
return true;
}

public function delete_flavor_param($id, $netid)
{
$client = $this->_get_kaltura_client($netid, true);
if (!$client) return false;

$client->flavorParams->delete($id);
}

/**
* Creates a new transcoding profile in Kaltura. Returns true upon succes, or false if the profile already exists.
*
* @param array $params
* @param conversionProfile
* @param string $netid
*/
public function add_transcoding_profile($conversionProfile, $netid)
{
$client = $this->_get_kaltura_client($netid, true);
if (!$client) return false;

$list = $client->conversionProfile->listAction();
$pager = new KalturaFilterPager();
$pager->pageSize = -1;
$list = $client->conversionProfile->listAction(null, $pager);
$objects = $list->objects;
foreach ($objects as $profile)
{
if ($profile->name == $conversionProfile->name)
return false;
}

$client->conversionProfile->add($conversionProfile);
return true;
}

/**
* Return an array {name: id} of a kaltura transcoding flavor if one exists by the given name.
* Return an array of form {name: id} of existing flavors in Kaltura.
*
* @param string name of conversion profile
* @param string $netid
*/
public function get_flavor_ids($name, $netid)
public function get_flavor_ids($netid)
{
$client = $this->_get_kaltura_client($netid, true);
if (!$client) return false;

$list = $client->flavorParams->listAction();
$result = array();
$pager = new KalturaFilterPager();
$pager->pageSize = -1;
$list = $client->flavorParams->listAction(null, $pager);
$objects = $list->objects;
foreach ($objects as $param)
{
if ($param->name == $name)
return $param->id;
$result[$param->name] = $param->id;
}
return false;
return $result;
}


Expand Down
1 change: 1 addition & 0 deletions reason_4.0/lib/core/config/admin_modules/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'AdminTools'=>array('file'=>'admin_tools.php','class'=>'ReasonAdminToolsModule'),
'ErrorVisibility'=>array('file'=>'error_visibility.php','class'=>'ErrorVisibilityModule'),
'MediaImagePicker'=>array('file'=>'media_work_image_picker.php','class'=>'mediaWorkImagePickerModule'),
'MediaDownloadLinks'=>array('file'=>'media_work_download_links.php','class'=>'mediaWorkDownloadLinksModule'),
'KalturaImport'=>array('file'=>'kaltura_import.php','class'=>'KalturaImportModule'),
'CustomizeTheme'=>array('file'=>'customize_theme.php','class'=>'CustomizeThemeModule'),
'SiteAccessDenied'=>array('file'=>'site_access_denied.php', 'class'=>'SiteAccessDeniedModule'),
Expand Down
10 changes: 9 additions & 1 deletion reason_4.0/lib/core/content_managers/media_work.php3
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ reason_include_once('ssh/ssh.php');
}
}

$this->set_order (array ( 'status_report', 'file_preview', 'name', 'upload_file', 'email_notification', 'show_download', 'show_embed', 'embed_small', 'embed_medium', 'embed_large', 'link', 'replacement_header', 'file_info_header', 'av_type', 'description', 'keywords', 'datetime', 'author', 'content', 'transcript_status', 'rights_statement', 'media_duration', 'media_publication_datetime', 'access_header', 'show_hide', 'restricted_group', 'no_share' ));
$this->set_order (array ( 'status_report', 'file_preview', 'name', 'upload_file', 'email_notification', 'show_download', 'show_embed', 'embed_small', 'embed_medium', 'embed_large', 'download_links', 'link', 'replacement_header', 'file_info_header', 'av_type', 'description', 'keywords', 'datetime', 'author', 'content', 'transcript_status', 'rights_statement', 'media_duration', 'media_publication_datetime', 'access_header', 'show_hide', 'restricted_group', 'no_share' ));
}
else
{
Expand Down Expand Up @@ -218,6 +218,14 @@ reason_include_once('ssh/ssh.php');

$this->change_element_type('show_embed', 'checkbox');
$this->change_element_type('show_download', 'checkbox');

if ($this->get_value('transcoding_status') == 'ready')
{
$download_links_url = carl_make_link(array('cur_module' => 'MediaDownloadLinks'));
$download_links_link = '<a href="'.$download_links_url.'"><strong>View download links for this media</strong></a>';
$this->add_element( 'download_links' , 'commentWithLabel' , array('text'=>$download_links_link));
$this->set_display_name('download_links', '');
}
}

function process()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ $(document).ready(function()
$("tr#embedlargeRow").hide();
$("tr#showdownloadRow").hide();
$("tr#showembedRow").hide();
$("tr#downloadlinksRow").hide();
$("#contentRow").addClass('offScreen');
$("#transcriptstatusRow").addClass('offScreen');
$("#rightsstatementRow").addClass('offScreen');
Expand All @@ -188,6 +189,7 @@ $(document).ready(function()
$("tr#embedlargeRow").show();
$("tr#showdownloadRow").show();
$("tr#showembedRow").show();
$("tr#downloadlinksRow").show();
return false;
});

Expand Down

0 comments on commit 670a687

Please sign in to comment.