You are here

uc_product_power_tools.install in Ubercart Product Power Tools 7

Same filename and directory in other branches
  1. 6.2 uc_product_power_tools.install
  2. 6 uc_product_power_tools.install

Install, update, and uninstall functions for the uc_product_power_tools module.

File

uc_product_power_tools.install
View source
<?php

/**
 * @file
 * Install, update, and uninstall functions for the uc_product_power_tools module.
 */

/**
 * Implements hook_schema().
 */
function uc_product_power_tools_schema() {
  $schema = array();
  $schema['uc_power_tools'] = array(
    'description' => 'Table for settings of Ubercart Product Power Tools module.',
    'fields' => array(
      'pcid' => array(
        'description' => 'Product class ID',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'enabled' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      // Auto SKU Generation Boolean on/off setting & replacement pattern
      'asku' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => FALSE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'asku_settings' => array(
        'description' => 'Replacement pattern',
        'type' => 'text',
        'not null' => FALSE,
      ),
      // List Price Boolean on/off setting & default price
      'lp' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'lp_settings' => array(
        'description' => 'Default list price value',
        'type' => 'numeric',
        'precision' => 15,
        'scale' => 3,
        'not null' => TRUE,
        'default' => 0.0,
      ),
      // Cost Boolean on/off setting & default price
      'cost' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'cost_settings' => array(
        'description' => 'Default cost value',
        'type' => 'numeric',
        'precision' => 15,
        'scale' => 3,
        'not null' => TRUE,
        'default' => 0.0,
      ),
      // Sell Price Boolean on/off setting & default price
      'sp' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'sp_settings' => array(
        'description' => 'Default sell price value',
        'type' => 'numeric',
        'precision' => 15,
        'scale' => 3,
        'not null' => TRUE,
        'default' => 0.0,
      ),
      // Default Qty Boolean on/off setting & default qty value
      'dq' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'dq_settings' => array(
        'description' => 'Default quantity value',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      // Package Qty Boolean on/off setting & default qty value
      'pq' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'pq_settings' => array(
        'description' => 'Default package quantity value',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      // Shipping: 0 - Disable, 1 - Hide Checkbox & other shipping fields, 2 - Hide checkbox and show other shipping fields
      'ship' => array(
        'description' => 'Shippable setting',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      // List Position Boolean on/off setting & default position value
      'lpos' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'lpos_settings' => array(
        'description' => 'Default list position value',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      // Stock Boolean on/off setting & default stock level (if stock module is installed)
      'stock' => array(
        'description' => 'Boolean',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'stock_settings' => array(
        'description' => 'Default stock value',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'stock_threshold' => array(
        'description' => 'Stock threshold',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'weight' => array(
        'description' => 'Weight',
        'type' => 'float',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'weight_units' => array(
        'description' => 'Weight units',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'lb',
      ),
      'length' => array(
        'description' => 'Length',
        'type' => 'float',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'width' => array(
        'description' => 'Width',
        'type' => 'float',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'height' => array(
        'description' => 'Height',
        'type' => 'numeric',
        'precision' => 15,
        'scale' => 3,
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'length_units' => array(
        'description' => 'Size units',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'in',
      ),
    ),
    'primary key' => array(
      'pcid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function uc_product_power_tools_install() {
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'uc_product_power_tools'");
  db_query("REPLACE INTO {uc_power_tools} (`pcid`, `enabled`) VALUES ('product', 0)");
}

/**
 * Allow for negative List position values.
 */
function uc_product_power_tools_update_7000() {
  db_change_field('uc_power_tools', 'lpos_settings', 'lpos_settings', array(
    'description' => t('default list position value'),
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
}

Functions

Namesort descending Description
uc_product_power_tools_install Implements hook_install().
uc_product_power_tools_schema Implements hook_schema().
uc_product_power_tools_update_7000 Allow for negative List position values.