You are here

function swftools_update_6010 in SWF Tools 6.3

Moves file handling defaults to new format.

File

./swftools.install, line 508
Install, update and uninstall functions for the SWF Tools module.

Code

function swftools_update_6010() {

  // Initialise a results array
  $ret = array();

  // We will iterate over these settings
  $settings = array(
    'audio',
    'audio_list',
    'video',
    'video_list',
    'swftools_swf_display',
    'image_list',
    'media_list',
  );

  // Store defaults in here if we find any
  $handlers = array();

  // Iterate, copy results to the new array, and deleting the original
  foreach ($settings as $variable) {
    if (($value = variable_get($variable, '__undefined')) != '__undefined') {
      $handlers[$variable] = $value;
      variable_del($variable);
    }
  }

  // Store new defaults and set return message if settings were altered
  if ($handlers) {

    // Attach swf handler
    $handlers['swf'] = 'swftools_swf';

    // Store new variable
    variable_set('swftools_handlers', $handlers);

    // Set return message
    $ret = array(
      array(
        'success' => TRUE,
        'query' => 'SWF Tools handler defaults migrated to new format.',
      ),
    );
  }

  // Return results
  return $ret;
}