forked from janguo-de/virtualdomains
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuninstall.package.php
254 lines (224 loc) · 8.36 KB
/
uninstall.package.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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
/**
* This is the special installer addon created by Andrew Eddie and the team of jXtended.
* We thank for this cool idea of extending the installation process easily
* @copyright 2005-2008 New Life in IT Pty Ltd. All rights reserved.
*/
/**
* @version $Id$
* @package jimtawl
* @subpackage Base
* @author EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
* @author Michael Liebler {@link http://www.janguo.de}
* @author Created on 14-Aug-09
*/
//--No direct access
defined('_JEXEC') or die('=;)');
jimport('joomla.application.helper');
$status = new JObject();
$status->modules = array();
$status->plugins = array();
/***********************************************************************************************
* ---------------------------------------------------------------------------------------------
* MODULE REMOVAL SECTION
* ---------------------------------------------------------------------------------------------
***********************************************************************************************/
$modules = &$this->manifest->getElementByPath('modules');
if (is_a($modules, 'JSimpleXMLElement') && count($modules->children()))
{
foreach ($modules->children() as $module)
{
$mname = $module->attributes('module');
$mclient = JApplicationHelper::getClientInfo($module->attributes('client'), true);
$mposition = $module->attributes('position');
//--Set the installation path
if( ! empty ($mname))
{
$this->parent->setPath('extension_root', $mclient->path.'/modules/'.$mname);
}
else
{
$this->parent->abort(JText::_('Module').' '.JText::_('Install').': '.JText::_('No module file specified'));
return false;
}
/**
* ---------------------------------------------------------------------------------------------
* Database Processing Section
* ---------------------------------------------------------------------------------------------
*/
$db = &JFactory::getDBO();
//--Lets delete all the module copies for the type we are uninstalling
$query = 'SELECT `id`' .
' FROM `#__modules`' .
' WHERE module = '.$db->Quote($mname) .
' AND client_id = '.(int)$mclient->id;
$db->setQuery($query);
$modules = $db->loadResultArray();
//--Do we have any module copies?
if (count($modules))
{
JArrayHelper::toInteger($modules);
$modID = implode(',', $modules);
$query = 'DELETE' .
' FROM #__modules_menu' .
' WHERE moduleid IN ('.$modID.')';
$db->setQuery($query);
if( ! $db->query())
{
JError::raiseWarning(100, JText::_('Module').' '.JText::_('Uninstall').': '.$db->stderr(true));
$retval = false;
}
}
//--Delete the modules in the #__modules table
$query = 'DELETE FROM #__modules WHERE module = '.$db->Quote($mname);
$db->setQuery($query);
if( ! $db->query())
{
JError::raiseWarning(100, JText::_('Plugin').' '.JText::_('Uninstall').': '.$db->stderr(true));
$retval = false;
}
/**
* ---------------------------------------------------------------------------------------------
* Filesystem Processing Section
* ---------------------------------------------------------------------------------------------
*/
//--Remove all necessary files
$element = &$module->getElementByPath('files');
if (is_a($element, 'JSimpleXMLElement') && count($element->children()))
{
$this->parent->removeFiles($element, -1);
}
//--Remove all necessary files
$element = &$module->getElementByPath('media');
if (is_a($element, 'JSimpleXMLElement') && count($element->children()))
{
$this->parent->removeFiles($element, -1);
}
$element = &$module->getElementByPath('languages');
if (is_a($element, 'JSimpleXMLElement') && count($element->children()))
{
$this->parent->removeFiles($element, $mclient->id);
}
//--Remove the installation folder
if ( ! JFolder::delete($this->parent->getPath('extension_root')))
{
}
$status->modules[] = array('name'=>$mname,'client'=>$mclient->name);
}
}
/***********************************************************************************************
* ---------------------------------------------------------------------------------------------
* PLUGIN REMOVAL SECTION
* ---------------------------------------------------------------------------------------------
***********************************************************************************************/
$plugins = &$this->manifest->getElementByPath('plugins');
if (is_a($plugins, 'JSimpleXMLElement') && count($plugins->children()))
{
foreach ($plugins->children() as $plugin)
{
$pname = $plugin->attributes('plugin');
$pgroup = $plugin->attributes('group');
//--Set the installation path
if ( ! empty($pname) && !empty($pgroup))
{
$this->parent->setPath('extension_root', JPATH_ROOT.'/plugins/'.$pgroup);
}
else
{
$this->parent->abort(JText::_('Plugin').' '.JText::_('Uninstall').': '.JText::_('No plugin file specified'));
return false;
}
/**
* ---------------------------------------------------------------------------------------------
* Database Processing Section
* ---------------------------------------------------------------------------------------------
*/
$db = &JFactory::getDBO();
//--Delete the plugins in the #__plugins table
$query = 'DELETE FROM #__plugins WHERE element = '.$db->Quote($pname).' AND folder = '.$db->Quote($pgroup);
$db->setQuery($query);
if ( ! $db->query())
{
JError::raiseWarning(100, JText::_('Plugin').' '.JText::_('Uninstall').': '.$db->stderr(true));
$retval = false;
}
/**
* ---------------------------------------------------------------------------------------------
* Filesystem Processing Section
* ---------------------------------------------------------------------------------------------
*/
//--Remove all necessary files
$element = &$plugin->getElementByPath('files');
if (is_a($element, 'JSimpleXMLElement') && count($element->children()))
{
$this->parent->removeFiles($element, -1);
}
$element = &$plugin->getElementByPath('languages');
if (is_a($element, 'JSimpleXMLElement') && count($element->children()))
{
$this->parent->removeFiles($element, 1);
}
//--If the folder is empty, let's delete it
$files = JFolder::files($this->parent->getPath('extension_root'));
if ( ! count($files))
{
JFolder::delete($this->parent->getPath('extension_root'));
}
$status->plugins[] = array('name'=>$pname,'group'=>$pgroup);
}
}
/***********************************************************************************************
* ---------------------------------------------------------------------------------------------
* OUTPUT TO SCREEN
* ---------------------------------------------------------------------------------------------
***********************************************************************************************/
$rows = 0;
?>
<h2>Jimtawl Removal</h2>
<table class="adminlist">
<thead>
<tr>
<th class="title" colspan="2"><?php echo JText::_('Extension'); ?></th>
<th width="30%"><?php echo JText::_('Status'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3"></td>
</tr>
</tfoot>
<tbody>
<tr class="row0">
<td class="key" colspan="2"><?php echo 'Jimtawl '.JText::_('Component'); ?></td>
<td><img src="images/publish_g.png" alt="OK" /><strong><?php echo JText::_('Removed'); ?></strong></td>
</tr>
<?php if (count($status->modules)) : ?>
<tr>
<th><?php echo JText::_('Module'); ?></th>
<th><?php echo JText::_('Client'); ?></th>
<th></th>
</tr>
<?php foreach ($status->modules as $module) : ?>
<tr class="row<?php echo (++ $rows % 2); ?>">
<td class="key"><?php echo $module['name']; ?></td>
<td class="key"><?php echo ucfirst($module['client']); ?></td>
<td><img src="images/publish_g.png" alt="OK" /><strong><?php echo JText::_('Removed'); ?></strong></td>
</tr>
<?php endforeach;
endif;
if (count($status->plugins)) : ?>
<tr>
<th><?php echo JText::_('Plugin'); ?></th>
<th><?php echo JText::_('Group'); ?></th>
<th></th>
</tr>
<?php foreach ($status->plugins as $plugin) : ?>
<tr class="row<?php echo (++ $rows % 2); ?>">
<td class="key"><?php echo ucfirst($plugin['name']); ?></td>
<td class="key"><?php echo ucfirst($plugin['group']); ?></td>
<td><img src="images/publish_g.png" alt="OK" /><strong><?php echo JText::_('Removed'); ?></strong></td>
</tr>
<?php endforeach;
endif; ?>
</tbody>
</table>