-
Notifications
You must be signed in to change notification settings - Fork 13
/
extension.driver.php
54 lines (48 loc) · 2.14 KB
/
extension.driver.php
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
<?php
class extension_uniqueuploadfield extends Extension
{
public function update($previousVersion = false)
{
$symphony_version = Symphony::Configuration()->get('version', 'symphony');
if (version_compare($symphony_version, '2.0.8RC3', '>=') && version_compare($previousVersion, '1.1', '<')) {
$uniqueupload_entry_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_uniqueupload`");
if (is_array($uniqueupload_entry_tables) && !empty($uniqueupload_entry_tables)) {
foreach ($uniqueupload_entry_tables as $field) {
Symphony::Database()->query(sprintf(
"ALTER TABLE `tbl_entries_data_%d` CHANGE `size` `size` INT(11) UNSIGNED NULL DEFAULT NULL",
$field
));
}
}
}
if (version_compare($symphony_version, '2.3.3beta1', '>')) {
// Remove directory from the unique upload fields, similar to Symphony's upload field
$upload_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_uniqueupload`");
if (is_array($upload_tables) && !empty($upload_tables)) {
foreach ($upload_tables as $field) {
Symphony::Database()->query(sprintf(
"UPDATE tbl_entries_data_%d SET file = substring_index(file, '/', -1)",
$field
));
}
}
}
}
public function uninstall()
{
Symphony::Database()->query("DROP TABLE `tbl_fields_uniqueupload`");
}
public function install()
{
return Symphony::Database()->query(
"CREATE TABLE `tbl_fields_uniqueupload` (
`id` int(11) unsigned NOT NULL auto_increment,
`field_id` int(11) unsigned NOT NULL,
`destination` varchar(255) NOT NULL,
`validator` varchar(255),
PRIMARY KEY (`id`),
KEY `field_id` (`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
}
}