本文整理汇总了PHP中MailTemplate::getNotificationEmailMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP MailTemplate::getNotificationEmailMessage方法的具体用法?PHP MailTemplate::getNotificationEmailMessage怎么用?PHP MailTemplate::getNotificationEmailMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailTemplate
的用法示例。
在下文中一共展示了MailTemplate::getNotificationEmailMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populatenoficationlistAction
/**
* Populate notification list.
*
* Example: ctl 1686825444, crc e233847ad0507ae1d0890633ced692b9
*/
public function populatenoficationlistAction()
{
$this->_helper->viewRenderer->setNoRender();
//view info disabled
$this->_helper->layout->disableLayout();
$ctl = $this->_getParam('ctl');
$crc = $this->_getParam('crc');
$customerKey = '';
$startDate = $this->_getParam('start');
$generated_crc = md5($ctl);
if ($generated_crc == $crc) {
$notifiedBeforeDate = $this->_helper->generator->manipulatDate($this->_helper->generator->generateCurrentTime(), -Constant::NOTIFICATION_DAY, Zend_Date::DAY);
$advertisements = $this->advertisement->findAdvertisementToSendNofication($notifiedBeforeDate);
$numOfAdvs = count($advertisements);
echo "Check advertisments created before " . $notifiedBeforeDate . "<br/>";
echo $numOfAdvs . " advertisements found might need to be notified<br/>";
$numOfAffected = 0;
foreach ($advertisements as $advertisement) {
$data = array("advertisement_id" => $advertisement->id, "type" => "close_advertisement", "status" => "valid", "created" => $this->_helper->generator->generateCurrentTime());
$db = Zend_Registry::get("db");
$db->beginTransaction();
// check if notification to be added is already exist.
// only add to mail queue if it's a new one.
$notification = $this->advertisementNotification->findByAdvertisementTypeAndStatus($advertisement->id, "close_advertisement", "valid");
if (empty($notification)) {
$this->advertisementNotification->addOneEntry($data);
$subject = MailTemplate::SUBJECT_CLOSE_NOTICATION;
$user = Advertisement::getUser($advertisement->id);
$pos = strpos($user->email, "@zugefangzi.com");
if ($pos == false) {
$sender = Constant::SYSTEM_MAIL;
} else {
$sender = Constant::EMAIL_TO_SERVER;
}
$recipient = $user->email;
$message = MailTemplate::getNotificationEmailMessage($advertisement, $recipient, MailTemplate::CLOSE_NOTIFICATION_BODY, Constant::CLOSE_NOTIFICATION);
$this->mailQueue->addToQueue(MailType::CLOSE_NOTIFICATION, null, $subject, $sender, $recipient, $message, $this->_helper->generator->generateCurrentTime());
$numOfAffected++;
}
$db->commit();
}
echo $numOfAffected . " advertisement(s) are affected";
echo "<hr/>";
// close down expired advertisements
$advertisements = $this->advertisement->findAdvertisementToClose();
$numOfAdvs = count($advertisements);
echo "Close expired advertisements<br/>";
echo $numOfAdvs . " advertisements found<br/>";
$numOfAffected = 0;
$db = Zend_Registry::get("db");
$db->beginTransaction();
foreach ($advertisements as $advertisement) {
$advertisement->status = PostStatus::CLOSED;
$advertisement->save();
$subject = MailTemplate::SUBJECT_CLOSED_POST;
$user = Advertisement::getUser($advertisement->id);
$pos = strpos($user->email, "@zugefangzi.com");
if ($pos == false) {
$sender = Constant::SYSTEM_MAIL;
} else {
$sender = Constant::EMAIL_TO_SERVER;
}
$recipient = $user->email;
$message = MailTemplate::getNotificationEmailMessage($advertisement, $recipient, MailTemplate::CLOED_POST_BODY, Constant::CLOSE_NOTIFICATION);
$this->mailQueue->addToQueue(MailType::SYSINFO, null, $subject, $sender, $recipient, $message, $this->_helper->generator->generateCurrentTime());
$numOfAffected++;
}
$db->commit();
echo $numOfAffected . " advertisement(s) are affected";
} else {
throw new Exception('Not allowed to run the service!');
}
}