-
Notifications
You must be signed in to change notification settings - Fork 0
/
uc_option_image.install
95 lines (90 loc) · 2.57 KB
/
uc_option_image.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
<?php
/**
* @file
* Provides install and uninstall hooks.
*/
/**
* Implementation of hook_schema().
**/
function uc_option_image_schema() {
$schema = array();
$schema['uc_option_image'] = array(
'description' => 'Stores data for UC Option Image.',
'fields' => array(
'type' => array(
'description' => 'The object type of the data being stored - uc_attribute, uc_option, uc_product or uc_class',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE
),
'aid' => array(
'description' => 'The associated attribute id',
'type' => 'int',
'default' => 0
),
'oid' => array(
'description' => 'The associated option id',
'type' => 'int',
'default' => 0
),
'pid' => array(
'description' => 'The associated product id',
'type' => 'int',
'default' => 0
),
'cid' => array(
'description' => 'The associated class id',
'type' => 'int',
'default' => 0
),
'fid' => array(
'description' => 'The fid of the associated image',
'type' => 'int',
'default' => 0
),
'inline_style' => array(
'description' => 'The image style of the image for the inline display mode.',
'type' => 'varchar',
'length' => 255,
'default' => NULL
),
'inline_active' => array(
'description' => 'Whether inline is active or not',
'type' => 'int',
'default' => 0
),
'selected_style' => array(
'description' => 'The image style of the image for the selected display mode.',
'type' => 'varchar',
'length' => 255,
'default' => NULL
),
'selected_active' => array(
'description' => 'Whether selected is active or not',
'type' => 'int',
'default' => 1
)
),
'indexes' => array(
'aid' => array('aid'),
'aid_oid' => array('aid', 'oid'),
'aid_oid_pid' => array('aid', 'oid', 'pid')
)
);
return $schema;
}
function uc_option_image_uninstall() {
// remove any images we're associated with
$result = db_select("file_usage", 'fu')
->fields('fu', array('fid'))
->condition('module', 'uc_option_image')
->execute();
foreach ($result as $row) {
$file = file_load($row->fid);
if (!$file) {
continue;
}
file_usage_delete($file, 'uc_option_image');
file_delete($file);
}
}