From 7b3cbeca386a2621ffa8a7f66ba043359dbb6d6e Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 12 Jun 2017 20:56:47 +0000 Subject: [PATCH] updated info file --- mnn_show_import.features.inc | 15 ++ mnn_show_import.feeds_importer_default.inc | 156 +++++++++++++++++++++ mnn_show_import.info | 10 ++ mnn_show_import.module | 72 ++++++++++ 4 files changed, 253 insertions(+) create mode 100644 mnn_show_import.features.inc create mode 100644 mnn_show_import.feeds_importer_default.inc create mode 100644 mnn_show_import.info create mode 100644 mnn_show_import.module diff --git a/mnn_show_import.features.inc b/mnn_show_import.features.inc new file mode 100644 index 0000000..d785230 --- /dev/null +++ b/mnn_show_import.features.inc @@ -0,0 +1,15 @@ + "1"); + } +} diff --git a/mnn_show_import.feeds_importer_default.inc b/mnn_show_import.feeds_importer_default.inc new file mode 100644 index 0000000..b100d6f --- /dev/null +++ b/mnn_show_import.feeds_importer_default.inc @@ -0,0 +1,156 @@ +disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */ + $feeds_importer->api_version = 1; + $feeds_importer->id = 'mnn_show_import'; + $feeds_importer->config = array( + 'name' => 'Show Import', + 'description' => '', + 'fetcher' => array( + 'plugin_key' => 'FeedsFileFetcher', + 'config' => array( + 'allowed_extensions' => 'txt csv tsv xml opml', + 'direct' => FALSE, + ), + ), + 'parser' => array( + 'plugin_key' => 'FeedsCSVParser', + 'config' => array( + 'delimiter' => ';', + 'no_headers' => 0, + ), + ), + 'processor' => array( + 'plugin_key' => 'FeedsNodeProcessor', + 'config' => array( + 'content_type' => 'cm_show', + 'expire' => '-1', + 'author' => '0', + 'mappings' => array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + 'unique' => 0, + ), + 1 => array( + 'source' => 'created', + 'target' => 'created', + 'unique' => FALSE, + ), + 2 => array( + 'source' => 'exec_producer_id', + 'target' => 'uid', + 'unique' => FALSE, + ), + 3 => array( + 'source' => 'language', + 'target' => 'taxonomy_pbcore_languages', + 'unique' => FALSE, + ), + 4 => array( + 'source' => 'device', + 'target' => 'field_device', + 'unique' => FALSE, + ), + 5 => array( + 'source' => 'runtime', + 'target' => 'field_runtime', + 'unique' => FALSE, + ), + 6 => array( + 'source' => 'content_type', + 'target' => 'field_pbcore_genres', + 'unique' => FALSE, + ), + 7 => array( + 'source' => 'format', + 'target' => 'field_format', + 'unique' => FALSE, + ), + 8 => array( + 'source' => 'topic', + 'target' => 'field_topic', + 'unique' => FALSE, + ), + 9 => array( + 'source' => 'schedule_type', + 'target' => 'taxonomy_cm_project_types', + 'unique' => FALSE, + ), + 10 => array( + 'source' => 'live_device', + 'target' => 'field_device', + 'unique' => FALSE, + ), + 11 => array( + 'source' => 'reject_reason', + 'target' => 'field_reject_reason', + 'unique' => FALSE, + ), + 12 => array( + 'source' => 'delivered_via', + 'target' => 'field_delivered_via', + 'unique' => FALSE, + ), + 13 => array( + 'source' => 'episode_id', + 'target' => 'guid', + 'unique' => 1, + ), + 14 => array( + 'source' => 'time_code_in', + 'target' => 'field_timecode_in', + 'unique' => FALSE, + ), + 15 => array( + 'source' => 'time_code_out', + 'target' => 'field_timecode_out', + 'unique' => FALSE, + ), + 16 => array( + 'source' => 'transcoded_time_code_in', + 'target' => 'field_trans_timecode_in', + 'unique' => FALSE, + ), + 17 => array( + 'source' => 'transcoded_time_code_out', + 'target' => 'field_trans_timecode_out', + 'unique' => FALSE, + ), + 18 => array( + 'source' => 'runtime_type', + 'target' => 'field_runtime', + 'unique' => FALSE, + ), + 19 => array( + 'source' => 'episode_number', + 'target' => 'field_episode_number', + 'unique' => FALSE, + ), + ), + 'update_existing' => '2', + 'input_format' => 'plain_text', + ), + ), + 'content_type' => '', + 'update' => 0, + 'import_period' => '-1', + 'expire_period' => 3600, + 'import_on_create' => 1, + 'process_in_background' => 1, + ); + $export['mnn_show_import'] = $feeds_importer; + + return $export; +} diff --git a/mnn_show_import.info b/mnn_show_import.info new file mode 100644 index 0000000..b09ba73 --- /dev/null +++ b/mnn_show_import.info @@ -0,0 +1,10 @@ +core = "7.x" +dependencies[] = "feeds" +description = "Feed for Importing Show CSV" +features[ctools][] = "feeds:feeds_importer_default:1" +features[feeds_importer][] = "mnn_show_import" +name = "MNN Show Import" +package = "MNN Features" +php = "5.2.4" +project = "mnn_show_import" +version = "7.x-1.0-beta1" diff --git a/mnn_show_import.module b/mnn_show_import.module new file mode 100644 index 0000000..703bb56 --- /dev/null +++ b/mnn_show_import.module @@ -0,0 +1,72 @@ + 'Resave All Shows', + 'description' => 'Enable Active Projects', + 'page callback' => 'mnn_show_import_resave_batch_init', + 'access arguments' => array('administer group'), + 'type' => MENU_CALLBACK + ); + + return $items; +} + +function mnn_show_import_resave_batch_init() { + + $batch = array( + 'title' => t('Resaving Show Nodes...'), + 'operations' => array(), + 'init_message' => t('Starting Resave'), + 'progress_message' => t('Processed @current out of @total.'), + 'error_message' => t('An error occurred during processing'), + 'finished' => 'mnn_show_import_resave_batch_finished', + 'progressive' => FALSE + ); + + //query all show nodes + + //SELECT nid, ogm.id FROM node n LEFT JOIN og_membership ogm ON etid = nid WHERE n.type = 'cm_show' and ogm.id IS NULL + + $result = db_query('SELECT nid FROM {node} n LEFT JOIN {og_membership} ogm ON etid = nid WHERE n.type = :type AND ogm.id IS NULL', array(':type' => 'cm_show')); + + //query show nodes without OG2 reference + //etid + + + $count = 0; + foreach ($result as $record) { + if ($count < 10000) { + $batch['operations'][] = array('mnn_show_import_resave_batch_worker', array($record->nid)); + $count++; + } + } + + + + batch_set($batch); + + batch_process('admin/content'); +} + +function mnn_show_import_resave_batch_worker($nid, &$context) { + + $node = node_load($nid); + if (isset($node->field_temp_project_id['und'][0]['value']) && $node->field_temp_project_id['und'][0]['value']) { + $node->og_node2['und'][0]['target_id'] = $node->field_temp_project_id['und'][0]['value']; + } + node_save($node); + + $context['results']['processed']++; + $context['message'] = 'Successfully resaved Show #' . $array[0]; +}