/**
  * Preapares data for saving of subscriber
  * Add the line for rapidmail status
  *
  * @param  Mage_Newsletter_Model_Subscriber $subscriber
  * @return array
  */
 protected function _prepareSave(Mage_Newsletter_Model_Subscriber $subscriber)
 {
     $data = array();
     $data['customer_id'] = $subscriber->getCustomerId();
     $data['store_id'] = $subscriber->getStoreId() ? $subscriber->getStoreId() : 0;
     $data['subscriber_status'] = $subscriber->getStatus();
     $data['subscriber_email'] = $subscriber->getEmail();
     $data['subscriber_confirm_code'] = $subscriber->getCode();
     $data['rapidmail_status'] = $subscriber->getRapidmailStatus();
     if ($subscriber->getIsStatusChanged()) {
         $data['change_status_at'] = Mage::getSingleton('core/date')->gmtDate();
     }
     $validators = array('subscriber_email' => 'EmailAddress');
     $filters = array();
     $input = new Zend_Filter_Input($filters, $validators, $data);
     $session = Mage::getSingleton($this->_messagesScope);
     if ($input->hasInvalid() || $input->hasMissing()) {
         foreach ($input->getMessages() as $message) {
             if (is_array($message)) {
                 foreach ($message as $error) {
                     $session->addError($error);
                 }
             } else {
                 $session->addError($message);
             }
         }
         Mage::throwException(Mage::helper('newsletter')->__('Form was filled incorrectly'));
     }
     return $data;
 }
 public function searchAction()
 {
     $filters = array('q' => array('StringTrim', 'StripTags'));
     $validators = array('q' => array('presence' => 'required'));
     $input = new Zend_Filter_Input($filters, $validators, $_GET);
     if (is_string($this->_request->getParam('q'))) {
         $queryString = $input->getEscaped('q');
         $this->view->queryString = $queryString;
         if ($input->isValid()) {
             $config = Zend_Registry::get('config');
             $index = App_Search_Lucene::open($config->luceneIndex);
             $query = new Zend_Search_Lucene_Search_Query_Boolean();
             $pathTerm = new Zend_Search_Lucene_Index_Term($queryString);
             $pathQuery = new Zend_Search_Lucene_Search_Query_Term($pathTerm);
             $query->addSubquery($pathQuery, true);
             $pathTerm = new Zend_Search_Lucene_Index_Term('20091023', 'CreationDate');
             $pathQuery = new Zend_Search_Lucene_Search_Query_Term($pathTerm);
             $query->addSubquery($pathQuery, true);
             try {
                 $hits = $index->find($query);
             } catch (Zend_Search_Lucene_Exception $ex) {
                 $hits = array();
             }
             $this->view->hits = $hits;
         } else {
             $this->view->messages = $input->getMessages();
         }
     }
 }
 public function contactUsAction()
 {
     $filters = array('name' => 'StringTrim', 'tel' => 'StringTrim', 'email' => 'StringTrim', 'enquiry' => 'StringTrim');
     $validators = array('name' => 'NotEmpty', 'tel' => 'NotEmpty', 'email' => 'NotEmpty', 'enquiry' => 'NotEmpty');
     $input = new Zend_Filter_Input($filters, $validators, $_POST);
     $returnArray = array();
     if ($input->isValid()) {
         $emailer = new Application_Core_Mail();
         $params = Zend_Registry::get('params');
         $emailer->setTo($params->email->contactUs, 'HomeLet');
         $emailer->setFrom($input->email, $input->name);
         $emailer->setSubject('HomeLet - Contact Us Form');
         $bodyHtml = 'Name : ' . $input->name . '<br />';
         $bodyHtml .= 'Email : ' . $input->email . '<br />';
         $bodyHtml .= 'Tel : ' . $input->tel . '<br />';
         $bodyHtml .= 'Enquiry : <pre>' . $input->enquiry . '</pre><br />';
         $emailer->setBodyHtml($bodyHtml);
         if ($emailer->send()) {
             // Email sent successfully
             $returnArray['success'] = true;
             $returnArray['errorMessage'] = '';
         } else {
             $returnArray['success'] = false;
             $returnArray['errorMessage'] = 'Problem sending email.';
         }
     } else {
         $returnArray['success'] = false;
         $returnArray['errorMessage'] = $input->getMessages();
     }
     echo Zend_Json::encode($returnArray);
 }
Exemple #4
0
 protected function _filterInputBlock($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim'), 'value' => array(array('Alnum', array('allowwhitespace' => true))), 'long_description' => array(), 'conclusion_text' => array(array('Alnum', array('allowwhitespace' => true)))), array('questionnaire_id' => array('NotEmpty'), 'designation' => array('allowEmpty' => true), 'value' => array('NotEmpty', 'messages' => array('O nome do bloco não pode ser vazio.')), 'long_description' => array('allowEmpty' => true), 'conclusion_text' => array('allowEmpty' => true)), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #5
0
 protected function _filterInputQuestion($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim'), 'term' => array(array('Alnum', array('allowwhitespace' => true))), 'description' => array(array('HtmlEntities'))), array('term' => array('NotEmpty'), 'description' => array('NotEmpty')), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #6
0
 protected function _filterInputConfiguration($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim')), array(), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
 protected function _filterInputECAC($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim')), array('enterprise_id' => array('NotEmpty', 'messages' => array('Erro ao cadastrar empresa'), 'presence' => 'required'), 'competition_id' => array('NotEmpty', 'messages' => array('Erro ao cadastrar empresa'), 'presence' => 'required'), 'category_award_id' => array('NotEmpty', 'messages' => array('Escolha a categoria do premio'), 'presence' => 'required'), 'token' => array('allowEmpty' => true)), $params);
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
 protected function _filterInputAnswerFeedbackImprove($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim')), array('user_id' => array('NotEmpty'), 'answer_id' => array('NotEmpty'), 'feedback_improve' => array('NotEmpty')), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
 protected function _filterInputLogCadastroEmpresa($params)
 {
     $input = new Zend_Filter_Input(array(), array('user_id_log' => array('NotEmpty', 'presence' => 'required'), 'enterprise_id' => array('NotEmpty', 'messages' => array('Erro ao cadastrar empresa.'), 'presence' => 'required'), 'programa_id' => array('NotEmpty', 'messages' => array('Erro ao cadastrar empresa.'), 'presence' => 'required'), 'acao' => array('NotEmpty', 'messages' => array('Erro ao cadastrar empresa.'), 'presence' => 'required')), $params, array());
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #10
0
 protected function _filterInputServiceArea($params)
 {
     $input = new Zend_Filter_Input(array(), array('regional_id' => array('NotEmpty', 'presence' => 'required'), 'StateId' => array('allowEmpty' => true), 'CityId' => array('allowEmpty' => true), 'NeighborhoodId' => array('allowEmpty' => true)), $params);
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
 protected function _filterInputEnterpriseProgramaRank($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim')), array('enterprise_id_key' => array('allowEmpty' => true), 'user_id' => array('allowEmpty' => true), 'programa_id' => array('allowEmpty' => true), 'classificar' => array('allowEmpty' => true), 'desclassificar' => array('allowEmpty' => true), 'justificativa' => array('allowEmpty' => true), 'classificado_verificacao' => array('allowEmpty' => true), 'desclassificado_verificacao' => array('allowEmpty' => true), 'motivo_desclassificado_verificacao' => array('allowEmpty' => true), 'classificado_ouro' => array('allowEmpty' => true), 'classificado_prata' => array('allowEmpty' => true), 'classificado_bronze' => array('allowEmpty' => true), 'desclassificado_final' => array('allowEmpty' => true), 'motivo_desclassificado_final' => array('allowEmpty' => true), 'classificar_nacional' => array('allowEmpty' => true), 'desclassificar_nacional' => array('allowEmpty' => true), 'motivo_desclassificado_nacional' => array('allowEmpty' => true), 'classificar_fase2_nacional' => array('allowEmpty' => true), 'desclassificar_fase2_nacional' => array('allowEmpty' => true), 'motivo_desclassificado_fase2_nacional' => array('allowEmpty' => true), 'classificado_ouro_nacional' => array('allowEmpty' => true), 'classificado_prata_nacional' => array('allowEmpty' => true), 'classificado_bronze_nacional' => array('allowEmpty' => true), 'classificar_fase3_nacional' => array('allowEmpty' => true), 'desclassificar_fase3_nacional' => array('allowEmpty' => true), 'motivo_desclassificado_fase3_nacional' => array('allowEmpty' => true)), $params);
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
 protected function _filterInputAnnualResultData($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim'), 'value' => array(array('Alnum', array('allowwhitespace' => true))), 'Year' => array(array('Digits', array('allowwhitespace' => true)))), array('annual_result_id' => array('NotEmpty'), 'year' => array('allowEmpty' => true), 'value' => array('allowEmpty' => true)), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #13
0
 protected function _filterInputUserLocality($params)
 {
     $input = new Zend_Filter_Input(array(), array('user_id' => array('NotEmpty', 'presence' => 'required'), 'enterprise_id' => array('allowEmpty' => true), 'regional_id' => array('allowEmpty' => true)), $params);
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #14
0
 protected function _filterInputPresident($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim'), 'name' => array(), 'cpf' => array('Digits')), array('enterprise_id' => array('NotEmpty', 'presence' => 'required'), 'education_id' => array('NotEmpty', 'messages' => array('Escolha o Nivel de Escolaridade.'), 'presence' => 'required'), 'position_id' => array('NotEmpty', 'messages' => array('Escolha o Cargo.'), 'presence' => 'required'), 'find_us_id' => array('NotEmpty', 'messages' => array('Selecione o item como nos conheceu.'), 'presence' => 'required'), 'name' => array('NotEmpty', 'messages' => array('Digite o Nome da candidata.'), 'presence' => 'required'), 'nick_name' => array('allowEmpty' => true), 'cpf' => array('NotEmpty', 'messages' => array('Digite o CPF.'), new Vtx_Validate_Cpf()), 'email' => array('allowEmpty' => true), 'phone' => array('allowEmpty' => true), 'cellphone' => array('allowEmpty' => true), 'born_date' => array('NotEmpty', 'messages' => array('Digite a Data de Nascimento.'), 'presence' => 'required', new Zend_Validate_Date('dd/MM/yyyy')), 'gender' => array('allowEmpty' => true), 'newsletter_email' => array('allowEmpty' => true), 'newsletter_mail' => array('allowEmpty' => true), 'newsletter_sms' => array('allowEmpty' => true), 'agree' => array('NotEmpty', 'messages' => array('É necessário aceitar o regulamento'), 'presence' => 'required'), 'created' => array('allowEmpty' => true)), $params, array());
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #15
0
 protected function _filterInputAnnualResult($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StringTrim'), 'value' => array()), array('question_id' => array(), 'mask' => array('NotEmpty', 'messages' => array('Escolha a máscara do Resultado Anual.')), 'value' => array('NotEmpty', 'messages' => array('Escolha o nome do Resultado Anual.'))), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #16
0
 protected function _filterInputGroup($params)
 {
     $input = new Zend_Filter_Input(array('name' => array(), 'description' => array()), array('name' => array('NotEmpty', 'messages' => array('O Nome não pode ser vazio.')), 'description' => array('NotEmpty', 'messages' => array('A Descrição não pode ser vazia.'))), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
 protected function _filterInputAddressPresident($params)
 {
     $input = new Zend_Filter_Input(array('cep' => array(array('Alnum', array('allowwhitespace' => true)), array('StripTags', 'StringTrim')), 'street_name_full' => array(array('Alnum', array('allowwhitespace' => true)), array('StripTags', 'StringTrim'))), array('address_id' => array('allowEmpty' => true), 'president_id' => array('NotEmpty', 'presence' => 'required'), 'cep' => array('NotEmpty', 'messages' => array('Digite apenas números no CEP da candidata.'), 'presence' => 'required'), 'state_id' => array('NotEmpty', 'messages' => array('Escolha o estado da candidata.')), 'city_id' => array('NotEmpty', 'messages' => array('Escolha a cidade da candidata.')), 'neighborhood_id' => array('NotEmpty', 'messages' => array('Escolha o bairro da candidata.')), 'name_full_log' => array('NotEmpty', 'messages' => array('Digite o nome da Rua da candidata.')), 'street_number' => array('NotEmpty', 'messages' => array('Digite o Número da Rua da candidata.')), 'street_completion' => array('allowEmpty' => true)), $params);
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #18
0
 protected function _filterInputEmailQueue($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim'), 'answer_value' => array(array('Alnum', array('allowwhitespace' => true)))), array('alternative_id' => array('NotEmpty'), 'answer_value' => array('allowEmpty' => true), 'start_time' => array('allowEmpty' => true), 'end_time' => array('allowEmpty' => true), 'answer_date' => array('allowEmpty' => true), 'user_id' => array('NotEmpty'), 'logged_user_id' => array('NotEmpty')), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
 protected function _filterInputRoleQuestionnaire($params)
 {
     $input = new Zend_Filter_Input(array(), array('role_id' => array('NotEmpty', 'messages' => array('Escolha o Papel (perfil)')), 'questionnaire_id' => array('NotEmpty', 'messages' => array('Escolha o questionário')), 'start_date' => array('NotEmpty', new Zend_Validate_Date('dd/MM/yyyy')), 'end_date' => array('NotEmpty', new Zend_Validate_Date('dd/MM/yyyy'))), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
 /**
  * executes the validation and creates an error array or
  * returns the Zend_Filter_Input object
  *
  * @return Zend_Filter_Input|array
  * @param Zend_Filter_Input $input
  */
 protected function validate($input)
 {
     if (!$input->isValid()) {
         $errors = array();
         foreach ($input->getMessages() as $field => $fieldArray) {
             foreach ($fieldArray as $message) {
                 $errors[$field] = $message;
             }
         }
         return $errors;
     } else {
         return $input;
     }
 }
 /**
  * Validate Newsletter template
  *
  * @throws Mage_Core_Exception
  * @return bool
  */
 public function validate()
 {
     $validators = array('template_code' => array(Zend_Filter_Input::ALLOW_EMPTY => false), 'template_type' => 'Int', 'template_sender_email' => 'EmailAddress', 'template_sender_name' => array(Zend_Filter_Input::ALLOW_EMPTY => false));
     $data = array();
     foreach (array_keys($validators) as $validateField) {
         $data[$validateField] = $this->getDataUsingMethod($validateField);
     }
     $validateInput = new Zend_Filter_Input(array(), $validators, $data);
     if (!$validateInput->isValid()) {
         $errorMessages = array();
         foreach ($validateInput->getMessages() as $messages) {
             if (is_array($messages)) {
                 foreach ($messages as $message) {
                     $errorMessages[] = $message;
                 }
             } else {
                 $errorMessages[] = $messages;
             }
         }
         Mage::throwException(join("\n", $errorMessages));
     }
 }
Exemple #22
0
 /**
  *
  * @param \Core_Dto_Mapping $dtoPass
  * @throws \Core_Exception_ServiceLayer_Verification
  */
 public function validatePass(\Core_Dto_Mapping $dtoPass)
 {
     $data = $dtoPass->toArray();
     $filters = array();
     $validators = array('txSenha' => array(array('NotEmpty'), array('StringLength', array('min' => 6)), 'messages' => array(0 => 'O campo Senha Antiga é de preenchimento obrigatório', 1 => 'MN043')), 'txSenhaNova' => array(array('NotEmpty'), array('StringLength', array('min' => 6)), 'messages' => array(0 => 'O campo Nova Senha é de preenchimento obrigatório', 1 => 'MN043')), 'txSenhaNovaConfirm' => array(array('NotEmpty'), array('StringLength', array('min' => 6)), array('Identical', $data['txSenhaNova']), 'messages' => array(0 => 'O campo Confirmação Nova Senha é de preenchimento obrigatório', 1 => 'MN043', 2 => 'A confirmação da nova senha não confere.')));
     $input = new \Zend_Filter_Input($filters, $validators, $data);
     if (!$input->isValid()) {
         foreach ($input->getMessages() as $msgError) {
             switch (key($msgError)) {
                 case 'isEmpty':
                     $this->getMessaging()->addErrorMessage($msgError['isEmpty']);
                     break;
                 case 'stringLengthTooShort':
                     $this->getMessaging()->addErrorMessage($msgError['stringLengthTooShort']);
                     break;
                 case 'notSame':
                     $this->getMessaging()->addErrorMessage($msgError['notSame']);
                     break;
             }
         }
         $this->getMessaging()->dispatchPackets();
         throw new \Core_Exception_ServiceLayer_Verification();
     }
 }
 public function viewAction()
 {
     $id = $this->_request->getParam('id');
     $captchaCode = $this->_request->getParam('captcha_code');
     $modelBlog = new Page();
     $blog = $modelBlog->getPage($id);
     if ($blog) {
         $this->view->blog = $blog;
         // tags
         $modelTags = new Tags();
         $where = array('blog_id' => $id);
         $tags = $modelTags->getTags($where);
         if ($tags) {
             $this->view->tags = $tags;
         }
         // 评论
         $modelComment = new Comment();
         $comments = $modelComment->getComments($id);
         $this->view->comments = $comments;
         $dataComment = $this->_request->getPost();
         // 获取表单提交值
         if ($dataComment) {
             if ($dataComment['captcha'] == $captchaCode) {
                 // 定义过滤规则
                 $filters = array('name' => array('StringTrim'), 'comment' => 'StripTags');
                 // 定义验证规则
                 $validators = array('name' => array(array('StringLength', 3, 16), 'NotEmpty', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_StringLength::INVALID => "请输入一个合法的字符串", Zend_Validate_StringLength::TOO_SHORT => "请输入字符长度为3-16", Zend_Validate_StringLength::TOO_LONG => "请输入字符长度为3-16"))), 'email' => array('EmailAddress', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_EmailAddress::INVALID_FORMAT => "邮件格式不正确,请重新输入。"))), 'comment' => array());
                 // 实例化过滤器并进行过滤验证
                 $data = $_POST;
                 $filterPost = new Zend_Filter_Input($filters, $validators, $data);
                 if ($filterPost->hasInvalid() || $filterPost->hasMissing()) {
                     $messages = $filterPost->getMessages();
                     foreach ($messages as $message) {
                         foreach ($message as $value) {
                             echo $value . "<br />";
                         }
                     }
                 }
                 // 将经过验证的数据写入数据库
                 $modelComment = new Comment();
                 $newComment = $modelComment->createComment($pid = $id, $filterPost->name, $filterPost->email, $filterPost->comment);
                 if ($newComment) {
                     $this->_redirect('/blog/view/id/' . $id);
                 } else {
                     echo "评论提交出错!";
                 }
             } else {
                 echo "验证码错误,请刷新后重新输入。";
             }
         }
         // 生成验证码
         $this->captcha_session = new Zend_Session_Namespace('captcha');
         //在默认构造函数里实例化
         $captcha = new Zend_Captcha_Image(array('font' => 'images/SIMYOU.TTF', 'session' => $this->captcha_session, 'fontsize' => 15, 'imgdir' => 'images/code/', 'width' => 120, 'height' => 30, 'gcFreq' => 3, 'dotNoiseLevel' => 5, 'lineNoiseLevel' => 1, 'wordlen' => 4));
         $captcha->generate();
         // 生成图片
         // 界面方式
         $this->view->img_dir = $captcha->getImgDir();
         $this->view->captcha_id = $captcha->getId();
         //图片文件名,md5编码
         $this->view->captcha_code = $captcha->getWord();
         $this->view->id = $id;
     } else {
         echo "该博客文章不存在!";
     }
 }
Exemple #24
0
 /**
  * Prepares template for saving, validates input data
  *
  * @param   Mage_Newsletter_Model_Template $template
  * @return  array
  */
 protected function _prepareSave(Mage_Newsletter_Model_Template $template)
 {
     $data = array();
     $data['template_code'] = $template->getTemplateCode();
     $data['template_text'] = $template->getTemplateText();
     $data['template_text_preprocessed'] = $template->getTemplateTextPreprocessed();
     $data['template_type'] = (int) $template->getTemplateType();
     $data['template_subject'] = $template->getTemplateSubject();
     $data['template_sender_name'] = $template->getTemplateSenderName();
     $data['template_sender_email'] = $template->getTemplateSenderEmail();
     $data['template_actual'] = !is_null($template->getTemplateActual()) && $template->getTemplateActual() == 0 ? 0 : 1;
     if (!$template->getAddedAt()) {
         $template->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
         $template->setModifiedAt(Mage::getSingleton('core/date')->gmtDate());
     }
     $data['modified_at'] = $template->getModifiedAt();
     $data['added_at'] = $template->getAddedAt();
     if ($this->checkCodeUsage($template)) {
         Mage::throwException(Mage::helper('newsletter')->__('Duplicate of template code'));
     }
     $validators = array('template_code' => array(Zend_Filter_Input::ALLOW_EMPTY => false), 'template_type' => 'Alnum', 'template_sender_email' => 'EmailAddress', 'template_sender_name' => array(Zend_Filter_Input::ALLOW_EMPTY => false));
     $validateInput = new Zend_Filter_Input(array(), $validators, $data);
     if (!$validateInput->isValid()) {
         $errorString = '';
         foreach ($validateInput->getMessages() as $message) {
             if (is_array($message)) {
                 foreach ($message as $str) {
                     $errorString .= $str . "\n";
                 }
             } else {
                 $errorString .= $message . "\n";
             }
         }
         Mage::throwException($errorString);
     }
     return $data;
 }
Exemple #25
0
 /**
  * Validate Newsletter template
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function validate()
 {
     $validators = ['template_code' => [\Zend_Filter_Input::ALLOW_EMPTY => false], 'template_type' => 'Int', 'template_sender_email' => 'EmailAddress', 'template_sender_name' => [\Zend_Filter_Input::ALLOW_EMPTY => false]];
     $data = [];
     foreach (array_keys($validators) as $validateField) {
         $data[$validateField] = $this->getDataUsingMethod($validateField);
     }
     $validateInput = new \Zend_Filter_Input([], $validators, $data);
     if (!$validateInput->isValid()) {
         $errorMessages = [];
         foreach ($validateInput->getMessages() as $messages) {
             if (is_array($messages)) {
                 foreach ($messages as $message) {
                     $errorMessages[] = $message;
                 }
             } else {
                 $errorMessages[] = $messages;
             }
         }
         throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $errorMessages)));
     }
 }
 public function testOptionNamespace()
 {
     $data = array('field1' => 'abc', 'field2' => '123', 'field3' => '123');
     $validators = array('field1' => 'MyDigits', 'field2' => 'MyDigits', 'field3' => 'digits');
     $options = array(Zend_Filter_Input::NAMESPACE => 'TestNamespace');
     $ip = get_include_path();
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files';
     $newIp = $dir . PATH_SEPARATOR . $ip;
     set_include_path($newIp);
     $input = new Zend_Filter_Input(null, $validators, $data, $options);
     $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false');
     $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true');
     $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
     $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
     set_include_path($ip);
     $this->assertEquals('123', (string) $input->field2);
     $this->assertEquals('123', (string) $input->field3);
     $messages = $input->getMessages();
     $this->assertType('array', $messages);
     $this->assertThat($messages, $this->arrayHasKey('field1'));
     $this->assertEquals("'abc' contains not only digit characters", $messages['field1'][0]);
 }
 public function applyAction()
 {
     $this->view->pageTitle = 'Careers';
     if ($this->getRequest()->isPost()) {
         // Handle the cv file and form data
         $filters = array('name' => 'StringTrim', 'tel' => 'StringTrim', 'email' => 'StringTrim', 'enquiry' => 'StringTrim');
         $validators = array('name' => array('NotEmpty', 'messages' => 'Please enter your name'), 'tel' => array('NotEmpty', 'messages' => 'Please enter your telephone number'), 'email' => array('NotEmpty', 'messages' => 'Please enter your email address'), 'enquiry' => array('NotEmpty', 'messages' => 'Please tell us why this position interests you'));
         $input = new Zend_Filter_Input($filters, $validators, $_POST);
         if ($input->isValid()) {
             $upload = new Zend_File_Transfer();
             // Make sure the file is actually a document
             $upload->clearValidators();
             $upload->setOptions(array('ignoreNoFile' => true));
             //$upload->addValidator('MimeType', false, array('application/msword', 'application/pdf', 'application/rtf', 'text/plain'));
             if ($upload->isValid()) {
                 $params = Zend_Registry::get('params');
                 $uploadPath = $params->cms->fileUploadPath;
                 $upload->setDestination($uploadPath);
                 $upload->receive();
                 $fileInfo = $upload->getFileInfo();
                 $emailer = new Application_Core_Mail();
                 $emailer->setTo($params->email->careers, 'HomeLet');
                 $emailer->setFrom($input->email, $input->name);
                 $emailer->setSubject('HomeLet - Job Application (' . $input->position . ')');
                 $bodyHtml = 'Position : ' . $input->position . '<br />';
                 $bodyHtml .= 'Name : ' . $input->name . '<br />';
                 $bodyHtml .= 'Email : ' . $input->email . '<br />';
                 $bodyHtml .= 'Tel : ' . $input->tel . '<br />';
                 $bodyHtml .= 'Enquiry : <pre>' . $input->enquiry . '</pre><br />';
                 if ($fileInfo['cv_file']['type'] !== null) {
                     $emailer->addAttachment($fileInfo['cv_file']['destination'] . '/' . $fileInfo['cv_file']['name'], $fileInfo['cv_file']['name']);
                 }
                 $emailer->setBodyHtml($bodyHtml);
                 if ($emailer->send()) {
                     $this->_helper->redirector('thanks', 'careers');
                 } else {
                 }
             } else {
                 // Invalid file type
                 $this->view->errors = array('cv_file' => 'Invalid file type');
                 $this->view->name = $input->name;
                 $this->view->tel = $input->tel;
                 $this->view->email = $input->email;
                 $this->view->enquiry = $input->enquiry;
             }
         } else {
             // Invalid form data
             $this->view->errors = $input->getMessages();
             $this->view->name = $input->name;
             $this->view->tel = $input->tel;
             $this->view->email = $input->email;
             $this->view->enquiry = $input->enquiry;
         }
     }
     $careerUrl = $this->getRequest()->getParam('careerID');
     $careerID = substr($careerUrl, 0, strpos($careerUrl, '-'));
     $careers = new Datasource_Cms_Careers();
     $career = $careers->getById($careerID);
     $this->view->title = $career['title'];
     $this->view->id = $career['id'];
 }
Exemple #28
0
 protected function _filterInputRole($params)
 {
     $input = new Zend_Filter_Input(array('*' => array('StripTags', 'StringTrim'), 'roleName' => array('Alpha', array('StringToLower', 'encoding' => 'UTF-8'), new Vtx_Filter_Transliterate())), array('longDescription' => array('NotEmpty'), 'roleName' => array('NotEmpty', 'messages' => $this->_messagesError['roleNameExists'])), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #29
0
 protected function _filterInputAppraiserToEnterprise($params)
 {
     $input = new Zend_Filter_Input(array('enterprise_id' => array()), array('enterprise_id' => array('NotEmpty', 'messages' => array('Empresa não informada.'))), $params, array('presence' => 'required'));
     if ($input->hasInvalid() || $input->hasMissing()) {
         throw new Vtx_UserException(Model_ErrorMessage::getFirstMessage($input->getMessages()));
     }
     return $input;
 }
Exemple #30
0
 /**
  * @group ZF-7394
  */
 public function testSettingMultipleNotEmptyMessages()
 {
     require_once 'Zend/Validate/NotEmpty.php';
     require_once 'Zend/Validate/Regex.php';
     require_once 'Zend/Validate/StringLength.php';
     $filters = array();
     $validators = array('name' => array('NotEmpty', 'messages' => 'Please enter your name'), 'subject' => array('NotEmpty', 'messages' => 'Please enter a subject'), 'email' => array('EmailAddress', 'messages' => 'Please enter a valid Email address'), 'content' => array('NotEmpty', 'messages' => 'Please enter message contents'));
     $data = array('name' => '', 'subject' => '', 'content' => '');
     $filter = new Zend_Filter_Input($filters, $validators, $data);
     $this->assertFalse($filter->isValid());
     $message = $filter->getMessages();
     $this->assertContains('Please enter your name', $message['name']['isEmpty']);
     $this->assertContains('Please enter a subject', $message['subject']['isEmpty']);
     $this->assertContains('Please enter message contents', $message['content']['isEmpty']);
 }