You are here

function field_kaltura_nodeapi in Kaltura 5

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

File

plugins/field_kaltura/field_kaltura.module, line 597
kaltura integration module - functions to provide kaltura as CCK field

Code

function field_kaltura_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'update') {

    // do something only if tags vocabulary applied and not empty on this node
    if ($node->taxonomy['tags']) {

      // get all tags as string
      foreach ($node->taxonomy['tags'] as $tags) {
        $node_tags[] = $tags;
      }
      $node_all_tags = implode(',', $node_tags);

      // get all fields for node which are kaltura fields
      foreach ($node as $obj_key => $values) {
        if (substr($obj_key, 0, 5) != 'field') {
          continue;
        }
        if ($type = kaltura_is_kaltura_field($obj_key)) {
          foreach ($values as $value) {
            if ($value['value']) {
              if ($type == 'Kaltura_Media') {
                $media_entries = explode(',', rtrim($value['value']));
                foreach ($media_entries as $entry) {
                  $kaltura_entries[] = $entry;
                }
              }
              else {
                $kaltura_entries[] = $value['value'];
              }
            }
          }
        }
      }

      // update taxonomy as entries tags
      if (is_array($kaltura_entries) && count($kaltura_entries)) {
        kaltura_update_field_entries_tags($kaltura_entries, $tags, $node->title);
      }
    }
  }
}