You are here

social_content_soundcloud.install in Social Content 7.2

Install/uninstall code for Social Content: SoundCloud.

File

modules/soundcloud/social_content_soundcloud.install
View source
<?php

/**
 * @file
 * Install/uninstall code for Social Content: SoundCloud.
 */

/**
 * Implements hook_install().
 */
function social_content_soundcloud_install() {
  $create_bundle = variable_get('social_content_create_bundles', TRUE);
  if (!$create_bundle) {
    return;
  }
  $t = get_t();

  // Create and save a new content object.
  // Machine name of the content type.
  $type = 'soundcloud';

  // Define the node type.
  $soundcloud = array(
    'type' => $type,
    'name' => $t('SoundCloud Track'),
    'base' => 'node_content',
    'title_label' => $t('Title'),
    'description' => $t('A track imported from SoundCloud.'),
    'custom' => TRUE,
  );

  // Set other node defaults not declared above.
  $content_type = node_type_set_defaults($soundcloud);

  // Add the body field.
  node_add_body_field($content_type, $t('Body'));

  // Save the content type.
  node_type_save($content_type);

  // Update persistent variables with settings.
  // Add persistent variables that control settings.
  variable_set('additional_settings__active_tab_' . $type, 'edit-menu');

  // 0 = disabled, 1 = optional, 2 = required.
  variable_set('node_preview_' . $type, 0);

  // array(0 => 'status', 1 => 'promote', 2 => 'sticky', 3 => 'revision') remove to uncheck.
  variable_set('node_options_' . $type, array(
    0 => 'status',
  ));

  // 1 = Display author and date information, 0 = none.
  variable_set('node_submitted_' . $type, 0);
  variable_set('menu_options_' . $type, array());
  variable_set('menu_parent_' . $type, 'main-menu:0');

  // Create and add instances of new fields.
  // Create all the fields we are adding to our content type.
  module_load_include('inc', 'social_content_soundcloud', 'social_content_soundcloud.fields');
  foreach (social_content_soundcloud_create_fields() as $field_name => $field) {
    if (field_info_field($field_name) == NULL) {
      field_create_field($field);
    }
  }

  // Create all the instances for our fields.
  foreach (social_content_soundcloud_create_instances() as $field_name => $instance) {
    if (field_info_instance('node', $field_name, $type) == NULL) {
      $instance['entity_type'] = 'node';
      $instance['bundle'] = $soundcloud['type'];
      field_create_instance($instance);
    }
  }
}

Functions