regcode.install in Registration codes 7
Same filename and directory in other branches
Install, uninstall and scheme functions for the regcode module.
File
regcode.installView source
<?php
/**
* @file
* Install, uninstall and scheme functions for the regcode module.
*/
/**
* Implements hook_uninstall().
*/
function regcode_uninstall() {
taxonomy_vocabulary_delete(variable_get('regcode_vocabulary', FALSE));
}
/**
* Implements hook_install().
*/
function regcode_install() {
_regcode_install_vocabulary();
}
/**
* Create a vocabulary.
*/
function _regcode_install_vocabulary() {
$vocabulary = new stdClass();
$vocabulary->name = t('Registration codes');
$vocabulary->description = t('Classify registration codes.');
$vocabulary->machine_name = 'regcode';
$vocabulary->hierarchy = 0;
$vocabulary->module = 'regcode';
$vocabulary->nodes = FALSE;
taxonomy_vocabulary_save($vocabulary);
variable_set('regcode_vocabulary', $vocabulary->vid);
}
/**
* Implements hook_schema().
*/
function regcode_schema() {
// Definition for the regcode table.
$schema['regcode'] = array(
'description' => 'Hold registration codes',
'fields' => array(
'rid' => array(
'description' => 'RID',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'User ID',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'created' => array(
'description' => 'Code creation time',
'type' => 'int',
'not null' => FALSE,
),
'lastused' => array(
'description' => 'Code last used time',
'type' => 'int',
'not null' => FALSE,
),
'begins' => array(
'description' => 'Code activation date',
'type' => 'int',
'not null' => FALSE,
),
'expires' => array(
'description' => 'Code expiry date',
'type' => 'int',
'not null' => FALSE,
),
'code' => array(
'description' => 'The registration code',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'is_active' => array(
'description' => 'Whether the code is active',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'maxuses' => array(
'description' => 'Maximum times a code can be used',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'uses' => array(
'description' => 'Number of times the code has been used',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'rid',
),
'unique keys' => array(
'code' => array(
'code',
),
),
);
// Definition for the regcode_term table.
$schema['regcode_term'] = array(
'description' => 'Map registration codes and taxonomy',
'fields' => array(
'id' => array(
'description' => 'ID',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'rid' => array(
'description' => 'Regcode ID',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'tid' => array(
'description' => 'Term ID',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'regcode_term' => array(
'rid',
'tid',
),
),
);
return $schema;
}
Functions
Name | Description |
---|---|
regcode_install | Implements hook_install(). |
regcode_schema | Implements hook_schema(). |
regcode_uninstall | Implements hook_uninstall(). |
_regcode_install_vocabulary | Create a vocabulary. |