forked from yakamara/yform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.php
70 lines (57 loc) · 2.66 KB
/
update.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @var rex_addon $this
*/
rex_dir::delete($this->getDataPath('fonts'));
foreach ($this->getInstalledPlugins() as $plugin) {
// use path relative to __DIR__ to get correct path in update temp dir
$file = __DIR__ . '/plugins/' . $plugin->getName() . '/update.php';
if (file_exists($file)) {
$plugin->includeFile($file);
}
}
if ($this->getPlugin('manager')->isInstalled() && rex_string::versionCompare($this->getVersion(), '3', '<')) {
$fields_removed = [];
$fields_renamed = ['labelexist' => 'in_names', 'existintable' => 'in_table'];
foreach ($fields_renamed as $field_old_name => $field_new_name) {
try {
rex_sql::factory()->setQuery('update ' . rex::getTable('yform_field') . ' set type_name = ? where type_id="value" and type_name = ?', [$field_new_name, $field_old_name]);
rex_sql::factory()->setQuery('update ' . rex::getTable('yform_history_field') . ' set field = ? where field = ?', [$field_new_name, $field_old_name]);
} catch (rex_sql_exception $e) {
}
}
foreach ($fields_removed as $field) {
try {
rex_sql::factory()->setQuery('delete from ' . rex_yform_manager_field::table() . ' where type_id="value" and type_name = ?', [$field]);
} catch (rex_sql_exception $e) {
}
}
try {
rex_sql::factory()->setQuery('UPDATE ' . rex_yform_manager_field::table() . ' SET `format` = "" WHERE type_name = "datestamp" AND `format` = "mysql"');
} catch (rex_sql_exception $e) {
}
}
if ($this->getPlugin('manager')->isInstalled() && rex_string::versionCompare($this->getVersion(), '1.9', '<')) {
$fields_removed = ['submits', 'uniqueform'];
$fields_change = ['html', 'php', 'date', 'datetime', 'fieldset', 'time', 'upload', 'google_geocode', 'submit', 'be_medialist'];
$actions_removed = ['fulltext_value', 'wrapper_value'];
foreach ($fields_removed as $field) {
try {
rex_sql::factory()->setQuery('delete from ' . rex_yform_manager_field::table() . ' where type_id="value" and type_name = ?', [$field]);
} catch (rex_sql_exception $e) {
}
}
foreach ($fields_change as $field) {
try {
rex_sql::factory()->setQuery('delete from ' . rex_yform_manager_field::table() . ' where type_id="value" and type_name = ?', [$field]);
} catch (rex_sql_exception $e) {
}
}
foreach ($actions_removed as $action) {
try {
rex_sql::factory()->setQuery('delete from ' . rex_yform_manager_field::table() . ' where type_id="action" and type_name = ?', [$action]);
} catch (rex_sql_exception $e) {
}
}
}
rex_autoload::removeCache();