Пример #1
0
 /**
  * Verify smarty Action
  *
  * Validates if the given value contains valid smartystring
  *
  * @return void
  */
 public function verifySmartyAction()
 {
     if (!($id = $this->Request()->getParam('id'))) {
         $this->View()->assign(array('success' => false, 'message' => 'mail id found'));
         return;
     }
     /* @var $mail Mail */
     $mail = $this->getRepository()->find($id);
     if (!$mail) {
         $this->View()->assign(array('success' => false, 'message' => 'Mail not found'));
         return;
     }
     if (!($value = $this->Request()->getParam('value'))) {
         $this->View()->assign(array('success' => false, 'message' => 'Value not found'));
     }
     $compiler = new Shopware_Components_StringCompiler($this->View()->Engine());
     $shop = Shopware()->Models()->getRepository('Shopware\\Models\\Shop\\Shop')->getActiveDefault();
     $shop->registerResources(Shopware()->Bootstrap());
     $defaultContext = array('sShop' => Shopware()->Config()->get('ShopName'), 'sShopURL' => 'http://' . $shop->getHost() . $shop->getBasePath(), 'sConfig' => Shopware()->Config());
     $compiler->setContext(array_merge($defaultContext, $mail->getContext()));
     try {
         $template = $compiler->compileString($value);
     } catch (Enlight_Exception $e) {
         $this->View()->assign(array('success' => false, 'message' => $e->getMessage()));
         return;
     }
     $this->View()->assign(array('success' => true, 'message' => $template));
 }
 /**
  * Test case
  *
  * @expectedException Enlight_Exception
  * @expectedExceptionMessage Syntax Error 74"  on line 1 "Hallo {$user|invalidmodifier}" unknown modifier "invalidmodifier&quot
  */
 public function testInvalidSmartyShouldThrowExceptionAndCustomExceptionMessage()
 {
     $defectSmartyString = 'Hallo {$user|invalidmodifier}';
     $this->compiler->compileString($defectSmartyString);
 }
Пример #3
0
 /**
  * Sends the mail to the merchant if the inquiry was
  * successful or was declined.
  *
  * @public
  * @return bool
  */
 public function sendMailToMerchantAction()
 {
     $params = $this->Request()->getParams();
     $mail = clone Shopware()->Container()->get('mail');
     $toMail = $params['toMail'];
     $fromName = $params['fromName'];
     $fromMail = $params['fromMail'];
     $subject = $params['subject'];
     $content = $params['content'];
     $userId = $params["userId"];
     $status = $params["status"];
     if (!$toMail || !$fromName || !$fromMail || !$subject || !$content || !$userId) {
         $this->View()->assign(array('success' => false, 'message' => 'All required fiels needs to be filled.'));
         return false;
     }
     $content = preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $params['content']);
     $compiler = new Shopware_Components_StringCompiler($this->View());
     $defaultContext = array('sConfig' => Shopware()->Config());
     $compiler->setContext($defaultContext);
     // Send eMail to customer
     $mail->IsHTML(false);
     $mail->From = $compiler->compileString($fromMail);
     $mail->FromName = $compiler->compileString($fromName);
     $mail->Subject = $compiler->compileString($subject);
     $mail->Body = $compiler->compileString($content);
     $mail->clearRecipients();
     $mail->addTo($toMail);
     if (!$mail->send()) {
         $this->View()->assign(array('success' => false, 'message' => 'The mail could not be sent.'));
         return false;
     } else {
         if ($status == "accepted") {
             Shopware()->Container()->get('db')->query("\n                                    UPDATE s_user SET customergroup = validation, validation = '' WHERE id = ?\n                                    ", array($userId));
         } else {
             Shopware()->Container()->get('db')->query("\n                                    UPDATE s_user SET validation = '' WHERE id = ?\n                                    ", array($userId));
         }
     }
     $this->View()->assign(array('success' => true, 'message' => 'The mail was send successfully.'));
 }