You are here

function mailhandler_update_7202 in Mailhandler 7.2

Adds new command plugins to existing Feeds importers.

Adds MailhandlerCommandsFiles and MailhandlerCommandsHeaders command plugins to existing Feeds importers.

See also

http://drupal.org/node/1147414

File

./mailhandler.install, line 129
Install, update and uninstall functions for the Mailhandler module.

Code

function mailhandler_update_7202() {
  $result = db_query('SELECT * FROM {feeds_importer}');
  while ($row = $result
    ->fetchAssoc()) {
    $row['config'] = unserialize($row['config']);
    $is_mailhandler = $row['config']['parser']['plugin_key'] == 'MailhandlerParser';
    $is_command = isset($row['config']['parser']['config']['command_plugin']);
    if ($is_mailhandler && $is_command) {
      $old_plugins = $row['config']['parser']['config']['command_plugin'];
      $new_plugins = array(
        'MailhandlerCommandsFiles' => 'MailhandlerCommandsFiles',
        'MailhandlerCommandsHeaders' => 'MailhandlerCommandsHeaders',
      );
      $row['config']['parser']['config']['command_plugin'] = array_merge($old_plugins, $new_plugins);
      drupal_write_record('feeds_importer', $row, 'id');
    }
  }
}