<?php
	$this->setMigrateTitle( "Sablonlevelek" );

	function fo3_mail_template_migrate( $s ) {
		$s = str_replace( "[" , "[{\$" , $s );
		$s = str_replace( "]" , "}]" , $s );

		$mit = array(
			"[{\$username}]",
			"[{\$hash}]",
			"[{\$aliasname}]",
			"[{\$pwd}]",
			"[{\$email}]",
			"[{\$reg_tstamp}]",
			"[{\$reg_date}]",
			"[{\$name}]",
			"[{\$zip}]",
			"[{\$city}]",
			"[{\$address}]",
			"[{\$phone}]",
			"[{\$fax}]",
			"[{\$url}]",
			"[{\$billing_name}]",
			"[{\$billing_zip}]",
			"[{\$billing_city}]",
			"[{\$billing_address}]",
			"[{\$shipping_name}]",
			"[{\$shipping_zip}]",
			"[{\$shipping_city}]",
			"[{\$shipping_address}]",
			"[{\$contact_name}]",
			"[{\$contact_phone}]",
			"[{\$motherlang}]",
			"[{\$paid_tstamp}]",
			"[{\$paid_date}]",
			"[{\$expires_tstamp}]",
			"[{\$expires_date}]",
			"[{\$custom_language}]",
			"[{\$custom_specialty}]"
		);
		$mire = array(
			"[{\$member.username}]",
			"[{\$user.hash}]",
			"[{\$member.aliasname}]",
			"[{\$user.pwd}]",
			"[{\$user.email}]",
			"[{\$user.reg_tstamp}]",
			"[{\$user.reg_date}]",
			"[{\$user.user_name}]",
			"[{\$member.zip}]",
			"[{\$member.city}]",
			"[{\$member.address}]",
			"[{\$member.phone}]",
			"[{\$member.fax}]",
			"[{\$member.url}]",
			"[{\$member.billing_name}]",
			"[{\$member.billing_zip}]",
			"[{\$member.billing_city}]",
			"[{\$member.billing_address}]",
			"[{\$member.shipping_name}]",
			"[{\$member.shipping_zip}]",
			"[{\$member.shipping_city}]",
			"[{\$member.shipping_address}]",
			"[{\$member.contact_name}]",
			"[{\$member.contact_phone}]",
			"[{\$member.motherlang}]",
			"[{\$member.paid_tstamp}]",
			"[{\$member.paid_date}]",
			"[{\$member.expires_tstamp}]",
			"[{\$member.expires_date}]",
			"[{\$member.custom_language}]",
			"[{\$member.custom_specialty}]"
		);
		return str_replace( $mit , $mire , $s );
	}

	$query = sprintf( "select * from fo_mailtemplates order by id" );
	$data = FNTH_db_get_resultset( $query , $this->olddb );
	foreach ($data as $row) {
		$ins = array();
		$ins["site_language_id"]=1;
		$ins["mail_template_type_id"]=0;
		$ins["ctstamp"]="'2006-01-01 00:00:00'";
		$ins["template_name"]=sprintf( "'%s'" , FNTH_db_addslashes( $row["name"] ) );
		$ins["template_title"]=sprintf( "'%s'" , FNTH_db_addslashes( $row["title"] ) );
		$ins["template_subject"]=sprintf( "'%s'" , FNTH_db_addslashes( fo3_mail_template_migrate( $row["subject"] ) ) );
		$ins["template_is_html"]="true";
		$ins["template_is_raw_html"]="false";
		$ins["template_content"]=sprintf( "'%s'" , FNTH_db_addslashes( fo3_mail_template_migrate( $row["content"] ) ) );
		FNTH_db_free_result( FNTH_db_query( FNTH_db_generate_insert_query( "mail_templates" , $ins ) ) );
	}

	
?>
