<?php
	/*
	** File: UPDATE_VARIATION
	** Description: update information about a variation
	** Version: $Revision: 1.7 $
	** Created: 04/21/1999
	** Author: Leon Atkinson
	** Email: leon@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/12/16 23:58:15 $
	**
	** Log : $Log: UPDATE_VARIATION,v $
	** Log : Revision 1.7  1999/12/16 23:58:15  leon
	** Log : Created new function for checking for required global variables.  I've
	** Log : converted a few actions to use this new function.  At some point we should
	** Log : convert them all.
	** Log :
	** Log : Revision 1.6  1999/12/09 23:23:27  leon
	** Log : Changed ActionResults use so that it's an array instead of a
	** Log : continually-growing string.  Note the little function in standard_library
	** Log : for printing out all the action results.
	** Log :
	** Log : Revision 1.5  1999/10/14 21:38:14  leon
	** Log : Started pulling text out of action modules
	** Log :
	** Log : Revision 1.4  1999/08/18 22:31:56  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.3  1999/07/28 19:27:17  leon
	** Log : Mass update based on code donation from a live project
	** Log :
	**
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	*/

	/* Make sure the user has admin rights. */
	if( !$UserInfo["Permission"]["Administrate"] )
	{
		$ActionResults[] = L_UPDATEVARIATION_ACCESS_DENIED;
	}
	elseif(! haveGlobals(array("inputName"=>"string",
		"inputDescription"=>"string",
		"inputGraphic"=>"string",
		"inputDisplayPrecedence"=>"integer",
		"variation"=>"integer")))
	{
		//validate input data	
		$ActionResults[] = L_UPDATEVARIATION_MISSING_INPUT;
	}
	else
	{
		//build query
		$Query = "UPDATE variation ";
		$Query .= "SET Name='" . substr(addslashes($inputName),0,255) . "', ";
		$Query .= "Description='" . 
			substr(addslashes($inputDescription),0,255) . "', ";
		$Query .= "Graphic='" . substr(addslashes($inputGraphic),0,255) . "', ";
		$Query .= "DisplayPrecedence=" . intval($inputDisplayPrecedence) . " ";
		$Query .= "WHERE ID=$variation";

		//execute query
		if(!mysql_query($Query, $DatabaseLink))
		{
			$ActionResults[] = mysql_errno() . ": " . mysql_error();
		}
		else
		{
			$ActionResults[] = L_UPDATEVARIATION_UPDATED;
		}
	}

?>
