Example #1
11
 /**
  * exec post user question
  * @return void
  * @throws \Exception
  */
 public function execute()
 {
     $post = $this->getRequest()->getPostValue();
     if (!$post) {
         $this->_redirect('*/*/');
         return;
     }
     $this->inlineTranslation->suspend();
     try {
         $postObject = new \Magento\Framework\DataObject();
         $postObject->setData($post);
         $error = false;
         /* validate-checking */
         if (!\Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
             $error = true;
         }
         if (!\Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
             $error = true;
         }
         if (!\Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
             $error = true;
         }
         /**
          * setting custome param
          * add new elements : product_name & product_sku information
          */
         if (array_key_exists('product_name', $post) && array_key_exists('product_sku', $post)) {
             if (!\Zend_Validate::is(trim($post['product_name']), 'NotEmpty')) {
                 $error = true;
             }
             if (!\Zend_Validate::is(trim($post['product_sku']), 'NotEmpty')) {
                 $error = true;
             }
         }
         /* this column, hideit, is not so sure for using during this process, so I close it temporarily....
            if (!\Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
                    $error = true;
            }*/
         if ($error) {
             throw new \Exception();
             //todo
         }
         /* Transport email to user */
         $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
         $transport = $this->_transportBuilder->setTemplateIdentifier($this->scopeConfig->getValue(self::XML_PATH_EMAIL_TEMPLATE, $storeScope))->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject])->setFrom($this->scopeConfig->getValue(self::XML_PATH_EMAIL_SENDER, $storeScope))->addTo($this->scopeConfig->getValue(self::XML_PATH_EMAIL_RECIPIENT, $storeScope))->setReplyTo($post['email'])->getTransport();
         $transport->sendMessage();
         $this->inlineTranslation->resume();
         $this->messageManager->addSuccess(__('Hi there, this is Optoma, and thanks for your contacting with us about your questions by nice information, and we will notify you very     soon, see you next time~'));
         /* redirect to new page :: pending */
         $this->_redirect('contact/index');
         return;
     } catch (\Exception $e) {
         /* Error Log should be noted here */
         $this->inlineTranslation->resume();
         $this->messageManager->addError(__('Hi there, this is Optoma, so sorry for that we just cant\'t process your request right now, please wait a minutes and we will contact y    ou very soon~'));
         $this->_redirect('contact/index');
         //todo
         return;
     }
 }
Example #2
1
 /**
  * Post user question
  *
  * @return void
  * @throws \Exception
  */
 public function execute()
 {
     $post = $this->getRequest()->getPostValue();
     if (!$post) {
         $this->_redirect('*/*/');
         return;
     }
     $this->inlineTranslation->suspend();
     try {
         $postObject = new \Magento\Framework\DataObject();
         $postObject->setData($post);
         $error = false;
         if (!\Zend_Validate::is(trim($post['contact_email']), 'EmailAddress')) {
             $error = true;
         }
         if (!\Zend_Validate::is(trim($post['contact_question']), 'NotEmpty')) {
             $error = true;
         }
         if ($error) {
             throw new \Exception();
         }
         $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
         $transport = $this->_transportBuilder->setTemplateIdentifier($this->scopeConfig->getValue(self::XML_PATH_EMAIL_TEMPLATE, $storeScope))->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject])->setFrom($this->scopeConfig->getValue(self::XML_PATH_EMAIL_SENDER, $storeScope))->addTo($this->scopeConfig->getValue(self::XML_PATH_EMAIL_RECIPIENT, $storeScope))->setReplyTo($post['contact_email'])->getTransport();
         $transport->sendMessage();
         $this->inlineTranslation->resume();
         $this->messageManager->addSuccess(__('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.'));
         $this->_redirect('delivery-charges');
         return;
     } catch (\Exception $e) {
         $this->inlineTranslation->resume();
         $this->messageManager->addError(__('We can\'t process your request right now. Sorry, that\'s all we know.'));
         $this->_redirect('delivery-charges');
         return;
     }
 }
Example #3
0
 /**
  * Parameters check for user-sign-in action 
  *
  * @param array $params
  * @param string $msg Error message when false
  * @return bool
  */
 public function isValid(&$params, &$msg = null)
 {
     if (!isset($params['uname'])) {
         $msg = 'Username can not be null';
         return false;
     }
     $params['uname'] = strtolower(trim($params['uname']));
     if (!ereg('^[a-z]{1,1}[a-z0-9]{2,15}$', $params['uname'])) {
         $msg = 'Invalid Username';
         return false;
     }
     if (!Zend_Validate::is($params['pass'], 'StringLength', array(6, 32))) {
         $msg = 'Password must between 6 and 32 characters long';
         return false;
     }
     if ($params['pass'] != $params['repass']) {
         $msg = 'Passwords do not match';
         return false;
     }
     if (!Zend_Validate::is($params['email'], 'EmailAddress')) {
         $msg = 'This is not a valid email address';
         return false;
     }
     return true;
 }
 /**
  * New subscription action
  */
 public function newAction()
 {
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
         $session = Mage::getSingleton('core/session');
         $customerSession = Mage::getSingleton('customer/session');
         $email = (string) $this->getRequest()->getPost('email');
         try {
             if (!Zend_Validate::is($email, 'EmailAddress')) {
                 Mage::throwException($this->__('Please enter a valid email address.'));
             }
             if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 && !$customerSession->isLoggedIn()) {
                 Mage::throwException($this->__('Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl()));
             }
             $ownerId = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email)->getId();
             if ($ownerId !== null && $ownerId != $customerSession->getId()) {
                 Mage::throwException($this->__('This email address is already assigned to another user.'));
             }
             $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
             if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
                 $session->addSuccess($this->__('Confirmation request has been sent.'));
             } else {
                 $session->addSuccess($this->__('Thank you for your subscription.'));
             }
         } catch (Mage_Core_Exception $e) {
             $session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
         } catch (Exception $e) {
             $session->addException($e, $this->__('There was a problem with the subscription.'));
         }
     }
     $this->_redirectReferer();
 }
Example #5
0
 public function validate()
 {
     $errors = array();
     if (!Zend_Validate::is(trim($this->getFirstname()), 'NotEmpty')) {
         $errors[] = Mage::helper('customer')->__('The first name cannot be empty.');
     }
     if (!Zend_Validate::is(trim($this->getLastname()), 'NotEmpty')) {
         $errors[] = Mage::helper('customer')->__('The last name cannot be empty.');
     }
     if (!Zend_Validate::is($this->getEmail(), 'EmailAddress')) {
         $errors[] = Mage::helper('customer')->__('Invalid email address "%s".', $this->getEmail());
     }
     if (!Zend_Validate::is($this->getPermission(), 'Int')) {
         $errors[] = Mage::helper('customer')->__('Invalid permissions "%s".', $this->getPermission());
     }
     if (!Zend_Validate::is($this->getParentCustomerId(), 'NotEmpty')) {
         $errors[] = Mage::helper('customer')->__('Invalid main account "%s".', $this->getParentCustomerId());
     }
     $password = $this->getPassword();
     if (!$this->getId() && !Zend_Validate::is($password, 'NotEmpty')) {
         $errors[] = Mage::helper('customer')->__('The password cannot be empty.');
     }
     if (strlen($password) && !Zend_Validate::is($password, 'StringLength', array(6))) {
         $errors[] = Mage::helper('customer')->__('The minimum password length is %s', 6);
     }
     $confirmation = $this->getPasswordConfirmation();
     if ($password != $confirmation) {
         $errors[] = Mage::helper('customer')->__('Please make sure your passwords match.');
     }
     if (empty($errors)) {
         return true;
     }
     return $errors;
 }
 /**
  * Forgot customer password action
  *
  * @return \Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     $email = (string) $this->getRequest()->getPost('email');
     if ($email) {
         if (!\Zend_Validate::is($email, 'EmailAddress')) {
             $this->session->setForgottenEmail($email);
             $this->messageManager->addErrorMessage(__('Please correct the email address.'));
             return $resultRedirect->setPath('*/*/forgotpassword');
         }
         try {
             $this->customerAccountManagement->initiatePasswordReset($email, AccountManagement::EMAIL_RESET);
         } catch (NoSuchEntityException $exception) {
             // Do nothing, we don't want anyone to use this action to determine which email accounts are registered.
         } catch (SecurityViolationException $exception) {
             $this->messageManager->addErrorMessage($exception->getMessage());
             return $resultRedirect->setPath('*/*/forgotpassword');
         } catch (\Exception $exception) {
             $this->messageManager->addExceptionMessage($exception, __('We\'re unable to send the password reset email.'));
             return $resultRedirect->setPath('*/*/forgotpassword');
         }
         $this->messageManager->addSuccessMessage($this->getSuccessMessage($email));
         return $resultRedirect->setPath('*/*/');
     } else {
         $this->messageManager->addErrorMessage(__('Please enter your email.'));
         return $resultRedirect->setPath('*/*/forgotpassword');
     }
 }
Example #7
0
 public function save($post)
 {
     $res = array('success' => true, 'errors' => array());
     if (!isset($post['name']) || empty($post['name'])) {
         $res['success'] = false;
         $res['errors'][] = 'Имя обязательно для ввода';
     }
     if (!isset($post['email']) || empty($post['email']) || !Zend_Validate::is($post['email'], 'EmailAddress')) {
         $res['success'] = false;
         $res['errors'][] = 'Введите корректно электронную почту';
     }
     if (!isset($post['date_birth']) || empty($post['date_birth']) || !strtotime($post['date_birth'])) {
         $res['success'] = false;
         $res['errors'][] = 'Введите корректно дату рождения';
     }
     if (!isset($post['level_id']) || empty($post['level_id']) || !in_array($post['level_id'], array(1, 2, 3, 4, 5, 6))) {
         $res['success'] = false;
         $res['errors'][] = 'Укажите корректно уровень';
     }
     if ($this->_pupilsModel->existsName($post['name'])) {
         $res['success'] = false;
         $res['errors'][] = 'Пользователь с именем ' . $post['name'] . ' уже существует';
     }
     if ($this->_pupilsModel->existsEmail($post['email'])) {
         $res['success'] = false;
         $res['errors'][] = 'Пользователь с почтой ' . $post['email'] . ' уже существует';
     }
     if (!$res['success']) {
         return $res;
     }
     $this->_pupilsModel->save(array('name' => $post['name'], 'email' => $post['email'], 'level_id' => $post['level_id'], 'date_birth' => strtotime($post['date_birth'])));
     return $res;
 }
Example #8
0
 /**
  * Used by the Zendesk single sign on functionality to authenticate users.
  * Only works for admin panel users, not for customers.
  */
 public function authenticateAction()
 {
     if (!Mage::getStoreConfig('zendesk/sso/enabled')) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('Single sign-on disabled.'));
         $this->_redirect(Mage::getSingleton('admin/session')->getUser()->getStartupPageUrl());
     }
     $domain = Mage::getStoreConfig('zendesk/general/domain');
     $token = Mage::getStoreConfig('zendesk/sso/token');
     if (!Zend_Validate::is($domain, 'NotEmpty')) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('Zendesk domain not set. Please add this to the settings page.'));
         $this->_redirect(Mage::getSingleton('admin/session')->getUser()->getStartupPageUrl());
     }
     if (!Zend_Validate::is($token, 'NotEmpty')) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('Zendesk SSO token not set. Please add this to the settings page.'));
         $this->_redirect(Mage::getSingleton('admin/session')->getUser()->getStartupPageUrl());
     }
     $now = time();
     $jti = md5($now . rand());
     $user = Mage::getSingleton('admin/session')->getUser();
     $name = $user->getName();
     $email = $user->getEmail();
     $externalId = $user->getId();
     $payload = array("iat" => $now, "jti" => $jti, "name" => $name, "email" => $email, "external_id" => $externalId);
     Mage::log('Admin JWT: ' . var_export($payload, true), null, 'zendesk.log');
     $jwt = JWT::encode($payload, $token);
     $url = "http://" . $domain . "/access/jwt?jwt=" . $jwt;
     Mage::log('Admin URL: ' . $url, null, 'zendesk.log');
     $this->_redirectUrl($url);
 }
 public function convertEmailsToSubscribers($emailsString)
 {
     // Get emails from test fields
     $emails = nl2br($emailsString);
     $newEmString = array();
     if (isset($emails) && $emails != "") {
         $mails = explode('<br />', $emails);
         foreach ($mails as $mail) {
             try {
                 if (!Zend_Validate::is($mail, 'EmailAddress')) {
                 }
                 if ($mail && $mail != "") {
                     $status = Mage::getModel('newsletter/subscriber')->subscribe(trim($mail));
                     if ($status > 0) {
                         $user = Mage::getModel('newsletter/subscriber')->loadByEmail(trim($mail));
                         $id = $user->getId();
                         $user->confirm($user->getCode());
                         $newEmString[] = $id;
                     }
                 }
             } catch (Mage_Core_Exception $e) {
             } catch (Exception $e) {
             }
         }
     }
     return $newEmString;
 }
Example #10
0
 /**
  * @return Json
  */
 public function execute()
 {
     $response = ['success' => false];
     $storeId = $this->_request->getParam('store');
     /** @var Store $store */
     $store = $this->_storeManager->getStore($storeId);
     if (!is_null($store)) {
         try {
             $emailAddress = $this->_request->getParam('email');
             $metaData = $this->_accountMetaBuilder->build($store);
             // todo: how to handle this class, DI?
             if (\Zend_Validate::is($emailAddress, 'EmailAddress')) {
                 /** @var \NostoOwner $owner */
                 $owner = $metaData->getOwner();
                 $owner->setEmail($emailAddress);
             }
             $account = $this->_accountService->create($metaData);
             if ($this->_accountHelper->saveAccount($account, $store)) {
                 // todo
                 //$this->_accountHelper->updateCurrencyExchangeRates($account, $store);
                 $response['success'] = true;
                 $response['redirect_url'] = $this->_accountHelper->getIframeUrl($store, $account, ['message_type' => \NostoMessage::TYPE_SUCCESS, 'message_code' => \NostoMessage::CODE_ACCOUNT_CREATE]);
             }
         } catch (\NostoException $e) {
             $this->_logger->error($e, ['exception' => $e]);
         }
     }
     if (!$response['success']) {
         $response['redirect_url'] = $this->_accountHelper->getIframeUrl($store, null, ['message_type' => \NostoMessage::TYPE_ERROR, 'message_code' => \NostoMessage::CODE_ACCOUNT_CREATE]);
     }
     return $this->_result->setData($response);
 }
 public function validate()
 {
     $errors = array();
     $helper = Mage::helper('zeon_jobs');
     if (!Zend_Validate::is(trim($this->getResumeTitle()), 'NotEmpty')) {
         $errors[] = $helper->__('The resume title cannot be empty.');
     }
     if (!Zend_Validate::is(trim($this->getFirstname()), 'NotEmpty')) {
         $errors[] = $helper->__('The first name cannot be empty.');
     }
     if (!Zend_Validate::is(trim($this->getLastname()), 'NotEmpty')) {
         $errors[] = $helper->__('The last name cannot be empty.');
     }
     if (!Zend_Validate::is(trim($this->getEmail()), 'NotEmpty')) {
         $errors[] = $helper->__('The email cannot be empty.');
     }
     if (Zend_Validate::is(trim($this->getEmail()), 'NotEmpty') && !Zend_Validate::is(trim($this->getEmail()), 'EmailAddress')) {
         $errors[] = $customerHelper->__('Invalid email address "%s".', $this->getEmail());
     }
     if (!Zend_Validate::is(trim($this->getTelephone()), 'NotEmpty')) {
         $errors[] = $helper->__('The telephone cannot be empty.');
     }
     if (!Zend_Validate::is(trim($this->getUploadResume()), 'NotEmpty')) {
         $errors[] = $helper->__('Select the resume to upload.');
     }
     if (empty($errors)) {
         return true;
     }
     return $errors;
 }
 public function uploadAndImport(Varien_Object $object)
 {
     $hlr = Mage::helper("amacart");
     if (empty($_FILES['groups']['tmp_name']['import']['fields']['blacklist']['value'])) {
         return $this;
     }
     $csvFile = $_FILES['groups']['tmp_name']['import']['fields']['blacklist']['value'];
     $io = new Varien_Io_File();
     $info = pathinfo($csvFile);
     $io->open(array('path' => $info['dirname']));
     $io->streamOpen($info['basename'], 'r');
     $emails = array();
     while (($csvLine = $io->streamReadCsv()) !== FALSE) {
         foreach ($csvLine as $email) {
             if (!Zend_Validate::is($email, 'NotEmpty')) {
             } else {
                 if (!Zend_Validate::is($email, 'EmailAddress')) {
                     $this->_warnings[] = $email . " " . $hlr->__("not valid email");
                 } else {
                     $emails[] = array("email" => $email, 'created_at' => date("Y-m-d H:i:s", time()));
                 }
             }
             if (count($emails) == 100) {
                 $this->saveImportData($emails);
                 $emails = array();
             }
         }
     }
     $this->saveImportData($emails);
     foreach (array_slice($this->_warnings, 0, 10) as $warning) {
         Mage::getSingleton('adminhtml/session')->addWarning($warning);
     }
     Mage::getSingleton('core/session')->addSuccess($hlr->__("Import completed"));
 }
 public function postAction()
 {
     if ($this->getRequest()->isPost()) {
         $comment = $this->getRequest()->getPost('comment');
         $session = $this->_getSession();
         try {
             $errorAr = array();
             if (!isset($comment['name']) || strlen(trim($comment['name'])) == 0) {
                 $errorAr[] = $this->__('Invalid name.');
             }
             if (!isset($comment['name']) || !Zend_Validate::is($comment['email'], 'EmailAddress')) {
                 $errorAr[] = $this->__('Invalid email address.');
             }
             if (!isset($comment['content']) || strlen(trim($comment['content'])) == 0) {
                 $errorAr[] = $this->__('Invalid content.');
             }
             if (count($errorAr) > 0) {
                 throw new Exception(implode("<br/>", $errorAr));
             }
             $enable = 1;
             $model = Mage::getModel('vc_miniblog/comment');
             $model->setUser($comment['name'])->setEmail($comment['email'])->setContent($comment['content'])->setPostId($comment['post_id'])->setCreatedAt(date('Y-m-d H:i:s'))->setEnable($enable)->save();
             $session->addSuccess($this->__('Your comment has posted.'));
         } catch (Exception $e) {
             $session->addError($e->getMessage());
         }
         $identifier = Mage::helper('vc_miniblog')->getPostIdentifierFromId($comment['post_id']);
         if ($identifier && strlen($identifier) > 0) {
             $this->_redirectUrl(Mage::getUrl('vc_miniblog/index/postDetail', array('_secure' => true, 'identifier' => $identifier)));
         }
     } else {
         $this->_redirectUrl(Mage::getUrl('vc_miniblog/index/index', array('_secure' => true)));
     }
 }
 /**
  * batch generate giftcard
  *
  * @returns   
  */
 public function generateRewardGiftcardAction()
 {
     try {
         //get config from BO
         $type = Newjueqi_Specialgiftcard_Model_Specialgiftcard::GIFT_CARD_TYPE_REWARD;
         $times = Mage::getStoreConfig(Newjueqi_Specialgiftcard_Model_Pool::REWARD_GIFTCARD_XML_CONFIG_CODE_GENERATE_TIME);
         $balance = Mage::getStoreConfig(Newjueqi_Specialgiftcard_Model_Pool::REWARD_GIFTCARD_XML_CONFIG_CODE_BALANCE);
         $website = Mage::getStoreConfig(Newjueqi_Specialgiftcard_Model_Pool::REWARD_GIFTCARD_XML_CONFIG_CODE_WEBSITE);
         $dateExpires = Mage::getStoreConfig(Newjueqi_Specialgiftcard_Model_Pool::REWARD_GIFTCARD_XML_CONFIG_CODE_EXPIRES_DATE);
         //if some config are not set, use default value
         if (!is_numeric($times)) {
             $times = 3;
         }
         if (!is_numeric($balance)) {
             $balance = 100;
         }
         if (!is_numeric($website)) {
             //set id of the first website
             $website = Mage::getSingleton('core/website')->getCollection()->getFirstItem()->getId();
         }
         if (!Zend_Validate::is($dateExpires, 'Date')) {
             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('specialgiftcard')->__('date format error'));
             $this->_redirectReferer('*/*/');
             return;
         }
         $param = array('status' => 1, 'is_redeemable' => 1, 'website_id' => $website, 'balance' => $balance, 'date_expires' => $dateExpires);
         $codes = Mage::getModel('enterprise_giftcardaccount/giftcardaccount')->generateSpecialGiftAccount($type, $times, $param);
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('enterprise_giftcardaccount')->__('gift card generate successful'));
     } catch (Mage_Core_Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addException($e, Mage::helper('enterprise_giftcardaccount')->__('Unable to generate new code pool.'));
     }
     $this->_redirectReferer('*/*/');
 }
Example #15
0
 public function editAction()
 {
     if ($this->view->login->group_id != 1) {
         $this->error("权限不够", "操作权限不够");
     }
     $id = $_GET['id'];
     if (!Zend_Validate::is($id, 'Int')) {
         $this->error("参数不正确", "所传递的参数不正确");
     }
     if ($this->isPost()) {
         $post = $_POST;
         $userModel = Doctrine_Core::getTable("DBModel_User")->find($id);
         $userModel->username = $post['username'];
         $userModel->password = $post['password'];
         $userModel->group_id = $post['group'];
         $userModel->department_id = $post['department'];
         $userModel->role = $post['role'];
         $userModel->save();
         $userModel->free();
         $this->redirect("user");
     }
     $user = Doctrine_Query::create()->from('DBModel_User u')->where("id = ?", $id);
     $user->leftJoin('u.Group g');
     $user->leftJoin('u.Department d');
     $user = $user->fetchOne();
     $group = Doctrine_Query::create()->from('DBModel_Group')->execute();
     $department = Doctrine_Query::create()->from('DBModel_Department')->execute();
     $this->view->group = $group;
     $this->view->department = $department;
     $this->view->data = $user;
     $this->view->render("useredit.html");
     $user->free();
     $group->free();
     $department->free();
 }
 /**
  * Set search fields required by search strategy
  *
  * @param array $params
  */
 public function setSearchParams(array $params)
 {
     if (empty($params['email']) || !Zend_Validate::is($params['email'], 'EmailAddress')) {
         throw new InvalidArgumentException(Mage::helper('enterprise_wishlist')->__('Please input a valid email address.'));
     }
     $this->_email = $params['email'];
 }
Example #17
0
 public function forgotpasswordpostAction()
 {
     $block = Mage::app()->getLayout()->createBlock('amajaxlogin/customer_form_login', 'form_login')->setTemplate('amasty/amajaxlogin/customer/form/forgotpassword.phtml');
     $message = $block->toHtml();
     $title = $this->__('Forgot Your Password?');
     $email = (string) $this->getRequest()->getPost('email');
     if ($email) {
         if (!Zend_Validate::is($email, 'EmailAddress')) {
             $this->_getSession()->setForgottenEmail($email);
             $this->showCartPopup($title, $this->__('Invalid email address.'), $message, 1);
             return;
         }
         /** @var $customer Mage_Customer_Model_Customer */
         $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
         if ($customer->getId()) {
             try {
                 $newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
                 $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
                 $customer->sendPasswordResetConfirmationEmail();
             } catch (Exception $exception) {
                 $this->showCartPopup($title, $exception->getMessage(), $message, 1);
                 return;
             }
         }
         $this->showCartPopup($title, Mage::helper('customer')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('customer')->htmlEscape($email)), $message, 2);
         return;
     } else {
         $this->showCartPopup($title, $this->__('Please enter your email.'), $message, 1);
         return;
     }
     $this->showCartPopup($title, "", $message, 3);
 }
 /**
  * Send invitations from frontend
  *
  */
 public function sendAction()
 {
     $data = $this->getRequest()->getPost();
     if ($data) {
         /* code block added as per functionality change for invitation */
         $email = explode(',', $data['email']);
         $data['email'] = $email;
         /* code block end */
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         /* code commented as per implementation of new functionality
             $invPerSend = Mage::getSingleton('enterprise_invitation/config')->getMaxInvitationsPerSend();
            */
         $attempts = 0;
         $sent = 0;
         $customerExists = 0;
         foreach ($data['email'] as $email) {
             $email = trim($email);
             if (!Zend_Validate::is($email, 'EmailAddress')) {
                 Mage::getSingleton('customer/session')->addError(Mage::helper('enterprise_invitation')->__('Invitation(s) were not sent, because email id is not valid : %s ', $email));
                 continue;
             }
             /* code commented as per implementation of new functionality
                 if ($attempts > $invPerSend) {
                 continue;
                 }
                */
             try {
                 $invitation = Mage::getModel('enterprise_invitation/invitation')->setData(array('email' => $email, 'customer' => $customer, 'message' => isset($data['message']) ? $data['message'] : ''))->save();
                 if ($invitation->sendInvitationEmail()) {
                     Mage::getSingleton('customer/session')->addSuccess(Mage::helper('enterprise_invitation')->__('Invitation for %s has been sent.', $email));
                     $sent++;
                 } else {
                     throw new Exception('');
                     // not Mage_Core_Exception intentionally
                 }
             } catch (Mage_Core_Exception $e) {
                 if (Enterprise_Invitation_Model_Invitation::ERROR_CUSTOMER_EXISTS === $e->getCode()) {
                     $customerExists++;
                 } else {
                     Mage::getSingleton('customer/session')->addError(Mage::helper('enterprise_invitation')->__('Failed to send email to %s.' . " " . $e->getMessage(), $email));
                 }
             } catch (Exception $e) {
                 Mage::getSingleton('customer/session')->addError(Mage::helper('enterprise_invitation')->__('Failed to send email to %s.', $email));
             }
         }
         if ($customerExists) {
             Mage::getSingleton('customer/session')->addNotice(Mage::helper('enterprise_invitation')->__('%d invitation(s) were not sent, because customer accounts already exist for specified email addresses.', $customerExists));
         }
         $this->_redirect('*/*/');
         return;
     }
     $this->loadLayout();
     $this->_initLayoutMessages('customer/session');
     $this->loadLayoutUpdates();
     $headBlock = $this->getLayout()->getBlock('head');
     if ($headBlock) {
         $headBlock->setTitle(Mage::helper('enterprise_invitation')->__('Send Invitations'));
     }
     $this->renderLayout();
 }
Example #19
0
 public function personalAction()
 {
     $aclUserDao = $this->dao->load('Core_User');
     $userId = $this->admin['id'] ? $this->admin['id'] : 0;
     $user = $aclUserDao->read($this->admin['id']);
     // do post
     if ($_POST) {
         // validation
         if (!$userId) {
             $this->addError('common.notempty', 'User Id');
         }
         if (!Zend_Validate::is($this->param('name'), 'NotEmpty')) {
             $this->addError('common.notempty', 'User name');
         }
         if ($this->noError()) {
             $data['name'] = $this->param('name');
             if ($this->param('pass')) {
                 $data['pass'] = Hush_Util::md5($this->param('pass'));
             }
             // do update
             if ($userId) {
                 $aclUserDao->update($data, 'id=' . $userId);
                 $this->addErrorMsg('Personal Infomation updated successfully');
             }
         }
     }
     $this->view->user = $user;
 }
 public function postAction()
 {
     if ($datas = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             // Test les eventuelles erreurs
             $errors = array();
             if (empty($datas['email']) or !Zend_Validate::is($datas['email'], 'emailAddress')) {
                 throw new Exception($this->_("Please enter a valid email address"));
             }
             $contact = $this->getCurrentOptionValue()->getObject();
             if (!$contact->getId()) {
                 throw new Exception($this->_('An error occurred while sending your request. Please try again later.'));
             }
             $dest_email = $contact->getEmail();
             $app_name = $this->getApplication()->getName();
             $layout = $this->getLayout()->loadEmail('contact', 'send_email');
             $layout->getPartial('content_email')->setData($datas);
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($datas['email'], $datas['name']);
             $mail->addTo($dest_email, $app_name);
             $mail->setSubject($this->_("Message from your app %s", $app_name));
             $mail->send();
             $html = array("success" => 1, "message" => $this->_("Your message has been sent"));
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
 }
Example #21
0
 /**
  * Get Data Order
  *
  * @throws \Exception
  * @throws \Zend_Validate_Exception
  */
 public function execute()
 {
     $orderId = $this->getRequest()->getParam('orderID');
     //check orderId is number
     if (\Zend_Validate::is($orderId, 'Regex', array('pattern' => '/^\\s*-?\\d*(\\.\\d*)?\\s*$/'))) {
         $order = $this->_orderFactory->create();
         $order->load($orderId);
         $orderData = [];
         if ($order->getId()) {
             $orderData['status'] = $order->getStatus();
             $orderData['total'] = $order->getGrandTotal();
             $items = [];
             foreach ($order->getAllVisibleItems() as $item) {
                 $items[] = ['sku' => $item->getSku(), 'item_id' => $item->getId(), 'price' => $item->getPriceInclTax()];
             }
             $orderData['items'] = $items;
             $orderData['total_invoiced'] = $order->getTotalInvoiced();
         }
         if (empty($orderData)) {
             $this->getResponse()->setBody('Order not found!');
         } else {
             $this->getResponse()->setBody(json_encode($orderData));
         }
     } else {
         $this->getResponse()->setBody('Error! OrderID must is number!');
     }
 }
Example #22
0
 /**
  * Validate registrant attribute values
  *
  * @return array|bool
  */
 public function validate()
 {
     // not Checking entityId !!!
     $errors = array();
     $helper = Mage::helper('enterprise_giftregistry');
     if (!Zend_Validate::is($this->getFirstname(), 'NotEmpty')) {
         $errors[] = $helper->__('Please enter the first name.');
     }
     if (!Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
         $errors[] = $helper->__('Please enter the last name.');
     }
     if (!Zend_Validate::is($this->getEmail(), 'EmailAddress')) {
         $errors[] = $helper->__('"Email" is not a valid email address.');
     }
     $customValues = $this->getCustom();
     $attributes = Mage::getSingleton('enterprise_giftregistry/entity')->getRegistrantAttributes();
     $errorsCustom = $helper->validateCustomAttributes($customValues, $attributes);
     if ($errorsCustom !== true) {
         $errors = empty($errors) ? $errorsCustom : array_merge($errors, $errorsCustom);
     }
     if (empty($errors)) {
         return true;
     }
     return $errors;
 }
 public function postAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         $customer = new Customer_Model_Customer();
         try {
             if (!Zend_Validate::is($data['email'], 'EmailAddress')) {
                 throw new Exception($this->_('Please enter a valid email address'));
             }
             $dummy = new Customer_Model_Customer();
             $dummy->find(array('email' => $data['email'], "app_id" => $this->getApplication()->getId()));
             if ($dummy->getId()) {
                 throw new Exception($this->_('We are sorry but this address is already used.'));
             }
             if (empty($data['show_in_social_gaming'])) {
                 $data['show_in_social_gaming'] = 0;
             }
             if (empty($data['password'])) {
                 throw new Exception($this->_('Please enter a password'));
             }
             $customer->setData($data)->setAppId($this->getApplication()->getId())->setPassword($data['password'])->save();
             $this->getSession()->setCustomer($customer);
             $this->_sendNewAccountEmail($customer, $data['password']);
             $html = array('success' => 1, 'customer_id' => $customer->getId(), 'can_access_locked_features' => $customer->canAccessLockedFeatures());
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
 }
Example #24
0
 public function validate()
 {
     $request = Mage::app()->getFrontController()->getRequest();
     if ((bool) Mage::helper('gomage_checkout')->getConfigData('general/enabled') && $request->getModulename() != "admin") {
         $errors = array();
         $helper = Mage::helper('customer');
         $this->implodeStreetAddress();
         foreach ($this->required_fields as $fieldName => $method) {
             if ($fieldName == 'region' && intval(Mage::getStoreConfig('gomage_checkout/address_fields/country_id')) > 0) {
                 if ($this->getCountryModel()->getRegionCollection()->getSize() && !Zend_Validate::is($this->getRegionId(), 'NotEmpty')) {
                     $errors[] = $helper->__('Please enter the state/province.');
                 }
             } elseif ($fieldName == 'postcode' && Mage::helper('gomage_checkout')->getIsAnymoreVersion(1, 4)) {
                 $_havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
                 if (!in_array($this->getCountryId(), $_havingOptionalZip) && !Zend_Validate::is($this->getPostcode(), 'NotEmpty')) {
                     $errors[] = $helper->__('Please enter the zip/postal code.');
                 }
             } else {
                 if (!Zend_Validate::is($this->getData($fieldName), $method[0])) {
                     $errors[] = $helper->__($method[1]);
                 }
             }
         }
         if (empty($errors) || $this->getShouldIgnoreValidation()) {
             return true;
         }
         return $errors;
     } else {
         return parent::validate();
     }
 }
Example #25
0
 public function checkemailregisterAction()
 {
     if (!Mage::helper('magenotification')->checkLicenseKeyFrontController($this)) {
         return;
     }
     $email_address = $this->getRequest()->getParam('email_address');
     $isvalid_email = true;
     if (!Zend_Validate::is(trim($email_address), 'EmailAddress')) {
         $isvalid_email = false;
     }
     if ($isvalid_email) {
         $error = false;
         $email = Mage::getResourceModel('customer/customer_collection')->addAttributeToFilter('email', $email_address)->getFirstItem();
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         if ($email->getId() && (!$customer || !$customer->getId() || $customer && $customer->getId() != $email->getId())) {
             $error = true;
         }
         if ($error) {
             $html = "<div class='error-msg'>" . $this->__('The email %s belongs to a customer. If it is your email address, you can use it to <a href="%s">login</a> our system.', $email_address, Mage::getUrl('*/*/login', array('id' => $this->getRequest()->getParam('id')))) . "</div>";
             $html .= '<input type="hidden" id="is_valid_email" value="0"/>';
         } else {
             $html = "<div class='success-msg'>" . $this->__('You can use this email address.') . "</div>";
             $html .= '<input type="hidden" id="is_valid_email" value="1"/>';
         }
     } else {
         $html = "<div class='error-msg'>" . $this->__('Invalid email address.') . "</div>";
         $html .= '<input type="hidden" id="is_valid_email" value="1"/>';
     }
     $this->getResponse()->setBody($html);
 }
Example #26
0
 /**
  * Displays a form to register a new user.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionIndex()
 {
     if (XenForo_Visitor::getUserId()) {
         throw $this->responseException($this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, $this->getDynamicRedirect()));
     }
     $this->_assertRegistrationActive();
     $username = '';
     $email = '';
     if ($login = $this->_input->filterSingle('login', XenForo_Input::STRING)) {
         if (Zend_Validate::is($login, 'EmailAddress')) {
             $email = $login;
         } else {
             $username = $login;
         }
     }
     $fields = array('username' => $username, 'email' => $email);
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_User');
     if ($username !== '') {
         $writer->set('username', $username);
     }
     if ($email !== '') {
         $writer->set('email', $email);
     }
     return $this->_getRegisterFormResponse($fields, $writer->getErrors());
 }
 /**
  * Forgot customer password action
  *
  * @return \Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     $email = (string) $this->getRequest()->getPost('email');
     if ($email) {
         if (!\Zend_Validate::is($email, 'EmailAddress')) {
             $this->_getSession()->setForgottenEmail($email);
             $this->messageManager->addError(__('Please correct the email address.'));
             $resultRedirect->setPath('*/*/forgotpassword');
             return $resultRedirect;
         }
         try {
             $this->customerAccountManagement->initiatePasswordReset($email, AccountManagement::EMAIL_RESET);
         } catch (NoSuchEntityException $e) {
             // Do nothing, we don't want anyone to use this action to determine which email accounts are registered.
         } catch (\Exception $exception) {
             $this->messageManager->addException($exception, __('Unable to send password reset email.'));
             $resultRedirect->setPath('*/*/forgotpassword');
             return $resultRedirect;
         }
         $email = $this->escaper->escapeHtml($email);
         // @codingStandardsIgnoreStart
         $this->messageManager->addSuccess(__('If there is an account associated with %1 you will receive an email with a link to reset your password.', $email));
         // @codingStandardsIgnoreEnd
         $resultRedirect->setPath('*/*/');
         return $resultRedirect;
     } else {
         $this->messageManager->addError(__('Please enter your email.'));
         $resultRedirect->setPath('*/*/forgotpassword');
         return $resultRedirect;
     }
 }
 /**
  * action for customer forgot password
  */
 public function customerForgotPasswordAction()
 {
     if ($this->_expireAjax()) {
         return;
     }
     $customerSession = Mage::getSingleton('customer/session');
     $result = array('success' => true, 'messages' => array());
     $email = (string) $this->getRequest()->getPost('email');
     if ($email) {
         if (Zend_Validate::is($email, 'EmailAddress')) {
             /** @var $customer Mage_Customer_Model_Customer */
             $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
             if ($customer->getId()) {
                 try {
                     Mage::helper('onestepcheckout/customer')->sendForgotPasswordForCustomer($customer);
                 } catch (Exception $exception) {
                     $result['success'] = false;
                     $result['messages'][] = $exception->getMessage();
                 }
             }
         } else {
             $customerSession->setForgottenEmail($email);
             $result['success'] = false;
             $result['messages'][] = $this->__('Invalid email address.');
         }
     } else {
         $result['success'] = false;
         $result['messages'][] = $this->__('Please enter your email.');
     }
     $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
 }
 public function forgotpassPostAction()
 {
     $email = $this->getRequest()->getPost('email');
     if ($email) {
         if (!Zend_Validate::is($email, 'EmailAddress')) {
             $message = $this->__('Invalid email address.');
         } else {
             $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
             if ($customer->getId()) {
                 try {
                     $newPassword = $customer->generatePassword();
                     $customer->changePassword($newPassword, false);
                     $customer->sendPasswordReminderEmail();
                     $message = $this->__('A new password has been sent.');
                 } catch (Exception $e) {
                     $message = $e->getMessage();
                 }
             } else {
                 $message = $this->__('This email address was not found in our records.');
             }
         }
     } else {
         $message = $this->__('Please enter your email.');
     }
     $result['error'] = $message;
     $this->getResponse()->setBody(Zend_Json::encode($result));
 }
 public function postAction()
 {
     $post = $this->getRequest()->getPost();
     if ($post) {
         $translate = Mage::getSingleton('core/translate');
         /* @var $translate Mage_Core_Model_Translate */
         $translate->setTranslateInline(false);
         try {
             $postObject = new Varien_Object();
             $postObject->setData($post);
             $error = false;
             if (!Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
                 $error = true;
             }
             //                if (!Zend_Validate::is(trim($post['vendoremail']), 'VendorEmail')) {
             //                    $error = true;
             //                }
             if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
                 $error = true;
             }
             if ($error) {
                 throw new Exception();
             }
             $sender = array('name' => Mage::getStoreConfig('trans_email/ident_general/name'), 'email' => Mage::getStoreConfig('trans_email/ident_general/email'));
             $emailTemplate = Mage::getStoreConfig('smvendors_email/contact_vendor/template');
             $mailSubject = "You gor an email from buyer";
             $vars = array('customer' => $post['name'], 'cutomeremail' => $post['email'], 'content' => $post['comment']);
             $bcc = array('name' => '*****@*****.**', 'email' => '*****@*****.**');
             $storeId = Mage::app()->getStore()->getId();
             $translate = Mage::getSingleton('core/translate');
             $mailTemplate = Mage::getModel('core/email_template');
             /* @var $mailTemplate Mage_Core_Model_Email_Template */
             $mailTemplate->setTemplateSubject($mailSubject)->addBcc($bcc)->sendTransactional($emailTemplate, $sender, $post['vendoremail'], 'vendor name', $vars, $storeId);
             //                if (!$mailTemplate->getSentSuccess()) {
             //                    throw new Exception();
             //                }
             $translate->setTranslateInline(true);
             Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
             //                $this->_redirect( "planet/contact/write/",array("vendor"=>$post['vendor']));
             //                 Mage::helper("adminhtml")->getUrl("adminhtml/customemail/index/",array("vendor"=>$post['vendor']));
             $this->_redirect('*/contact/success');
             $this->loadLayout();
             $this->renderLayout();
             //                return;
         } catch (Exception $e) {
             $translate->setTranslateInline(true);
             Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
             $this->_redirect('*/*/');
             return;
         }
     } else {
         $this->_redirect('*/write/');
     }
 }