<?php

						/*************************************\
						
						    Handshakes Professional (3.0)
						            by DZOIC LTD
						       Copyright(c) 2005-2006
						        http://www.dzoic.com
						
						\*************************************/

						///////////////////////////////////////

						admin_validate_section("customize",5);
						$action = $GLOBALS["Get"]->val("action");

							switch($action){

								case '':
									preset_invitations();
									break;
									
								case 'save_invitations':
									save_invitations();
									break;

							}//switch

						///////////////////////////////////////
						
function preset_invitations(){
	
	admin_validate();
	
	$data["action"] = "preset_invitation";
	$data["themes"] = admin_get_themes();
	
	$theme = $GLOBALS["Get"]->val("theme");
	
	if(empty($theme))
		$theme = $GLOBALS["THEME"];
	
	if($theme){
		
	$data["theme"] = $theme;
	
	include(DOC_ROOT."/themes/".$theme."/invitations.inc.php");
	
	$data["invitations"] = $invitations;
	$data["titles"][invite]      = "General Invitation";
	$data["titles"][ecards]      = "eCard Invitation";
	$data["titles"][blogs]       = "Blog Invitation";
	$data["titles"][classifieds] = "Classified Ad Invitation";
	$data["titles"][events]      = "Event Invitation";
	$data["titles"][clubs]       = "Clubs Invitation";
	
	$layout[0] = "invitations";
	
	}//if
	
	$data["section"] = "customize";
	$data["subsection"] = 5;
	$data["title_id"] = "43";	
	admin_output($layout,$data);
	
}//preset_invitations

function save_invitations(){
	
	admin_validate();
	
	$subjects = $GLOBALS["Get"]->val("subjects");
	$bodies   = $GLOBALS["Get"]->val("bodies");
	$theme    = $GLOBALS["Get"]->val("theme");
	
	$write_str = "<?php\n\n";
	while(list($key,$val) = each($subjects)){
		$subject = stripslashes(html_entity_decode($val));
		$subject = hs_ereg_replace('"','\"',$subject);
		$subject = hs_ereg_replace(preg_quote("&#124;"),"|",$subject);
		$body    = stripslashes(html_entity_decode($bodies[$key]));
		$body    = hs_ereg_replace('"','\"',$body);
		$body    = hs_ereg_replace(preg_quote("&#124;"),"|",$body);
		$write_str.= "\$invitations[".$key."][subject] = \"".$subject."\";\n";
		$write_str.= "\$invitations[".$key."][body] = \"".$body."\";\n\n";
	}//while
	$write_str.= "\n?>";
	
	$file_handler = fopen(DOC_ROOT."/themes/".$theme."/invitations.inc.php","w");
	fwrite($file_handler, $write_str);
	fclose($file_handler);
	
	load_page("index.php?section=preset_invitations&theme=".$theme);
	
}//save_invitations
						
?>