You are here

function mailhandler_update_6211 in Mailhandler 6.2

Move default commands to source config.

File

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

Code

function mailhandler_update_6211() {
  $ret = array();
  $importers = db_query('SELECT * FROM {feeds_importer}');
  while ($importer = db_fetch_array($importers)) {
    $importer['config'] = unserialize($importer['config']);
    if ($importer['config']['parser']['plugin_key'] == 'MailhandlerParser') {
      if (!empty($importer['config']['content_type'])) {
        $nodes = db_query("SELECT * FROM {node} WHERE type = '%s'", $importer['config']['content_type']);
        while ($node = db_fetch_array($nodes)) {
          $sources = db_query('SELECT * FROM {feeds_source} WHERE feed_nid = %d', $node['nid']);
          $source = db_fetch_array($sources);
          $source['config'] = unserialize($source['config']);
          $source['config']['MailhandlerParser']['default_commands'] = $importer['config']['parser']['config']['default_commands'];
          $source['config']['MailhandlerParser']['commands_failed_auth'] = $importer['config']['parser']['config']['commands_failed_auth'];
          drupal_write_record('feeds_source', $source, array(
            'id',
            'feed_nid',
          ));
        }
      }
    }
  }
  return $ret;
}