! [Install-testdata plugin] Add ability to purge custom fields and their values.
gruffen

gruffen commited on 2011-08-01 05:02:19
Showing 5 changed files, with 25 additions and 1 deletions.

... ...
@@ -47,6 +47,8 @@ $txt['shdp_install_testdata_warning'] = 'These options are primarily for testing
47 47
 $txt['shdp_install_testdata_nothingselected'] = 'No options were selected, nothing can be removed for that reason.';
48 48
 
49 49
 $txt['shdp_install_testdata_purge_actionlog'] = 'Remove all existing action log entries';
50
+$txt['shdp_install_testdata_purge_cf'] = 'Remove ALL custom value information';
51
+$txt['shdp_install_testdata_purge_cf_values'] = 'Remove only the values from custom fields (leave the fields intact)';
50 52
 $txt['shdp_install_testdata_purge_roles'] = 'Remove all existing roles';
51 53
 $txt['shdp_install_testdata_purge_relationships'] = 'Remove all existing relationships between tickets';
52 54
 
... ...
@@ -47,6 +47,8 @@ $txt['shdp_install_testdata_warning'] = 'These options are primarily for testing
47 47
 $txt['shdp_install_testdata_nothingselected'] = 'No options were selected, nothing can be removed for that reason.';
48 48
 
49 49
 $txt['shdp_install_testdata_purge_actionlog'] = 'Remove all existing action log entries';
50
+$txt['shdp_install_testdata_purge_cf'] = 'Remove ALL custom value information';
51
+$txt['shdp_install_testdata_purge_cf_values'] = 'Remove only the values from custom fields (leave the fields intact)';
50 52
 $txt['shdp_install_testdata_purge_roles'] = 'Remove all existing roles';
51 53
 $txt['shdp_install_testdata_purge_relationships'] = 'Remove all existing relationships between tickets';
52 54
 
... ...
@@ -47,6 +47,8 @@ $txt['shdp_install_testdata_warning'] = 'These options are primarily for testing
47 47
 $txt['shdp_install_testdata_nothingselected'] = 'No options were selected, nothing can be removed for that reason.';
48 48
 
49 49
 $txt['shdp_install_testdata_purge_actionlog'] = 'Remove all existing action log entries';
50
+$txt['shdp_install_testdata_purge_cf'] = 'Remove ALL custom value information';
51
+$txt['shdp_install_testdata_purge_cf_values'] = 'Remove only the values from custom fields (leave the fields intact)';
50 52
 $txt['shdp_install_testdata_purge_roles'] = 'Remove all existing roles';
51 53
 $txt['shdp_install_testdata_purge_relationships'] = 'Remove all existing relationships between tickets';
52 54
 
... ...
@@ -47,6 +47,8 @@ $txt['shdp_install_testdata_warning'] = 'These options are primarily for testing
47 47
 $txt['shdp_install_testdata_nothingselected'] = 'No options were selected, nothing can be removed for that reason.';
48 48
 
49 49
 $txt['shdp_install_testdata_purge_actionlog'] = 'Remove all existing action log entries';
50
+$txt['shdp_install_testdata_purge_cf'] = 'Remove ALL custom value information';
51
+$txt['shdp_install_testdata_purge_cf_values'] = 'Remove only the values from custom fields (leave the fields intact)';
50 52
 $txt['shdp_install_testdata_purge_roles'] = 'Remove all existing roles';
51 53
 $txt['shdp_install_testdata_purge_relationships'] = 'Remove all existing relationships between tickets';
52 54
 
... ...
@@ -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', 'relationships', 'roles');
65
+$context['shd_delete_rules'] = array('actionlog', 'cf_values', 'cf', 'relationships', 'roles');
66 66
 $context['page_title_html_safe'] = $txt['shdp_install_testdata_title'];
67 67
 template_header();
68 68
 
... ...
@@ -400,6 +400,22 @@ elseif (!empty($_REQUEST['go']) && $_REQUEST['go'] == 'yeah-for-delete')
400 400
 		flush();
401 401
 	}
402 402
 
403
+	if (!empty($_POST['purge_cf_values']))
404
+	{
405
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_custom_fields_values');
406
+		echo $txt['shdp_install_testdata_purge_cf_values'], ' - <strong>', $txt['shdp_install_testdata_completed_purge'], '</strong><br />';
407
+		flush();
408
+	}
409
+
410
+	if (!empty($_POST['purge_cf']))
411
+	{
412
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_custom_fields_values');
413
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_custom_fields_depts');
414
+		$smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_custom_fields');
415
+		echo $txt['shdp_install_testdata_purge_cf'], ' - <strong>', $txt['shdp_install_testdata_completed_purge'], '</strong><br />';
416
+		flush();
417
+	}
418
+
403 419
 	// Purging relationships
404 420
 	if (!empty($_POST['purge_relationships']))
405 421
 	{
406 422