-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuc_node_checkout.install
More file actions
118 lines (101 loc) · 3.15 KB
/
uc_node_checkout.install
File metadata and controls
118 lines (101 loc) · 3.15 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* @file
* Install, update, and uninstall functions for the uc_node_checkout module.
*/
/**
* Implements hook_install().
*/
function uc_node_checkout_install() {
// Create tables.
drupal_install_schema('uc_node_checkout');
}
/**
* Implements hook_uninstall().
*/
function uc_node_checkout_uninstall() {
// Remove tables.
drupal_uninstall_schema('uc_node_checkout');
// Remove all module variables from the database
db_query("DELETE FROM {variable} WHERE name LIKE 'uc_node_checkout_%%'");
}
/**
* Implements hook_schema().
*/
function uc_node_checkout_schema() {
$schema['uc_node_checkout_types'] = array(
'description' => t('Designates node types that, when created, will add a selected product into the shopping cart.'),
'fields' => array(
'node_type' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => t('The {node}.type of the node the user can add; for example, "registration".'),
),
'product_nid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => t('The {node}.nid of the product node that will be placed in the shopping cart when the node_type node is added.'),
),
'node_view' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => t('The name of a view offering product selections that the user may choose to get added to their cart.'),
),
),
'indexes' => array(
'node_type' => array('node_type'),
),
);
$schema['uc_node_checkout_order_products'] = array(
'description' => 'Mapping of user-created nodes to order line numbers.',
'fields' => array(
'nid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {node}.nid of the user-created node (ex: registration for an event).',
),
'order_product_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {uc_order_products}.order_product_id of the order.',
),
),
'primary key' => array('nid'),
);
return $schema;
}
/**
* Implements hook_update_N().
*/
function uc_node_checkout_update_6200() {
$ret = array();
// Change the type column to a varchar(255).
db_change_field($ret, 'uc_node_checkout_types', 'type', 'node_type', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
// Add the node_view column.
db_add_field($ret, 'uc_node_checkout_types', 'node_view', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
// Add the uc_node_checkout_order_products table.
$table = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'order_product_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('nid'),
);
db_create_table($ret, 'uc_node_checkout_order_products', $table);
return $ret;
}