-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuc_restrict_qty.install
99 lines (92 loc) · 2.73 KB
/
uc_restrict_qty.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* @file
* uc_restrict_qty module install file.
*/
/**
* Implements hook_schema().
*
* @return
* The schema which contains the structure for the uc_restrict_qty module's tables.
*/
function uc_restrict_qty_schema() {
$schema['uc_restrict_qty_products'] = array(
'fields' => array(
'rqpid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'pfid' => array(
'description' => t('The ID of the product feature this is attached to.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'description' => t('The ID of the node this role feature is attached to.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'model' => array(
'description' => t('The product model.'),
'type' => 'varchar',
'length' => 255,
'default' => NULL,
),
'qty' => array(
'description' => t('The quantity restriction.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'lifetime' => array(
'description' => t('Is restriction lifetime?'),
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
),
'indexes' => array(
'nid' => array('nid'),
'model' => array('model'),
),
'primary key' => array('rqpid'),
);
return $schema;
}
/**
* Implements hook_uninstall().
*
* Remove the variables and schema corresponding to the uc_restrict_qty module.
*/
function uc_restrict_qty_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'uc_restrict_qty_%%'");
}
/**
* Migrate uc_restrict_qty variables to config.
*/
function uc_restrict_qty_update_1000() {
$config = config('uc_restrict_qty.settings');
$config->set('uc_restrict_qty_global', update_variable_get('uc_restrict_qty_global', '0'));
$config->set('uc_restrict_qty_global_replace', update_variable_get('uc_restrict_qty_global_replace', array()));
$config->set('uc_restrict_qty_default_qty', update_variable_get('uc_restrict_qty_default_qty', '0'));
$config->set('uc_restrict_qty_default_lifetime', update_variable_get('uc_restrict_qty_default_lifetime', array()));
$config->save();
update_variable_del('uc_restrict_qty_global');
update_variable_del('uc_restrict_qty_global_replace');
update_variable_del('uc_restrict_qty_default_qty');
update_variable_del('uc_restrict_qty_default_lifetime');
}
/**
* Implements hook_install().
*/
function uc_restrict_qty_install() {
// Dynamically generated variable data was detected.
}