You are here

webform_protected_downloads.install in Webform Protected Downloads 6

File

webform_protected_downloads.install
View source
<?php

function webform_protected_downloads_install() {
  $weight = (int) db_result(db_query("SELECT weight FROM {system} WHERE name = 'private_upload'"));
  db_query("UPDATE {system} SET weight = %d WHERE name = 'webform_protected_download'", $weight + 1);
  drupal_install_schema('webform_protected_downloads');
}
function webform_protected_downloads_uninstall() {
  drupal_uninstall_schema('webform_protected_downloads');
}
function webform_protected_downloads_schema() {
  $schema = array();
  $schema['wpd_access_hashes'] = array(
    'fields' => array(
      'sid' => array(
        'description' => 'The submission identifier',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'hash' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Hash to identify this submission if needed',
      ),
      'processed' => array(
        'description' => 'The timestamp when the submission has been processed',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'expires' => array(
        'description' => 'The timestamp when the download expires',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'used' => array(
        'description' => 'The timestamp when the hash has been last used',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'sid',
    ),
  );
  $schema['wpd_protected_files'] = array(
    'fields' => array(
      'nid' => array(
        'description' => 'The node id of the protected webform',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'fid' => array(
        'description' => 'The file id that is protected',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'created' => array(
        'description' => 'The timestamp when the file has been protected',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'nid',
      'fid',
    ),
  );
  $schema['wpd_node_configuration'] = array(
    'fields' => array(
      'nid' => array(
        'description' => 'The node id of the protected webform',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'mail_field_cid' => array(
        'description' => 'The component id of the webform that is used as mail adress to confirm the download',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'mail_from' => array(
        'description' => 'The from address for the confimation mail',
        'type' => 'varchar',
        'length' => 255,
      ),
      'mail_subject' => array(
        'description' => 'The subject for the confimation mail',
        'type' => 'varchar',
        'length' => 255,
      ),
      'mail_body' => array(
        'description' => 'The body text for the confimation mail',
        'type' => 'text',
      ),
      'text_download_access' => array(
        'description' => 'The text for the download page, above the file listing',
        'type' => 'text',
      ),
      'text_download_noaccess' => array(
        'description' => 'The text for the download page, if access can not be granted',
        'type' => 'text',
      ),
      'access_type' => array(
        'description' => 'The type of access, either 0 for one-time or 1 for repeated',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
      'expiration_download' => array(
        'description' => 'The timestamp when the download expires',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'expiration_session' => array(
        'description' => 'The timestamp when the session expires',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'retroactive' => array(
        'description' => 'The timestamp when the session expires',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
      'redirect' => array(
        'description' => 'Whether the user should be redirected to the downloads page after form submission',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  return $schema;
}
function webform_protected_downloads_update_6001() {
  $ret = array();
  db_add_field($ret, 'wpd_node_configuration', 'mail_from', array(
    'description' => 'The from address for the confimation mail',
    'type' => 'varchar',
    'length' => 255,
  ));
  return $ret;
}
function webform_protected_downloads_update_6002() {
  $ret = array();
  db_add_field($ret, 'wpd_node_configuration', 'retroactive', array(
    'description' => 'The timestamp when the session expires',
    'type' => 'int',
    'size' => 'tiny',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 1,
  ));
  return $ret;
}
function webform_protected_downloads_update_6003() {
  $ret = array();
  db_add_field($ret, 'wpd_node_configuration', 'access_type', array(
    'description' => 'The type of access, either 0 for one-time or 1 for repeated',
    'type' => 'int',
    'size' => 'tiny',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 1,
  ));
  db_add_field($ret, 'wpd_access_hashes', 'used', array(
    'description' => 'The timestamp when the hash has been last used',
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ));
  return $ret;
}
function webform_protected_downloads_update_6004() {
  $ret = array();
  db_add_field($ret, 'wpd_node_configuration', 'redirect', array(
    'description' => 'Whether the user should be redirected to the downloads page after form submission',
    'type' => 'int',
    'size' => 'tiny',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  return $ret;
}