web357framework.script.php
8.61 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
/* ======================================================
# Web357 Framework - Joomla! System Plugin v1.5.1
# -------------------------------------------------------
# For Joomla! 3.x
# Author: Yiannis Christodoulou (yiannis@web357.eu)
# Copyright (©) 2009-2018 Web357. All rights reserved.
# License: GNU/GPLv3, http://www.gnu.org/licenses/gpl-3.0.html
# Website: https://www.web357.eu/
# Support: support@web357.eu
# Last modified: 09 Feb 2018, 13:55:18
========================================================= */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// http://docs.joomla.org/J2.5:Developing_a_MVC_Component/Adding_an_install-uninstall-update_script_file
if (!class_exists("plgSystemWeb357FrameworkInstallerScript")):
class plgSystemWeb357FrameworkInstallerScript
{
var $extension_type = '';
var $extension_name = '';
var $extension_real_name = '';
function __construct()
{
$this->extension_type = "component";
$this->extension_name = "monthlyarchive";
$this->extension_real_name = "Monthly Archive";
}
/**
* method to install the component
*
* @return void
*/
function install($parent)
{
// $parent is the class calling this method
}
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($parent)
{
// $parent is the class calling this method
}
/**
* method to update the component
*
* @return void
*/
function update($parent)
{
// $parent is the class calling this method
}
/**
* method to run before an install/update/uninstall method
*
* @return void
*/
function preflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
JFactory::getLanguage()->load('plg_system_web357framework', __DIR__);
}
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
function postflight($type, $parent)
{
if (!in_array($type, array('install', 'update')))
{
return;
}
// Connect to DB
$db = JFactory::getDbo();
// Delete old names of Extensions
$query = "DELETE FROM #__extensions WHERE element='com_web357loginasuser'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='com_web357fix404errorlinks'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='com_virtuemartsales'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE name='MOD_TOOLBAR' AND element='mod_toolbar' AND client_id=0 AND protected=0"; $db->setQuery($query); $db->query();
// BEGIN: Delete Old packages
// components
$query = "DELETE FROM #__extensions WHERE element='pkg_vmsales'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='pkg_fix404errorlinks'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='pkg_loginasuser'"; $db->setQuery($query); $db->query();
// modules
$query = "DELETE FROM #__extensions WHERE element='pkg_toolbar'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='pkg_fixedhtmltoolbar'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='pkg_vmcountproducts'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='pkg_datetime'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='pkg_countdown'"; $db->setQuery($query); $db->query();
// plugins
$query = "DELETE FROM #__extensions WHERE element='pkg_failedloginattempts'"; $db->setQuery($query); $db->query();
$query = "DELETE FROM #__extensions WHERE element='pkg_cookiespolicynotificationbar'"; $db->setQuery($query); $db->query();
// END: Delete Old packages
// BEGIN: Update and Set the correct names for extensions.
// components
$query = "UPDATE #__extensions SET name='COM_VMSALES' WHERE element='com_vmsales'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='COM_FIX404ERRORLINKS' WHERE element='com_fix404errorlinks'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='COM_LOGINASUSER' WHERE element='com_loginasuser'"; $db->setQuery($query); $db->query();
// modules
$query = "UPDATE #__extensions SET name='MOD_FIXEDHTMLTOOLBAR' WHERE element='mod_fixedhtmltoolbar'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='MOD_VMCOUNTPRODUCTS' WHERE element='mod_vmcountproducts'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='MOD_DATETIME' WHERE element='mod_datetime'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='MOD_COUNTDOWN' WHERE element='mod_countdown'"; $db->setQuery($query); $db->query();
// plugins
$query = "UPDATE #__extensions SET name='PLG_AUTHENTICATION_FAILEDLOGINATTEMPTS' WHERE element='failedloginattempts'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='PLG_SYSTEM_COOKIESPOLICYNOTIFICATIONBAR' WHERE element='cookiespolicynotificationbar'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='PLG_SYSTEM_WEB357FRAMEWORK' WHERE element='web357framework'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='PLG_SYSTEM_VMSALES' WHERE element='vmsales'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='PLG_SYSTEM_FIX404ERRORLINKS' WHERE element='fix404errorlinks'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__extensions SET name='PLG_SYSTEM_LOGINASUSER' WHERE element='loginasuser'"; $db->setQuery($query); $db->query();
// END: Update Extensions
// Update Menu
$query = "UPDATE #__menu SET title='COM_VMSALES', alias='com-vmsales', path='com-vmsales' WHERE link='index.php?option=com_vmsales'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__menu SET title='COM_FIX404ERRORLINKS', alias='com-fix404errorlinks', path='com-fix404errorlinks' WHERE link='index.php?option=com_fix404errorlinks'"; $db->setQuery($query); $db->query();
$query = "UPDATE #__menu SET title='COM_LOGINASUSER', alias='com-loginasuser', path='com-loginasuser' WHERE link='index.php?option=com_loginasuser'"; $db->setQuery($query); $db->query();
// Define DS
if (!defined("DS")):
define("DS", DIRECTORY_SEPARATOR);
endif;
// Import filesystem libraries. Perhaps not necessary, but does not hurt
jimport('joomla.filesystem.file');
// Remove files from older versions
$remove_files_arr = array(
// supporthours
JPATH_ROOT.DS.'modules'.DS.'mod_supporthours'.DS.'timezone.php',
// failedloginattempts
JPATH_ROOT.DS.'plugins'.DS.'authentication'.DS.'failedloginattempts'.DS.'elements'.DS.'info.php',
JPATH_ROOT.DS.'plugins'.DS.'authentication'.DS.'failedloginattempts'.DS.'elements'.DS.'footer.php',
// cookiespolicynotificationbar
JPATH_ROOT.DS.'plugins'.DS.'system'.DS.'cookiespolicynotificationbar'.DS.'elements'.DS.'info.php',
);
// Remove action
foreach ($remove_files_arr as $remove_file):
if (JFile::exists($remove_file)):
JFile::delete($remove_file);
endif;
endforeach;
// Import the folder system library
jimport('joomla.filesystem.folder');
// Remove folders from older versions
$remove_folders_arr = array();
// Remove action
if (!empty($remove_folders_arr)):
foreach ($remove_folders_arr as $remove_folder):
if (JFolder::exists($remove_folder)):
JFolder::delete($remove_folder);
endif;
endforeach;
endif;
// Connect to DB
$db = JFactory::getDbo();
// BEGIN: Enable Plugin
$query = "UPDATE #__extensions SET enabled=1 WHERE element='web357framework' AND type='plugin'";
$db->setQuery($query);
$db->query();
// END: Enable Plugin
// display product's description
require_once(JPATH_PLUGINS."/system/web357framework/elements/description.php");
$class = new JFormFieldDescription;
echo $class->getHtmlDescription($this->extension_type, $this->extension_name, "", $this->extension_real_name);
echo "<hr><br><br>";
// Install the rest of the packages
$this->installPackages();
}
private function installPackages()
{
$packages = JFolder::folders(__DIR__ . '/packages');
$packages = array_diff($packages, array('plg_system_web357framework'));
foreach ($packages as $package):
if (!$this->installPackage($package)):
return false;
endif;
endforeach;
return true;
}
private function installPackage($package)
{
$tmpInstaller = new JInstaller;
return $tmpInstaller->install(__DIR__ . '/packages/' . $package);
}
}
endif;