<?php

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

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

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

							switch($action){

								case '':
									system_emails();
									break;
									
								case 'save_messages':
									save_messages();
									break;

							}//switch

						///////////////////////////////////////
						
function system_emails(){
	
	admin_validate();
	
	$data["section"] = "customize";
	$data["subsection"] = 2;
	$data["title_id"] = "46";	
	$data["themes"] = admin_get_themes();	
	$theme = $GLOBALS["Get"]->val("theme");
	
	if(empty($theme))
		$theme = $GLOBALS["THEME"];
	
	if($theme){
		include(DOC_ROOT."/themes/".$theme."/system/messages.inc.php");
		$data["messages"] = $messages;
		$data["theme"] = $theme;
		$layout[0] = "system_emails";
	}//if
	
	$patterns[0] = array (
		"|recipient_name|" => "recipient name",
		"|login|" => "member login (email/username)",
		"|password|" => "member password",
		"|link|" => "email verification link",
		"|code|" => "email verification code",
		"|site_name|" => "site name"
	);
	
	$patterns[1] = array (
		"|recipient_name|" => "recipient name",
		"|login|" => "member login (email/username)",
		"|password|" => "member password",
		"|site_name|" => "site name"
	);
	
	$patterns[2] = array (
		"|recipient_name|" => "recipient name",
		"|login|" => "member login (email/username)",
		"|password|" => "member password",
		"|site_name|" => "site name"
	);
	
	$patterns[3] = array (
		"|recipient_name|" => "recipient name",
		"|login|" => "member login (email/username)",
		"|password|" => "member password",
		"|site_name|" => "site name"
	);
	
	$patterns[4] = array (
		"|subject|" => "invitation subject",
		"|body|" => "invitation message",
		"|link|" => "invitation link",
		"|site_name|" => "site name"
	);
	
	$patterns[5] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"	
	);
	
	$patterns[6] = array (
		"|recipient_name|" => "recipient name",
		"|login|" => "member login (email/username)",
		"|password|" => "member password",
		"|site_name|" => "site name"
	);
	
	$patterns[7] = array (
		"|subject|" => "invitation subject",
		"|body|" => "invitation message",
		"|link|" => "invitation link",
		"|site_name|" => "site name"
	);
	
	$patterns[8] = array (
		"|recipient_name|" => "recipient name",
		"|link|" => "eCard URL",
		"|site_name|" => "site name"
	);
	
	$patterns[9] = array (
		"|recipient_name|" => "recipient name",
		"|invitee_name|" => "invitee member name",
		"|site_name|" => "site name"
	);
	
	$patterns[10] = array (
		"|recipient_name|" => "recipient name",
		"|person_email|" => "eCard viewer email",
		"|site_name|" => "site name"
	);
	
	$patterns[11] = array (
		"|recipient_name|" => "recipient name",
		"|member_name|" => "eCard viewer name",
		"|site_name|" => "site name"
	);
	
	$patterns[12] = array (
		"|member_name|" => "member name",
		"|recipient_name|" => "recipient name",
		"|blog_name|" => "blog name",
		"|site_name|" => "site name"
	);
	
	$patterns[13] = array (
		"|subject|" => "invitation subject",
		"|body|" => "invitation message",
		"|link|" => "invitation link",
		"|site_name|" => "site name"
	);
	
	$patterns[14] = array (
		"|member_name|" => "member name",
		"|recipient_name|" => "recipient name",
		"|classified_ad_name|" => "classified ad name",
		"|site_name|" => "site name"
	);
	
	$patterns[15] = array (
		"|subject|" => "invitation subject",
		"|body|" => "invitation message",
		"|link|" => "invitation link",
		"|site_name|" => "site name"
	);
	
	$patterns[16] = array (
		"|member_name|" => "member name",
		"|recipient_name|" => "recipient name",
		"|event_name|" => "event name",
		"|site_name|" => "site name"
	);
	
	$patterns[17] = array (
		"|subject|" => "invitation subject",
		"|body|" => "invitation message",
		"|link|" => "invitation link",
		"|site_name|" => "site name"
	);
	
	$patterns[18] = array (
		"|member_name|" => "member name",
		"|recipient_name|" => "recipient name",
		"|club_name|" => "club name",
		"|site_name|" => "site name"
	);
	
	$patterns[19] = array (
		"|subject|" => "invitation subject",
		"|body|" => "invitation message",
		"|link|" => "invitation link",
		"|site_name|" => "site name"
	);
	
	$patterns[20] = array (
		"|recipient_name|" => "recipient name",
		"|search_name|" => "saved search name",
		"|items|" => "search matches",
		"|site_name|" => "site name"
	);
	
	$patterns[21] = array (
		"|recipient_name|" => "recipient name",
		"|item_type|" => "item type",
		"|item_name|" => "item name",
		"|site_name|" => "site name"
	);
	
	$patterns[22] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "blog name",
		"|link|" => "unsubscribe link",
		"|site_name|" => "site name"
	);
	
	$patterns[23] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "blog name",
		"|site_name|" => "site name"
	);
	
	$patterns[24] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "classified ad name",
		"|link|" => "unsubscribe link",
		"|site_name|" => "site name"
	);
	
	$patterns[25] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "classified ad name",
		"|site_name|" => "site name"
	);
	
	$patterns[26] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "event name",
		"|link|" => "unsubscribe link",
		"|site_name|" => "site name"
	);
	
	$patterns[27] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "event name",
		"|site_name|" => "site name"
	);
	
	$patterns[28] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "club name",
		"|link|" => "unsubscribe link",
		"|site_name|" => "site name"
	);
	
	$patterns[29] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "club name",
		"|site_name|" => "site name"
	);
	
	$patterns[30] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "classified ad name",
		"|link|" => "unsubscribe link",
		"|site_name|" => "site name"
	);
	
	$patterns[31] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "classified ad name",
		"|site_name|" => "site name"
	);
	
	$patterns[32] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "event name",
		"|link|" => "unsubscribe link",
		"|site_name|" => "site name"
	);
	
	$patterns[33] = array (
		"|recipient_name|" => "recipient name",
		"|name|" => "event name",
		"|site_name|" => "site name"
	);
	
	$patterns[34] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[35] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[36] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[37] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[38] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[39] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[40] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[41] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[42] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[43] = array (
		"|recipient_name|" => "recipient name",
		"|site_name|" => "site name"
	);
	
	$patterns[44] = array (
        "|recipient_name|" => "recipient name",
        "|site_name|" => "site name"
    );
    
    $patterns[45] = array (
        "|recipient_name|" => "recipient name",
        "|site_name|" => "site name"
    );
	
	$patterns[100] = array (
		"|member_name|" => "member name",
		"|site_name|" => "site name"
	);
	
	$patterns[101] = array (
		"|member_name|" => "member name",
		"|site_name|" => "site name"
	);
	
	$patterns[102] = array (
		"|club_name|" => "club name",
		"|member_name|" => "member name",
		"|site_name|" => "site name"
	);
	
	$patterns[103] = array (
		"|member_name|" => "invitee member name",
		"|member_name2|" => "invited member name",
		"|club_name|" => "club name",
		"|site_name|" => "site name"
	);
	
	$patterns[104] = array (
		"|club_name|" => "club name",
		"|member_name|" => "member name",
		"|site_name|" => "site name"
	);
	
	$patterns[105] = array (
		"|club_name|" => "club name",
		"|member_name|" => "member name",
		"|site_name|" => "site name"
	);
	
	$patterns[106] = array (
		"|member_name|" => "member name",
		"|custommessage|" => "custom message",
		"|site_name|" => "site name"
	);
	
	$patterns[107] = array (
		"|member_name|" => "member name",
		"|blog_name|" => "blog name",
		"|site_name|" => "site name"
	);
	
	$patterns[108] = array (
		"|member_name|" => "member name",
		"|classified_ad_name|" => "classified ad name",
		"|site_name|" => "site name"
	);
	
	$patterns[109] = array (
		"|member_name|" => "member name",
		"|event_name|" => "event name",
		"|site_name|" => "site name"
	);
	
	$patterns[110] = array (
		"|member_name|" => "member name",
		"|club_name|" => "club name",
		"|site_name|" => "site name"
	);
	
	$data["patterns"] = $patterns;
	
	admin_output($layout,$data);
	
}//system_emails

function save_messages(){
	
	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.= "\$messages[\"subject\"][".$key."] = \"".$subject."\";\n";
		$write_str.= "\$messages[\"body\"][".$key."] = \"".$body."\";\n\n";
	}//while
	$write_str.= "\n?>";
	
	$file = DOC_ROOT."/themes/".$theme."/system/messages.inc.php";
	$file_handler = fopen($file,"w");
	fwrite($file_handler,$write_str);
	fclose($file_handler);
	
	load_page("index.php?section=system_emails&theme=".$theme);
	
}//save_messages
						
?>