You are here

function pmpapi_update_uninstall in Public Media Platform API Integration 7

Implements hook_uninstall().

File

pmpapi_update/pmpapi_update.install, line 13

Code

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');
}