You are here

webform_addmore.install in Webform Add More 7.2

Same filename and directory in other branches
  1. 6 webform_addmore.install
  2. 7 webform_addmore.install

Install hooks for Webform Add More module.

File

webform_addmore.install
View source
<?php

/**
 * @file
 * Install hooks for Webform Add More module.
 */

/**
 * Upgrade path from 7.x-1.x version to 7.x-2.x.
 */
function webform_addmore_update_7200() {
  $variables = db_select('variable', 'v')
    ->fields('v')
    ->condition('name', 'webform_addmore%', 'LIKE')
    ->execute()
    ->fetchAll();
  foreach ($variables as $variable) {
    $changed = TRUE;
    $nid = (int) str_replace('webform_addmore_', '', $variable->name);
    $settings = unserialize($variable->value);
    $node = node_load($nid);
    $add = !empty($settings['addlabel']) ? $settings['addlabel'] : t('Add one');
    $remove = !empty($settings['dellabel']) ? $settings['dellabel'] : t('Remove one');
    foreach ($node->webform['components'] as $delta => $component) {
      if (!empty($settings[$component['cid']])) {
        $node->webform['components'][$delta]['extra']['webform_addmore'] = array(
          'addmore' => 1,
          'addmore_add' => check_plain($add),
          'addmore_remove' => check_plain($remove),
          'addmore_show' => 1,
        );
      }
    }
    node_save($node);
    variable_del($variable->name);
  }
}

Functions

Namesort descending Description
webform_addmore_update_7200 Upgrade path from 7.x-1.x version to 7.x-2.x.