You are here

function vimeo_video_uploader_node_delete in Vimeo Video Uploader 7

Same name and namespace in other branches
  1. 8.4 vimeo_video_uploader.module \vimeo_video_uploader_node_delete()
  2. 8 vimeo_video_uploader.module \vimeo_video_uploader_node_delete()
  3. 7.2 vimeo_video_uploader.module \vimeo_video_uploader_node_delete()

Implements hook_node_delete($node).

File

./vimeo_video_uploader.module, line 126
Module file for the Vimeo Video Uploader.

Code

function vimeo_video_uploader_node_delete($node) {
  $video_id_val = substr($node->field_embeddedvideo["und"][0]["video_url"], 17);
  if (!empty($video_id_val)) {
    if ($node->type == variable_get('vimeo_content_type_select') && !empty($node->nid)) {
      require_once 'vimeo-lib-api/vimeo.php';
      $consumer_key = variable_get('vimeo_api_key');
      $consumer_secret = variable_get('vimeo_api_secret');
      $oauth_access_token = variable_get('vimeo_oauth_access_token');
      $oauth_request_token_secret = variable_get('vimeo_oauth_request_token_secret');
      $vimeo_user_id = variable_get('vimeo_user_id');
      $video_id_ = substr($node->field_embeddedvideo["und"][0]["video_url"], 17);
      $vimeo_ = new phpVimeo($consumer_key, $consumer_secret);
      $vimeo_
        ->setToken($oauth_access_token, $oauth_request_token_secret);
      $vimeo_->user_id = $vimeo_user_id;
      try {
        $vimeo_
          ->call('vimeo.videos.delete', array(
          'video_id' => $video_id_,
        ));
        unset($vimeo_);
      } catch (Exception $e) {
        drupal_goto('admin/content');
        drupal_exit();
      }
    }
  }
}