本文整理汇总了PHP中MailTemplate::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP MailTemplate::assign方法的具体用法?PHP MailTemplate::assign怎么用?PHP MailTemplate::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailTemplate
的用法示例。
在下文中一共展示了MailTemplate::assign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPerform
function actionPerform(&$skin, $moduleID)
{
$usernameError = '';
if (isset($_POST["event"]) && $_POST["event"] == 'forgetPassword') {
//Check username
//Inorder to avoid sql injection attacks both
//should contains characters form a to z and/or numbers only
if (isset($_POST["username"]) && (!$skin->main->checkString('[^a-zA-Z0-9]', $_POST["username"]) || $_POST["username"] == "")) {
$usernameError = "Username must contains numbers and/or character from a to z only";
} else {
$query = "SELECT * FROM {$skin->main->databaseTablePrefix}users WHERE username=" . $skin->main->databaseConnection->qstr($_POST["username"]);
$recordSet = $skin->main->databaseConnection->Execute($query);
$password = $this->randomNumber();
$record = array('password' => md5($password));
//Start Update Transaction
$skin->main->databaseConnection->StartTrans();
$updateSQL = $skin->main->databaseConnection->GetUpdateSQL($recordSet, $record);
$skin->main->databaseConnection->Execute($updateSQL);
$recordSet2 = $skin->main->databaseConnection->Execute("SELECT * FROM {$skin->main->databaseTablePrefix}templates \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype='mail'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tname = 'forgetPasswordSubject'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tname = 'forgetPasswordBody'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)");
$templates = array('forgetPasswordSubject' => '', 'forgetPasswordBody' => '');
while (!$recordSet2->EOF) {
$templates[$recordSet2->fields["name"]] = $recordSet2->fields["content"];
$recordSet2->MoveNext();
}
$mailer = new Mailer($skin->main);
$mailTemplate = new MailTemplate($skin->main);
$mailTemplate->assign('username', $_POST["username"]);
$mailTemplate->assign('password', $password);
$mailer->addUserAddress($_POST["username"]);
$mailer->Subject = $mailTemplate->fetch('mail/forgetPasswordSubject');
$mailer->Body = $mailTemplate->fetch('mail/forgetPasswordBody');
$mailer->Send();
if ($mailer->ErrorInfo) {
//Transaction failed
$skin->main->databaseConnection->FailTrans();
trigger_error("Unable to send password remind mail. Reason is : " . $mailer->ErrorInfo);
}
//Complete update transaction
$skin->main->databaseConnection->CompleteTrans();
}
}
//Assign codeBehind variables
$skin->main->controlVariables["forgetPassword"] = array('usernameError' => $usernameError);
}
示例2: actionPerform
function actionPerform($eventName, $args)
{
$mailer = new Mailer($this->main);
$mailTemplate = new MailTemplate($this->main);
$mailTemplate->assign('username', $args);
$mailer->addSystemAddress();
if ($eventName == "login_fail") {
$mailer->Subject = $mailTemplate->fetch('event/loginFailSubject');
$mailer->Body = $mailTemplate->fetch('event/loginFaildBody');
$mailer->Send();
} elseif ($eventName == "login_succeed") {
$mailer->Subject = $mailTemplate->fetch('event/loginSucceedSubject');
$mailer->Body = $mailTemplate->fetch('event/loginSucceedBody');
$mailer->Send();
} elseif ($eventName == "user_activate") {
$mailer->Subject = $mailTemplate->fetch('event/userActivateSubject_Admin');
$mailer->Body = $mailTemplate->fetch('event/userActivateBody_Admin');
$mailer->Send();
} elseif ($eventName == "user_deactivate") {
$mailer->Subject = $mailTemplate->fetch('event/userDeactivateSubject_Admin');
$mailer->Body = $mailTemplate->fetch('event/userDeactivateBody_Admin');
$mailer->Send();
}
}