You are here

function kaltura_node_update_index in Kaltura 7.2

Same name and namespace in other branches
  1. 7.3 kaltura.module \kaltura_node_update_index()

Implements hook_node_update_index().

File

./kaltura.module, line 244
Kaltura integration module - core functions.

Code

function kaltura_node_update_index($node) {

  // Add kaltura metadata to node search index.
  $text = '';
  $lang = $node->language;

  // Get all fields of field_kaltura_entryid type.
  $fields = field_read_fields(array(
    'type' => 'field_kaltura_entryid',
  ));
  foreach (array_keys($fields) as $field) {
    if (!empty($node->{$field}[$lang])) {
      foreach ($node->{$field}[$lang] as $item) {
        $qry = db_select('node_kaltura', 'k')
          ->fields('k', array(
          'kaltura_tags',
          'kaltura_title',
          'kaltura_description',
        ))
          ->condition('kaltura_entryid', $item['entryid'])
          ->execute()
          ->fetchAssoc();
        $text .= ($text ? ',' : '') . implode(',', $qry);
      }
    }
  }
  return $text;
}