uc_file.install in Ubercart 8.4
Same filename and directory in other branches
Install, update and uninstall functions for the uc_file module.
File
uc_file/uc_file.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the uc_file module.
*/
// -1 is the UC_FILE_LIMIT_SENTINEL constant in uc_file.module, but
// it might not be available (like when upgrading from 5 -> 6.
/**
* Implements hook_schema().
*/
function uc_file_schema() {
$schema = [];
$schema['uc_files'] = [
'description' => 'Stores information on purchasable files.',
'fields' => [
'fid' => [
'description' => 'Primary key: the file ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'filename' => [
'description' => 'The name of the file.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
],
'primary key' => [
'fid',
],
'indexes' => [
'filename' => [
'filename',
],
],
];
$schema['uc_file_products'] = [
'description' => 'Maps file product features to files.',
'fields' => [
'fpid' => [
'description' => 'Primary key: the ID for the file-product combination.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'pfid' => [
'description' => 'The {uc_product_features}.pfid.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'fid' => [
'description' => 'The {uc_files}.fid of the purchasable file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'model' => [
'description' => 'The product model.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
'description' => [
'description' => 'The description of the file.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
'shippable' => [
'description' => 'Is this file feature shippable? 1 => Yes. 0 => No.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
],
'download_limit' => [
'description' => 'The number of times the file may be downloaded by a user. -1 indicates the store default will be used.',
'type' => 'int',
'not null' => FALSE,
'default' => -1,
],
'address_limit' => [
'description' => 'The number of different IP addresses from which the file may be downloaded. -1 indicates the store default will be used.',
'type' => 'int',
'not null' => FALSE,
'default' => -1,
],
'time_granularity' => [
'description' => 'The units of time for time_quantity. -1 indicates the store default will be used.',
'type' => 'varchar',
'length' => 16,
'not null' => TRUE,
'default' => '-1',
],
'time_quantity' => [
'description' => 'With time_granularity, the amount of time the file will be available for download. -1 indicates the store default will be used.',
'type' => 'int',
'not null' => TRUE,
'default' => -1,
],
],
'indexes' => [
'pfid' => [
'pfid',
],
'fid' => [
'fid',
],
],
'primary key' => [
'fpid',
],
'foreign keys' => [
'uc_product_features' => [
'table' => 'uc_product_features',
'columns' => [
'pfid' => 'pfid',
],
],
'uc_files' => [
'table' => 'uc_files',
'columns' => [
'fid' => 'fid',
],
],
],
];
$schema['uc_file_users'] = [
'description' => 'The customers and the files they have purchased.',
'fields' => [
'fuid' => [
'description' => 'Primary key: the ID of the file-user combination.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'fid' => [
'description' => 'The {uc_files}.fid that was purchased.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'uid' => [
'description' => 'The {users}.uid of the user who purchased the file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'pfid' => [
'description' => 'The product feature ID of the product that was ordered, from {uc_file_products}.pfid.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
],
'file_key' => [
'description' => 'A hash of the data in this row.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
],
'granted' => [
'description' => 'The Unix timestamp indicating when the file was made available for download.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
'expiration' => [
'description' => 'The Unix timestamp indicating when the file will no longer be available for download.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
],
'accessed' => [
'description' => 'The number of times the file has been downloaded by the user.',
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'addresses' => [
'description' => 'The number of different IP addresses the user has used to download the file.',
'type' => 'text',
'serialize' => TRUE,
'not null' => FALSE,
],
'download_limit' => [
'description' => 'The number of times the user may download the file.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
],
'address_limit' => [
'description' => 'The number of different IP addresses the user may use to download the file.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
],
],
'indexes' => [
'fid_uid' => [
'fid',
'uid',
],
'uid' => [
'uid',
],
],
'primary key' => [
'fuid',
],
'foreign keys' => [
'uc_product_features' => [
'table' => 'uc_product_features',
'columns' => [
'pfid' => 'pfid',
],
],
'uc_files' => [
'table' => 'uc_files',
'columns' => [
'fid' => 'fid',
],
],
'users' => [
'table' => 'users',
'columns' => [
'uid' => 'uid',
],
],
],
];
return $schema;
}
/**
* Implements hook_uninstall().
*/
function uc_file_uninstall() {
$connection = \Drupal::database();
$connection
->delete('uc_product_features')
->condition('fid', 'file')
->execute();
}
Functions
Name | Description |
---|---|
uc_file_schema | Implements hook_schema(). |
uc_file_uninstall | Implements hook_uninstall(). |