access_unpublished.install in Access unpublished 6
Same filename and directory in other branches
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.installView 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
Name | Description |
---|---|
access_unpublished_install | Implements hook_install(). |
access_unpublished_uninstall | Implements hook_uninstall(). |
Constants
Name | Description |
---|---|
ACCESS_UNPUBLISHED_DEFAULTQUERYSTRING | The ACCESS_UNPUBLISHED_DEFAULTQUERYSTRING is only used when the module is installed to set the default value |