Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2016 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/48de54997b71cf19f107 to your computer and use it in GitHub Desktop.
Save anonymous/48de54997b71cf19f107 to your computer and use it in GitHub Desktop.
Custom Drupal 7 module to toggle the Storage API "External" setting for Amazon S3 containers. See: https://www.drupal.org/node/1832364
name = "S3 External Toggle"
description = "Enable to set all Storage API Amazon S3 containers to 'External' (disable to reverse the setting)"
package = "Storage API"
core = 7.x
version = 7.x-1.0
dependencies[] = storage
<?php
/**
* Implement hook_enable()
*/
function storage_api_external_enable() {
db_update('storage_container')
->fields(array('external' => 1))
->condition('service_id', 'storage:s3', '=')
->execute();
}
/**
* Implement hook_disable()
*/
function storage_api_external_disable() {
db_update('storage_container')
->fields(array('external' => 0))
->condition('service_id', 'storage:s3', '=')
->execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment