forked from Llewellynvdm/Joomla-Sermon-Distributor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.php
2204 lines (2041 loc) · 117 KB
/
script.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
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x
@created 22nd October, 2015
@package Sermon Distributor
@subpackage script.php
@author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.modal');
/**
* Script File of Sermondistributor Component
*/
class com_sermondistributorInstallerScript
{
/**
* Constructor
*
* @param JAdapterInstance $parent The object responsible for running this script
*/
public function __construct(JAdapterInstance $parent) {}
/**
* Called on installation
*
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function install(JAdapterInstance $parent) {}
/**
* Called on uninstallation
*
* @param JAdapterInstance $parent The object responsible for running this script
*/
public function uninstall(JAdapterInstance $parent)
{
// Get Application object
$app = JFactory::getApplication();
// Get The Database object
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Preacher alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.preacher') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$preacher_found = $db->getNumRows();
// Now check if there were any rows
if ($preacher_found)
{
// Since there are load the needed preacher type ids
$preacher_ids = $db->loadColumn();
// Remove Preacher from the content type table
$preacher_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.preacher') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($preacher_condition);
$db->setQuery($query);
// Execute the query to remove Preacher items
$preacher_done = $db->execute();
if ($preacher_done)
{
// If succesfully remove Preacher add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.preacher) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Preacher items from the contentitem tag map table
$preacher_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.preacher') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($preacher_condition);
$db->setQuery($query);
// Execute the query to remove Preacher items
$preacher_done = $db->execute();
if ($preacher_done)
{
// If succesfully remove Preacher add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.preacher) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Preacher items from the ucm content table
$preacher_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_sermondistributor.preacher') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($preacher_condition);
$db->setQuery($query);
// Execute the query to remove Preacher items
$preacher_done = $db->execute();
if ($preacher_done)
{
// If succesfully remove Preacher add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.preacher) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Preacher items are cleared from DB
foreach ($preacher_ids as $preacher_id)
{
// Remove Preacher items from the ucm base table
$preacher_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $preacher_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($preacher_condition);
$db->setQuery($query);
// Execute the query to remove Preacher items
$db->execute();
// Remove Preacher items from the ucm history table
$preacher_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $preacher_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($preacher_condition);
$db->setQuery($query);
// Execute the query to remove Preacher items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Sermon alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.sermon') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$sermon_found = $db->getNumRows();
// Now check if there were any rows
if ($sermon_found)
{
// Since there are load the needed sermon type ids
$sermon_ids = $db->loadColumn();
// Remove Sermon from the content type table
$sermon_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.sermon') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($sermon_condition);
$db->setQuery($query);
// Execute the query to remove Sermon items
$sermon_done = $db->execute();
if ($sermon_done)
{
// If succesfully remove Sermon add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.sermon) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Sermon items from the contentitem tag map table
$sermon_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.sermon') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($sermon_condition);
$db->setQuery($query);
// Execute the query to remove Sermon items
$sermon_done = $db->execute();
if ($sermon_done)
{
// If succesfully remove Sermon add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.sermon) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Sermon items from the ucm content table
$sermon_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_sermondistributor.sermon') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($sermon_condition);
$db->setQuery($query);
// Execute the query to remove Sermon items
$sermon_done = $db->execute();
if ($sermon_done)
{
// If succesfully remove Sermon add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.sermon) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Sermon items are cleared from DB
foreach ($sermon_ids as $sermon_id)
{
// Remove Sermon items from the ucm base table
$sermon_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $sermon_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($sermon_condition);
$db->setQuery($query);
// Execute the query to remove Sermon items
$db->execute();
// Remove Sermon items from the ucm history table
$sermon_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $sermon_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($sermon_condition);
$db->setQuery($query);
// Execute the query to remove Sermon items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Sermon catid alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.sermon.category') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$sermon_catid_found = $db->getNumRows();
// Now check if there were any rows
if ($sermon_catid_found)
{
// Since there are load the needed sermon_catid type ids
$sermon_catid_ids = $db->loadColumn();
// Remove Sermon catid from the content type table
$sermon_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.sermon.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($sermon_catid_condition);
$db->setQuery($query);
// Execute the query to remove Sermon catid items
$sermon_catid_done = $db->execute();
if ($sermon_catid_done)
{
// If succesfully remove Sermon catid add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.sermon.category) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Sermon catid items from the contentitem tag map table
$sermon_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.sermon.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($sermon_catid_condition);
$db->setQuery($query);
// Execute the query to remove Sermon catid items
$sermon_catid_done = $db->execute();
if ($sermon_catid_done)
{
// If succesfully remove Sermon catid add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.sermon.category) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Sermon catid items from the ucm content table
$sermon_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_sermondistributor.sermon.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($sermon_catid_condition);
$db->setQuery($query);
// Execute the query to remove Sermon catid items
$sermon_catid_done = $db->execute();
if ($sermon_catid_done)
{
// If succesfully remove Sermon catid add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.sermon.category) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Sermon catid items are cleared from DB
foreach ($sermon_catid_ids as $sermon_catid_id)
{
// Remove Sermon catid items from the ucm base table
$sermon_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $sermon_catid_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($sermon_catid_condition);
$db->setQuery($query);
// Execute the query to remove Sermon catid items
$db->execute();
// Remove Sermon catid items from the ucm history table
$sermon_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $sermon_catid_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($sermon_catid_condition);
$db->setQuery($query);
// Execute the query to remove Sermon catid items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Series alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.series') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$series_found = $db->getNumRows();
// Now check if there were any rows
if ($series_found)
{
// Since there are load the needed series type ids
$series_ids = $db->loadColumn();
// Remove Series from the content type table
$series_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.series') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($series_condition);
$db->setQuery($query);
// Execute the query to remove Series items
$series_done = $db->execute();
if ($series_done)
{
// If succesfully remove Series add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.series) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Series items from the contentitem tag map table
$series_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.series') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($series_condition);
$db->setQuery($query);
// Execute the query to remove Series items
$series_done = $db->execute();
if ($series_done)
{
// If succesfully remove Series add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.series) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Series items from the ucm content table
$series_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_sermondistributor.series') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($series_condition);
$db->setQuery($query);
// Execute the query to remove Series items
$series_done = $db->execute();
if ($series_done)
{
// If succesfully remove Series add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.series) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Series items are cleared from DB
foreach ($series_ids as $series_id)
{
// Remove Series items from the ucm base table
$series_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $series_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($series_condition);
$db->setQuery($query);
// Execute the query to remove Series items
$db->execute();
// Remove Series items from the ucm history table
$series_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $series_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($series_condition);
$db->setQuery($query);
// Execute the query to remove Series items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Statistic alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.statistic') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$statistic_found = $db->getNumRows();
// Now check if there were any rows
if ($statistic_found)
{
// Since there are load the needed statistic type ids
$statistic_ids = $db->loadColumn();
// Remove Statistic from the content type table
$statistic_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.statistic') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($statistic_condition);
$db->setQuery($query);
// Execute the query to remove Statistic items
$statistic_done = $db->execute();
if ($statistic_done)
{
// If succesfully remove Statistic add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.statistic) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Statistic items from the contentitem tag map table
$statistic_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.statistic') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($statistic_condition);
$db->setQuery($query);
// Execute the query to remove Statistic items
$statistic_done = $db->execute();
if ($statistic_done)
{
// If succesfully remove Statistic add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.statistic) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Statistic items from the ucm content table
$statistic_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_sermondistributor.statistic') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($statistic_condition);
$db->setQuery($query);
// Execute the query to remove Statistic items
$statistic_done = $db->execute();
if ($statistic_done)
{
// If succesfully remove Statistic add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.statistic) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Statistic items are cleared from DB
foreach ($statistic_ids as $statistic_id)
{
// Remove Statistic items from the ucm base table
$statistic_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $statistic_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($statistic_condition);
$db->setQuery($query);
// Execute the query to remove Statistic items
$db->execute();
// Remove Statistic items from the ucm history table
$statistic_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $statistic_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($statistic_condition);
$db->setQuery($query);
// Execute the query to remove Statistic items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where External_source alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.external_source') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$external_source_found = $db->getNumRows();
// Now check if there were any rows
if ($external_source_found)
{
// Since there are load the needed external_source type ids
$external_source_ids = $db->loadColumn();
// Remove External_source from the content type table
$external_source_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.external_source') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($external_source_condition);
$db->setQuery($query);
// Execute the query to remove External_source items
$external_source_done = $db->execute();
if ($external_source_done)
{
// If succesfully remove External_source add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.external_source) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove External_source items from the contentitem tag map table
$external_source_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.external_source') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($external_source_condition);
$db->setQuery($query);
// Execute the query to remove External_source items
$external_source_done = $db->execute();
if ($external_source_done)
{
// If succesfully remove External_source add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.external_source) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove External_source items from the ucm content table
$external_source_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_sermondistributor.external_source') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($external_source_condition);
$db->setQuery($query);
// Execute the query to remove External_source items
$external_source_done = $db->execute();
if ($external_source_done)
{
// If succesfully remove External_source add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.external_source) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the External_source items are cleared from DB
foreach ($external_source_ids as $external_source_id)
{
// Remove External_source items from the ucm base table
$external_source_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $external_source_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($external_source_condition);
$db->setQuery($query);
// Execute the query to remove External_source items
$db->execute();
// Remove External_source items from the ucm history table
$external_source_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $external_source_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($external_source_condition);
$db->setQuery($query);
// Execute the query to remove External_source items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Local_listing alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.local_listing') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$local_listing_found = $db->getNumRows();
// Now check if there were any rows
if ($local_listing_found)
{
// Since there are load the needed local_listing type ids
$local_listing_ids = $db->loadColumn();
// Remove Local_listing from the content type table
$local_listing_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.local_listing') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($local_listing_condition);
$db->setQuery($query);
// Execute the query to remove Local_listing items
$local_listing_done = $db->execute();
if ($local_listing_done)
{
// If succesfully remove Local_listing add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.local_listing) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Local_listing items from the contentitem tag map table
$local_listing_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.local_listing') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($local_listing_condition);
$db->setQuery($query);
// Execute the query to remove Local_listing items
$local_listing_done = $db->execute();
if ($local_listing_done)
{
// If succesfully remove Local_listing add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.local_listing) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Local_listing items from the ucm content table
$local_listing_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_sermondistributor.local_listing') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($local_listing_condition);
$db->setQuery($query);
// Execute the query to remove Local_listing items
$local_listing_done = $db->execute();
if ($local_listing_done)
{
// If succesfully remove Local_listing add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.local_listing) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Local_listing items are cleared from DB
foreach ($local_listing_ids as $local_listing_id)
{
// Remove Local_listing items from the ucm base table
$local_listing_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $local_listing_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($local_listing_condition);
$db->setQuery($query);
// Execute the query to remove Local_listing items
$db->execute();
// Remove Local_listing items from the ucm history table
$local_listing_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $local_listing_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($local_listing_condition);
$db->setQuery($query);
// Execute the query to remove Local_listing items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Help_document alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.help_document') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$help_document_found = $db->getNumRows();
// Now check if there were any rows
if ($help_document_found)
{
// Since there are load the needed help_document type ids
$help_document_ids = $db->loadColumn();
// Remove Help_document from the content type table
$help_document_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.help_document') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($help_document_condition);
$db->setQuery($query);
// Execute the query to remove Help_document items
$help_document_done = $db->execute();
if ($help_document_done)
{
// If succesfully remove Help_document add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.help_document) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Help_document items from the contentitem tag map table
$help_document_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.help_document') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($help_document_condition);
$db->setQuery($query);
// Execute the query to remove Help_document items
$help_document_done = $db->execute();
if ($help_document_done)
{
// If succesfully remove Help_document add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.help_document) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Help_document items from the ucm content table
$help_document_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_sermondistributor.help_document') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($help_document_condition);
$db->setQuery($query);
// Execute the query to remove Help_document items
$help_document_done = $db->execute();
if ($help_document_done)
{
// If succesfully remove Help_document add queued success message.
$app->enqueueMessage(JText::_('The (com_sermondistributor.help_document) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Help_document items are cleared from DB
foreach ($help_document_ids as $help_document_id)
{
// Remove Help_document items from the ucm base table
$help_document_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $help_document_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($help_document_condition);
$db->setQuery($query);
// Execute the query to remove Help_document items
$db->execute();
// Remove Help_document items from the ucm history table
$help_document_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $help_document_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($help_document_condition);
$db->setQuery($query);
// Execute the query to remove Help_document items
$db->execute();
}
}
// If All related items was removed queued success message.
$app->enqueueMessage(JText::_('All related items was removed from the <b>#__ucm_base</b> table'));
$app->enqueueMessage(JText::_('All related items was removed from the <b>#__ucm_history</b> table'));
// Remove sermondistributor assets from the assets table
$sermondistributor_condition = array( $db->quoteName('name') . ' LIKE ' . $db->quote('com_sermondistributor%') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__assets'));
$query->where($sermondistributor_condition);
$db->setQuery($query);
$help_document_done = $db->execute();
if ($help_document_done)
{
// If succesfully remove sermondistributor add queued success message.
$app->enqueueMessage(JText::_('All related items was removed from the <b>#__assets</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Sermondistributor from the action_logs_extensions table
$sermondistributor_action_logs_extensions = array( $db->quoteName('extension') . ' = ' . $db->quote('com_sermondistributor') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_logs_extensions'));
$query->where($sermondistributor_action_logs_extensions);
$db->setQuery($query);
// Execute the query to remove Sermondistributor
$sermondistributor_removed_done = $db->execute();
if ($sermondistributor_removed_done)
{
// If successfully remove Sermondistributor add queued success message.
$app->enqueueMessage(JText::_('The com_sermondistributor extension was removed from the <b>#__action_logs_extensions</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Sermondistributor Preacher from the action_log_config table
$preacher_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.preacher') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($preacher_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_sermondistributor.preacher
$preacher_action_log_config_done = $db->execute();
if ($preacher_action_log_config_done)
{
// If successfully removed Sermondistributor Preacher add queued success message.
$app->enqueueMessage(JText::_('The com_sermondistributor.preacher type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Sermondistributor Sermon from the action_log_config table
$sermon_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.sermon') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($sermon_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_sermondistributor.sermon
$sermon_action_log_config_done = $db->execute();
if ($sermon_action_log_config_done)
{
// If successfully removed Sermondistributor Sermon add queued success message.
$app->enqueueMessage(JText::_('The com_sermondistributor.sermon type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Sermondistributor Series from the action_log_config table
$series_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.series') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($series_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_sermondistributor.series
$series_action_log_config_done = $db->execute();
if ($series_action_log_config_done)
{
// If successfully removed Sermondistributor Series add queued success message.
$app->enqueueMessage(JText::_('The com_sermondistributor.series type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Sermondistributor Statistic from the action_log_config table
$statistic_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.statistic') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($statistic_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_sermondistributor.statistic
$statistic_action_log_config_done = $db->execute();
if ($statistic_action_log_config_done)
{
// If successfully removed Sermondistributor Statistic add queued success message.
$app->enqueueMessage(JText::_('The com_sermondistributor.statistic type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Sermondistributor External_source from the action_log_config table
$external_source_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.external_source') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($external_source_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_sermondistributor.external_source
$external_source_action_log_config_done = $db->execute();
if ($external_source_action_log_config_done)
{
// If successfully removed Sermondistributor External_source add queued success message.
$app->enqueueMessage(JText::_('The com_sermondistributor.external_source type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Sermondistributor Local_listing from the action_log_config table
$local_listing_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.local_listing') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($local_listing_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_sermondistributor.local_listing
$local_listing_action_log_config_done = $db->execute();
if ($local_listing_action_log_config_done)
{
// If successfully removed Sermondistributor Local_listing add queued success message.
$app->enqueueMessage(JText::_('The com_sermondistributor.local_listing type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Sermondistributor Help_document from the action_log_config table
$help_document_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_sermondistributor.help_document') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($help_document_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_sermondistributor.help_document
$help_document_action_log_config_done = $db->execute();
if ($help_document_action_log_config_done)
{
// If successfully removed Sermondistributor Help_document add queued success message.
$app->enqueueMessage(JText::_('The com_sermondistributor.help_document type alias was removed from the <b>#__action_log_config</b> table'));
}
// little notice as after service, in case of bad experience with component.
echo '<h2>Did something go wrong? Are you disappointed?</h2>
<p>Please let me know at <a href="mailto:[email protected]">[email protected]</a>.
<br />We at Vast Development Method are committed to building extensions that performs proficiently! You can help us, really!
<br />Send me your thoughts on improvements that is needed, trust me, I will be very grateful!
<br />Visit us at <a href="https://www.vdm.io/" target="_blank">https://www.vdm.io/</a> today!</p>';
}
/**
* Called on update
*
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function update(JAdapterInstance $parent){}
/**
* Called before any type of action
*
* @param string $type Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($type, JAdapterInstance $parent)
{
// get application
$app = JFactory::getApplication();
// is redundant or so it seems ...hmmm let me know if it works again