You are here

access_unpublished.install in Access unpublished 6

Same filename and directory in other branches
  1. 7 access_unpublished.install

Create a privatekey on install and remove the key when the module is removed. The private key can be changed in the module settings.

File

access_unpublished.install
View source
<?php

/**
 * @file
 * Create a privatekey on install and remove the key when the module
 * is removed. The private key can be changed in the module settings.
 */

/**
 * The ACCESS_UNPUBLISHED_DEFAULTQUERYSTRING is only used when the module
 * is installed to set the default value
 */
define("ACCESS_UNPUBLISHED_DEFAULTQUERYSTRING", "hash");

/**
 * Implements hook_install().
 */
function access_unpublished_install() {
  watchdog('access_unpublished', 'Generating default private key');
  variable_set('access_unpublished_privatekey', uniqid());
  watchdog('access_unpublished', 'Generating default query string');
  variable_set('access_unpublished_querystring', ACCESS_UNPUBLISHED_DEFAULTQUERYSTRING);
}

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

  //Display the old key value in the message log, so that if you need to

  //recover the key value you will be able to find it in the logs
  watchdog('access_unpublished', 'Removing private key: @key', array(
    '@key' => variable_get('access_unpublished_privatekey', NULL),
  ));
  variable_del('access_unpublished_privatekey');

  //Display the old query string value in the message log, so that if you

  //need to recover the value you will be able to find it in the logs
  watchdog('access_unpublished', 'Removing query string: @querystring', array(
    '@querystring' => variable_get('access_unpublished_querystring', NULL),
  ));
  variable_del('access_unpublished_querystring');
}

Functions

Constants

Namesort descending Description
ACCESS_UNPUBLISHED_DEFAULTQUERYSTRING The ACCESS_UNPUBLISHED_DEFAULTQUERYSTRING is only used when the module is installed to set the default value