This repository has been archived by the owner on May 28, 2021. It is now read-only.
/
install.zasilkovna.php
184 lines (161 loc) · 7.49 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
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();
$q="CREATE TABLE IF NOT EXISTS `#__virtuemart_shipment_plg_zasilkovna` (
`id` int(1) unsigned NOT NULL AUTO_INCREMENT,
`virtuemart_order_id` int(11) unsigned DEFAULT NULL,
`virtuemart_shipmentmethod_id` mediumint(1) unsigned DEFAULT NULL,
`order_number` char(32) DEFAULT NULL,
`zasilkovna_packet_id` decimal(10,0) DEFAULT NULL,
`zasilkovna_packet_price` decimal(15,2) DEFAULT NULL,
`branch_id` decimal(10,0) DEFAULT NULL,
`branch_currency` char(5) DEFAULT NULL,
`branch_name_street` varchar(500) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`first_name` varchar(255) DEFAULT NULL,
`last_name` varchar(255) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
`city` varchar(255) DEFAULT NULL,
`zip_code` varchar(255) DEFAULT NULL,
`virtuemart_country_id` varchar(255) DEFAULT NULL,
`adult_content` smallint(1) DEFAULT '0',
`is_cod` smallint(1) DEFAULT NULL,
`exported` smallint(1) DEFAULT NULL,
`printed_label` smallint(1) DEFAULT '0',
`shipment_name` varchar(5000) DEFAULT NULL,
`shipment_cost` decimal(10,2) DEFAULT NULL,
`shipment_package_fee` decimal(10,2) DEFAULT NULL,
`tax_id` smallint(1) DEFAULT NULL,
`created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(11) NOT NULL DEFAULT '0',
`modified_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` int(11) NOT NULL DEFAULT '0',
`locked_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`locked_by` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='zasilkovna';";
$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');
}
}