forked from justafish/drupal_amazons3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamazons3.install
170 lines (158 loc) · 4.57 KB
/
amazons3.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
/**
* @file
* Install, update and uninstall functions for the AmazonS3 module.
*/
/**
* Implements hook_requirements().
*/
function amazons3_requirements($phase) {
$t = get_t();
if ($phase != 'runtime') {
return array();
}
$fopen_allowed = ini_get('allow_url_fopen');
$ok_message = $t('The PHP allow_url_fopen setting is on.');
$error_message = $t('Amazon S3 module requires that the allow_url_fopen setting be turned on in php.ini.');
$requirements['amazons3_allow_url_fopen'] = array(
'severity' => $fopen_allowed ? REQUIREMENT_OK : REQUIREMENT_ERROR,
'title' => $t('AmazonS3'),
'value' => 'allow_url_fopen',
'description' => $fopen_allowed ? $ok_message : $error_message,
);
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function amazons3_uninstall() {
variable_del('amazons3_bucket');
variable_del('amazons3_cname');
variable_del('amazons3_domain');
variable_del('amazons3_cache');
variable_del('amazons3_torrents');
variable_del('amazons3_presigned_urls');
variable_del('amazons3_saveas');
}
/**
* Implements hook_schema().
*/
function amazons3_schema() {
$schema['amazons3_file'] = array(
'description' => 'Stores information for uploaded Amazon S3 files.',
'fields' => array(
'uri' => array(
'description' => 'The URI to access the file (either local or remote).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'filesize' => array(
'description' => 'The size of the file in bytes.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'timestamp' => array(
'description' => 'UNIX timestamp for when the file was added.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'dir' => array(
'description' => 'Boolean indicating whether or not this object is a directory.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'mode' => array(
'description' => 'The file mode returned by the stat function.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => 'The uid of the user who is associated with the file (not Drupal uid).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'timestamp' => array('timestamp'),
),
'primary key' => array('uri'),
);
return $schema;
}
/**
* Install the caching table
*/
function amazons3_update_7100($sandbox) {
$schema['amazons3_file'] = array(
'description' => 'Stores information for uploaded Amazon S3 files.',
'fields' => array(
'uri' => array(
'description' => 'The URI to access the file (either local or remote).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'filesize' => array(
'description' => 'The size of the file in bytes.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'timestamp' => array(
'description' => 'UNIX timestamp for when the file was added.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'dir' => array(
'description' => 'Boolean indicating whether or not this object is a directory.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'mode' => array(
'description' => 'The file mode returned by the stat function.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => 'The uid of the user who is associated with the file (not Drupal uid).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'timestamp' => array('timestamp'),
),
'primary key' => array('uri'),
);
db_create_table('amazons3_file', $schema['amazons3_file']);
}
function amazons3_update_7101(&$sandbox) {
$spec = array(
'description' => 'The uid of the user who is associated with the file (not Drupal uid).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
);
db_change_field('amazons3_file', 'uid', 'uid', $spec);
}