/** * Displays the contact page */ public function actionContact() { $model = CustomPage::LoadByRequestUrl('contact-us'); $this->pageTitle = $model->PageTitle; $this->pageDescription = $model->meta_description; $this->breadcrumbs = array($model->title => $model->RequestUrl); $this->layout = "//layouts/column" . $model->column_template; $ContactForm = new ContactForm(); if (isset($_POST['ContactForm'])) { $ContactForm->attributes = $_POST['ContactForm']; if ($ContactForm->validate()) { $objEmail = new EmailQueue(); if (!Yii::app()->user->isGuest) { $objCustomer = Customer::GetCurrent(); $objEmail->customer_id = $objCustomer->id; $ContactForm->fromName = $objCustomer->mainname; $ContactForm->fromEmail = $objCustomer->email; } $strHtmlBody = $this->renderPartial('/mail/_contactform', array('model' => $ContactForm), true); $strSubject = Yii::t('email', 'Contact Us:') . $ContactForm->contactSubject; $objEmail->htmlbody = $strHtmlBody; $objEmail->subject = $strSubject; $orderEmail = _xls_get_conf('ORDER_FROM', ''); $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail; $objHtml = new HtmlToText(); //If we get back false, it means conversion failed which 99.9% of the time means improper HTML. $strPlain = $objHtml->convert_html_to_text($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } if (!$objEmail->save()) { Yii::log("Error creating email " . print_r($objEmail, true) . " " . print_r($objEmail->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } Yii::app()->user->setFlash('success', Yii::t('email', 'Message sent. Thank you for contacting us. We will respond to you as soon as possible.')); //Attempt to use an AJAX call to send the email. If it doesn't work, the Download process will catch it anyway. $jsScript = "\$.ajax({url:\"" . CController::createUrl('site/sendemail', array("id" => $objEmail->id)) . "\"});"; Yii::app()->clientScript->registerScript('sendemail', $jsScript, CClientScript::POS_READY); } else { Yii::app()->user->setFlash('error', Yii::t('cart', 'Please check your form for errors.')); if (YII_DEBUG) { Yii::app()->user->setFlash('error', print_r($ContactForm->getErrors(), true)); } } } if (!Yii::app()->user->isGuest) { $objCustomer = Customer::GetCurrent(); $ContactForm->fromName = $objCustomer->mainname; $ContactForm->fromEmail = $objCustomer->email; } $this->canonicalUrl = $model->canonicalUrl; $this->render('contact', array('ContactForm' => $ContactForm, 'model' => $model)); }
public function actionEmail() { if (Yii::app()->user->isGuest) { _xls_404(); } $model = new ShareForm(); if (isset($_POST['ShareForm'])) { $model->attributes = $_POST['ShareForm']; if ($model->validate()) { $strCode = $model->code; //Make sure code we've been passed is valid $objWishlist = Wishlist::model()->findByAttributes(array('gift_code' => $strCode)); if (!$objWishlist->Visible) { _xls_404(); } if (!Yii::app()->user->isGuest) { $objCustomer = Customer::model()->findByPk(Yii::app()->user->Id); $model->fromEmail = $objCustomer->email; $model->fromName = $objCustomer->fullname; } $strHtmlBody = $this->renderPartial('/mail/_cart', array('model' => $model), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_WISHLIST', $objWishlist->customer->fullname, null); $objEmail = new EmailQueue(); $objEmail->customer_id = $objWishlist->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->subject = $strSubject; $objEmail->to = $model->toEmail; $objHtml = new HtmlToText(); //If we get back false, it means conversion failed which 99.9% of the time means improper HTML. $strPlain = $objHtml->convert_html_to_text($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); $response_array = array('status' => "success", 'message' => Yii::t('wishlist', 'Your wish list has been sent'), 'url' => CController::createUrl('site/sendemail', array("id" => $objEmail->id)), 'reload' => true); } else { $response_array['status'] = 'error'; $response_array['errormsg'] = _xls_convert_errors($model->getErrors()); } echo json_encode($response_array); } }
if ($response) { if (isset($api->_response_code) && $api->_response_code === MailjetAPI::MAILJET_STATUS_CODE_OK_VIEW) { $campaign = $response->Data[0]; } } else { // case, id is not a newsletter's id but a campaign's id $response = $api->campaign(array('method' => 'VIEW', 'ID' => $campaignId)); if (isset($api->_response_code) && $api->_response_code === MailjetAPI::MAILJET_STATUS_CODE_OK_VIEW) { $campaign = $api->newsletter(array('method' => 'VIEW', 'ID' => $response->Data[0]->NewsLetterID))->Data[0]; } } if ($pageId && $valid) { $contentErrors = CMS_module_mailjet::checkNewsletterContent($pageId); $email = CMS_module_mailjet::getNewsletterContent($pageId); $htmlVersion = $email['content']; $textVersion = HtmlToText::convert_html_to_text($htmlVersion); } if (!$valid || count($contentErrors) > 0) { $disableActions = true; } $validateContentSubmitted = io::post('validate-content'); if ($validateContentSubmitted) { $params = array('method' => 'PUT', 'ID' => $campaignId, 'Html-part' => $htmlVersion, 'Text-part' => $textVersion); $response = $api->newsletterDetailContent($params); if (isset($api->_response_code) && $api->_response_code === MailjetAPI::MAILJET_STATUS_CODE_OK_VIEW) { $contentOk = true; } elseif (isset($api->_response_code) && $api->_response_code === MailjetAPI::MAILJET_STATUS_CODE_OK_ERROR) { $errors[] = 'Erreur pendant l\'envoi du code source de l\'email à Mailjet.'; } else { $errors[] = 'Erreur interne pendant l\'envoi du code source de l\'email à Mailjet.'; }