You are here

function _media_youtube_save_status_data in Media: YouTube 6

File

includes/media_youtube.api.inc, line 116
Miscellaneous API function calls for Media: YouTube.

Code

function _media_youtube_save_status_data(&$node, $code, $item, $field_name, $delta) {

  // Check the real status of the video.
  $status = media_youtube_check_status($code);

  // If the status has changed, then save it in the node.
  if ($status != $item['status'] && $node->nid) {
    foreach ($node->{$field_name} as $delta => $field) {
      if ($field['provider'] == 'youtube' && $field['value'] == $code && $field['status'] == $item['status']) {
        $node->{$field_name}[$delta]['status'] = $status;
      }
    }
    node_save($node);
  }
  return $status;
}