You are here

webform_campaignmonitor.install in Webform Campaign Monitor 7.3

Same filename and directory in other branches
  1. 7.2 webform_campaignmonitor.install

Code for the install file of the Webform Campaign Monitor module.

File

webform_campaignmonitor.install
View source
<?php

/**
 * @file
 * Code for the install file of the Webform Campaign Monitor module.
 */

/**
 * Update structure of old components.
 */
function webform_campaignmonitor_update_7200(&$sandbox) {
  $result = db_select('webform_component', 'c')
    ->fields('c')
    ->condition('type', 'campaignmonitor')
    ->execute();
  foreach ($result as $record) {
    $record->extra = unserialize($record->extra);
    $record->extra['lists'] = array();
    $record->extra['fields_mappings'] = array();
    foreach ($record->extra['list'] as $key => $value) {
      $record->extra['lists'][$key] = $value;
      if ($value) {
        $record->extra['fields_mappings'][$key] = array(
          'Name' => $record->extra['textfield_component'],
          'Email' => $record->extra['email_component'],
        );
      }
    }
    unset($record->extra['list']);
    unset($record->extra['textfield_component']);
    unset($record->extra['email_component']);
    db_update('webform_component')
      ->fields(array(
      'extra' => serialize($record->extra),
    ))
      ->condition('nid', $record->nid)
      ->condition('cid', $record->cid)
      ->execute();
  }
}

Functions

Namesort descending Description
webform_campaignmonitor_update_7200 Update structure of old components.