-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
418 lines (340 loc) · 15 KB
/
install.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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<?php
/*------------------------------------------------------------------------
# Copyright (C) 2005-2012 WebxSolution Ltd. All Rights Reserved.
# @license - GPLv2.0
# Author: WebxSolution Ltd
# Websites: http://www.webxsolution.com
# Terms of Use: An extension that is derived from the JoomlaCK editor will only be allowed under the following conditions: http://joomlackeditor.com/terms-of-use
# ------------------------------------------------------------------------*/
defined( '_JEXEC' ) or die();
// -PC- J3.0 fix
if( !defined( 'DS' ) ) define( 'DS', DIRECTORY_SEPARATOR );
class com_jckmanInstallerScript
{
function preflight( $type, $parent )
{
$jversion = new JVersion();
// Installing component manifest file version
$this->release = $parent->get( "manifest" )->version;
// If fresh install, lang file can't be loaded yet so use the tmp dir one.
$lang = JFactory::getLanguage();
$lang->load( 'com_jckman' , dirname(__FILE__) );
$lang->load( 'com_jckman.sys' , dirname(__FILE__) );
// Manifest file minimum Joomla version
$this->minimum_joomla_release = $parent->get( "manifest" )->attributes()->version;
if( version_compare( $jversion->getShortVersion(), $this->minimum_joomla_release, 'lt' ) )
{
JError::raiseWarning(null, JText::sprintf( 'COM_JCKMAN_CUSTOM_INSTALL_NOT_JOOMLA_PRIOR', $this->minimum_joomla_release ) );
return false;
}
}
function install($parent)
{
$version = '6.4.1';
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$query = "SELECT count(1) FROM #__modules"
." WHERE module = 'mod_jckquickicon'";
$db->setQuery( $query );
$count = $db->loadResult();
if($count) $this->uninstall($parent);
jimport('joomla.filesystem.folder');
$src = 'components' .DS. 'com_jckman' .DS. 'modules' .DS. 'mod_jckquickicon';
$dest = 'modules' .DS. 'mod_jckquickicon';
if( !JFolder::copy( $src, $dest, JPATH_ADMINISTRATOR, true ) ){
$mainframe->enqueueMessage( JText::sprintf( 'COM_JCKMAN_CUSTOM_INSTALL', 'control panel icon module!' ) );
}
/*===========================================================> */
/*==============================================> LEFT MODULES */
/*===========================================================> */
$row = JTable::getInstance('module');
$row->position = 'jck_icon';
$row->published = 1;
$row->showtitle = 1;
$row->access = 1;
$row->client_id = 1;
$row->params = '';
$row->id = 0;
$row->title = 'JCK Manager';
$row->content = '<img alt="" src="components/com_jckman/icons/jck-manager-logo.png" />';
$row->ordering = $row->getNextOrder( "position='jck_icon'" );
$row->module = 'mod_custom';
$row->params = '{"prepare_content":0}';
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','JCK PlugMan custom Module data!') );
}
$row->id = 0;
$row->title = 'Dashboard';
$row->module = 'mod_jckquickicon';
$row->params = '';
$row->ordering = $row->getNextOrder( "position='jck_icon'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','Control Panel icon Module data!') );
}
$row->id = 0;
$row->title = 'JCK Manager v' . $version;
$row->module = 'mod_custom';
$row->content =
'<table class="table table-striped" border="0" cellpadding="0" cellspacing="0" style="margin-bottom:0px;">
<tr>
<td>Version:</td>
<td>' . $version . '</td>
</tr>
<tr>
<td>Author:</td>
<td><a href="http://www.joomlackeditor.com" target="_blank">www.joomlackeditor.com</a></td>
</tr>
<tr>
<td>Copyright:</td>
<td>© WebxSolution Ltd, All rights reserved.</td>
</tr>
<tr>
<td>License:</td>
<td>GPLv2.0</td>
</tr>
<tr>
<td>More info:</td>
<td><a href="http://joomlackeditor.com/terms-of-use" target="_blank">http://joomlackeditor.com/terms-of-use</a></td>
</tr>
</table>';
$row->ordering = $row->getNextOrder( "position='jck_icon'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','JCK PlugMan custom Module data!') );
}
/*===========================================================> */
/*============================================> CPANEL MODULES */
/*===========================================================> */
$row = JTable::getInstance('module');
$row->position = 'jck_cpanel';
$row->published = 1;
$row->showtitle = 1;
$row->access = 1;
$row->client_id = 1;
$row->params = '';
$row->id = 0;
$row->title = 'COM_JCKMAN_CPANEL_SLIDER_MANAGER_LABEL';
$row->content = 'COM_JCKMAN_CPANEL_SLIDER_MANAGER_HTML';
$row->ordering = $row->getNextOrder( "position='jck_cpanel'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','JCK PlugMan custom Module data!') );
}
$row->id = 0;
$row->title = 'COM_JCKMAN_CPANEL_SLIDER_PLUGIN_LABEL';
$row->content = 'COM_JCKMAN_CPANEL_SLIDER_PLUGIN_HTML';
$row->ordering = $row->getNextOrder( "position='jck_cpanel'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','JCK PlugMan custom Module data!') );
}
$row->id = 0;
$row->title = 'COM_JCKMAN_CPANEL_SLIDER_SYSTEM_CHECK_LABEL';
$row->content = 'COM_JCKMAN_CPANEL_SLIDER_SYSTEM_CHECK_HTML';
$row->ordering = $row->getNextOrder( "position='jck_cpanel'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','JCK PlugMan custom Module data!') );
}
$row->id = 0;
$row->title = 'COM_JCKMAN_CPANEL_SLIDER_SYSTEM_LAYOUT_MANAGER';
$row->content = 'COM_JCKMAN_CPANEL_SLIDER_SYSTEM_LAYOUT_MANAGER_HTML';
$row->ordering = $row->getNextOrder( "position='jck_cpanel'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','JCK PlugMan custom Module data!') );
}
$row->id = 0;
$row->title = 'COM_JCKMAN_CPANEL_SLIDER_BACKUP_LABEL';
$row->content = 'COM_JCKMAN_CPANEL_SLIDER_BACKUP_LABEL_HTML';
;
$row->ordering = $row->getNextOrder( "position='jck_cpanel'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTAL','custom Module data!') );
}
$row->id = 0;
$row->title = 'COM_JCKMAN_CPANEL_SLIDER_RESTORE_LABEL';
$row->content = 'COM_JCKMAN_CPANEL_SLIDER_RESTORE_HTML';
$row->ordering = $row->getNextOrder( "position='jck_cpanel'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','JCK PlugMan custom Module data!') );
}
$row->id = 0;
$row->title = 'COM_JCKMAN_CPANEL_SLIDER_SYNC_LABEL';
$row->content = 'COM_JCKMAN_CPANEL_SLIDER_SYNC_HTML';
$row->ordering = $row->getNextOrder( "position='jck_cpanel'" );
if (!$row->store()) {
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL','JCK PlugMan custom Module data!') );
}
jimport('joomla.filesystem.file');
$src = JPATH_ADMINISTRATOR.DS.'components' .DS. 'com_jckman' .DS. 'editor' .DS. 'pluginoverrides.php';
$dest = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins'.DS.'editor'.DS. 'pluginoverrides.php';
if( !JFile::copy( $src, $dest) ){
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF','pluginoverrides JCK plugin!') );
}
$src = JPATH_ADMINISTRATOR.DS.'components' .DS. 'com_jckman' .DS. 'editor' .DS. 'languageoverrides.php';
$dest = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins'.DS.'editor'.DS. 'languageoverrides.php';
if( !JFile::copy( $src, $dest) ){
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF','languageoverrides JCK plugin!') );
}
$src = JPATH_ADMINISTRATOR.DS.'components' .DS. 'com_jckman' .DS. 'editor' .DS. 'acl.php';
$dest = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins'.DS.'editor'.DS. 'acl.php';
if( !JFile::copy( $src, $dest) ){
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF',' ACL JCK plugin!') );
}
$src = JPATH_ADMINISTRATOR.DS.'components' .DS. 'com_jckman' .DS. 'editor' .DS. 'components.php';
$dest = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins'.DS.'toolbar'.DS. 'components.php';
if( !JFile::copy( $src, $dest) ){
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF','JCK toolbar plugin!') );
}
$src = JPATH_ADMINISTRATOR.DS .'components' .DS. 'com_jckman' .DS. 'editor'.DS.'plugins.php';
$dest = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins.php';
if( !JFile::copy( $src, $dest) ){
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF','base plugins file to JCK library!') );
}
//$src = JPATH_ADMINISTRATOR.DS .'components' .DS. 'com_jckman' .DS. 'editor'.DS.'includes.php';
//$dest = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'includes.php';
/*
if( !JFile::copy( $src, $dest) ){
$mainframe->enqueueMessage( JText::_('Unable to move updated includes file to JCK plugin!') );
}
*/
unset( $row );
//Check System requirements for the editor
define('JCK_BASE',JPATH_CONFIGURATION .DS.'plugins'.DS.'editors'.DS.'jckeditor');
if(!JFolder::exists(JCK_BASE))
{
$mainframe->enqueueMessage( JText::_('COM_JCKMAN_CUSTOM_INSTALL_SYSTEM_DETECTED_EDITOR_NOT_INSTALLED') );
return;
}
$perms = fileperms(JPATH_CONFIGURATION.DS.'index.php');
$perms = (decoct($perms & 0777));
$default_fperms = '0644';
$default_dperms = '0755';
if($perms == 777 || $perms == 666)
{
$default_fperms = '0666';
$default_dperms = '0777';
}
$fperms = JCK_BASE.DS.'config.js';
if(!stristr(PHP_OS,'WIN') && JPath::canChmod(JCK_BASE) && $perms != decoct(fileperms($fperms) & 0777))
{
$path = JCK_BASE.DS.'plugins';
if(!JPath::setPermissions($path,$default_fperms,$default_dperms))
{
$mainframe->enqueueMessage( JText::_('COM_JCKMAN_CUSTOM_INSTALL_SYSTEM_DETECTED_INCORRECT_FILE_PERMISSONS_FOR_EDITOR') );
}
}
// clear explorer cache to avoid breaking the export feature (filename too long)
// This code is also run of install/upgrade of the jckexplorer plugin
$cache = JCK_BASE . '/plugins/jckexplorer/cache';
if( JFolder::exists( $cache ) )
{
// Delete cache folders
foreach( JFolder::folders( $cache ) as $folder )
{
JFolder::delete( $cache . DS . $folder );
}//end foreach
// Delete cache files
foreach( JFolder::files( $cache ) as $file )
{
if( $file != 'index.html' )
{
JFile::delete( $cache . DS . $file );
}//end if
}//end foreach
}//end if
//for upgrade
$query = 'SELECT p.name FROM `#__jckplugins` p WHERE p.iscore = 0';
$db->setQuery( $query );
$results = $db->loadObjectList();
if(!empty($results))
{
for($i = 0; $i < count($results);$i++)
{
if(JFolder::exists(JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'plugins'.DS.$results[$i]->name) &&
!JFolder::exists(JPATH_ADMINISTRATOR.DS .'components' .DS. 'com_jckman'.DS.'editor'.DS.'plugins'.DS.$results[$i]->name)
)
{
$src = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'plugins'.DS.$results[$i]->name;
$dest = JPATH_ADMINISTRATOR.DS .'components'.DS.'com_jckman'.DS.'editor'.DS.'plugins'.DS.$results[$i]->name;
if( !JFolder::copy( $src, $dest) )
{
$mainframe->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF','base plugin .'.$results[$i]->name.' to JCK backup folder!') );
}
}
}//end for loop
}
//fix remove component install file from the editor's folder
$file = JPATH_ADMINISTRATOR.DS .'components' .DS. 'com_jckman'.DS.'editor'.DS.'com_jckman.xml';
if(JFile::exists($file))
JFile::delete($file);
}
function update($parent)
{
$this->install($parent);
$db = JFactory::getDBO();
if(method_exists($parent, 'extension_root')) {
$sqlfile = $parent->getPath('extension_root').DS.'sql'.DS.'install.sql';
} else {
$sqlfile = $parent->getParent()->getPath('extension_root').DS.'sql'.DS.'install.sql';
}
// Don't modify below this line
$buffer = file_get_contents($sqlfile);
if ($buffer !== false) {
jimport('joomla.installer.helper');
$queries = JInstallerHelper::splitSql($buffer);
if (count($queries) != 0) {
foreach ($queries as $query)
{
$query = trim($query);
if ($query != '' && $query{0} != '#') {
$db->setQuery($query);
if (!$db->query()) {
if( !class_exists( 'JCKHelper' ) ) require_once( JPATH_COMPONENT_ADMINISTRATOR . DS . 'helper.php' );
JCKHelper::error( JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
return false;
}
}
}
}
}
}
function uninstall($parent)
{
$app = JFactory::getApplication();
$db = JFactory::getDBO();
$path = JPATH_ADMINISTRATOR .DS. 'modules' .DS. 'mod_jckquickicon';
jimport('joomla.filesystem.folder');
if( JFolder::exists( $path ) && !JFolder::delete( $path ) ){
$app->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_UNINSTALL','control panel icon module!') );
}
$sql = $db->getQuery( true );
$sql->delete( '#__modules' )
->where( 'position IN ( "jck_cpanel", "jck_icon" )' );
if( !$db->setQuery( $sql )->query() )
{
$app->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_UNINSTALL','PlugMan modules data!') );
}
$file = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins'.DS.'editor'.DS. 'pluginoverrides.php';
if(JFile::exists($file) && !JFile::delete($file)) {
$app->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_UNINSTALL','pluginoverrides JCK plugin!') );
}
$file = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins'.DS.'editor'.DS. 'languageoverrides.php';
if(JFile::exists($file) && !JFile::delete($file)) {
$app->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_UNINSTALL','languageoverrides JCK plugin!') );
}
$file = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins'.DS.'editor'.DS. 'acl.php';
if(JFile::exists($file) && !JFile::delete($file)) {
$app->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_UNINSTALL','ACL JCK plugin!') );
}
$file = JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'jckeditor'.DS.'includes'.DS.'ckeditor'.DS.'plugins'.DS.'toolbar'.DS. 'components.php';
if(JFile::exists($file) && !JFile::delete($file)) {
$app->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_UNINSTALL','components JCK toolbar plugin!') );
}
// For some reason we need to remove the row from the asset table?!
$sql = $db->getQuery( true );
$sql->delete( '#__assets' )
->where( 'name = "com_jckman"' )
->where( 'title = "com_jckman"' );
if( !$db->setQuery( $sql )->query() )
{
$app->enqueueMessage( JText::sprintf('COM_JCKMAN_CUSTOM_UNINSTALL','Unable to remove JCKMan asset record!') );
}
}
}