You are here

function _simplenews_init_simplenews_category in Simplenews 7

Create initial simplenews categories.

1 call to _simplenews_init_simplenews_category()
simplenews_install in ./simplenews.install
Implements hook_install().

File

./simplenews.install, line 421
Install, update and uninstall functions for the simplenews module

Code

function _simplenews_init_simplenews_category() {
  if ($tree = taxonomy_get_tree(variable_get('simplenews_vid', ''))) {
    $categories = simplenews_categories_load_multiple();
    $first = TRUE;
    foreach ($tree as $term) {

      // Create a newsletter category for each newsletter taxonomy term.
      if (!isset($categories[$term->tid])) {
        $category = new stdClass();
        $category->tid = $term->tid;

        // @todo use a function for category default values
        $category->from_name = variable_get('site_name', 'Drupal');
        $category->email_subject = '[[simplenews-category:name]] [node:title]';
        $category->from_address = variable_get('site_mail', ini_get('sendmail_from'));
        $category->format = 'plain';
        $category->priority = SIMPLENEWS_PRIORITY_NONE;
        $category->receipt = 0;
        $category->hyperlinks = 1;
        $category->new_account = 'none';
        $category->opt_inout = 'double';
        $category->block = 0;
        if ($first) {
          $category->block = 1;
          $first = FALSE;
        }
        simplenews_category_save($category);
      }
    }
  }
}