View source
<?php
function commerce_file_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$int64_ok = PHP_INT_MAX === 9223372036854775807;
$requirements['commerce_file_int64'] = array(
'title' => t('Support for files larger than 2GB'),
'value' => $int64_ok ? t('Available') : t('Unavailable'),
'description' => t('A 64-bit PHP installation is required in order to support files larger than 2GB.'),
'severity' => $int64_ok ? REQUIREMENT_OK : REQUIREMENT_WARNING,
);
}
return $requirements;
}
function commerce_file_schema() {
$schema['commerce_file_download_log'] = array(
'fields' => array(
'log_id' => array(
'description' => 'The primary key.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'license_id' => array(
'description' => 'The {commerce_license}.license_id of the downloaded file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'fid' => array(
'description' => 'The {file_managed}.fid of the downloaded file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The {users}.uid of the user that downloaded the file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'timestamp' => array(
'description' => 'The UNIX timestamp of the date the file was downloaded.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'ip_address' => array(
'description' => 'The IP address of the user that downloaded the file.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'log_id',
),
'indexes' => array(
'license_id' => array(
'license_id',
),
'fid' => array(
'fid',
),
'uid' => array(
'uid',
),
),
'foreign keys' => array(
'licenses' => array(
'table' => 'commerce_license',
'columns' => array(
'license_id' => 'license_id',
),
),
'file_managed' => array(
'table' => 'file_managed',
'columns' => array(
'fid' => 'fid',
),
),
'users' => array(
'table' => 'users',
'columns' => array(
'uid' => 'uid',
),
),
),
);
return $schema;
}
function commerce_file_install() {
$spec = array(
'description' => 'The size of the file in bytes.',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
db_change_field('file_managed', 'filesize', 'filesize', $spec);
}
function commerce_file_uninstall() {
field_attach_delete_bundle('commerce_license', 'file');
field_delete_field('commerce_file');
variable_del('commerce_file_product_types');
variable_del('commerce_file_enable_download_limit');
variable_del('commerce_file_download_limit');
}
function commerce_file_update_7200() {
$schema = commerce_file_schema();
db_create_table('commerce_file_download_log', $schema['commerce_file_download_log']);
}