Location: PHPKode > projects > ConPortal > conportal/inc/shift_changelog/db.php
<?php
/*
 *  ConPortal - Pomona College ITS scheduling appplication
 *  Copyright (C) 2005-2008  Pomona College & Bucknell University
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of version 2 of the GNU General Public License
 *  as published by the Free Software Foundation.
 *
 *  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 St, Fifth Floor, Boston, MA  02110-1301  USA
 */

function addChangelogRecord($text, $is_temp, $shiftPid)
{
	//get end_date from shiftPid
	$shift_info = getShiftDetails($shiftPid);
	//if it's a temp, we actually want the "start date" of the temp shift, since that's when the shift actually happens
	if($is_temp)
	{
		$end_date = $shift_info['start_date'];
	}
	else
	{
		$end_date = $shift_info['end_date'];
	}
	$result = safeQuery("INSERT INTO shift_changelog (text, shiftPid, end_date) VALUES (\"".$text."\",".$shiftPid.",FROM_UNIXTIME(".$end_date."))");
}

function removeChangelogRecordByShiftPid($shiftPid)
{
	$result = safeQuery("DELETE FROM shift_changelog WHERE shiftPid = " . $shiftPid);
	return $result;	
}

function removeChangelogRecordByPid($pid)
{
	$result = safeQuery("DELETE FROM shift_changelog WHERE pid = " . $pid);	
	return $result;
}

//purges old records
function removeOldChangelogRecords()
{
	$result = safeQuery("DELETE FROM shift_changelog WHERE end_date < CURDATE()");	
}

function getChangelogForDisplay()
{
	$result = safeQuery("SELECT pid, text FROM shift_changelog ORDER BY timestamp DESC");
	$a = array();
	while ($row = mysql_fetch_assoc($result))
	{
			$a[] = $row;
	}
	return $a;
}

?>
Return current item: ConPortal