You are here

function social_content_facebook_install in Social Content 7.2

Same name and namespace in other branches
  1. 7 modules/facebook/social_content_facebook.install \social_content_facebook_install()

Implements hook_node_install().

File

modules/facebook/social_content_facebook.install, line 10
Install/uninstall code for Social Content: Facebook.

Code

function social_content_facebook_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 = 'facebook';

  // Define the node type.
  $fb_post = array(
    'type' => $type,
    'name' => $t('Facebook Page Post'),
    'base' => 'node_content',
    'title_label' => $t('Title'),
    'description' => $t('A post imported from Facebook.'),
    'custom' => TRUE,
  );

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

  // 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');
  module_load_include('inc', 'social_content_facebook', 'social_content_facebook.fields');
  $fields = social_content_facebook_field_default_field_bases();
  foreach ($fields as $field_name => $field) {
    if (field_info_field($field_name) == NULL) {
      field_create_field($field);
    }
  }
  $instances = social_content_facebook_field_default_field_instances();
  foreach ($instances as $instance) {
    if (field_info_instance($instance['entity_type'], $instance['field_name'], $type) == NULL) {
      $instance['entity_type'] = 'node';
      $instance['bundle'] = $fb_post['type'];
      field_create_instance($instance);
    }
  }
}