From 433c99d1f089184dc8f6d4d9b13e370c7b9da543 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 14 May 2005 22:31:33 +0000 Subject: [PATCH] r137: Adding datatools.php and datatools_store.php which are used to insert the default table data (except phrases). --- docs/datatools.php | 130 +++++++++++++++++++++++++++++++++++++++ docs/datatools_store.php | 8 +++ 2 files changed, 138 insertions(+) create mode 100644 docs/datatools.php create mode 100644 docs/datatools_store.php diff --git a/docs/datatools.php b/docs/datatools.php new file mode 100644 index 0000000..019829a --- /dev/null +++ b/docs/datatools.php @@ -0,0 +1,130 @@ + array('table' => db table, 'rebuild' => rebuild function) + +$THELIST = array( + 'usergroups' => array( + 'table' => 'usergroup', + 'rebuild' => 'build_usergroups' + ), + + 'statuses' => array( + 'table' => 'status', + 'rebuild' => 'build_statuses' + ), + + 'severity' => array( + 'table' => 'severity', + 'rebuild' => 'build_severities' + ), + + 'priorities' => array( + 'table' => 'priority', + 'rebuild' => 'build_priorities' + ), + + 'resolutions' => array( + 'table' => 'resolution', + 'rebuild' => 'build_resolutions' + ) +); + +?> + +

Data Tools

+ +Here you can either export or import the standard data tables for BugStrike. These include things such as usergroups, priorities, etc. However phrases are not handled here, but instead with lang_file_to_db.php + +

[Export] [Import]

+ +
+ +
+
+ $data)
+	{
+		$fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "$data[table] ORDER BY {$data[table]}id ASC");
+		while ($fitem = $db->fetch_array($fetch))
+		{
+			$exportlist["$display"][] = $fitem;
+		}
+		$db->free_result($fetch);
+		
+		echo "Exported $display\n";
+	}
+	
+	$phpfile = '';
+	
+	if ($handle = fopen('./docs/datatools_store.php', 'w'))
+	{
+		if (fwrite($handle, $phpfile))
+		{
+			fclose($handle);
+		}
+		else
+		{
+			echo 'Could not write the file';
+			exit;
+		}
+	}
+	else
+	{
+		echo 'Could not open the file with mode "w"';
+		exit;
+	}
+	
+	echo "Wrote the file\n";
+}
+
+// ###################################################################
+
+if ($_REQUEST['do'] == 'import')
+{
+	require('./docs/datatools_store.php');
+	$DATASTORE = unserialize(stripslashes($DATASTORE));
+	
+	foreach ($THELIST AS $display => $data)
+	{
+		$db->query("TRUNCATE TABLE " . TABLE_PREFIX . "$data[table]");
+		
+		$fields = array();
+		$values = array();
+		foreach ($DATASTORE["$display"] AS $mainarray)
+		{
+			$fields = $values = array();
+			foreach ($mainarray AS $field => $value)
+			{
+				$fields[] = $field;
+				$values[] = "'" . $bugsys->escape($value) . "'";
+			}
+			$query = "INSERT INTO " . TABLE_PREFIX . "$data[table] (" . implode(', ', $fields) . ") VALUES (" . implode(', ', $values) . ")";
+			echo str_replace(array('>', '<'), array('>', '<'), $query) . "\n";
+			$db->query($query);
+		}
+		
+		$data['rebuild']();
+		echo "Rebuilding $data[table]\n\n";
+	}
+}
+
+?>
\ No newline at end of file
diff --git a/docs/datatools_store.php b/docs/datatools_store.php
new file mode 100644
index 0000000..ff0c8f7
--- /dev/null
+++ b/docs/datatools_store.php
@@ -0,0 +1,8 @@
+\";s:8:\"closetag\";s:9:\"\";s:11:\"permissions\";s:7:\"3153919\";}i:5;a:6:{s:11:\"usergroupid\";s:1:\"6\";s:5:\"title\";s:14:\"Administrators\";s:12:\"displaytitle\";s:13:\"Administrator\";s:7:\"opentag\";s:12:\"\";s:8:\"closetag\";s:14:\"\";s:11:\"permissions\";s:7:\"4194303\";}}s:8:\"statuses\";a:6:{i:0;a:4:{s:8:\"statusid\";s:1:\"1\";s:6:\"status\";s:11:\"Unconfirmed\";s:12:\"displayorder\";s:1:\"1\";s:5:\"color\";s:7:\"#FFBBAA\";}i:1;a:4:{s:8:\"statusid\";s:1:\"2\";s:6:\"status\";s:8:\"Verified\";s:12:\"displayorder\";s:1:\"2\";s:5:\"color\";s:7:\"#99BBAA\";}i:2;a:4:{s:8:\"statusid\";s:1:\"3\";s:6:\"status\";s:8:\"Assigned\";s:12:\"displayorder\";s:1:\"3\";s:5:\"color\";s:7:\"#BBAAFF\";}i:3;a:4:{s:8:\"statusid\";s:1:\"4\";s:6:\"status\";s:8:\"Resolved\";s:12:\"displayorder\";s:1:\"4\";s:5:\"color\";s:7:\"#AAFFBB\";}i:4;a:4:{s:8:\"statusid\";s:1:\"5\";s:6:\"status\";s:6:\"Closed\";s:12:\"displayorder\";s:1:\"5\";s:5:\"color\";s:7:\"#AAAAAA\";}i:5;a:4:{s:8:\"statusid\";s:1:\"6\";s:6:\"status\";s:8:\"Reopened\";s:12:\"displayorder\";s:1:\"6\";s:5:\"color\";s:7:\"#BBEEFF\";}}s:8:\"severity\";a:5:{i:0;a:3:{s:10:\"severityid\";s:1:\"1\";s:8:\"severity\";s:7:\"Trivial\";s:12:\"displayorder\";s:1:\"1\";}i:1;a:3:{s:10:\"severityid\";s:1:\"2\";s:8:\"severity\";s:5:\"Minor\";s:12:\"displayorder\";s:1:\"2\";}i:2;a:3:{s:10:\"severityid\";s:1:\"3\";s:8:\"severity\";s:8:\"Moderate\";s:12:\"displayorder\";s:1:\"3\";}i:3;a:3:{s:10:\"severityid\";s:1:\"4\";s:8:\"severity\";s:5:\"Major\";s:12:\"displayorder\";s:1:\"4\";}i:4;a:3:{s:10:\"severityid\";s:1:\"5\";s:8:\"severity\";s:8:\"Critical\";s:12:\"displayorder\";s:1:\"5\";}}s:10:\"priorities\";a:5:{i:0;a:3:{s:10:\"priorityid\";s:1:\"1\";s:8:\"priority\";s:6:\"Normal\";s:12:\"displayorder\";s:1:\"1\";}i:1;a:3:{s:10:\"priorityid\";s:1:\"2\";s:8:\"priority\";s:3:\"Low\";s:12:\"displayorder\";s:1:\"2\";}i:2;a:3:{s:10:\"priorityid\";s:1:\"3\";s:8:\"priority\";s:4:\"High\";s:12:\"displayorder\";s:1:\"3\";}i:3;a:3:{s:10:\"priorityid\";s:1:\"4\";s:8:\"priority\";s:11:\"Address Now\";s:12:\"displayorder\";s:1:\"4\";}i:4;a:3:{s:10:\"priorityid\";s:1:\"5\";s:8:\"priority\";s:8:\"Deferred\";s:12:\"displayorder\";s:1:\"5\";}}s:11:\"resolutions\";a:6:{i:0;a:3:{s:12:\"resolutionid\";s:1:\"1\";s:10:\"resolution\";s:4:\"Open\";s:12:\"displayorder\";s:1:\"1\";}i:1;a:3:{s:12:\"resolutionid\";s:1:\"2\";s:10:\"resolution\";s:5:\"Fixed\";s:12:\"displayorder\";s:1:\"2\";}i:2;a:3:{s:12:\"resolutionid\";s:1:\"3\";s:10:\"resolution\";s:5:\"Bogus\";s:12:\"displayorder\";s:1:\"3\";}i:3;a:3:{s:12:\"resolutionid\";s:1:\"4\";s:10:\"resolution\";s:9:\"Duplicate\";s:12:\"displayorder\";s:1:\"4\";}i:4;a:3:{s:12:\"resolutionid\";s:1:\"5\";s:10:\"resolution\";s:9:\"Won\'t Fix\";s:12:\"displayorder\";s:1:\"5\";}i:5;a:3:{s:12:\"resolutionid\";s:1:\"6\";s:10:\"resolution\";s:12:\"Works for Me\";s:12:\"displayorder\";s:1:\"6\";}}}"; 
+
+?>
\ No newline at end of file
-- 
2.43.5