-
Notifications
You must be signed in to change notification settings - Fork 1
/
uc_member_pricing.install
117 lines (98 loc) · 3.21 KB
/
uc_member_pricing.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
// $Id: uc_member_pricing.install,v 1.1 2009/11/30 17:23:19 awebb Exp $
//------------------------------------------------------------------------------
// Installation / removal
//------------------------------------------------------------------------------
/**
* Implementation of hook_install().
*
* @see http://api.drupal.org/api/function/hook_install/6
*/
function uc_member_pricing_install( ) {
drupal_install_schema( 'uc_member_pricing' );
}
/**
* Implementation of hook_uninstall().
*
* @see http://api.drupal.org/api/function/hook_uninstall/6
*/
function uc_member_pricing_uninstall( ) {
drupal_uninstall_schema( 'uc_member_pricing' );
// Delete individual price settings. ( if there are any )
$result = db_query(
"SELECT name FROM {variable} WHERE name LIKE 'uc_member_pricing_%'" );
while ( $row = db_fetch_object( $result ) ) {
variable_del( $row->name );
}
}
//------------------------------------------------------------------------------
// Database
//------------------------------------------------------------------------------
/**
* Implementation of hook_schema().
*
* @see http://api.drupal.org/api/function/hook_schema/6
*/
function uc_member_pricing_schema( ) {
$schema[ 'uc_member_prices' ] = array(
'description' => t(
'List of special pricing rules for products.' ),
'fields' => array(
'ppid' => array(
'description' => t(
'The price rule id.' ),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE
),
'nid' => array(
'description' => t(
'The product id that this price rule applies to.' ),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE
),
'type' => array(
'description' => t(
'The type of the individual pricing rule.' ),
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => ''
),
'xid' => array(
'description' => t(
'The id of the type used for this pricing rule.' ),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE
),
'price' => array(
'description' => t(
'The amount the customer pays for the product.' ),
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '0'
)
),
'indexes' => array(
'uc_member_pricing_nid' => array(
'nid'
),
'uc_member_pricing_type' => array(
'nid',
'type',
'xid'
)
),
'primary key' => array(
'ppid'
)
);
return $schema;
}
//------------------------------------------------------------------------------
// Updates
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------