Download & Extend

Delete Kaltura media entries on node deletion

Project:Kaltura
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

has anyone implimented
http://www.kaltura.org/delete-files-kaltura-db-when-deleting-nodes
and willing to share the code?

thanks,
joseph

Comments

#1

FYI: looks like that link is broken now.

#2

Something like this should work:

<?php
function YOURMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
    if(
$op == 'delete' && $node->type == 'YOUR KALTURA CONTENT TYPE NAME'){
       
$session_user = KalturaHelpers::getSessionUser();
       
$kaltura_client = KalturaHelpers::getKalturaClient(TRUE); 
             
$result = $kaltura_client->deleteEntry($session_user, $node->kaltura_entryId);
    }
}
?>

#3

Hi JaceRider,
I tried to implement it in the kaltura.module. But I seems to work not in that way I did it.. is the "if" wrong implemented?

Cheers

...
/**
* Implementation of hook_nodeapi().
*
* All we do here is to alter the body and teaser fields when a node goes to view mode
* we call our functions to replcae the special "tags", which we create in theme_node_kaltura_*_entryId(), with the embed tag
*
*/
function kaltura_nodeapi(&$node, $op, $teaser, $a3 = NULL, $a4 = NULL) {
switch ($op) {
    case "delete":
    if($node->type == 'blog_crossposting'){
      $session_user = KalturaHelpers::getSessionUser();
      $kaltura_client = KalturaHelpers::getKalturaClient(TRUE);
      $result = $kaltura_client->deleteEntry($session_user, $node->kaltura_entryId);
    }
      break;

#4

I don't know bud, that looks like it should work to me.

Try doing a dsm($result); after the line "$result = $kaltura_client->deleteEntry($session_user, $node->kaltura_entryId);" and see what it returns. (Make sure you have the devel module installed, otherwise do print_r($result))

If I remember correctly, the message that is displayed should tell you what the issue is.

#5

Hi JaceRider,
I got this:

Array ( [result] => Array ( [serverTime] => 1257865714 ) [error] => Array ( [0] => Array ( [code] => MANDATORY_PARAMETER_MISSING [desc] => Mandatory paramter missing [entry_id] ) ) [debug] => Array ( [sigtype] => 1 [signature] => d094f66cd60462b6ee2854ea055248b3 [execute_impl_time] => -1257865714.0101 [execute_time] => 0.067968130111694 [total_time] => 0.0689699649811 ) )

#6

Well, it would seem something is wrong with "$node->kaltura_entryId". I would do a dsm of $node and make sure that kaltura_entryId is listed in that object. If it isn't, that's why it isn't working and you will need to track down why it isn't there.

#7

I get this message when trying the method listed above. Any ideas on what I need to add?

Fatal error: Call to undefined method KalturaClient::deleteEntry()

#8

Version:6.x-1.4» 6.x-2.x-dev
Category:support request» feature request
Status:active» needs work

At a guess, your node has Kaltura items attached via CCK and so $node->kaltura_entryId is not populated.

For this to go in you will need to provide UI for the user to *optionally* select whether the referenced item should be deleted when the node is deleted. You'll also need to extract the Kaltura entryId from the field values, and bear in mind that this may be a comma-separated list of entries.

For field_kaltura, you'll need to implement in hook_field() instead of hook_nodeapi(). $op will still be 'delete'.

#9

Title:delete node = delete kaltura media» Delete Kaltura media entries on node deletion

Looks like the Kaltura API code above is from the v2 API too. That will need to be updated for v3.