//baseDir=Zend_Registry::get('config')->publicDir; $this->theme = array(1 => "Заказать (Презентацию, Систему)", 2 => "Техническая поддержка", 3 => "Информационная поддержка", 4 => "Получить консультацию", 5 => "Заказать счет", 6 => "Test-Drive"); } public function saveFeedback($name, $text, $email) { $mFeedback=new Feedback(); $feedback=$mFeedback->createRow(); $feedback->fb_dt=new Zend_Db_Expr('CURDATE()'); $feedback->fb_name=$name; $feedback->fb_text=$text; $feedback->fb_email=$email; $feedback->save(); } public function sendFeedback($formData) { $email = Zend_Registry::get('config')->mail; $cfg = array('auth' => $email->auth, 'username' => $email->smtp_login, 'password' => $email->smtp_password); $transport = new Zend_Mail_Transport_Smtp($email->host);//, $cfg); $mail = new Zend_Mail('UTF-8'); //$mail->setBodyText(iconv('UTF-8', 'ISO-8859-1', $this->_getParam('msg'))); $mail->setBodyHtml("{$formData['text']} From: {$formData['name']} {$formData['email']}; Phone: {$formData['phone']}"); $mail->setFrom($email->from_addres, "Сайт Nargus.com.ua"); $mail->addTo($email->to_addres, $email->to_addres); //$mail->addBcc("x-technology@narod.ru"); $mail->setSubject("Сообщение с сайта Nargus.com.ua - {$formData['theme']}"); //$protocol->rset(); $mail->send($transport); } public function letterAction() { $form=$this->getRForm(); if($this->getRequest()->isPost()) { if($form->isValid($_POST)) { $formData = $form->getValues(); $config = Zend_Registry::get('config'); $email = $config->mail; $cfg = array('auth' => 'login', 'username' => $email->smtp_login, 'password' => $email->smtp_password); $transport = new Zend_Mail_Transport_Smtp($email->smtp_addres, $cfg); /*$protocol = new Zend_Mail_Protocol_Smtp('localhost'); $protocol->connect(); $protocol->helo('localhost');*/ //$transport->setConnection($protocol); $this->view->submitted = $this->_getParam('submitted'); $mail = new Zend_Mail('UTF-8'); //>_getParam('email') //$mail->setBodyText(iconv('UTF-8', 'ISO-8859-1', $this->_getParam('msg'))); $mail->setBodyHtml("{$formData['text']} From: {$formData['name']} {$formData['email']}"); $mail->setFrom($email->from_addres, 'Сообщение с сайта НКЦ «Интеллектуальные системы» - '.$formData['name']); $mail->addTo($email->to_addres, $email->to_addres); $mail->setSubject('НКЦ «Интеллектуальные системы» - '); //$protocol->rset(); $mail->send($transport); // $mailText=" // Имя: {$formData['name']}
// {$formData['text']}
// "; // // $mail = new Zend_Mail( 'utf-8' ); // $mail->setFrom('phantom_778@mail.ru', 'city.kharkov.ua'); // $mail->addTo('oleg@shemetov.info', 'мишо добкин'); // $mail->setSubject('[city.kharkov.ua] письмо городскому голове'); // $mail->setBodyText($mailText); //$mail->send(); $this->saveFeedback($formData['name'], $formData['text']); $this->_helper->viewRenderer('letterok'); } else $this->view->form=$form; } else { $this->view->form=$form; } } public function listAction() { $mFeedback=new Feedback(); $fbs=$mFeedback->fetchAll($mFeedback->select()->order('fb_id DESC')); $this->view->fbs=$fbs; $this->view->jquery("admin_letter_lister()"); } public function indexAction() { $th = Zend_Filter_Digits::filter($this->_getParam('t', 4)); $mFeedback = new Feedback(); $limit = 10; $pg = Zend_Filter_Digits::filter($this->_getParam('pg', 1)); $total_cmt = $mFeedback->getCount(); $count = (ceil($total_cmt / $limit)); if ($pg > $count) $pg = $count; if (!$pg) $pg = 1; $Pages = array(); for ($p = 0; $p < $count; $p++) $Pages[] = $p+1; $fbs = $mFeedback->fetchAll($mFeedback->select()->where('fb_enabled=1')->limitPage($pg, $limit)->order('fb_dt DESC')); $this->view->itemsList = $Pages; $this->view->pg = $pg; $this->view->fbs = $fbs; $form=$this->getRForm($th); if($this->getRequest()->isPost()) { if($form->isValid($_POST)) { $formData=$form->getValues(); /*$mailText=" ФИО: {$formData['name']}
email: {$formData['email']}
адрес: {$formData['address']}
телефон: {$formData['phone']}
{$formData['text']}
"; $mail = new Zend_Mail( 'utf-8' ); $mail->setFrom('phantom_778@mail.ru', 'city.kharkov.ua'); $mail->addTo('oleg@shemetov.info', 'мишо добкин'); $mail->setSubject('[city.kharkov.ua] письмо городскому голове'); $mail->setBodyText($mailText);*/ //$mail->send(); //XPA $this->saveFeedback($formData['name'], $formData['text'], $formData['email']); $this->sendFeedback($formData); //XPA $this->_helper->viewRenderer('letterok'); } else $this->view->form=$form; } else { $this->view->form=$form; } $this->view->headTitle($this->translate->_('feedback')); } public function deleteAction() { $id=Zend_Filter_Digits::filter($this->_getParam('id', null)); if(!$id) throw new Zend_Db_Exception('exceptionNoID'); $mFeedback=new Feedback(); $fb=$mFeedback->find($id)->current(); $fb->delete(); $this->_redirect($this->lang.'/feedback/list/'); } public function activateAction() { $id=Zend_Filter_Digits::filter($this->_getParam('id', null)); if(!$id) throw new Zend_Db_Exception('exceptionNoID'); $mFeedback=new Feedback(); $fb=$mFeedback->find($id)->current(); $fb->fb_enabled = !$fb->fb_enabled; $fb->save(); $this->_redirect($this->lang.'/feedback/list/'); } public function getRForm($th) { $mDecorators = new DefaultDecorators(); $form=new Zend_Form(array('method'=>'post', 'class' => 'feedback')); /*$form->addElement('select', 'theme', array( 'label'=>'theme', 'registerInArrayValidator'=>false, 'required'=>true, 'value'=>$th, //'decorators' => $mDecorators->_standardElementDivDecorator, 'MultiOptions' => $this->theme));*/ $form->addElement('text', 'theme', array( 'label'=>'theme', 'class' => 'input_text_string', 'required'=>true, //'decorators' => $mDecorators->_standardElementDivDecorator, 'validators'=>array(array('StringLength', false, array(1, 255))))); $form->addElement('text', 'name', array( 'label'=>'name', 'class' => 'input_text_string', 'required'=>true, //'decorators' => $mDecorators->_standardElementDivDecorator, 'validators'=>array(array('StringLength', false, array(1, 255))))); $form->addElement('text', 'email', array( 'label'=>'email', 'class' => 'input_text_string', 'required'=>true, 'filters'=>array('StripTags'), //'decorators' => $mDecorators->_standardElementNoFloatDivDecorator, 'validators'=>array(array('StringLength', false, array(1, 255)), array('EmailAddress', false)))); $form->addElement('text', 'phone', array( 'label'=>'pe_phone', 'class' => 'input_text_string', 'required'=>true, //'decorators' => $mDecorators->_standardElementDivDecorator, 'validators'=>array(array('StringLength', false, array(1, 255))))); $form->addElement('textarea', 'text', array( 'label'=>'text', 'filters'=>array('StripTags'), //'decorators' => $mDecorators->_standardTextareaNoFloatDivDecorator, 'required'=>true)); $element = new Zend_Form_Element_Captcha('captcha', array( 'label' => "fu_captcha", 'id' => "fu_captcha", 'captcha' => 'Image', // 'decorators' => $mDecorators->_standardCaptchaDivDecorator, 'captchaOptions' => array( 'captcha' => 'Image', 'wordLen' => 6, 'height' => 50, 'font' => "{$this->baseDir}js/verdana.ttf", 'ImgDir' => "{$this->baseDir}images/captcha/", 'ImgUrl' => "{$this->view->baseUrl()}/images/captcha/", 'timeout' => 300 ), )); $form->addElement($element, "fu_captcha"); $form->addElement('submit', 'save', array( 'label'=>'send', //'decorators' => $mDecorators->_standardButtonDecorator )); return $form; } }getResponse()->setHttpResponseCode(404); $errors = $this->_getParam('error_handler'); // $language = Zend_Registry::get('lang'); // тут че-то с языком делать будем if($errors) $this->view->assign('error_msg', $errors['exception']->getMessage()); else { $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found'); $this->view->assign('error_msg', 'error_404'); } $this->view->headTitle($this->translate->_('error')); } }