-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathinstallscript.php
700 lines (591 loc) · 25.8 KB
/
installscript.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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
<?php
/**
* @copyright Copyright (C) 2005-2013 JoomLeague.net. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.filesystem.folder');
class com_joomleagueInstallerScript
{
private function _install($update=false) {
?>
<?php
self::createImagesFolder();
self::installComponentLanguages();
if($update) {
self::migratePicturePath();
}
$updateArray = array();
include_once(JPATH_SITE.DS.'components'.DS.'com_joomleague'.DS.'joomleague.core.php');
include_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomleague'.DS.'assets'.DS.'updates'.DS.'jl_install.php');
self::installModules();
self::installPlugins();
if($update) {
self::updateDatabase();
}
else
{
self::insertVersionString();
}
?>
<h2>Welcome to JoomLeague!</h2>
<img
src="../media/com_joomleague/jl_images/joomleague_logo.png"
alt="JoomLeague" title="JoomLeague" />
<hr />
<br>Click on <a href="index.php?option=com_installer&view=discover&task=discover.refresh">Discover->Refresh</a> to discover new or updated Modules and Plugins.
<?php
}
/**
* method to install the component languages
*
* @return void
*/
public function installComponentLanguages()
{
$mainframe =& JFactory::getApplication();
//$lang = JFactory::getLanguage();
$db =& JFactory::getDBO();
$query = $db->getQuery(true);
$type = "language";
$query->select('a.element');
$query->from('#__extensions AS a');
$type = $db->Quote($type);
$query->where('(a.type = '.$type.')');
$query->group('a.element');
$db->setQuery($query);
$langlist = $db->loadObjectList();
//echo 'Language -> <pre>'.print_r($langlist,true).'</pre><br>';
//$languages = JLanguageHelper::getLanguages('lang_code');
// echo 'Copy Administration language(s) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a><br>';
//echo 'Language -> <pre>'.print_r($languages,true).'</pre><br>';
foreach ( $langlist as $key )
{
//$mainframe->enqueueMessage('Language installed -> ' . $key,'Notice');
echo 'Copy Administration language( '.$key->element.' ) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a><br>';
$src=JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomleague'.DS;
$dest=JPATH_ADMINISTRATOR.DS.'modules';
JFolder::copy($src.DS.'language'.DS.$key->element, JPATH_ADMINISTRATOR.DS.'language'.DS.$key->element, '', true);
echo ' - <span style="color:green">'.JText::_('Success-> '.$key->element).'</span><br />';
echo 'Copy Site language( '.$key->element.' ) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a><br>';
$src=JPATH_SITE.DS.'components'.DS.'com_joomleague'.DS;
$dest=JPATH_SITE.DS;
JFolder::copy($src.DS.'language'.DS.$key->element, JPATH_SITE.DS.'language'.DS.$key->element, '', true);
echo ' - <span style="color:green">'.JText::_('Success -> '.$key->element).'</span><br />';
}
}
/**
* method to install the modules
*
* @return void
*/
public function installModules()
{
$mainframe =& JFactory::getApplication();
// $lang = JFactory::getLanguage();
// $languages = JLanguageHelper::getLanguages('lang_code');
$db =& JFactory::getDBO();
$query = $db->getQuery(true);
$type = "language";
$query->select('a.element');
$query->from('#__extensions AS a');
$type = $db->Quote($type);
$query->where('(a.type = '.$type.')');
$query->group('a.element');
$db->setQuery($query);
$langlist = $db->loadObjectList();
echo 'Copy Administration Modules language(s) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a><br>';
$src=JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomleague'.DS.'modules';
$dest=JPATH_ADMINISTRATOR.DS.'modules';
$modules = JFolder::folders($src);
foreach ( $langlist as $key )
{
echo 'Copy Administration Modules language( '.$key->element.' ) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a><br>';
foreach ($modules as $module)
{
if ( JFolder::exists($src.DS.$module.DS.'language'.DS.$key->element) )
{
JFolder::copy($src.DS.$module.DS.'language'.DS.$key->element, JPATH_ADMINISTRATOR.DS.'language'.DS.$key->element, '', true);
echo ' - <span style="color:green">'.JText::_('Success -> '.$module.' - '.$key->element).'</span><br />';
}
}
}
//echo ' - <span style="color:green">'.JText::_('Success').'</span><br />';
echo 'Copy Administration Module(s)';
JFolder::copy($src, $dest, '', true);
echo ' - <span style="color:green">'.JText::_('Success').'</span><br />';
// echo 'Copy Site Module(s) language(s) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a>';
$src=JPATH_SITE.DS.'components'.DS.'com_joomleague'.DS.'modules';
$dest=JPATH_SITE.DS.'modules';
$modules = JFolder::folders($src);
foreach ( $langlist as $key )
{
echo 'Copy Site Module(s) language( '.$key->element.' ) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a><br>';
foreach ($modules as $module)
{
if ( JFolder::exists($src.DS.$module.DS.'language'.DS.$key->element) )
{
JFolder::copy($src.DS.$module.DS.'language'.DS.$key->element, JPATH_SITE.DS.'language'.DS.$key->element, '', true);
echo ' - <span style="color:green">'.JText::_('Success -> '.$module.' - '.$key->element).'</span><br />';
}
}
}
//echo ' - <span style="color:green">'.JText::_('Success').'</span><br />';
echo 'Copy Site Module(s)';
JFolder::copy($src, $dest, '', true);
echo ' - <span style="color:green">'.JText::_('Success').'</span><br />';
/*
$title = 'JL2 diddipoeler GitHub Commits Module';
$tblModules = JTable::getInstance('module');
$tblModules->load(array('title'=>$title));
$tblModules->title = $title;
$tblModules->module = 'mod_joomleague_github';
$tblModules->position = 'cpanel';
$tblModules->published = 1;
$tblModules->client_id = 1;
$tblModules->ordering = 1;
$tblModules->access = 3;
$tblModules->language = '*';
$tblModules->publish_up = '2000-00-00 00:00:00';
$tblModules->params = '{"username":"diddipoeler","repo":"joomleague-2-komplettpaket","count":15,"relativeTime":"1","layout":"_:default","moduleclass_sfx":"","cache":"1","cache_time":"900","cachemode":"static"}';
if (!$tblModules->store()) {
echo $tblModules->getError().'<br />';
}
$db = JFactory::getDBO();
$query = 'INSERT INTO #__modules_menu (moduleid,menuid) VALUES ('.$tblModules->id.',0)';
$db->setQuery($query);
if (!$db->query())
{
//echo $db->getErrorMsg().'<br />';
}
// Initialise variables
$conf = JFactory::getConfig();
$dispatcher = JDispatcher::getInstance();
$options = array(
'defaultgroup' => ($tblModules->module) ? $tblModules->module : (isset($this->option) ? $this->option : JRequest::getCmd('option')),
'cachebase' => ($tblModules->client_id) ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache'));
$cache = JCache::getInstance('callback', $options);
$cache->clean();
// Trigger the onContentCleanCache event.
$dispatcher->trigger('onContentCleanCache', $options);
*/
}
/**
* method to install the plugins
*
* @return void
*/
public function installPlugins()
{
$mainframe =& JFactory::getApplication();
// $lang = JFactory::getLanguage();
// $languages = JLanguageHelper::getLanguages('lang_code');
$db =& JFactory::getDBO();
$query = $db->getQuery(true);
$type = "language";
$query->select('a.element');
$query->from('#__extensions AS a');
$type = $db->Quote($type);
$query->where('(a.type = '.$type.')');
$query->group('a.element');
$db->setQuery($query);
$langlist = $db->loadObjectList();
// echo 'Copy Plugin(s) language(s) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a>';
$src=JPATH_SITE.DS.'components'.DS.'com_joomleague'.DS.'plugins';
$dest=JPATH_SITE.DS.'plugins';
$groups = JFolder::folders($src);
foreach ( $langlist as $key )
{
echo 'Copy Plugin(s) language( '.$key->element.' ) provided by <a href="https://opentranslators.transifex.com/projects/p/joomleague/">Transifex</a><br />';
foreach ($groups as $group)
{
$plugins = JFolder::folders($src.DS.$group);
foreach ($plugins as $plugin)
{
if ( JFolder::exists($src.DS.$group.DS.$plugin.DS.'language'.DS.$key->element) )
{
JFolder::copy($src.DS.$group.DS.$plugin.DS.'language'.DS.$key->element, JPATH_ADMINISTRATOR.DS.'language'.DS.$key->element, '', true);
echo ' - <span style="color:green">'.JText::_('Success -> '.$group.' - '.$plugin.' - '.$key->element).'</span><br />';
}
}
}
}
//echo ' - <span style="color:green">'.JText::_('Success').'</span><br />';
echo 'Copy Plugin(s)';
JFolder::copy($src, $dest, '', true);
echo ' - <span style="color:green">'.JText::_('Success').'</span><br />';
}
public function insertVersionString()
{
$mainframe =& JFactory::getApplication();
$tblVersion = JTable::getInstance("Version", "Table");
$teile = explode(".", $this->release);
$tblVersion->major = $teile[0];
$tblVersion->minor = $teile[1];
$tblVersion->build = $teile[2];
$tblVersion->revision = '-diddipoeler';
$tblVersion->date = NULL;
$tblVersion->version = 'a';
$tblVersion->file = 'joomleague';
if (!$tblVersion->store())
{
echo($tblVersion->getError());
}
}
public function updateDatabase()
{
$mainframe =& JFactory::getApplication();
$to = '[email protected]';
$subject = 'JoomLeague 2.0 Complete Installation';
$message = 'JoomLeague 2.0 Complete Installation wurde auf der Seite : '.JURI::base().' gestartet.';
JUtility::sendMail( '', JURI::base(), $to, $subject, $message );
if ( $this->release == $this->getParam('version') )
{
// kein update, da die selbe version installiert wird
}
else
{
$db =& JFactory::getDBO();
$db_table = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomleague'.DS.'sql'.DS.'updates'.DS.$this->release.'.sql';
$result = JInstallationHelper::populateDatabase($db, $db_table, $errors);
}
// $params = JComponentHelper::getParams('com_joomleague');
// $xmlfile = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomleague'.DS.'config.xml';
// $jRegistry = new JRegistry;
// $jRegistry->loadString($params->toString('ini'), 'ini');
// $form =& JForm::getInstance('com_joomleague', $xmlfile, array('control'=> 'params'), false, "/config");
// $form->bind($jRegistry);
// diddipoeler
// erstmal keine weiterleitung
/*
$mainframe->enqueueMessage(JText::_('Sie werden gleich zum Tabellenupdate weitergeleitet !'),'Notice');
$restart_link = JURI::base() . 'index.php?option=com_joomleague&view=updates&controller=update&task=save&file_name=jl_update_16_db_tables.php';
echo '<meta http-equiv="refresh" content="6; URL='.$restart_link.'">';
*/
// echo '<iframe height="400" scrolling="auto" width="100%" src="index.php?option=com_joomleague&view=updates&task=update.save&file_name=jl_update_db_tables.php&tmpl=component&print=1" frameborder="0" ></iframe>';
}
/**
* method to install the component
*
* @return void
*/
public function install($parent)
{
?>
<hr>
<h1>JoomLeague Installation</h1>
<?php
self::_install(false);
}
/**
* method to update the component
*
* @return void
*/
public function update($parent)
{
$db = JFactory::getDBO();
$result = $db->getTableFields( '#__joomleague_version_history' );
//echo '<pre>'.print_r( $result, true ).'</pre><br>';
if ( array_key_exists('version', $result['#__joomleague_version_history'] ) )
{
//echo 'vorhanden<br>';
}
else
{
//echo 'nicht vorhanden<br>';
$query2 = "ALTER TABLE `#__joomleague_version_history` ADD `version` VARCHAR(255) NOT NULL DEFAULT '' AFTER `text`;";
$db->setQuery($query2);
if (!$db->query())
{
} else {
//echo "-> done !<br>";
}
}
?>
<hr>
<h1>JoomLeague Update</h1>
<?php
/*
// eine tabelle mit allen spalten
$query = "SELECT ordinal_position
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = '#__joomleague_version_history'
and column_name = 'version' ";
$db->setQuery($query);
$table_field = $db->loadResult();
if ( !$table_field )
{
$query2 = "ALTER TABLE `#__joomleague_version_history` ADD `version` VARCHAR(255) NOT NULL DEFAULT '' AFTER `text`;";
$db->setQuery($query2);
if (!$db->query())
{
// echo '-> '.JText::_('Failed').'! <br>';
// $this->setError($db->getErrorMsg());
// echo $db->getErrorMsg();
//return false;
} else {
//echo "-> done !<br>";
}
}
*/
self::_install(true);
}
public function migratePicturePath() {
$arrQueries = array();
$query = "update #__joomleague_club set logo_big = replace(logo_big, 'media/com_joomleague/clubs/large', 'images/com_joomleague/database/clubs/large')";
array_push($arrQueries, $query);
$query = "update #__joomleague_club set logo_middle = replace(logo_middle, 'media/com_joomleague/clubs/medium', 'images/com_joomleague/database/clubs/medium')";
array_push($arrQueries, $query);
$query = "update #__joomleague_club set logo_small = replace(logo_small, 'media/com_joomleague/clubs/small', 'images/com_joomleague/database/clubs/small')";
array_push($arrQueries, $query);
$query = "update #__joomleague_eventtype set icon = replace(icon, 'media/com_joomleague/event_icons', 'images/com_joomleague/database/events')";
array_push($arrQueries, $query);
$query = "update #__joomleague_person set picture = replace(picture, 'media/com_joomleague/persons', 'images/com_joomleague/database/persons')";
array_push($arrQueries, $query);
$query = "update #__joomleague_team_player set picture = replace(picture, 'media/com_joomleague/persons', 'images/com_joomleague/database/persons')";
array_push($arrQueries, $query);
$query = "update #__joomleague_project set picture = replace(picture, 'media/com_joomleague/projects', 'images/com_joomleague/database/projects')";
array_push($arrQueries, $query);
$query = "update #__joomleague_playground set picture = replace(picture, 'media/com_joomleague/playgrounds', 'images/com_joomleague/database/playgrounds')";
array_push($arrQueries, $query);
$query = "update #__joomleague_sports_type set icon = replace(icon, 'media/com_joomleague/sportstypes', 'images/com_joomleague/database/sport_types')";
array_push($arrQueries, $query);
$query = "update #__joomleague_team set picture = replace(picture, 'media/com_joomleague/teams', 'images/com_joomleague/database/teams')";
array_push($arrQueries, $query);
$query = "update #__joomleague_project_team set picture = replace(picture, 'media/com_joomleague/teams', 'images/com_joomleague/database/teams')";
array_push($arrQueries, $query);
$query = "update #__joomleague_statistic set icon = replace(icon, 'media/com_joomleague/statistics', 'images/com_joomleague/database/statistics')";
array_push($arrQueries, $query);
$db = JFactory::getDBO();
$query="SHOW TABLES LIKE '%_joomleague%'";
$db->setQuery($query);
$results = $db->loadColumn();
if(is_array($results)) {
echo JText::_('Database Tables Picture Path Migration');
foreach ($arrQueries as $key=>$value) {
$db->setQuery($value);
if (!$db->query())
{
echo '-> '.JText::_('Failed').'! <br>';
$this->setError($db->getErrorMsg());
echo $db->getErrorMsg();
//return false;
} else {
//echo "-> done !<br>";
}
}
echo ' - <span style="color:green">'.JText::_('Success').'</span><br />';
} else {
echo JText::_('No Picture Path Migration neccessary!');
}
}
public function createImagesFolder()
{
echo JText::_('Creating new Image Folder structure');
$dest = JPATH_ROOT.'/images/com_joomleague';
$update = JFolder::exists($dest);
$folders = array('clubs', 'clubs/large', 'clubs/medium', 'clubs/small', 'clubs/trikot_home', 'clubs/trikot_away','events','leagues','divisions','person_playground',
'flags_associations','persons', 'placeholders', 'predictionusers','playgrounds', 'projects','projectreferees','projectteams','projectteams/trikot_home', 'projectteams/trikot_away',
'associations','rosterground','matchreport','seasons','sport_types', 'teams','flags','teamplayers','teamstaffs','venues', 'statistics');
JFolder::create(JPATH_ROOT.'/images/com_joomleague');
JFile::copy(JPATH_ROOT.'/images/index.html', JPATH_ROOT.'/images/com_joomleague/index.html');
JFolder::create(JPATH_ROOT.'/images/com_joomleague/database');
JFile::copy(JPATH_ROOT.'/images/index.html', JPATH_ROOT.'/images/com_joomleague/database/index.html');
foreach ($folders as $folder) {
JFolder::create(JPATH_ROOT.'/images/com_joomleague/database/'.$folder);
JFile::copy(JPATH_ROOT.'/images/index.html', JPATH_ROOT.'/images/com_joomleague/database/'.$folder.'/index.html');
}
foreach ($folders as $folder) {
$from = JPath::clean(JPATH_ROOT.'/media/com_joomleague/'.$folder);
if(JFolder::exists($from)) {
$to = JPath::clean($dest.'/database/'.$folder);
if(!JFolder::exists($to)) {
$ret = JFolder::move($from, $to);
} else {
$ret = JFolder::copy($from, $to, '', true);
//$ret = JFolder::delete($from);
}
}
}
echo ' - <span style="color:green">'.JText::_('Success').'</span><br />';
}
private function _dropTables()
{
$query="SHOW TABLES LIKE '%_joomleague%'";
$db = JFactory::getDBO();
$db->setQuery($query);
$results = $db->loadColumn();
foreach ($results as $result)
{
echo JText::_('removing database tables of JoomLeague -> '.$result).'<br>';
$query='DROP TABLE IF EXISTS `'.$result.'`';
$db->setQuery($query);
if (!$db->query())
{
$this->setError($db->getErrorMsg());
return false;
}
}
/*
// leider falscher zeitpunkt
if (!$db->query())
{
$this->setError($db->getErrorMsg());
return false;
}
*/
return true;
}
public function preflight($route, $adapter)
{
$mainframe =& JFactory::getApplication();
// echo '<br>route -> '.$route.'<br>';
// echo 'adapter -> '.$adapter.'<br>';
//-----------------------------------------------------
//Table `#__extensions` Bugfix needed due a wrong client_id for the update system
//-----------------------------------------------------
// diddipoeler
$jversion = new JVersion();
// Installing component manifest file version
$this->release = $adapter->get( "manifest" )->version;
// Manifest file minimum Joomla version
$this->minimum_joomla_release = $adapter->get( "manifest" )->attributes()->version;
$mainframe->enqueueMessage('<p>Installing component manifest file version = ' . $this->release,'Notice');
$mainframe->enqueueMessage('Current manifest cache commponent version = ' . $this->getParam('version'),'Notice');
$mainframe->enqueueMessage('Installing component manifest file minimum Joomla version = ' . $this->minimum_joomla_release,'Notice');
$mainframe->enqueueMessage('Current Joomla version = ' . $jversion->getShortVersion(),'Notice');
// $mainframe->enqueueMessage(,'Notice');
// $mainframe->enqueueMessage(,'Notice');
// Show the essential information at the install/update back-end
//echo '<p>Installing component manifest file version = ' . $this->release;
//echo '<br />Current manifest cache commponent version = ' . $this->getParam('version');
//echo '<br />Installing component manifest file minimum Joomla version = ' . $this->minimum_joomla_release;
//echo '<br />Current Joomla version = ' . $jversion->getShortVersion();
// abort if the current Joomla release is older
if( version_compare( $jversion->getShortVersion(), $this->minimum_joomla_release, 'lt' ) ) {
Jerror::raiseWarning(null, 'Cannot install com_democompupdate in a Joomla release prior to '.$this->minimum_joomla_release);
return false;
}
// abort if the component being installed is not newer than the currently installed version
if ( $type == 'update' ) {
$oldRelease = $this->getParam('version');
$rel = $oldRelease . ' to ' . $this->release;
if ( version_compare( $this->release, $oldRelease, 'le' ) ) {
Jerror::raiseWarning(null, 'Incorrect version sequence. Cannot upgrade ' . $rel);
return false;
}
}
else { $rel = $this->release; }
//echo '<p>' . JText::_('COM_DEMOCOMPUPDATE_PREFLIGHT_' . $type . ' ' . $rel) . '</p>';
$mainframe->enqueueMessage(JText::_('Joomleague Preflight : ' . $route . ' ' . $rel. '</p>'),'Notice');
}
public function postflight($route, $adapter)
{
$mainframe =& JFactory::getApplication();
$db = JFactory::getDbo();
// echo '<br>route -> '.$route.'<br>';
// echo 'adapter -> '.$adapter.'<br>';
/*
// always create or modify these parameters
$params['my_param0'] = 'Component version ' . $this->release;
$params['my_param1'] = 'Another value';
// define the following parameters only if it is an original install
if ( $type == 'install' ) {
$params['my_param2'] = '4';
$params['my_param3'] = 'Star';
}
*/
/*
$params = JComponentHelper::getParams('com_joomleague');
$xmlfile = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomleague'.DS.'config.xml';
$jRegistry = new JRegistry;
$jRegistry->loadString($params->toString('ini'), 'ini');
$form =& JForm::getInstance('com_joomleague', $xmlfile, array('control'=> 'params'), false, "/config");
$form->bind($jRegistry);
*/
$paramsdata = JComponentHelper::getParams('com_joomleague');
$paramsdefs = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomleague'.DS.'config.xml';
$params = new JParameter( $paramsdata, $paramsdefs );
$jRegistry = new JRegistry();
//$jRegistry->loadArray($params);
$jRegistry->loadString($params->toString('ini'), 'ini');
$newparams = $jRegistry->toString();
// store the combined new and existing values back as a JSON string
/*
$db->setQuery('UPDATE #__extensions SET params = ' .
$db->quote( $newparams ) .
' WHERE name = "joomleague"' );
$db->query();
*/
//$mainframe->enqueueMessage(JText::_('newparams<br><pre>'.print_r($newparams,true).'</pre>' ),'');
//$this->setParams( $form );
// echo '<p>' . JText::_('COM_DEMOCOMPUPDATE_POSTFLIGHT ' . $route . ' to ' . $this->release) . '</p>';
$mainframe->enqueueMessage(JText::_('Joomleague Postflight : ' . $route . ' to ' . $this->release),'Notice');
$db = JFactory::getDBO();
$query="UPDATE `#__extensions` SET client_id=1 WHERE name='joomleague'";
$db->setQuery($query);
if (!$db->query()) {
echo $db->getErrorMsg();
}
}
/*
* get a variable from the manifest file (actually, from the manifest cache).
*/
function getParam( $name ) {
$db = JFactory::getDbo();
$db->setQuery('SELECT manifest_cache FROM #__extensions WHERE name = "joomleague" and type = "component" ');
$manifest = json_decode( $db->loadResult(), true );
return $manifest[ $name ];
}
/*
* sets parameter values in the component's row of the extension table
*/
function setParams($param_array) {
$db = JFactory::getDbo();
if ( count($param_array) > 0 ) {
// read the existing component value(s)
$db = JFactory::getDbo();
$db->setQuery('SELECT params FROM #__extensions WHERE name = "joomleague"');
$params = json_decode( $db->loadResult(), true );
// add the new variable(s) to the existing one(s)
foreach ( $param_array as $name => $value ) {
$params[ (string) $name ] = (string) $value;
}
// store the combined new and existing values back as a JSON string
$paramsString = json_encode( $params );
$db->setQuery('UPDATE #__extensions SET params = ' .
$db->quote( $paramsString ) .
' WHERE name = "joomleague"' );
$db->query();
}
}
public function uninstall($adapter)
{
$params =& JComponentHelper::getParams('com_joomleague');
//Also uninstall db tables of JoomLeague?
$uninstallDB = $params->get('cfg_drop_joomleague_tables_when_uninstalled',0);
if ($uninstallDB)
{
echo JText::_('Also removing database tables of JoomLeague');
self::_dropTables();
}
else
{
echo JText::_('Database tables of JoomLeague are not removed');
}
?>
<div class="header">JoomLeague now has been removed from your system!</div>
<p>We're sorry to see you go!</p>
<p>To completely remove Joomleague from your system, be sure to also
uninstall the JoomLeague modules and languages.</p>
<?php
return true;
}
}