! [Install-testdata plugin] Added the ability to purge canned replies and preferences (including monitor/ignore lists)
gruffen

gruffen commited on 2011-08-05 04:40:35
Showing 5 changed files, with 32 additions and 2 deletions.

... ...
@@ -48,8 +48,10 @@ $txt['shdp_install_testdata_nothingselected'] = 'No options were selected, nothi
48 48
 
49 49
 $txt['shdp_install_testdata_purge_actionlog'] = 'Remove all existing action log entries';
50 50
 $txt['shdp_install_testdata_purge_attachments'] = 'Remove all existing attachments to tickets (leaving forum attachments alone)';
51
+$txt['shdp_install_testdata_purge_cannedreplies'] = 'Remove all existing canned replies';
51 52
 $txt['shdp_install_testdata_purge_cf'] = 'Remove ALL custom value information';
52 53
 $txt['shdp_install_testdata_purge_cf_values'] = 'Remove only the values from custom fields (leave the fields intact)';
54
+$txt['shdp_install_testdata_purge_prefs'] = 'Remove all existing user preferences (including monitor/ignore) in the helpdesk';
53 55
 $txt['shdp_install_testdata_purge_roles'] = 'Remove all existing roles';
54 56
 $txt['shdp_install_testdata_purge_relationships'] = 'Remove all existing relationships between tickets';
55 57
 
... ...
@@ -48,8 +48,10 @@ $txt['shdp_install_testdata_nothingselected'] = 'No options were selected, nothi
48 48
 
49 49
 $txt['shdp_install_testdata_purge_actionlog'] = 'Remove all existing action log entries';
50 50
 $txt['shdp_install_testdata_purge_attachments'] = 'Remove all existing attachments to tickets (leaving forum attachments alone)';
51
+$txt['shdp_install_testdata_purge_cannedreplies'] = 'Remove all existing canned replies';
51 52
 $txt['shdp_install_testdata_purge_cf'] = 'Remove ALL custom value information';
52 53
 $txt['shdp_install_testdata_purge_cf_values'] = 'Remove only the values from custom fields (leave the fields intact)';
54
+$txt['shdp_install_testdata_purge_prefs'] = 'Remove all existing user preferences (including monitor/ignore) in the helpdesk';
53 55
 $txt['shdp_install_testdata_purge_roles'] = 'Remove all existing roles';
54 56
 $txt['shdp_install_testdata_purge_relationships'] = 'Remove all existing relationships between tickets';
55 57
 
... ...
@@ -48,8 +48,10 @@ $txt['shdp_install_testdata_nothingselected'] = 'No options were selected, nothi
48 48
 
49 49
 $txt['shdp_install_testdata_purge_actionlog'] = 'Remove all existing action log entries';
50 50
 $txt['shdp_install_testdata_purge_attachments'] = 'Remove all existing attachments to tickets (leaving forum attachments alone)';
51
+$txt['shdp_install_testdata_purge_cannedreplies'] = 'Remove all existing canned replies';
51 52
 $txt['shdp_install_testdata_purge_cf'] = 'Remove ALL custom value information';
52 53
 $txt['shdp_install_testdata_purge_cf_values'] = 'Remove only the values from custom fields (leave the fields intact)';
54
+$txt['shdp_install_testdata_purge_prefs'] = 'Remove all existing user preferences (including monitor/ignore) in the helpdesk';
53 55
 $txt['shdp_install_testdata_purge_roles'] = 'Remove all existing roles';
54 56
 $txt['shdp_install_testdata_purge_relationships'] = 'Remove all existing relationships between tickets';
55 57
 
... ...
@@ -48,8 +48,10 @@ $txt['shdp_install_testdata_nothingselected'] = 'No options were selected, nothi
48 48
 
49 49
 $txt['shdp_install_testdata_purge_actionlog'] = 'Remove all existing action log entries';
50 50
 $txt['shdp_install_testdata_purge_attachments'] = 'Remove all existing attachments to tickets (leaving forum attachments alone)';
51
+$txt['shdp_install_testdata_purge_cannedreplies'] = 'Remove all existing canned replies';
51 52
 $txt['shdp_install_testdata_purge_cf'] = 'Remove ALL custom value information';
52 53
 $txt['shdp_install_testdata_purge_cf_values'] = 'Remove only the values from custom fields (leave the fields intact)';
54
+$txt['shdp_install_testdata_purge_prefs'] = 'Remove all existing user preferences (including monitor/ignore) in the helpdesk';
53 55
 $txt['shdp_install_testdata_purge_roles'] = 'Remove all existing roles';
54 56
 $txt['shdp_install_testdata_purge_relationships'] = 'Remove all existing relationships between tickets';
55 57
 
... ...
@@ -62,7 +62,7 @@ $lorem = new LoremIpsumGenerator;
62 62
 if (SMF != 'SSI')
63 63
 	fatal_error('This script can only be run via direct link, it cannot be embedded into the forum or helpdesk itself.', false);
64 64
 
65
-$context['shd_delete_rules'] = array('actionlog', 'attachments', 'cf_values', 'cf', 'relationships', 'roles');
65
+$context['shd_delete_rules'] = array('actionlog', 'attachments', 'cannedreplies', 'cf_values', 'cf', 'prefs', 'relationships', 'roles');
66 66
 $context['page_title_html_safe'] = $txt['shdp_install_testdata_title'];
67 67
 template_header();
68 68
 
... ...
@@ -400,9 +400,10 @@ elseif (!empty($_REQUEST['go']) && $_REQUEST['go'] == 'yeah-for-delete')
400 400
 		flush();
401 401
 	}
402 402
 
403
+	// Purging all SD attachments
403 404
 	if (!empty($_POST['purge_attachments']))
404 405
 	{
405
-		// Fetch the SD attachments.
406
+		// Fetch the SD attachments data log.
406 407
 		$attachments = array();
407 408
 		$query = $smcFunc['db_query']('', 'SELECT id_attach FROM {db_prefix}helpdesk_attachments ORDER BY null');
408 409
 		while ($row = $smcFunc['db_fetch_row']($query))
... ...
@@ -425,6 +426,17 @@ elseif (!empty($_REQUEST['go']) && $_REQUEST['go'] == 'yeah-for-delete')
425 426
 		flush();
426 427
 	}
427 428
 
429
+	// Purging canned replies
430
+	if (!empty($_POST['purge_cannedreplies']))
431
+	{
432
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_cannedreplies');
433
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_cannedreplies_cats');
434
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_cannedreplies_depts');
435
+		echo $txt['shdp_install_testdata_purge_cannedreplies'], ' - <strong>', $txt['shdp_install_testdata_completed_purge'], '</strong><br />';
436
+		flush();
437
+	}
438
+
439
+	// Purging custom fields - only the values
428 440
 	if (!empty($_POST['purge_cf_values']))
429 441
 	{
430 442
 		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_custom_fields_values');
... ...
@@ -432,6 +444,7 @@ elseif (!empty($_REQUEST['go']) && $_REQUEST['go'] == 'yeah-for-delete')
432 444
 		flush();
433 445
 	}
434 446
 
447
+	// Purging custom fields - the fields themselves (including any values)
435 448
 	if (!empty($_POST['purge_cf']))
436 449
 	{
437 450
 		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_custom_fields_values');
... ...
@@ -441,6 +454,15 @@ elseif (!empty($_REQUEST['go']) && $_REQUEST['go'] == 'yeah-for-delete')
441 454
 		flush();
442 455
 	}
443 456
 
457
+	// Purging user preferences
458
+	if (!empty($_POST['purge_prefs']))
459
+	{
460
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_preferences');
461
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_notify_override');
462
+		echo $txt['shdp_install_testdata_purge_prefs'], ' - <strong>', $txt['shdp_install_testdata_completed_purge'], '</strong><br />';
463
+		flush();
464
+	}
465
+
444 466
 	// Purging relationships
445 467
 	if (!empty($_POST['purge_relationships']))
446 468
 	{
447 469