Index: mm_s3.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/media_mover/contrib/mm_s3/Attic/mm_s3.module,v retrieving revision 1.1.2.13 diff -u -p -r1.1.2.13 mm_s3.module --- mm_s3.module 30 Nov 2009 16:52:09 -0000 1.1.2.13 +++ mm_s3.module 6 Dec 2009 09:50:38 -0000 @@ -215,15 +215,6 @@ function mm_s3_config($action_id, $confi '#default_value' => $configuration['mm_s3_drupal_file_path'] ? $configuration['mm_s3_drupal_file_path'] : false, ); - $form['mm_s3']['mm_s3_drupal_file_path'] = array( - '#type' => 'checkbox', - '#title' => t('Use full Drupal filepath on S3'), - '#description' => t('Selecting this will store your files on S3 with the Drupal directory path as - part of the file name- for example sites/default/files/myfile.jpg This is useful if you - are concerned about duplicate filenames or using URL rewriting to serve files from Amazon'), - '#default_value' => $configuration['mm_s3_drupal_file_path'] ? $configuration['mm_s3_drupal_file_path'] : false, - ); - $form['mm_s3']['mm_s3_delete_source'] = array( '#type' => 'checkbox', '#title' => t('Delete source material after succesfully moving to S3'), @@ -240,7 +231,7 @@ function mm_s3_config($action_id, $confi $form['mm_s3']['advanced']['mm_s3_server_url'] = array( '#type' => 'textfield', '#title' => t('Server URL'), - '#default_value' => $configuration['mm_s3_server_url'] ? $configuration['mm_s3_server_url'] : variable_get('mm_s3_default_server_url', 'https://s3.amazonaws.com/'), + '#default_value' => $configuration['mm_s3_server_url'] ? $configuration['mm_s3_server_url'] : variable_get('mm_s3_url', 'https://s3.amazonaws.com/'), '#description' => t('Server URL. Use this to set the URL where your files will be served from. Normally this is s3.amazonaws.com, however you can define your own S3 URL with your DNS service.'), ); @@ -274,9 +265,9 @@ function mm_s3_validate_configuration($c // now check to see if we have a good bucket else{ // does this bucket exist? - if (! mm_s3_bucket_exists($test_bucket, $s3)) { + if (! mm_s3_bucket_exists($configuration['mm_s3_bucket'], $s3)) { // try to create the bucket - if (! $s3->putBucket($configuration['mm_s3_bucket'], S3::ACL_PUBLIC_READ, false, false)) { + if (! $s3->putBucket($configuration['mm_s3_bucket'], ACL_PUBLIC_READ, false, false)) { return array( array( 'element' => 'mm_s3_bucket', @@ -311,8 +302,7 @@ function mm_s3_send($file, $configuratio // can we read the file? if (! is_readable($filepath)) { - watchdog('MM S3', 'Harvested file is not readable, check permissions: !file', - array('!file' => $filepath), WATCHDOG_ERROR, l($file['mmfid'], 'admin/build/media_mover/file/edit/'. $file['mmfid'])); + watchdog('MM S3', 'Harvested file is not readable, check permissions: ' . $filepath, WATCHDOG_ERROR, l($file['mmfid'], 'admin/build/media_mover/file/edit/'. $file['mmfid'])); return; } @@ -324,7 +314,6 @@ function mm_s3_send($file, $configuratio // set the permisisons $perms = $configuration['mm_s3_perm'] ? $configuration['mm_s3_perm'] : ACL_PUBLIC_READ; - $perms = constant('S3::'. $perms); // Create the bucket on S3 if it does not exist $s3->putBucket($bucket, $perms); @@ -346,10 +335,9 @@ function mm_s3_send($file, $configuratio // Error check if (! $info['hash']) { // Error condition when trying to put file up - $message = 'media_mover s3 could not upload file to amazon. Reporting error: @error'; - $variables = array('@error' => print_r($s3, true)); + $message = 'media_mover s3 could not upload file to amazon. Reporting error: ' . print_r($info, true); $link = l('Change S3 Settings', 'admin/settings/media_mover'); - watchdog('MM S3', $message, $variables, WATCHDOG_ERROR, $link); + watchdog('MM S3', $message, WATCHDOG_ERROR, $link); return false; } @@ -380,13 +368,13 @@ function mm_s3_send($file, $configuratio } } foreach ($delete_files as $delete_file) { - watchdog('MM S3', 'Deleted local file: !file', array('!file' => $file[$delete_file])); + watchdog('MM S3', 'Deleted local file: ' . $file[$delete_file]); unlink($file[$delete_file]); } } // create the return file - return $configuration['mm_s3_server_url'] . $filename; + return $configuration['mm_s3_server_url'] . $filepath; } @@ -417,6 +405,7 @@ function mm_s3_delete_file($item, $confi // files is our list of stuff we want to delete. Put it the form bucket/file foreach ($files as $file) { $file = str_replace($configuration['mm_s3_server_url'], '', $file); + // @TODO - dirname to get bucket no longer works because we can be storing full Drupal paths $delete_files[] = array('bucket' => dirname($file), 'file' => basename($file) ); } @@ -428,10 +417,12 @@ function mm_s3_delete_file($item, $confi $s3 = new S3(awsAccessKey, awsSecretKey); foreach($delete_files as $file) { + // @todo remove debug watchdog here + watchdog('MM S3', t('Attempting to delete S3 - bucket: ' .$file['bucket'].', file: '.$file['file'])); $s3->deleteObject($file['bucket'], $file['file']); } - watchdog('MM S3', t('Deleted S3 for node !nid, file: !mmfid', array('!mmfid' => $item['mmfid'], '!nid' => $item['nid']))); + watchdog('MM S3', t('Deleted S3 for node ' . $item['nid'] . ', file: ' . $item['mmfid'])); drupal_set_message(t('Deleted S3 file')); } }