You are here

social_content_pinterest.install in Social Content 7.2

Install/uninstall code for Social Content: Pinterest.

File

modules/pinterest/social_content_pinterest.install
View source
<?php

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

/**
 * Implements hook_node_install().
 */
function social_content_pinterest_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 = 'pinterest';

  // Define the node type.
  $pin = array(
    'type' => $type,
    'name' => $t('Pinterest Pin'),
    'base' => 'node_content',
    'title_label' => $t('Title'),
    'description' => $t('A pinned post on a user\'s Pinterest board.'),
    'custom' => TRUE,
  );

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

  // 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_pinterest', 'social_content_pinterest.fields');
  foreach (social_content_pinterest_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_pinterest_create_instances() as $field_name => $instance) {
    if (field_info_instance('node', $field_name, $type) == NULL) {
      $instance['entity_type'] = 'node';
      $instance['bundle'] = $pin['type'];
      field_create_instance($instance);
    }
  }
}

Functions

Namesort descending Description
social_content_pinterest_install Implements hook_node_install().