You are here

function webform_update_7318 in Webform 7.3

Same name and namespace in other branches
  1. 7.4 webform.install \webform_update_7318()

Upgrade file components to support the new AJAX-upload element.

File

./webform.install, line 748
Webform module install/schema hooks.

Code

function webform_update_7318() {
  $result = db_select('webform_component', 'wc', array(
    'fetch' => PDO::FETCH_ASSOC,
  ))
    ->fields('wc')
    ->condition('type', 'file')
    ->execute();
  foreach ($result as $component) {
    $component['extra'] = unserialize($component['extra']);
    if (!isset($component['extra']['directory'])) {
      $component['extra']['directory'] = $component['extra']['savelocation'];
      $component['extra']['scheme'] = file_default_scheme();
      $component['extra']['filtering']['size'] = $component['extra']['filtering']['size'] . ' KB';
      unset($component['extra']['savelocation']);
      $component['extra'] = serialize($component['extra']);
      drupal_write_record('webform_component', $component, array(
        'nid',
        'cid',
      ));
    }
  }
  return t('File components updated to support AJAX uploading.');
}