Location: PHPKode > projects > BugIn and Ticketing System > bugin-0.65/inc/add_submit.inc.php
<?php

if ((isset($_SESSION['loggedin']) && $_SESSION['loggedin']) || 
		((isset($_REQUEST['email']) && ($_SESSION['userinfo'] = checkUser($_REQUEST['email']))) && ($mod['creator'] = $_SESSION['userinfo']['uid']))) {

	if ($mod['owner'] == $_SESSION['userinfo']['uid']) {
		$mod['status'] = $takeStatusNum;
	}

	// Reset important var's...
	$upNum = 0;
	$upNumField = 0;

	// Set the update information...  here we go!
	$update[$upNum]['action'] = "add";
	$update[$upNum]['tableName'] = "tickets";
	$update[$upNum]['uniqueRow'] = "id";

	// OK, We're making the ticket!
	$modification = $verbage['ticket_added'];

	reset($mod);
	while (list($key, $value) = each($mod)) {
		$update[$upNum]['modify'][$upNumField]['fieldName'] = $key;
		$update[$upNum]['modify'][$upNumField]['fieldValue'] = $bugDatabase->db->qstr($mod[$key]);
		$upNumField ++;
	}

	$update[$upNum]['modify'][$upNumField]['fieldName'] = "date_modified";
	$update[$upNum]['modify'][$upNumField]['fieldValue'] = $bugDatabase->db->DBTimeStamp(time());
	$upNumField ++;
	$update[$upNum]['modify'][$upNumField]['fieldName'] = "date_added";
	$update[$upNum]['modify'][$upNumField]['fieldValue'] = $bugDatabase->db->DBTimeStamp(time());
	$upNumField = 0;
	$upNum ++;

	// Update the DB if we need to.
	if (isset($update) && !isset($error)) {
		$bugDatabase->alterDb($update);

		if ($bugDatabase->dbType == 'pgsql') {
			$r = $bugDatabase->db->Execute("SELECT id FROM {$bugDatabase->tablePrefix}_tickets WHERE oid=" . $bugDatabase->db->Insert_ID());
			$temp = $r->fields['id'];
			printvar($temp);
			$r->Close();
			$ticketNum = $temp;
		} else {
			$ticketNum = $bugDatabase->db->Insert_ID();
		}

		$update = array();
		$upNum = 0;
		$update[$upNum]['action'] = "add";
		$update[$upNum]['tableName'] = "modifications";

		// The last modification is pretty standard....
		$update[$upNum]['modify'][0]['fieldName'] = "uid";
		$update[$upNum]['modify'][0]['fieldValue'] = $userinfo['uid'];
		$update[$upNum]['modify'][1]['fieldName'] = "text";
		$update[$upNum]['modify'][1]['fieldValue'] = $bugDatabase->db->qstr(wordwrap($modification));
		$update[$upNum]['modify'][2]['fieldName'] = "ts";
		$update[$upNum]['modify'][2]['fieldValue'] = $bugDatabase->db->DBTimeStamp(time());
		$update[$upNum]['modify'][3]['fieldName'] = "ticket_id";
		$update[$upNum]['modify'][3]['fieldValue'] = $ticketNum;
		$bugDatabase->alterDb($update);

		$ticket = $bugDatabase->getTicket($ticketNum);

		$newTicket = $ticket;

		$mod['num'] = $ticketNum;
		$mod['modification'] = $modification;
		
		$run = runTriggers(TRIGGER_FLAG_ADD, $ticket, $mod);
		if (isset($run['notifyList']))
			$_SESSION['message'] = runNotify($ticket, $newTicket, $mod, $run['notifyList']);
		}
}
echo <<<EOT

<script language="javascript">
window.location.replace="{$options['baseURL']}/?area=add";
</script>

EOT;
?>
Return current item: BugIn and Ticketing System