<?
	#---------------------------------------------------------------------#
	# This source code is (c)2000 White Pajamas, Inc                      #
	# see http://www.stonekeep.com/license.html for licensing information #
	#---------------------------------------------------------------------#

	#--------------------------------------------------------------------
	# $Id: phonepost.php3,v 1.6 2000/12/14 19:13:53 shevett Exp $
	#--------------------------------------------------------------------

	#
	# called when a phone entry in the contact list needs to be updated.  $f_flag 
	# should contain 'add' or 'modify'.  Use $a_label and $a_tag to manipulate
	# the phone table.
	#

	LogIt("DEBUG","phonepost.php3","f_flag is $f_flag");
	if (strcmp($a_label,"userwritein") == 0) {
		$a_label = strtoupper($a_writeinvalue);
	}
	if ($f_flag == "add") {
		# first check to see if there is a label in there that exists
		# already.
		$acheck = db_query("select * from phones where tag='$a_tag' and label='$a_label'");
		if (db_numrows($acheck)) {
			Message("An phone number with that label already exists.  Please choose a unique address.");
			$f_flag='skip';
		} else {
			$acheck = db_query("insert into phones values ('$a_tag','$a_label','0','$a_number')");
			$lastresult[0]=0;
			$lastresult[1]="New phone number added to contact $a_tag";
		}
	} else {
		if ($f_flag=='modify') {
			$oq = db_query("delete from phones where tag='$a_tag' and label='$o_label' and number='$o_number'");
			$oq = db_query("insert into phones values ('$a_tag','$a_label','$a_main','$a_number')");
			$lastresult[0]=0;
			$lastresult[1]="Phone entry '$a_label' for contact '$a_tag' updated.";
		} else {
			if ($f_flag == 'delete') {
				$oq = db_query("delete from phones where tag='$f_contact' and label='$f_label'");
				$lastresult[0]=0;
				$lastresult[1]="Phone entry '$a_label' deleted from contact '$a_tag'.";
			}
		}
	}

