You are here

pmpapi_pull.install in Public Media Platform API Integration 7

Install, update and uninstall functions for the pmpapi_pull module.

File

pmpapi_pull/pmpapi_pull.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the pmpapi_pull module.
 */

/**
 * Implements hook_install().
 */
function pmpapi_pull_install() {
  variable_set('pmpapi_pull_pull_active', TRUE);
}

/**
 * Implements hook_uninstall().
 */
function pmpapi_pull_uninstall() {
  variable_del('pmpapi_pull_pull_active');
  variable_del('pmpapi_pull_pull_user');
  variable_del('pmpapi_pull_last_validity_check');
  module_load_include('module', 'pmpapi_pull');
  module_load_include('module', 'pmpapi');
  foreach (pmpapi_pull_get_entities() as $entity_type => $entity) {
    $bundles = $entity['bundles'];
    if ($bundles) {
      foreach ($bundles as $bundle_name => $bundle) {
        $uname = $entity_type . '__' . $bundle_name;
        variable_del('pmpapi_pull_' . $uname . '_profile');
        foreach (pmpapi_get_profile_list() as $profile) {
          variable_del('pmpapi_pull_mapping_' . $uname . '_' . $profile);
        }
      }
    }
  }
}

/**
 * Implements hook_schema().
 */
function pmpapi_pull_schema() {
  $schema['pmpapi_pull_pulled_docs'] = array(
    'description' => 'A table that tracks pulled docs from the PMP.',
    'fields' => array(
      'guid' => array(
        'description' => 'The PMP GUID of this entity.',
        'type' => 'char',
        'length' => 36,
        'not null' => TRUE,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the doc was (re-)pulled.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'valid_from' => array(
        'description' => 'The date-time that content is valid from.',
        'type' => 'char',
        'length' => 25,
      ),
      'valid_to' => array(
        'description' => 'The date-time that content is valid to.',
        'type' => 'char',
        'length' => 25,
      ),
    ),
    'primary key' => array(
      'guid',
    ),
  );
  return $schema;
}

Functions