You are here

pmpapi.install in Public Media Platform API Integration 7

Install, update and uninstall functions for the PMPAPI Push module.

File

pmpapi.install
View source
<?php

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

/**
 * Implements hook_install().
 */
function pmpapi_install() {
  variable_set('pmpapi_cache', TRUE);
}

/**
 * Implements hook_uninstall().
 */
function pmpapi_uninstall() {
  variable_del('pmpapi_base_url');
  variable_del('pmpapi_user_id');
  variable_del('pmpapi_auth_client_id');
  variable_del('pmpapi_auth_client_secret');
  variable_del('pmpapi_cache');
  variable_del('pmpapi_auth_client');
}

/**
 * Implements hook_requirements().
 */
function pmpapi_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break during installation.
  $t = get_t();

  // If AuthClient doesn't live in module or sites/all/libraries, stop the
  // install. Crude and not foolproof; but effective.
  $auth_path = 'phpsdk/lib/Pmp/Sdk/AuthClient.php';
  $in_module = file_exists(DRUPAL_ROOT . '/' . drupal_get_path('module', 'pmpapi') . '/' . $auth_path);
  $in_library = file_exists(DRUPAL_ROOT . '/sites/all/libraries/' . $auth_path);
  if (!$in_module && !$in_library) {
    $requirements['pmpapi'] = array(
      'title' => $t('PMP PHP SDK'),
      'description' => 'The pmpapi module requires a 3rd-party PHP SDK before it can be installed. See the README file for more info.',
      'severity' => REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}

/**
 * Implements hook_schema().
 */
function pmpapi_schema() {
  $schema['pmpapi_local_docs'] = array(
    'description' => 'Stores local PMP docs data (that is not stored elsewhere, e.g., in fields).',
    'fields' => array(
      'entity_type' => array(
        'description' => 'The type of this entity (e.g., node).',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'entity_id' => array(
        'description' => 'The (Drupal) unique identifier (e.g., value of the nid, for a node).',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'guid' => array(
        'description' => 'The PMP GUID of this entity.',
        'type' => 'char',
        'length' => 36,
        'not null' => TRUE,
      ),
      'permissions' => array(
        'description' => 'The PMP permissions of this entity (as a serialized array of objects).',
        'type' => 'blob',
      ),
    ),
    'indexes' => array(
      'guid' => array(
        'guid',
      ),
    ),
    'primary key' => array(
      'entity_type',
      'entity_id',
    ),
  );
  return $schema;
}

Functions