当前位置: 首页>>代码示例>>PHP>>正文


PHP LogHelper::addWarning方法代码示例

本文整理汇总了PHP中LogHelper::addWarning方法的典型用法代码示例。如果您正苦于以下问题:PHP LogHelper::addWarning方法的具体用法?PHP LogHelper::addWarning怎么用?PHP LogHelper::addWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogHelper的用法示例。


在下文中一共展示了LogHelper::addWarning方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 /**
  * The main send of one letter to one or mode recipients.
  * The mail content generates for each user
  *
  * TODO: Need to refactor it all to:
  * sendNewsletterToSubscriber($nid, $sid, $options)
  * sentNewsletterToEmail($nid, array $emailAndName, $options)
  * sentLetterToEmail(array $letterData, array $emailAndName, $options)
  * 
  * @param  array $params newsletter_id, subscriber(object), type ('html'|'plain'), tracking(bool)
  *
  * @return object
  * @since  1.0
  */
 public function send($params = null)
 {
     // load letter to send....
     if (empty($params['newsletter_id'])) {
         $msg = 'Newsletter id is absent. There is nothing to send.';
         $this->setError($msg);
         throw new Exception($msg);
     }
     if (empty($params['subscriber'])) {
         $msg = 'Subscriber is absent. There is no one to send.';
         $this->setError($msg);
         throw new Exception($msg);
     }
     if (empty($params['tracking'])) {
         $params['tracking'] = false;
     }
     // Load newsletter...
     $letter = JModel::getInstance('Newsletter', 'NewsletterModelEntity');
     if (!$letter->load($params['newsletter_id'])) {
         $msg = 'Loading letter error or newsletter_id is not defined. Id:' . $params['newsletter_id'];
         $this->setError($msg);
         throw new Exception($msg);
     }
     // Load newsletter's SMTP profile...
     $smtpProfile = JModel::getInstance('Smtpprofile', 'NewsletterModelEntity');
     if (!$smtpProfile->load($letter->smtp_profile_id)) {
         $msg = 'Cant load SMTP profile with id: ' . $letter->smtp_profile_id;
         $this->setError($msg);
         throw new Exception($msg);
     }
     // Load mailbox profile bound to loaded SMTP profile...
     $mailboxProfile = JModel::getInstance('Mailboxprofile', 'NewsletterModelEntity');
     if (!$mailboxProfile->load($smtpProfile->mailbox_profile_id)) {
         LogHelper::addWarning('COM_NEWSLETTER_CANT_LOAD_MAILBOX_CANT_SET_SOME_HEADERS', LogHelper::CAT_MAILER, array('Mailbox profile id' => $smtpProfile->mailbox_profile_id, 'SMTP profile' => $smtpProfile->smtp_profile_name));
     }
     // Now we have newsletter, subscriber, SMTP profile and, probably, Mailbox profile.
     // So we can start to send...
     // Use the phpMailer exceptions
     $sender = new MigurMailerSender(array('exceptions' => true));
     $subscriber = $params['subscriber'];
     $type = MailHelper::filterType(!empty($params['type']) ? $params['type'] : null);
     if (!$type) {
         $msg = 'The type "' . $type . '" is not supported';
         $this->setError($msg);
         throw new Exception($msg);
     }
     // emulate user environment
     SubscriberHelper::saveRealUser();
     if (!SubscriberHelper::emulateUser(array('email' => $subscriber->email))) {
         $msg = 'The user "' . $subscriber->email . '" is absent';
         $this->setError($msg);
         throw new Exception($msg);
     }
     PlaceholderHelper::setPlaceholder('newsletter id', $letter->newsletter_id);
     // render the content of letter for each user
     $letter->content = $this->render(array('type' => $type, 'newsletter_id' => $letter->newsletter_id, 'tracking' => true));
     $letter->subject = $this->renderSubject($letter->subject);
     $letter->encoding = $letter->params->encoding;
     SubscriberHelper::restoreRealUser();
     // Result object
     $res = new StdClass();
     $res->state = false;
     $res->errors = array();
     $res->content = $letter->content;
     if ($letter->content === false) {
         return $res;
     }
     // Add custom headers
     // Set the email to bounce
     if (!empty($mailboxProfile->username)) {
         $sender->AddCustomHeader('Return-Path:' . $mailboxProfile->username);
         $sender->AddCustomHeader('Return-Receipt-To:' . $mailboxProfile->username);
         $sender->AddCustomHeader('Errors-To:' . $mailboxProfile->username);
     }
     // Add info about newsleerter and subscriber
     $sender->AddCustomHeader(MailHelper::APPLICATION_HEADER);
     $sender->AddCustomHeader(MailHelper::EMAIL_NAME_HEADER . ':' . $letter->name);
     $sender->AddCustomHeader(MailHelper::NEWSLETTER_ID_HEADER . ':' . $params['newsletter_id']);
     $sender->AddCustomHeader(MailHelper::SUBSCRIBER_ID_HEADER . ':' . $subscriber->subscriber_id);
     // Get attachments
     $atts = DownloadHelper::getByNewsletterId($params['newsletter_id']);
     if (!$smtpProfile->isJoomlaProfile()) {
         $fromName = $smtpProfile->from_name;
         $fromEmail = $smtpProfile->from_email;
         $toName = $smtpProfile->reply_to_name;
         $toEmail = $smtpProfile->reply_to_email;
//.........这里部分代码省略.........
开发者ID:Rikisha,项目名称:proj,代码行数:101,代码来源:mailer.php


注:本文中的LogHelper::addWarning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。