You are here

function brightcove_cck_field in Brightcove Video Connect 6

Same name and namespace in other branches
  1. 6.2 brightcove_cck/brightcove_cck.module \brightcove_cck_field()

Implementation of hook_field().

File

brightcove_cck/brightcove_cck.module, line 173
Brightcove CCK module provides a Content Construction Kit module to developers, allowing them to browse videos in their Brightcove Studio and upload them.

Code

function brightcove_cck_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case 'validate':
      foreach ($items as $delta => $item) {
        if (is_array($item)) {
          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
          if (is_array($item) && isset($item['_error_element'])) {
            unset($item['_error_element']);
          }
          if (!empty($item['video_id'])) {
            $video = brightcove_video_load($item['video_id']);
            if (empty($video->id)) {

              // Check for video in session - uploaded file.
              if (is_null(brightcove_video_cache_get($item['video_id']))) {
                form_set_error($error_element, t('%name: invalid video.', array(
                  '%name' => t($field['widget']['label']),
                )));
              }
            }
          }
        }
      }
      return $items;
  }
}