Location: PHPKode > projects > BugIn and Ticketing System > bugin-0.65/inc/pre/view.pre.inc.php
<?php
require_once("{$options['buginLibBase']}notify.inc.php");
$noView = 0;
if (!isset($_REQUEST['num'])) {
	$noView = $verbage['err_no_ticket'];
}
else {
	if ((!isset($_SESSION['loggedin']) || !$_SESSION['loggedin'])) {
		include($options['buginIncBase']."/pre/login.pre.inc.php");
	}
	$modifications = "";
	$num = intval($_REQUEST['num']);
	if (!($ticket = $bugDatabase->getTicket($num)) ) {
		$noView = "{$verbage['err_invalid_ticket']} $num";
	}
	else {
		$ticket['acl'] = getACL($ticket);

		if (isset($bugDatabase->lists['user'][$ticket['creator']]))
			$creator = htmlentities($bugDatabase->lists['user'][$ticket['creator']]['name']);
		else
			$creator = $verbage['unknown'];

		if (!$ticket['acl'] & ACL_READ) {
			buginError ("Access to {$options['ticketName']} denied");
			$noView = 1;
		}
		else {
			if ($ticket['acl'] & ACL_MODIFY)
				$writable = 1;
			else
				$writable = 0;

			// Assemble the project list.
			buginError("Generating projects list", 1);
			$projects = generateOptionList($bugDatabase->lists['project'], "id", $ticket['project'], "optionName");
	
			// Assemble the category list. 
			buginError("Generating category list", 1);
			$categories = generateOptionList($bugDatabase->lists['category'], "id", $ticket['category']);
	
			// Assemble the status list. 
			buginError("Generating status list", 1);
	
			$notifyList = htmlentities(generateNotifyList($ticket,$ticket));
                
			$status = "\n";
			if ($ticket['owner']) {
				$status = generateOptionList($bugDatabase->lists['status'], "id", $ticket['status']);
			}
			else {
	 			while (list($key, $value) = each($bugDatabase->lists['status'])) {
					$name = htmlentities($value['name']);
					if (($ticket['status'] != -1) && ($value['id'] == $ticket['status'])) {
						buginError("-Option-Selected {$name}", MESSAGE_DEBUG);
						$status .= "\t\t\t\t<option value=\"{$value['id']}\" selected>{$name}</option>\n";
					} 
					else {
						//if (!in_array($value["id"], explode(",", $options['closedNum'])))
							$status .= "\t\t\t\t<option value=\"{$value['id']}\">{$value['name']}</option>\n";
					}
				}
			}
			// Assemble the field lists. 
			if (count($bugDatabase->lists['field'])) {
				$addrows = "";
				$long_desc_rowspan = 4 + count($bugDatabase->lists['field']);
				buginError("Generating field lists", 1);
				while (list($key, $value) = each($bugDatabase->lists['field'])) {
					$pname = htmlentities($value['name']);
					switch($value['type']) {
						case "select":
							break;
						case "multi_select":
							break;
						case "datetime":
							$ppvalue = date($options['dateFormat'], strtotime($ticket[$value['field_name']]));
							$pvalue = "<input type=\"text\" name=\"mod[{$value['field_name']}]\" value=\"{$ppvalue}\" />";
							break;
						default:
							break;
					}
					$addRows .= <<<EOT
	<tr bgcolor="{$options['colorTableBgAlt2']}" valign=top>
		<td><b>$pname</b></td>
		<td bgcolor="{$options['colorBg']}">$pvalue</td>
	</tr>
		
EOT;
				}
			}
			else {
				$addRows = "";
				$long_desc_rowspan = 4;
				buginError("No field list to generate.", 1);
			}

			// Assemble the priority list 
			buginError("Generating priority list", 1);
			$priority = generateOptionList($bugDatabase->lists['priority'], "id", $ticket['priority']);
		
			// Assemble the owner (assigned to)
			buginError("Generating Owner list", 1);
			$validOwner = isValidOwner($userinfo, $ticket['validOwners']);
			$owners = "<option value=0>Unowned</option>\n";
		
			$owners .= generateOptionList($ticket['validOwners'], "uid", $ticket['owner']);
	
			/* Assemble the modifications strings.... {{{ */
			buginError("Generating Modifications list", 1);
			if (isset($ticket['modifications']) && count($ticket['modifications'])) {
				while (list($key, $value) = each($ticket['modifications'])) {
					$mb = $bugDatabase->lists['user'][intval($value['uid'])]; // Get user for this modification.
					$name = htmlentities($mb['name']);
					$modby = "<a href=\"\" onClick=\"userInfo({$mb['uid']})\">{$name}</a>"; // Link to the e-mail name
					$modifications .= "<b>** {$verbage['modification_by']} <u>{$modby}</u>{$verbage['modification_at']}<i>{$value['date']}</i></b>\n"; // Add modification text

					$modText = htmlentities(str_replace("\\%", "%", wordwrap("{$value['text']}\n\n", 80)));
					$modImage = eregImageMatch($modText);
					$modifications .= $modImage.ereg_replace("([[:alnum:]]+://[^[:space:]]*[[:alnum:]#?/&=])", "<a href=\"\\1\" target=\"_new\">\\1</a>", $modText); // Add user input
				}
			}
			else
				$modifications = "No Modifications Found";
				$mods = "<pre>".$modifications."</pre>\n";
			/* }}} */
	
			/* Other miscelanious HTML formatting things {{{ */
			$short_desc = htmlentities(($ticket['short_desc'] ? $ticket['short_desc'] : "NO SHORT DESCRIPTION SUPPLIED"));
		
			$long_desc = htmlentities($ticket['long_desc']);
			$long_desc_rows = count(explode("\n", $long_desc)) + 1;

	
			if ($long_desc_rows < 5) 
				$long_desc_rows = 5;
			}
		}
	}
?>
Return current item: BugIn and Ticketing System