diff --git a/simplenews.install b/simplenews.install index 7e0292d..986627b 100644 --- a/simplenews.install +++ b/simplenews.install @@ -769,3 +769,33 @@ function simplenews_update_7006() { 'default' => 0, )); } + +/** + * Convert old content type settings. + */ +function simplenews_update_7007() { + module_load_include('module', 'node'); + module_load_include('module', 'simplenews'); + + // Update the machine name of the simplenews vocabulary. + if ($vid = variable_get('simplenews_vid', '')) { + db_update('taxonomy_vocabulary') + ->fields(array( + 'machine_name' => 'newsletter', + )) + ->condition('vid', $vid) + ->execute(); + } + variable_del('simplenews_vid'); + + $content_types = variable_get('simplenews_content_types'); + if (!empty($content_types)) { + foreach ($content_types as $simplenews_content_type) { + variable_set('simplenews_content_type_' . $simplenews_content_type, TRUE); + if (!field_info_instance('node', 'field_simplenews_term', $simplenews_content_type)) { + simplenews_add_term_field(node_type_load($simplenews_content_type)); + } + } + } + variable_del('simplenews_content_types'); +} diff --git a/tests/simplenews.test b/tests/simplenews.test index ba5a077..adce9fe 100644 --- a/tests/simplenews.test +++ b/tests/simplenews.test @@ -1786,6 +1786,15 @@ class SimpleNewsUpgradePath61TestCase extends UpgradePathTestCase { $this->drupalGet('admin/people/simplenews'); $this->assertText('another@example.org'); + + // Check simplenews content type. + $this->drupalGet('admin/structure/types/manage/simplenews'); + $this->assertFieldChecked('edit-simplenews-content-type'); + $this->drupalGet('admin/structure/types/manage/simplenews/fields'); + + $this->drupalGet('node/add/simplenews'); + $this->assertText('Newsletter category'); + $this->assertText('Drupal 6 newsletter'); } } @@ -1840,6 +1849,15 @@ class SimpleNewsUpgradePath62TestCase extends UpgradePathTestCase { $this->drupalGet('admin/people/simplenews'); $this->assertText('another@example.org'); + + // Check simplenews content type. + $this->drupalGet('admin/structure/types/manage/simplenews'); + $this->assertFieldChecked('edit-simplenews-content-type'); + $this->drupalGet('admin/structure/types/manage/simplenews/fields'); + + $this->drupalGet('node/add/simplenews'); + $this->assertText('Newsletter category'); + $this->assertText('Drupal 6 newsletter'); } }