<?php 
/*
##################################################################
#                       PHP 4&5 MySQL 4&5                        #
##################################################################
#           Copyright (c) 2004-2008 Armia Systems Inc            #
##################################################################
#               This file is part of Cybermatch site             #
##################################################################
#    Developed By: simi (simi@armia.com)                         #
##################################################################
#               Developed On:   03-23-2009                       #
##################################################################
#               Modified By:                                     #
##################################################################
#               Modified On:                                     #
##################################################################
# This script may not be distributed, sold, given away for free  #
# to third party, or used as a part of any internet services 	 #
# such as webdesign etc.                                         #
##################################################################
*/

require_once ("config.inc.php");
require_once ("includes/userlogincheck.inc.php");
require_once ("includes/mysql.inc.php");
require_once ("includes/arrays.inc.php");
require_once ("classes/userside.class.php");
require_once ("classes/miscellaneous.class.php");
require_once ("classes/misc.class.php");

$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";
$id			= isset($_REQUEST['id'])	?	trim($_REQUEST['id'])	:	"0";

$objM			= new Misc($objDB);

//checking testimonal approval type
switch($siteSettingsPage['testimonialmode'])
{
	case "auto":
		$chkActive='1';
	break;

	case "admin":
		$chkActive='0';
	break;
}//end switch

if(isset($_GET['mode']) && $_GET['mode']=='delete')
{
	//delete records
	mysql_query("delete from ".TABLEPREFIX."testimonial where nTestimonial_Id='".$id."' and nUser_Id='".$_SESSION['user_id']."'") 
		or die(mysql_error());
	$message2="<font color='green'>Testimonials deleted successfully</font>";
	header("Location: testimonials.php?msg=".$message2);
	exit();
}//end if

$message	= "";
if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objMc		= new miscellaneous($objDB);
	$objMc->set_testimonial($_POST);
	if (isset($_POST['SaveNow'])) {
		$message	= $objMc->save_testimonial($id,$_SESSION['user_id'],$chkActive);
		if ($message == "") {
			if($id!='')
			{
				$message2='<font color="green">Testimonials updated successfully</font>';
			}//end if
			else
			{
				$message2='<font color="green">Testimonials added successfully . It will display only after approved by admin !!!!!.</font>';
			}//end else
			
			header("Location: testimonials.php?msg=".$message2);
			exit;
		}
	} elseif (isset($_POST['BackNow'])) {
		if ($message == "") {
			header("Location: testimonials.php?page=$page");
			exit;
		}
	} else {
		$array	= $objMc->get_testimonial($id);
		$objMc->set_testimonial($array);
	}
}
include_once ("title.inc.php");
include_once ("tophtml.inc.php");
?>

<div class="row">
	<div class="eight columns">
		<div class="search-rslts">
			<div class="row"><div class="inenr-hd"><h2>Add Testimonials</h2></div></div>
			<div class="clear">&nbsp;</div>
			<div class="full_row"><a href="testimonials.php" class="add-story01">Back Testimonials</a></div>
			<div class="row">
				<form name="frmUser" method="post" action="" onSubmit="return validate();">
					<input type="hidden" value="<?php echo $_SESSION['user_id'];?>" name="nUserId">
					<div class="newdesignforinput maintext1">
						<?php if(isset($message2) && trim($message2)!='')
					      {
						?>
						<div class="full_row">
							<div class="maintext1 warning"><?php echo $message2;?></div>
						</div>
						<?php }//end if
							  if ($objDB) 
							  { 
						?>
						
						<div class="full_row">
							<div class="three columns">Testimonial Description</div>
							<div class="nine columns">
								<textarea name="tContent" cols="80" rows="12" class="textbox_textarea"><?php echo stripslashes($array['tContent'])?></textarea>
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">&nbsp;</div>
							<div class="nine columns">
								<input name="SaveNow" type="submit" class="loginbutton" value="Save">
								<input type="hidden" name="page" value="<?php echo $page?>">
								<input type="hidden" name="id" value="<?php echo $id?>">
							</div>
						</div>
						<?php  }//end if?>
					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="four columns right search_result_R">
		<?php include_once ("left.inc.php");?>
	</div>
</div>

<?php include_once('bottomhtml.inc.php');?>
