This repository has been archived by the owner on May 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.zasilkovna.php
executable file
·158 lines (134 loc) · 6.8 KB
/
install.zasilkovna.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
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
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
function recurse_copy($src,$dst) {
if(is_dir($src)){
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
echo "<b>adding file:</b> ".$dst.DS.$file."<br>";
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}else{
echo "<b>adding file:</b> ".$dst."<br>";
copy($src,$dst);
}
}
function recurse_delete($dir) {
echo "deleting: ".$dir."<br>";
if(is_dir($dir)){
foreach(glob($dir . '/*') as $file) {
if(is_dir($file))
recurse_delete($file);
else
unlink($file);
}
rmdir($dir);
}else{
unlink($dir);
}
}
class plgVmShipmentZasilkovnaInstallerScript
{
/**
* Constructor
*
* @param JAdapterInstance $adapter The object responsible for running this script
*/
public function __constructor(JAdapterInstance $adapter){
}
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($route, JAdapterInstance $adapter){
}
/**
* Called after any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($route, JAdapterInstance $adapter){
$vm_admin_path=JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart';
if($route=="install"){
$media_path=JPATH_ROOT.DS.'media'.DS.'com_zasilkovna'.DS;
recurse_copy($media_path.'admin'.DS.'com_virtuemart'.DS,$vm_admin_path.DS);
foreach(array('en-GB','cs-CZ','sk-SK') as $langCode){
recurse_copy($media_path.'admin'.DS.$langCode.'.plg_vmshipment_zasilkovna.ini',JPATH_ADMINISTRATOR.DS.'language'.DS.$langCode.DS.$langCode.'.plg_vmshipment_zasilkovna.ini');
}
$db =& JFactory::getDBO();
$q="CREATE TABLE IF NOT EXISTS #__virtuemart_zasilkovna_branches (
`id` int(10) NOT NULL,
`name_street` varchar(200) NOT NULL,
`currency` text NOT NULL,
`country` varchar(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$db->setQuery($q);
$db->query();
$queries[] = "ALTER TABLE `#__virtuemart_shipment_plg_zasilkovna` ADD COLUMN `first_name` VARCHAR(255) NULL DEFAULT NULL AFTER `phone`;";
$queries[] = "ALTER TABLE `#__virtuemart_shipment_plg_zasilkovna` ADD COLUMN `last_name` VARCHAR(255) NULL DEFAULT NULL AFTER `phone`;";
$queries[] = "ALTER TABLE `#__virtuemart_shipment_plg_zasilkovna` ADD COLUMN `address` VARCHAR(255) NULL DEFAULT NULL AFTER `phone`;";
$queries[] = "ALTER TABLE `#__virtuemart_shipment_plg_zasilkovna` ADD COLUMN `city` VARCHAR(255) NULL DEFAULT NULL AFTER `phone`;";
$queries[] = "ALTER TABLE `#__virtuemart_shipment_plg_zasilkovna` ADD COLUMN `zip_code` VARCHAR(255) NULL DEFAULT NULL AFTER `phone`;";
$queries[] = "ALTER TABLE `#__virtuemart_shipment_plg_zasilkovna` ADD COLUMN `virtuemart_country_id` VARCHAR(255) NULL DEFAULT NULL AFTER `phone`;";
foreach ($queries as $q) {
$db->setQuery($q);
$db->query();
}
$q = "INSERT INTO #__virtuemart_adminmenuentries (`module_id`, `parent_id`, `name`, `link`, `depends`, `icon_class`, `ordering`, `published`, `tooltip`, `view`, `task`) VALUES
(5, 0, 'ZASILKOVNA', '', '', 'vmicon vmicon-16-zasilkovna', 1, 1, '', 'zasilkovna', '');";
$db->setQuery($q);
$db->query();
}
}
/**
* Called on installation
*
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function install(JAdapterInstance $adapter){
}
/**
* Called on update
*
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function update(JAdapterInstance $adapter){
}
/**
* Called on uninstallation
*
* @param JAdapterInstance $adapter The object responsible for running this script
*/
public function uninstall(JAdapterInstance $adapter){
$db =& JFactory::getDBO();
$q="DELETE FROM #__virtuemart_adminmenuentries WHERE `name` = 'zasilkovna';";
$db->setQuery($q);
$db->query();
$vm_admin_path=JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart';
recurse_delete($vm_admin_path.DS.'models'.DS.'zasilkovna.php');
recurse_delete($vm_admin_path.DS.'models'.DS.'zasilkovna_orders.php');
recurse_delete($vm_admin_path.DS.'views'.DS.'zasilkovna'.DS);
recurse_delete($vm_admin_path.DS.'controllers'.DS.'zasilkovna.php');
recurse_delete(JPATH_ADMINISTRATOR.DS.'language'.DS.'en-GB'.DS.'en-GB.plg_vmshipment_zasilkovna.ini');
}
}