forked from Llewellynvdm/Joomla-Questions-and-Answers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.php
557 lines (503 loc) · 34 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
<?php
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
__ __ _ _____ _ _ __ __ _ _ _
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
| |
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 1.0.x
@build 27th December, 2018
@created 30th January, 2017
@package Questions and Answers
@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
Questions & Answers
/-----------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.modal');
/**
* Script File of Questionsanswers Component
*/
class com_questionsanswersInstallerScript
{
/**
* method to install the component
*
* @return void
*/
function install($parent)
{
}
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($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 Question_and_answer alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_questionsanswers.question_and_answer') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$question_and_answer_found = $db->getNumRows();
// Now check if there were any rows
if ($question_and_answer_found)
{
// Since there are load the needed question_and_answer type ids
$question_and_answer_ids = $db->loadColumn();
// Remove Question_and_answer from the content type table
$question_and_answer_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_questionsanswers.question_and_answer') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($question_and_answer_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer items
$question_and_answer_done = $db->execute();
if ($question_and_answer_done)
{
// If succesfully remove Question_and_answer add queued success message.
$app->enqueueMessage(JText::_('The (com_questionsanswers.question_and_answer) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Question_and_answer items from the contentitem tag map table
$question_and_answer_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_questionsanswers.question_and_answer') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($question_and_answer_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer items
$question_and_answer_done = $db->execute();
if ($question_and_answer_done)
{
// If succesfully remove Question_and_answer add queued success message.
$app->enqueueMessage(JText::_('The (com_questionsanswers.question_and_answer) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Question_and_answer items from the ucm content table
$question_and_answer_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_questionsanswers.question_and_answer') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($question_and_answer_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer items
$question_and_answer_done = $db->execute();
if ($question_and_answer_done)
{
// If succesfully remove Question_and_answer add queued success message.
$app->enqueueMessage(JText::_('The (com_questionsanswers.question_and_answer) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Question_and_answer items are cleared from DB
foreach ($question_and_answer_ids as $question_and_answer_id)
{
// Remove Question_and_answer items from the ucm base table
$question_and_answer_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $question_and_answer_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($question_and_answer_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer items
$db->execute();
// Remove Question_and_answer items from the ucm history table
$question_and_answer_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $question_and_answer_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($question_and_answer_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer 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 Question_and_answer catid alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_questionsanswers.questions_and_answers.category') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$question_and_answer_catid_found = $db->getNumRows();
// Now check if there were any rows
if ($question_and_answer_catid_found)
{
// Since there are load the needed question_and_answer_catid type ids
$question_and_answer_catid_ids = $db->loadColumn();
// Remove Question_and_answer catid from the content type table
$question_and_answer_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_questionsanswers.questions_and_answers.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($question_and_answer_catid_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer catid items
$question_and_answer_catid_done = $db->execute();
if ($question_and_answer_catid_done)
{
// If succesfully remove Question_and_answer catid add queued success message.
$app->enqueueMessage(JText::_('The (com_questionsanswers.questions_and_answers.category) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Question_and_answer catid items from the contentitem tag map table
$question_and_answer_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_questionsanswers.questions_and_answers.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($question_and_answer_catid_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer catid items
$question_and_answer_catid_done = $db->execute();
if ($question_and_answer_catid_done)
{
// If succesfully remove Question_and_answer catid add queued success message.
$app->enqueueMessage(JText::_('The (com_questionsanswers.questions_and_answers.category) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Question_and_answer catid items from the ucm content table
$question_and_answer_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_questionsanswers.questions_and_answers.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($question_and_answer_catid_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer catid items
$question_and_answer_catid_done = $db->execute();
if ($question_and_answer_catid_done)
{
// If succesfully remove Question_and_answer catid add queued success message.
$app->enqueueMessage(JText::_('The (com_questionsanswers.questions_and_answers.category) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Question_and_answer catid items are cleared from DB
foreach ($question_and_answer_catid_ids as $question_and_answer_catid_id)
{
// Remove Question_and_answer catid items from the ucm base table
$question_and_answer_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $question_and_answer_catid_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($question_and_answer_catid_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer catid items
$db->execute();
// Remove Question_and_answer catid items from the ucm history table
$question_and_answer_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $question_and_answer_catid_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($question_and_answer_catid_condition);
$db->setQuery($query);
// Execute the query to remove Question_and_answer 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 Help_document alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_questionsanswers.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_questionsanswers.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_questionsanswers.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_questionsanswers.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_questionsanswers.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_questionsanswers.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_questionsanswers.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 questionsanswers assets from the assets table
$questionsanswers_condition = array( $db->quoteName('name') . ' LIKE ' . $db->quote('com_questionsanswers%') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__assets'));
$query->where($questionsanswers_condition);
$db->setQuery($query);
$help_document_done = $db->execute();
if ($help_document_done)
{
// If succesfully remove questionsanswers add queued success message.
$app->enqueueMessage(JText::_('All related items was removed from the <b>#__assets</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>';
}
/**
* method to update the component
*
* @return void
*/
function update($parent)
{
}
/**
* method to run before an install/update/uninstall method
*
* @return void
*/
function preflight($type, $parent)
{
// get application
$app = JFactory::getApplication();
// is redundant ...hmmm
if ($type == 'uninstall')
{
return true;
}
// the default for both install and update
$jversion = new JVersion();
if (!$jversion->isCompatible('3.6.0'))
{
$app->enqueueMessage('Please upgrade to at least Joomla! 3.6.0 before continuing!', 'error');
return false;
}
// do any updates needed
if ($type == 'update')
{
}
// do any install needed
if ($type == 'install')
{
}
}
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
function postflight($type, $parent)
{
// get application
$app = JFactory::getApplication();
// set the default component settings
if ($type == 'install')
{
// Get The Database object
$db = JFactory::getDbo();
// Create the question_and_answer content type object.
$question_and_answer = new stdClass();
$question_and_answer->type_title = 'Questionsanswers Question_and_answer';
$question_and_answer->type_alias = 'com_questionsanswers.question_and_answer';
$question_and_answer->table = '{"special": {"dbtable": "#__questionsanswers_question_and_answer","key": "id","type": "Question_and_answer","prefix": "questionsanswersTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$question_and_answer->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "answer","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"question":"question","answer":"answer","answer_documents":"answer_documents","main_image":"main_image"}}';
$question_and_answer->router = 'QuestionsanswersHelperRoute::getQuestion_and_answerRoute';
$question_and_answer->content_history_options = '{"formFile": "administrator/components/com_questionsanswers/models/forms/question_and_answer.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","answer_documents","main_image"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","catid"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$question_and_answer_Inserted = $db->insertObject('#__content_types', $question_and_answer);
// Create the question_and_answer category content type object.
$question_and_answer_category = new stdClass();
$question_and_answer_category->type_title = 'Questionsanswers Question_and_answer Catid';
$question_and_answer_category->type_alias = 'com_questionsanswers.questions_and_answers.category';
$question_and_answer_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
$question_and_answer_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
$question_and_answer_category->router = 'QuestionsanswersHelperRoute::getCategoryRoute';
$question_and_answer_category->content_history_options = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}';
// Set the object into the content types table.
$question_and_answer_category_Inserted = $db->insertObject('#__content_types', $question_and_answer_category);
// Create the help_document content type object.
$help_document = new stdClass();
$help_document->type_title = 'Questionsanswers Help_document';
$help_document->type_alias = 'com_questionsanswers.help_document';
$help_document->table = '{"special": {"dbtable": "#__questionsanswers_help_document","key": "id","type": "Help_document","prefix": "questionsanswersTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$help_document->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "title","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "content","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"title":"title","type":"type","groups":"groups","location":"location","admin_view":"admin_view","site_view":"site_view","not_required":"not_required","content":"content","article":"article","url":"url","target":"target","alias":"alias"}}';
$help_document->router = 'QuestionsanswersHelperRoute::getHelp_documentRoute';
$help_document->content_history_options = '{"formFile": "administrator/components/com_questionsanswers/models/forms/help_document.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","type","location","not_required","article","target"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "article","targetTable": "#__content","targetColumn": "id","displayColumn": "title"}]}';
// Set the object into the content types table.
$help_document_Inserted = $db->insertObject('#__content_types', $help_document);
// Install the global extenstion params.
$query = $db->getQuery(true);
// Field to update.
$fields = array(
$db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"[email protected]","crop_main":"0","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_load":"1","uikit_min":"","uikit_style":""}'),
);
// Condition.
$conditions = array(
$db->quoteName('element') . ' = ' . $db->quote('com_questionsanswers')
);
$query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions);
$db->setQuery($query);
$allDone = $db->execute();
echo '<a target="_blank" href="https://www.vdm.io/" title="Questions and Answers">
<img src="components/com_questionsanswers/assets/images/vdm-component.jpg"/>
</a>';
}
// do any updates needed
if ($type == 'update')
{
// Get The Database object
$db = JFactory::getDbo();
// Create the question_and_answer content type object.
$question_and_answer = new stdClass();
$question_and_answer->type_title = 'Questionsanswers Question_and_answer';
$question_and_answer->type_alias = 'com_questionsanswers.question_and_answer';
$question_and_answer->table = '{"special": {"dbtable": "#__questionsanswers_question_and_answer","key": "id","type": "Question_and_answer","prefix": "questionsanswersTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$question_and_answer->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "answer","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"question":"question","answer":"answer","answer_documents":"answer_documents","main_image":"main_image"}}';
$question_and_answer->router = 'QuestionsanswersHelperRoute::getQuestion_and_answerRoute';
$question_and_answer->content_history_options = '{"formFile": "administrator/components/com_questionsanswers/models/forms/question_and_answer.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","answer_documents","main_image"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","catid"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Check if question_and_answer type is already in content_type DB.
$question_and_answer_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($question_and_answer->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$question_and_answer->type_id = $db->loadResult();
$question_and_answer_Updated = $db->updateObject('#__content_types', $question_and_answer, 'type_id');
}
else
{
$question_and_answer_Inserted = $db->insertObject('#__content_types', $question_and_answer);
}
// Create the question_and_answer category content type object.
$question_and_answer_category = new stdClass();
$question_and_answer_category->type_title = 'Questionsanswers Question_and_answer Catid';
$question_and_answer_category->type_alias = 'com_questionsanswers.questions_and_answers.category';
$question_and_answer_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
$question_and_answer_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
$question_and_answer_category->router = 'QuestionsanswersHelperRoute::getCategoryRoute';
$question_and_answer_category->content_history_options = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}';
// Check if question_and_answer category type is already in content_type DB.
$question_and_answer_category_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($question_and_answer_category->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$question_and_answer_category->type_id = $db->loadResult();
$question_and_answer_category_Updated = $db->updateObject('#__content_types', $question_and_answer_category, 'type_id');
}
else
{
$question_and_answer_category_Inserted = $db->insertObject('#__content_types', $question_and_answer_category);
}
// Create the help_document content type object.
$help_document = new stdClass();
$help_document->type_title = 'Questionsanswers Help_document';
$help_document->type_alias = 'com_questionsanswers.help_document';
$help_document->table = '{"special": {"dbtable": "#__questionsanswers_help_document","key": "id","type": "Help_document","prefix": "questionsanswersTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$help_document->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "title","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "content","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"title":"title","type":"type","groups":"groups","location":"location","admin_view":"admin_view","site_view":"site_view","not_required":"not_required","content":"content","article":"article","url":"url","target":"target","alias":"alias"}}';
$help_document->router = 'QuestionsanswersHelperRoute::getHelp_documentRoute';
$help_document->content_history_options = '{"formFile": "administrator/components/com_questionsanswers/models/forms/help_document.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","type","location","not_required","article","target"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "article","targetTable": "#__content","targetColumn": "id","displayColumn": "title"}]}';
// Check if help_document type is already in content_type DB.
$help_document_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($help_document->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$help_document->type_id = $db->loadResult();
$help_document_Updated = $db->updateObject('#__content_types', $help_document, 'type_id');
}
else
{
$help_document_Inserted = $db->insertObject('#__content_types', $help_document);
}
echo '<a target="_blank" href="https://www.vdm.io/" title="Questions and Answers">
<img src="components/com_questionsanswers/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 1.0.2 Was Successful! Let us know if anything is not working as expected.</h3>';
}
}
}