| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id: mm_s3.module,v 1.1.2.2.2.23 2009/11/01 15:44:29 arthuregg Exp $ |
// $Id: mm_s3.module,v 1.1.2.2.2.24 2009/11/01 15:47:02 arthuregg Exp $ |
| 4 |
|
|
| 5 |
define('ACL_PRIVATE', 'private'); |
define('ACL_PRIVATE', 'private'); |
| 6 |
define('ACL_PUBLIC_READ', 'public-read'); |
define('ACL_PUBLIC_READ', 'public-read'); |
| 246 |
'#default_value' => $configuration['mm_s3_drupal_file_path'] ? $configuration['mm_s3_drupal_file_path'] : false, |
'#default_value' => $configuration['mm_s3_drupal_file_path'] ? $configuration['mm_s3_drupal_file_path'] : false, |
| 247 |
); |
); |
| 248 |
|
|
| 249 |
$form['mm_s3']['mm_s3_delete_source'] = array( |
$form['mm_s3']['mm_s3_drupal_file_path'] = array( |
| 250 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 251 |
'#title' => t('Use full Drupal filepath on S3'), |
'#title' => t('Use full Drupal filepath on S3'), |
| 252 |
'#description' => t('Selecting this will store your files on S3 with the Drupal directory path as |
'#description' => t('Selecting this will store your files on S3 with the Drupal directory path as |
| 253 |
part of the file name- for example <em>sites/default/files/myfile.jpg</em> This is useful if you |
part of the file name- for example <em>sites/default/files/myfile.jpg</em> This is useful if you |
| 254 |
are concerned about duplicate filenames or using URL rewriting to serve files from Amazon'), |
are concerned about duplicate filenames or using URL rewriting to serve files from Amazon'), |
| 255 |
'#default_value' => $configuration['mm_s3_delete_source'], |
'#default_value' => $configuration['mm_s3_drupal_file_path'] ? $configuration['mm_s3_drupal_file_path'] : false, |
| 256 |
); |
); |
| 257 |
|
|
| 258 |
$form['mm_s3']['mm_s3_drupal_file_path'] = array( |
$form['mm_s3']['mm_s3_delete_source'] = array( |
| 259 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 260 |
'#title' => t('Delete source material after succesfully moving to S3'), |
'#title' => t('Delete source material after succesfully moving to S3'), |
| 261 |
'#description' => t('Be very careful when you select this option. This will remove your original material, which will prevent future harvests and potentially removing it from the Drupal file system. Do not activate thus UNLESS you understand that you may loose your source material.'), |
'#description' => t('Be very careful when you select this option. This will remove your original material, which will prevent future harvests and potentially removing it from the Drupal file system. Do not activate thus UNLESS you understand that you may loose your source material.'), |
| 262 |
'#default_value' => $configuration['mm_s3_drupal_file_path'], |
'#default_value' => $configuration['mm_s3_delete_source'] ? $configuration['mm_s3_delete_source'] : false, |
| 263 |
); |
); |
| 264 |
|
|
| 265 |
$form['mm_s3']['advanced'] = array( |
$form['mm_s3']['advanced'] = array( |
| 292 |
if ($values['mm_s3_bucket'] != strtolower($values['mm_s3_bucket'])) { |
if ($values['mm_s3_bucket'] != strtolower($values['mm_s3_bucket'])) { |
| 293 |
form_error($element, t('Your bucket name must be lower case.')); |
form_error($element, t('Your bucket name must be lower case.')); |
| 294 |
} |
} |
|
|
|
| 295 |
// alert on delete |
// alert on delete |
| 296 |
if ($values['mm_s3_delete_source']) { |
if ($values['mm_s3_delete_source']) { |
| 297 |
drupal_set_message('You have choosen to delete your source material. Please be aware that this will remove files from your server\'s file system'); |
drupal_set_message('You have choosen to delete your source material. Please be aware that this will remove files from your server\'s file system'); |
| 353 |
// We need to set the filename based on the setting in this configuration |
// We need to set the filename based on the setting in this configuration |
| 354 |
// Sometimes it is a good idea to save the full $filepath as the filename |
// Sometimes it is a good idea to save the full $filepath as the filename |
| 355 |
if (! $configuration['mm_s3_drupal_file_path']) { |
if (! $configuration['mm_s3_drupal_file_path']) { |
| 356 |
$s3_filename = basebath($filepath); |
$s3_filename = basebath($filepath); |
| 357 |
} |
} |
| 358 |
else { |
else { |
| 359 |
$s3_filename = $filepath; |
$s3_filename = $filepath; |
| 360 |
} |
} |
| 361 |
|
|
| 362 |
// Put file on amazon. Note that we are using the full path as the file name on S3 |
// Put file on amazon. Note that we are using the full path as the file name on S3 |