You are here

pmpapi_update.install in Public Media Platform API Integration 7

File

pmpapi_update/pmpapi_update.install
View source
<?php

/**
 * Implements hook_install().
 */
function pmpapi_update_install() {
  variable_set('pmpapi_update_updates_active', 1);
}

/**
 * Implements hook_uninstall().
 */
function pmpapi_update_uninstall() {

  // One last try to unsubscribe the site
  $topics = array(
    'updated',
    'deleted',
  );
  foreach ($topics as $topic) {
    module_load_include('module', 'pmpapi_update');
    module_load_include('php', 'pmpapi_update', 'classes/PMPAPIDrupalUpdate');
    $topic_uri = pmpapi_update_get_topic_uri($topic);
    $update = new PMPAPIDrupalUpdate($topic_uri, 'unsubscribe');
    $pending = array(
      'verify_token' => $update->verify_token,
      'mode' => $update->mode,
      'topic_uri' => $topic_uri,
    );
    variable_set('pmpapi_update_subscribe_pending', $pending);
    $update
      ->sendRequestToHub();
  }

  // Delete variables
  variable_del('pmpapi_update_subscribed_to_updated');
  variable_del('pmpapi_update_subscribed_to_deleted');
  variable_del('pmpapi_update_subscribe_pending');
  variable_del('pmpapi_update_updates_active');
}

Functions