Location: PHPKode > projects > Bugdar > upload/explain.php
<?php
/*=====================================================================*\
|| ###################################################################
|| # Bugdar
|| # Copyright ©2002-2007 Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version 2 of the License.
|| #
|| # This program is distributed in the hope that it will be useful, but
|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/

$fetchtemplates = array(
	'explain_product',
	'explain_automation',
	'explain_row'
);

define('SVN', '$Id$');

$focus['showreport'] = 'focus';

require_once('./global.php');

// ###################################################################

if (empty($_REQUEST['do']))
{
	$_REQUEST['do'] = 'products';
}

// ###################################################################

if ($_REQUEST['do'] == 'products')
{
	if (!is_array($bugsys->datastore['product']))
	{
		$message->error(T('There are no products set up.'));
	}
	
	foreach ($bugsys->datastore['product'] AS $product)
	{
		if ($product['parentid'])
		{
			$components["$product[componentmother]"]["$product[productid]"] = $product;
		}
		else
		{
			$products["$product[productid]"] = $product;
		}
	}
	
	foreach ($bugsys->datastore['version'] AS $version)
	{
		$versions["$version[productid]"]["$version[versionid]"] = $version;
	}
	
	// global versions
	if (is_array($versions['0']))
	{
		foreach ($versions['0'] AS $version)
		{
			$left = $version['version'];
			$right = null;
			eval('$globalversions .= "' . $template->fetch('explain_row') . '";');
		}
	}
	
	foreach ($products AS $product)
	{
		$left = $product['title'];
		$right = $product['description'];
		$trextra = ' class="altcolor"';
		eval('$productlist .= "' . $template->fetch('explain_row') . '";');
		
		if (is_array($components["$product[productid]"]))
		{
			foreach ($components["$product[productid]"] AS $component)
			{
				$left = '&nbsp; &rsaquo; &nbsp; ' . $component['title'];
				$right = $component['description'];
				$trextra = '';
				eval('$productlist .= "' . $template->fetch('explain_row') . '";');
			}
		}
	}
	
	eval('$template->flush("' . $template->fetch('explain_product') . '");');
}

// ###################################################################

if ($_REQUEST['do'] == 'automations')
{
	$fields_fetch = $bugsys->db->query("
		SELECT bugfield.*, MAX(permission.mask) AS mask
		FROM " . TABLE_PREFIX . "bugfield AS bugfield
		LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
			ON (bugfield.fieldid = permission.fieldid)
		WHERE (permission.mask = 2 OR permission.mask = 1)
		AND permission.usergroupid IN ({$bugsys->userinfo['usergroupid']}" . (sizeof($bugsys->userinfo['groupids']) != 0 ? ',' . implode(',', $bugsys->userinfo['groupids']) : '') . ")
		GROUP BY (bugfield.fieldid)
	");
	while ($field = $bugsys->db->fetch_array($fields_fetch))
	{
		$fields["$field[fieldid]"] = $field;
	}
	
	if (is_array($bugsys->datastore['automation']))
	{
		foreach ($bugsys->datastore['automation'] AS $automation)
		{
			$automation['fieldchanges'] = unserialize($automation['fieldchanges']);
			
			$left = $automation['name'];
			$right = $automation['description'];
			$trextra = ' class="listinghead"';
			
			eval('$automations .= "' . $template->fetch('explain_row') . '";');
			
			if ($automation['comment'])
			{
				$left = T('Add Comment');
				$right = $automation['comment'];
				$trextra = ' class="altcolor"';
				
				eval('$automations .= "' . $template->fetch('explain_row') . '";');
			}
			
			$trextra = '';
			
			if (is_array($automation['fieldchanges']['builtin']))
			{
				foreach ($automation['fieldchanges']['builtin'] AS $name => $value)
				{
					$left = $name;
					$right = $bugsys->datastore["$left"]["$value"]["$left"];
					eval('$automations .= "' . $template->fetch('explain_row') . '";');
				}
			}
			
			if (is_array($automation['fieldchanges']['custom']))
			{
				foreach ($automation['fieldchanges']['custom'] AS $id => $value)
				{
					if (!$fields["$id"])
					{
						continue;
					}
					
					$left = $fields["$id"]['name'] . ' ' . sprintf(T('(Custom #%1$d, type: %2$s)'), $id, $fields["$id"]['type']);
					$right = $value;
					eval('$automations .= "' . $template->fetch('explain_row') . '";');
				}
			}
		}
	}
	
	eval('$template->flush("' . $template->fetch('explain_automation') . '");');
}

/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>
Return current item: Bugdar