本文整理汇总了PHP中EmailMessage::forget方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailMessage::forget方法的具体用法?PHP EmailMessage::forget怎么用?PHP EmailMessage::forget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailMessage
的用法示例。
在下文中一共展示了EmailMessage::forget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateEmailMessageThatIsANotification
/**
* A notification email is different than a regular outbound email because it is owned by a super user
* that is different than the user logged in. So the sender does not have a 'person'
*/
public function testCreateEmailMessageThatIsANotification()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$billy = User::getByUsername('billy');
$this->assertEquals(0, EmailMessage::getCount());
$emailMessage = new EmailMessage();
$emailMessage->owner = BaseControlUserConfigUtil::getUserToRunAs();
$emailMessage->subject = 'My First Email';
//Set sender, and recipient, and content
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'My First Message';
$emailContent->htmlContent = 'Some fake HTML content';
$emailMessage->content = $emailContent;
//Sending from the system, does not have a 'person'.
$sender = new EmailMessageSender();
$sender->fromAddress = 'system@somewhere.com';
$sender->fromName = 'Zurmo System';
$emailMessage->sender = $sender;
//Recipient is billy.
$recipient = new EmailMessageRecipient();
$recipient->toAddress = 'billy@fakeemail.com';
$recipient->toName = 'Billy James';
$recipient->type = EmailMessageRecipient::TYPE_TO;
$recipient->personsOrAccounts->add($billy);
$emailMessage->recipients->add($recipient);
//At this point the message is in no folder
$this->assertTrue($emailMessage->folder->id < 0);
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
//Save, at this point the email should be in the draft folder
$saved = $emailMessage->save();
$this->assertTrue($saved);
$this->assertTrue($emailMessage->folder->id > 0);
$this->assertEquals(0, EmailMessageSendError::getCount());
$emailMessageSendError = new EmailMessageSendError();
$data = array();
$data['message'] = 'error message';
$emailMessageSendError->serializedData = serialize($data);
$emailMessage->folder = EmailFolder::getByBoxAndType($emailMessage->folder->emailBox, EmailFolder::TYPE_OUTBOX_ERROR);
$emailMessage->error = $emailMessageSendError;
$saved = $emailMessage->save();
$this->assertTrue($saved);
$this->assertEquals(1, EmailMessageSendError::getCount());
//Now swap the error with a new one
$emailMessageId = $emailMessage->id;
$emailMessage->forget();
$emailMessage = EmailMessage::getById($emailMessageId);
$emailMessageSendError = new EmailMessageSendError();
$data = array();
$data['message'] = 'error message 2';
$emailMessageSendError->serializedData = serialize($data);
$emailMessage->error = $emailMessageSendError;
$saved = $emailMessage->save();
$this->assertTrue($saved);
$this->assertEquals(1, EmailMessageSendError::getCount());
}
示例2: updateEmailMessageForSending
/**
* Updates the email message using stored procedure
* @param EmailMessage $emailMessage
*/
protected function updateEmailMessageForSending(EmailMessage $emailMessage, $useSQL = false)
{
if (!$useSQL) {
Yii::log("EmailMessage should have been saved by this point. Anyways, saving now", CLogger::LEVEL_INFO);
// we save it and return. No need to call SP as the message is saved already;
$emailMessage->save(false);
return;
}
$nowTimestamp = "'" . DateTimeUtil::convertTimestampToDbFormatDateTime(time()) . "'";
$sendAttempts = $emailMessage->sendAttempts ? $emailMessage->sendAttempts : 1;
$sentDateTime = $emailMessage->sentDateTime ? "'" . $emailMessage->sentDateTime . "'" : 'null';
$serializedData = $emailMessage->error->serializedData ? "'" . $emailMessage->error->serializedData . "'" : 'null';
$sql = '`update_email_message_for_sending`(
' . $emailMessage->id . ',
' . $sendAttempts . ',
' . $sentDateTime . ',
' . $emailMessage->folder->id . ',
' . $serializedData . ',
' . $nowTimestamp . ')';
ZurmoDatabaseCompatibilityUtil::callProcedureWithoutOuts($sql);
$emailMessage->forget();
}