webform_purge.install in Webform Purge 7
Webform Purge installation.
File
webform_purge.installView source
<?php
/**
* @file
* Webform Purge installation.
*/
/**
* Implements hook_install().
*/
function webform_purge_install() {
// Set default variables.
variable_set('webform_purge_enabled', 0);
variable_set('webform_purge_run_once', 1);
variable_set('webform_purge_days_to_retain', 30);
variable_set('webform_purge_cron_limit', 100000);
$query = db_select('webform', 'w');
$query
->join('node', 'n', 'w.nid = n.nid');
$query
->fields('n', array(
'nid',
'title',
))
->condition('w.status', '1')
->orderBy('n.title', 'ASC')
->addTag('node_access');
$webforms = $query
->execute();
$active_webforms = array();
foreach ($webforms as $webform) {
$active_webforms[$webform->nid] = $webform->nid;
}
variable_set('webform_purge_checkbox_state', $active_webforms);
// Get localization function for installation as t() may be unavailable.
$t = get_t();
// Give user feedback.
drupal_set_message($t('Webform Purge variables created.'));
}
/**
* Implements hook_uninstall().
*/
function webform_purge_uninstall() {
// Delete variables.
variable_del('webform_purge_enabled');
variable_del('webform_purge_run_once');
variable_del('webform_purge_all_submissions');
variable_del('webform_purge_days_to_retain');
variable_del('webform_purge_checkbox_state');
variable_del('webform_purge_cron_limit');
// Inform the user of the removal.
$t = get_t();
drupal_set_message($t('Webform Purge variables removed.'));
}
/**
* By default purge all webforms.
*/
function webform_purge_update_7001(&$sandbox) {
$query = db_select('webform', 'w');
$query
->join('node', 'n', 'w.nid = n.nid');
$query
->fields('n', array(
'nid',
'title',
))
->condition('w.status', '1')
->orderBy('n.title', 'ASC')
->addTag('node_access');
$webforms = $query
->execute();
$active_webforms = array();
foreach ($webforms as $webform) {
$active_webforms[$webform->nid] = $webform->nid;
}
variable_set('webform_purge_checkbox_state', $active_webforms);
}
Functions
Name![]() |
Description |
---|---|
webform_purge_install | Implements hook_install(). |
webform_purge_uninstall | Implements hook_uninstall(). |
webform_purge_update_7001 | By default purge all webforms. |