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_import.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";
	}
}

?>