You are here

function webform_purge_install in Webform Purge 7

Implements hook_install().

File

./webform_purge.install, line 11
Webform Purge installation.

Code

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