You are here

feedapi_node.install in FeedAPI 6

Same filename and directory in other branches
  1. 5 feedapi_node/feedapi_node.install

Install file for FeedAPI Node module.

File

feedapi_node/feedapi_node.install
View source
<?php

/**
 * @file
 * Install file for FeedAPI Node module.
 */

/**
 * Implementation of hook_schema().
 */
function feedapi_node_schema() {
  $schema['feedapi_node_item'] = array(
    'description' => t('Stores additional information about feed item nodes.'),
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t("Primary Key: The feed item node's nid."),
      ),
      'url' => array(
        'type' => 'text',
        'not null' => TRUE,
        'description' => t('Link to the feed item.'),
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('Post date of the feed item, as a Unix timestamp.'),
      ),
      'arrived' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('Import date of the feed item, as a Unix timestamp.'),
      ),
      'guid' => array(
        'type' => 'text',
        'not null' => TRUE,
        'description' => t('Unique identifier for the feed item.'),
      ),
    ),
    'primary key' => array(
      'nid',
    ),
    'indexes' => array(
      'url' => array(
        array(
          'url',
          255,
        ),
      ),
      'arrived' => array(
        'arrived',
      ),
      'guid' => array(
        array(
          'guid',
          255,
        ),
      ),
    ),
  );
  $schema['feedapi_node_item_feed'] = array(
    'description' => t('Bridge table; maps feed items to feeds.'),
    'fields' => array(
      'feed_nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t('The {feedapi}.nid to which the feed item is being assigned.'),
      ),
      'feed_item_nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t("The feed item's {feedapi_node_item}.nid."),
      ),
    ),
    'primary key' => array(
      'feed_nid',
      'feed_item_nid',
    ),
    'indexes' => array(
      'feed_nid' => array(
        'feed_nid',
      ),
      'feed_item_nid' => array(
        'feed_item_nid',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function feedapi_node_install() {

  // Create tables.
  drupal_install_schema('feedapi_node');

  // Add the node type.
  _feedapi_node_install_type_create();
}

/**
 * Implementation of hook_uninstall().
 */
function feedapi_node_uninstall() {

  // Remove tables.
  drupal_uninstall_schema('feedapi_node');

  // node_type_delete('feed');
  variable_del('feedapi_settings_feed');
  menu_rebuild();
}

/**
 * Create feedapi content-type with sane default values.
 */
function _feedapi_node_install_type_create() {

  // Create an additional node type.
  $feed_node_type = array(
    'type' => 'feed',
    'name' => t('Feed'),
    'module' => 'node',
    'description' => t('Items from these feeds will be turned into nodes.'),
    'custom' => TRUE,
    'modified' => TRUE,
    'locked' => FALSE,
  );
  $feed_node_type = (object) _node_type_set_defaults($feed_node_type);
  node_type_save($feed_node_type);

  // Default to not promoted.
  variable_set('node_options_feed', array(
    'status',
  ));

  // Adding default FeedAPI settings.
  $preset = unserialize('a:3:{s:7:"enabled";s:1:"1";s:12:"items_delete";s:1:"0";s:10:"processors";a:1:{s:12:"feedapi_node";a:7:{s:7:"enabled";s:1:"1";s:6:"weight";s:1:"0";s:12:"content_type";s:5:"story";s:9:"node_date";s:4:"feed";s:7:"promote";s:1:"0";s:9:"list_feed";s:1:"3";s:4:"user";s:5:"admin";}}}');
  if (is_array(variable_get('feedapi_settings_feed', FALSE))) {
    $preset = array_merge($preset, variable_get('feedapi_settings_feed', FALSE));
  }
  variable_set('feedapi_settings_feed', $preset);
}
function feedapi_node_update_1() {
  $ret = array();
  db_add_index($ret, 'feedapi_node_item_feed', 'feed_nid', array(
    'feed_nid',
  ));
  db_add_index($ret, 'feedapi_node_item_feed', 'feed_item_nid', array(
    'feed_item_nid',
  ));
  return $ret;
}

Functions

Namesort descending Description
feedapi_node_install Implementation of hook_install().
feedapi_node_schema Implementation of hook_schema().
feedapi_node_uninstall Implementation of hook_uninstall().
feedapi_node_update_1
_feedapi_node_install_type_create Create feedapi content-type with sane default values.