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


PHP Subscriber::setCode方法代码示例

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


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

示例1: executeResult

 public function executeResult()
 {
     $this->setLayout(false);
     if ($code = $this->getRequestParameter("codeid")) {
         $c = new Criteria();
         $c->add(SubscriberPeer::CODE, $code);
         $user = SubscriberPeer::doSelectOne($c);
         if ($user) {
             $user->setPublicationStatus(UtilsHelper::STATUS_ACTIVE);
             //$user->setCode(null);
             $user->save();
             $this->msg = "Subscribtion confirmed";
         } else {
             $this->err = "A problem occured";
         }
         return "Confirm";
     }
     $email = trim($this->getRequestParameter('newsletter_email'));
     if (!empty($email)) {
         $new = false;
         $c = new Criteria();
         $c->add(SubscriberPeer::EMAIL, $email);
         $c->add(SubscriberPeer::PUBLICATION_STATUS, UtilsHelper::STATUS_WAITING);
         $subscriber = SubscriberPeer::doSelectOne($c);
         if (!$subscriber) {
             $subscriber = new Subscriber();
             $subscriber->setLabel($email);
             $subscriber->setEmail($email);
             $code = md5(time());
             $subscriber->setCode($code);
             $new = true;
         } else {
             $code = $subscriber->getCode();
         }
         $from_name = UtilsHelper::SYSTEM_SENDER;
         $from_email = UtilsHelper::NO_REPLY_MAIL;
         $mail = new sfMail();
         $mail->initialize();
         $mail->setMailer('sendmail');
         $mail->setCharset('utf-8');
         $mail->setSender($from_email, $from_name);
         $mail->setFrom($from_email, $from_name);
         $mail->addReplyTo($from_email);
         $mail->addAddress($email);
         $mail->addBcc(UtilsHelper::COPY_MAIL);
         $mail->setContentType('text/html');
         $mail->setSubject('Newsletter subscribtion');
         $resultPage = Document::getDocumentByExclusiveTag('website_page_newsletter_result');
         if ($resultPage) {
             $resultPageHref = $resultPage->getHref();
         }
         $request = $this->getRequest();
         $request->setParameter('activationUrl', $resultPageHref . "?codeid=" . $code);
         $body = $this->getPresentationFor("newsletter", "confirmMail");
         $mail->setBody($body);
         try {
             $mail->send();
             $defMailinglist = Document::getDocumentByExclusiveTag('newsletter_mailinglist_default');
             if ($defMailinglist && $new) {
                 $subscriber->save(null, $defMailinglist);
                 $subscriber->setPublicationStatus(UtilsHelper::STATUS_WAITING, true);
             }
             $this->msg = "Subscribtion successfull, check your email";
         } catch (Exception $e) {
             $this->getRequest()->setError('newsletter_email', "A problem occured");
         }
     } else {
         $this->getRequest()->setError('newsletter_email', "Please enter your email");
         $this->form = true;
     }
 }
开发者ID:kotow,项目名称:work,代码行数:71,代码来源:actions.class.php


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