'Delete Bucket', 'page callback' => 'video_s3_bucket_delete', 'page arguments' => array(5), 'access arguments' => array('administer amazon s3'), 'file' => 'video_s3.admin.inc', 'type' => MENU_CALLBACK, ); return $items; } /* * Implementation of hook_cron(). */ function video_s3_cron() { if (!_video_s3_is_active_fs()) { return; } module_load_include('lib.inc', 'video_s3'); $s3 = new video_amazon_s3(); $s3->connect(); // Lets run our queue. $s3->queue(); } /** * Implementation of hook_video_delete. * we can use hook_file_delete() */ function video_s3_video_delete($file) { module_load_include('lib.inc', 'video_s3'); $s3 = new video_amazon_s3(); $s3->connect(); // Lets run our queue. $s3->delete($file->fid); } /** * Implementation of hook_video_update. * Submit handler to update our s3 table to include the node id. */ function video_s3_video_update($form, &$form_state) { //lets update our video rending table to include the node id created if (isset($form_state['nid']) && isset($form_state['values']['video_id']) && is_array($form_state['values']['video_id'])) { foreach ($form_state['values']['video_id'] as $fid) { //lets update our table to include the nid db_query("UPDATE {video_s3} SET nid=%d WHERE fid=%d", $form_state['nid'], $fid); } } } /** * Implementing hook_video_insert * @param $element * @param $form_state */ function video_s3_video_insert(&$element, &$form_state) { if (!_video_s3_is_active_fs()) { return; } $file = $element['#value']; //we need to check if this fid has already been added to the database AND that there is in fact a fid if (is_array($file) && isset($file['fid']) && !empty($file['fid'])) { module_load_include('lib.inc', 'video_s3'); $s3 = new video_amazon_s3(); $s3->connect(); // Lets verify that we haven't added this video already. Multiple validation fails will cause this to be ran more than once if (!$video = $s3->verify($file['fid'])) { // Video has not been added to the queue yet so lets add it. $s3->insert($file['fid']); drupal_set_message(t('Video submission queued for transfer to your Amazon S3 server. Will be there shortly.')); } } } function video_s3_get_object_info($object) { module_load_include('lib.inc', 'video_s3'); $s3 = new video_amazon_s3(); $s3->connect(); return $s3->get_object_info($object); } /** * @param string $objectUri * @deprecated Use video_amazon_s3::get_authenticated_url($objectUri) */ function video_s3_get_authenticated_url($objectUri) { module_load_include('lib.inc', 'video_s3'); $s3 = new video_amazon_s3(); $s3->connect(); return $s3->get_authenticated_url($objectUri); } function video_s3_get_object($object, $save_to = false) { module_load_include('lib.inc', 'video_s3'); $s3 = new video_amazon_s3(); $s3->connect(); return $s3->get_object($object, $save_to); } /* * Deletes a bucket from your Amazon S3 server. */ function video_s3_bucket_delete($bucket) { module_load_include('lib.inc', 'video_s3'); $s3 = new video_amazon_s3(); $s3->connect(); $buckets = $s3->s3->listBuckets(); if (is_array($buckets) && in_array($bucket, $buckets)) { if ($s3->s3->deleteBucket($bucket)) { drupal_set_message(t('Successfully deleted the bucket %bucket', array('%bucket' => $bucket))); } else { drupal_set_message(t('Could not delete the bucket %bucket', array('%bucket' => $bucket)), 'error'); } } else { drupal_set_message(t('The bucket %bucket does not exist for deletion.', array('%bucket' => $bucket)), 'error'); } drupal_goto('admin/settings/video/amazon_s3'); } function _video_s3_is_active_fs() { return variable_get('vid_filesystem', 'drupal') === 'video_s3'; }