index.php.20110202 4.38 KB
<?
require_once("config_FormSaveMail.php");

header('Content-Type: text/html; charset='.$_LOSP_CHARSET);

function check_password($password) {
	global $_KINDOFEMAILLIST;
	return ($password == $_KINDOFEMAILLIST[$_POST['KindOfList']]['password']);
}

$DB = StorableFactory::create($_LOSP_STORABLE_KINDOF, $_LOSP_STORABLE_DATA);

if(array_key_exists($_GET['KindOfList'], $_KINDOFEMAILLIST) || array_key_exists($_POST['KindOfList'], $_KINDOFEMAILLIST)) {
	if($_GET['KindOfList']) {
		$var_KindOfList = $_GET['KindOfList'];
	} else {
		$var_KindOfList = $_POST['KindOfList'];
	}

	$quickform = new HTML_QuickForm2('FormSaveMail');
	$quickform->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
			'KindOfList'        => $var_KindOfList,
	)));

	$fsText = $quickform->addElement('fieldset')->setLabel('Registrierung');

	$qf_KindOfList =  $fsText->addElement('text', 'KindOfList', array('style' => 'width: 300px;'), array('label' => 'Art der Liste:'));
	$qf_KindOfList->addRule('required', '<b>:-( Email ist ein Pflichtfeld!!!</b>');

	$qf_Email = $fsText->addElement('text', 'Email', array('style' => 'width: 300px;'), array('label' => 'Email:'));
	$qf_Email->addRule('required', '<b>:-( Email ist ein Pflichtfeld!!!</b>');


	$qf_NickName = $fsText->addElement('text', 'NickName', array('style' => 'width: 300px;'), array('label' => 'NickName:'));
	$qf_NickName->addRule('required', '<b>:-( NickName ist ein Pflichtfeld!!!</b>');

	$fsText->addElement('text', 'FirstName', array('style' => 'width: 300px;'), array('label' => 'Vorame:'));
	$fsText->addElement('text', 'SurName', array('style' => 'width: 300px;'), array('label' => 'Nachname:'));

	$area = $fsText->addElement(
			'textarea', 'Note', array('style' => 'width: 300px;', 'cols' => 50, 'rows' => 7),
	array('label' => 'Notiz:')
	);

	if(is_array($_KINDOFEMAILLIST[$var_KindOfList]) && array_key_exists('password', $_KINDOFEMAILLIST[$var_KindOfList]) && $_KINDOFEMAILLIST[$var_KindOfList]['password']) {
		$fsText = $quickform->addElement('fieldset')->setLabel('Passwort geschützte Liste');
		$qf_Password = $fsText->addElement('password', 'pwdTest', array('style' => 'width: 300px;'), array('label' => 'Passwort:'));
		$qf_Password->addRule('required', '<b>:-( Passwort ist ein Pflichtfeld!!!</b>');
		$qf_Password->addRule('empty')->or_($qf_Password->createRule('callback', '<b>Passwort falsch!!!!!!!!!!</b>', 'check_password'));

	}

	$fsButton = $quickform->addElement('fieldset')->setLabel('Buttons');
	$testReset = $fsButton->addElement( 'reset', 'testReset', array('value' => 'Abbrechen') );

	$fsButton->addElement( 'button', 'SubmitButton', array('type' => 'submit'),	 array('content' => '<img src="logo.png"  width="46" height="35" alt="pear" />Fertig')	);



}

?>
<html>
<head>
<style type="text/css">
body {
	margin-left: 10px;
	font-family: Arial, sans-serif;
	font-size: small;
}

.quickform {
	min-width: 350px;
	max-width: 600px;
	width: 350px;
}
</style>
<title>EMail Liste "<?=$var_KindOfList?>"</title>
</head>
<body>

<?
if($quickform) {
	?>
<h2>EMail Liste "<?=$var_KindOfList?>"</h2>
	<?
	if ($quickform->validate()) {
		$var_bindValueArray = array(
					':NickName'		=>	$_POST['NickName'],
					':EMail'		=>	$_POST['Email'],
					':FirstName'	=>	$_POST['FirstName'],
					':SurName'		=>	$_POST['SurName'],
					':Text'			=>	$_POST['Note'],
					':KindOfList'	=>	$_POST['KindOfList'],
		);
		$var_query = 'SELECT tool_insertEmailToList(:NickName, :EMail, :FirstName, :SurName, :Text, :KindOfList) AS ID';
		$stmt = $DB->PDO_query($var_query, $var_bindValueArray);
		$row = $DB->PDO_getResultRow($stmt);

		if($row['ID']) {
			echo ':-) '.$_POST['Email'].' wurde erfolgreich in die '.$var_KindOfList.' Liste eingetragen';

			$param_subject = '[mensch.coop][maillist]['.$var_KindOfList.'] '.$_POST['Email'].'';
			$param_message = ":-) ".$_POST['Email']." wurde erfolgreich in die ".$var_KindOfList." Liste eingetragen \n\n
										\t	NickName	=	".$_POST['NickName']." \n
										\t	EMail		=	".$_POST['Email']." \n
										\t	FirstName	=	".$_POST['FirstName']." \n
										\t	SurName		=	".$_POST['SurName']." \n
										\t	Text		=	".$_POST['Note']." \n
										\t	KindOfList	=	".$_POST['KindOfList']." \n 
						";
			mail($_TOOL_MAILADMIN, $param_subject, $param_message);

		} else {
			echo ':-( '.$_POST['Email'].' wurde nicht erfolgreich in die '.$var_KindOfList.' Liste eingetragen';
			D::show($var_bindValueArray);
		}

	} else {
		echo $quickform;
	}
}
?>
</body>
</html>