You are here

function node_kaltura_entry_update in Kaltura 5

Same name and namespace in other branches
  1. 6.2 plugins/node_kaltura_entry/node_kaltura_entry.module \node_kaltura_entry_update()
  2. 6 plugins/node_kaltura_entry/node_kaltura_entry.module \node_kaltura_entry_update()

Implementation of hook_update().

This hook can be initiated in two cases: 1) the node was updated in drupal 2) the node was updated in kaltura (or in one of kaltura's widgets) and a notification of update_entry was received

File

plugins/node_kaltura_entry/node_kaltura_entry.module, line 464

Code

function node_kaltura_entry_update($node) {

  // if this is a new node or we're adding a new revision,
  if ($node->revision) {
    node_example_insert($node);
  }
  else {
    require_once drupal_get_path('module', 'kaltura') . '/kaltura.install';
    $fields = kaltura_schema();
    $first = '';
    watchdog('node', print_r($node, TRUE));
    foreach ($fields['node_kaltura']['fields'] as $field => $structure) {
      if ($field == 'vid' || $field == 'nid' || $field == 'kaltura_entryId' || $field == 'kaltura_video_comment' || $field == 'kaltura_entry_data') {
        continue;
      }
      $update_str .= $first . $field . ' = ' . ($structure['type'] == 'int' ? "%d" : "'%s'");
      $first = ', ';
    }

    // we don't expose the tags and admin tags fields, to no need to update taxonomy by hand.
    //    update_entry_node_taxonomy($node);
    kaltura_update_entry_tags_from_taxonomy($node);
    $sql = 'UPDATE {node_kaltura} SET ' . $update_str . ' WHERE vid = %d';
    db_query($sql, $node->kaltura_tags, $node->kaltura_admin_tags, $node->kstatus, $node->kaltura_media_type, $node->kaltura_duration, $node->kaltura_thumbnail_url, $node->kaltura_partner_data, $node->kaltura_source, $node->kaltura_source_id, $node->kaltura_source_link, $node->kaltura_width, $node->kaltura_height, $node->kaltura_download_url, $node->kaltura_media_date, $node->kaltura_views, $node->kaltura_plays, $node->kaltura_votes, $node->kaltura_rank, $node->kaltura_total_rank, $node->vid);

    // in case the update was done in drupal, and not by notification, we want to update
    // the metadata in kaltura's DB
    if ($node->notification_update !== TRUE) {
      kaltura_update_entry_tags($node->kaltura_entryId, $node->kaltura_tags, $node->kaltura_admin_tags);
    }
    else {

      // updated through notification. no need to call Kaltura API
    }
  }
}