• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Validate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Zend_Validate的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate类的具体用法?PHP Zend_Validate怎么用?PHP Zend_Validate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Zend_Validate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * 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;
     }
 }
开发者ID:ddlawrence303,项目名称:Customized_Modules,代码行数:65,代码来源:Post.php


示例2: execute

 /**
  * 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;
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:41,代码来源:Post.php


示例3: isValid

 /**
  * Make sure the user is valid
  *
  * @return void
  */
 public function isValid($value)
 {
     $valid = true;
     $this->_user = $value;
     $namePartsValidator = new Zend_Validate();
     $namePartsValidator->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->addValidator(new Zend_Validate_Alpha(array('allowWhiteSpace' => true)))->addValidator(new Zend_Validate_StringLength(array('min' => 2)));
     if (!$namePartsValidator->isValid($this->_user->getFirstName())) {
         $valid = false;
         $this->_error($this->_view->translate('The first name must have at least 2 characters and consist only of letters'));
     }
     if (!$namePartsValidator->isValid($this->_user->getLastName())) {
         $valid = false;
         $this->_error($this->_view->translate('The last name must have at least 2 characters and consist only of letters'));
     }
     $emailValidator = new Zend_Validate_EmailAddress();
     if (!$emailValidator->isValid($this->_user->getEmail())) {
         $valid = false;
         $this->_error($this->_view->translate('You must entre a valid email'));
     }
     if ($this->_user->isNew()) {
         $usernameValidator = new Zend_Validate();
         $usernameValidator->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => false)))->addValidator(new Zend_Validate_StringLength(array('min' => 5)));
         if (!$usernameValidator->isValid($this->_user->getUsername())) {
             $this->_error($this->_view->translate('The username must have at least 5 characters and contains no white spaces'));
         }
     }
     return $valid;
 }
开发者ID:EricHogue,项目名称:Koryukan,代码行数:33,代码来源:UserValidator.php


示例4: mailAction

 public function mailAction()
 {
     $error = array();
     $posts = array('First Name' => $_POST['first_name'], 'Last Name' => $_POST['last_name'], 'Email' => $_POST['email'], 'Message' => $_POST['message']);
     $validatorChain = new Zend_Validate();
     $validatorChain->addValidator(new Zend_Validate_NotEmpty());
     $valid_email = new Zend_Validate_EmailAddress();
     if ($valid_email->isValid($posts['Email'])) {
     } else {
         foreach ($valid_email->getMessages() as $message) {
             $error[] = "Email {$message}\n";
         }
     }
     foreach ($posts as $key => $post) {
         if ($validatorChain->isValid($post)) {
         } else {
             foreach ($validatorChain->getMessages() as $message) {
                 $error[] = "{$key} {$message}\n";
             }
         }
     }
     if (count($error) != 0) {
         $this->view->alerts = $error;
     } else {
         $to = '[email protected]';
         $subject = 'Email from Illustrated Portland';
         $message = $posts['Message'];
         $headers = "From: {$posts['First Name']} {$posts['Last Name']} <{$posts['Email']}>";
         mail($to, $subject, $message, $headers);
         //$this->view->alerts = array("Thank You! Your message has been sent.");
     }
 }
开发者ID:kellancraddock,项目名称:illustrated_portland,代码行数:32,代码来源:ContactController.php


示例5: _savePanel

 /**
  * Save changes to an existing panel. This can be expanded to allow adding of new Panels in the future.
  *
  * @return void
  */
 protected function _savePanel()
 {
     // First of all we need to validate and sanitise the input from the form
     $urlFilter = new Zend_Filter();
     $urlFilter->addFilter(new Zend_Filter_StringTrim());
     $urlFilter->addFilter(new Zend_Filter_StringTrim('/'));
     $requiredText = new Zend_Validate();
     $requiredText->addValidator(new Zend_Validate_NotEmpty());
     $filters = array('id' => 'Digits');
     $validators = array('id' => array('allowEmpty' => true), 'content' => array('allowEmpty' => true));
     $input = new Zend_Filter_Input($filters, $validators, $_POST);
     if ($input->isValid()) {
         // Data is all valid, formatted and sanitized so we can save it in the database
         $panel = new Datasource_Cms_Panels();
         if (!$input->id) {
             // This is a new panel so we need to create a new ID
             // NOT IMPLEMENTED - YET
         } else {
             $panel->saveChanges($input->id, $input->getUnescaped('content'));
             $panelID = $input->id;
         }
         // Changes saved - so send them back with a nice success message
         $this->_helper->getHelper('FlashMessenger')->addMessage(array('saved' => true));
         $this->_helper->getHelper('Redirector')->goToUrl('/cms-admin/panels/edit?id=' . $panelID);
     } else {
         // Invalid data in form
         /*
         print_r($_POST);
         print_r($input->getErrors());
         print_r($input->getInvalid());
         */
     }
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:38,代码来源:PanelsController.php


示例6: init

 /**
  * Initializes the form element.
  */
 function init()
 {
     // set label
     $this->setLabel('Email');
     // set required
     $this->setRequired(true);
     // set filter
     $this->addFilter('StringTrim');
     // add validator for max string length
     $this->addValidator('StringLength', false, array(0, 256));
     // add validator for email addresses
     $emailValidator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_LOCAL);
     $this->addValidator($emailValidator);
     // add validator for beeing unique in the database
     $validator = new Zend_Validate();
     $message = 'The email is already in the database, please check if you are already registered.';
     $userTableValidator = new Zend_Validate_Db_NoRecordExists('Auth_User', 'email');
     $userTableValidator->setMessage($message);
     if (!empty($this->_excludeId)) {
         $userTableValidator->setExclude(array('field' => 'id', 'value' => $this->_excludeId));
     }
     $registrationTableValidator = new Zend_Validate_Db_NoRecordExists('Auth_Registration', 'email');
     $registrationTableValidator->setMessage($message);
     // chainvalidators and add to field
     $validator->addValidator($userTableValidator)->addValidator($registrationTableValidator);
     $this->addValidator($validator);
 }
开发者ID:vrtulka23,项目名称:daiquiri,代码行数:30,代码来源:Email.php


示例7: init

 /**
  * Initializes the form element.
  */
 function init()
 {
     $this->setLabel('Email');
     // set required
     $this->setRequired(true);
     // set filter
     $this->addFilter('StringTrim');
     // add validator for max string length
     $this->addValidator('StringLength', false, array(0, 256));
     // add validator for email addresses
     $this->addValidator('emailAddress');
     // add validator for beeing unique in the database
     $validator = new Zend_Validate();
     $message = 'The email is already in the database, please check if you are already registered.';
     $participantsTableValidator = new Meetings_Form_Validate_Email('Meetings_Participants', 'email');
     $participantsTableValidator->setMessage($message);
     $participantsTableValidator->setMeetingId($this->_meetingId);
     if (!empty($this->_excludeId)) {
         $participantsTableValidator->setExcludeId($this->_excludeId);
     }
     $registrationTableValidator = new Meetings_Form_Validate_Email('Meetings_Registration', 'email');
     $registrationTableValidator->setMessage($message);
     $registrationTableValidator->setMeetingId($this->_meetingId);
     // chainvalidators and add to field
     $validator->addValidator($participantsTableValidator)->addValidator($registrationTableValidator);
     $this->addValidator($validator);
 }
开发者ID:vrtulka23,项目名称:daiquiri,代码行数:30,代码来源:Email.php


示例8: init

 /**
  * Initializes the form element.
  */
 function init()
 {
     // set filter
     $this->addFilter('StringTrim');
     // set required
     $this->setRequired(true);
     // set label
     $this->setLabel(ucfirst($this->getName()));
     // set validator for lowercase or regular alnum
     if (Daiquiri_Config::getInstance()->auth->lowerCaseUsernames) {
         $this->addValidator(new Daiquiri_Form_Validator_LowerCaseAlnum());
     } else {
         $this->addValidator(new Daiquiri_Form_Validator_AlnumUnderscore());
     }
     // add validator for min and max string length
     $minLength = Daiquiri_Config::getInstance()->auth->usernameMinLength;
     $this->addValidator('StringLength', false, array($minLength, 256));
     // add validator for beeing unique in the database
     $validator = new Zend_Validate();
     $message = 'The username is in use, please use another username.';
     $userTableValidator = new Zend_Validate_Db_NoRecordExists('Auth_User', 'username');
     $userTableValidator->setMessage($message);
     if (!empty($this->_excludeId)) {
         $userTableValidator->setExclude(array('field' => 'id', 'value' => $this->_excludeId));
     }
     $registrationTableValidator = new Zend_Validate_Db_NoRecordExists('Auth_Registration', 'username');
     $registrationTableValidator->setMessage($message);
     $appTableValidator = new Zend_Validate_Db_NoRecordExists('Auth_Apps', 'appname');
     $appTableValidator->setMessage($message);
     $validator->addValidator($userTableValidator)->addValidator($registrationTableValidator)->addValidator($appTableValidator);
     $this->addValidator($validator);
 }
开发者ID:vrtulka23,项目名称:daiquiri,代码行数:35,代码来源:AbstractName.php


示例9: indexAction

 public function indexAction()
 {
     $emailValidator = new Zend_Validate_EmailAddress();
     $nameValidator = new Zend_Validate_NotEmpty(array(Zend_Validate_NotEmpty::STRING, Zend_Validate_NotEmpty::SPACE));
     $password1_Validator = new Zend_Validate();
     $password1_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
     $password2_Validator = new Zend_Validate();
     $password2_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
     $captcha = new Zend_Captcha_Image();
     $captcha->setName('captchaword')->setFont(APPLICATION_PATH . '/data/arial.ttf')->setFontSize(28)->setImgDir(APPLICATION_PATH . '/../public/img')->setImgUrl('/img')->setWordLen(5)->setDotNoiseLevel(20)->setExpiration(300);
     $request = $this->getRequest();
     $post = $request->getPost();
     // $passwordIdentical = new Zend_Validate_Identical(array('token' => $post['password1']));
     $messages = array();
     $error = array();
     $noValiError = true;
     if ($this->getRequest()->isPost()) {
         if (!$emailValidator->isValid($post['user-email'])) {
             $error['user-emailVali'] = '請輸入正確的Email帳號';
             $noValiError = false;
         }
         if (!$nameValidator->isValid($post['name'])) {
             $error['nameVali'] = '姓名必填';
             $noValiError = false;
         }
         if (!$password1_Validator->isValid($post['password1'])) {
             $error['password1_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文';
             $noValiError = false;
         }
         if (!$password2_Validator->isValid($post['password2'])) {
             $error['password2_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文';
             $noValiError = false;
         }
         if (isset($post['password1']) && isset($post['password2']) && !($post['password1'] == $post['password2'])) {
             $error['passwordIdentical'] = '2.密碼輸入不同';
             $noValiError = false;
         }
         if (!($post['agree'] == 1)) {
             $error['agreeVali'] = '需同意服務條款及隱私權政策,才可以註冊';
             $noValiError = false;
         }
         if (!$captcha->isValid($post['captchaword'])) {
             $error['captchawordVali'] = '認證碼輸入錯誤';
             $noValiError = false;
         }
         if ($noValiError) {
             // register process
             $this->_signup($post);
             $this->view->messages = $post;
             $this->redirect('index/index');
         } else {
             $this->_genCaptcha($captcha);
             $this->view->error = $error;
             $this->view->messages = $post;
         }
     } else {
         $this->_genCaptcha($captcha);
     }
 }
开发者ID:ChenYoyo,项目名称:NLC-Event-Platform,代码行数:59,代码来源:SignupController.php


示例10: validInput

 public function validInput($data)
 {
     $validator = new Zend_Validate();
     //$validator->addValidator(new Zend_Validate_Int());
     if ($validator->isValid($data)) {
         return $data;
     } else {
         //$this->_model->isValid = false;
         return $this->_info['errMsg'];
     }
 }
开发者ID:laiello,项目名称:xinhuxi,代码行数:11,代码来源:Text.php


示例11: testValidateWithInvalidFile

 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage The file 'File Title' for 'Option Title' has an invalid extension.
  */
 public function testValidateWithInvalidFile()
 {
     $relativePath = '/custom_options/quote/file';
     $optionValues = ['quote_path' => '/custom_options/quote/file', 'title' => 'File Title'];
     $this->prepare();
     $this->directoryRead->expects($this->once())->method('isReadable')->with($relativePath)->willReturn(false);
     $this->option->expects($this->once())->method('getTitle')->willReturn('Option Title');
     $this->zendValidator->expects($this->at(2))->method('getErrors')->willReturn(true);
     $this->zendValidator->expects($this->at(3))->method('getErrors')->willReturn([\Zend_Validate_File_ExcludeExtension::FALSE_EXTENSION]);
     $this->validator->validate($optionValues, $this->option);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:ValidatorTest.php


示例12: __construct

 public function __construct($arrParam = array(), $options = null)
 {
     //////////////////////////////////
     //Kiem tra Name /////////////
     //////////////////////////////////
     if ($arrParam['action'] == 'add') {
         $options = array('table' => 'da_album', 'field' => 'album_name');
     } elseif ($arrParam['action'] == 'edit') {
         $options = array('table' => 'da_album', 'field' => 'album_name', 'exclude' => array('field' => 'id', 'value' => $arrParam['id']));
     }
     $validator = new Zend_Validate();
     $validator->addValidator(new Zend_Validate_NotEmpty(), true)->addValidator(new Zend_Validate_StringLength(3, 100), true);
     if (!$validator->isValid($arrParam['album_name'])) {
         $message = $validator->getMessages();
         $this->_messageError['album_name'] = 'Tên album: ' . current($message);
         $arrParam['album_name'] = '';
     }
     //////////////////////////////////
     //Kiem tra Picture small ///////////
     //////////////////////////////////
     $upload = new Zend_File_Transfer_Adapter_Http();
     $fileInfo = $upload->getFileInfo('picture');
     $fileName = $fileInfo['picture']['name'];
     if (!empty($fileName)) {
         $upload->addValidator('Extension', true, array('jpg', 'gif', 'png'), 'picture');
         $upload->addValidator('Size', true, array('min' => '2KB', 'max' => '1000KB'), 'picture');
         if (!$upload->isValid('picture')) {
             $message = $upload->getMessages();
             $this->_messageError['picture'] = 'Hình ảnh đại diện: ' . current($message);
         }
     }
     //////////////////////////////////
     //Kiem tra Order /////////////
     //////////////////////////////////
     $validator = new Zend_Validate();
     $validator->addValidator(new Zend_Validate_StringLength(1, 10), true)->addValidator(new Zend_Validate_Digits(), true);
     if (!$validator->isValid($arrParam['order'])) {
         $message = $validator->getMessages();
         $this->_messageError['order'] = 'Sắp xếp: ' . current($message);
         $arrParam['order'] = '';
     }
     //////////////////////////////////
     //Kiem tra Status /////////////
     //////////////////////////////////
     if (empty($arrParam['status']) || !isset($arrParam['status'])) {
         $arrParam['status'] = 0;
     }
     //========================================
     // TRUYEN CAC GIA TRI DUNG VAO MANG $_arrData
     //========================================
     $this->_arrData = $arrParam;
 }
开发者ID:brianbui171,项目名称:website_zend_1.11,代码行数:52,代码来源:ValidateAlbum.php


示例13: addRule

 /**
  * Add rule to be applied to a validation scope
  *
  * @param \Zend_Validate_Interface $validator
  * @param string $fieldName Field name to apply validation to, or empty value to validate entity as a whole
  * @return \Magento\Framework\Validator\DataObject
  * @api
  */
 public function addRule(\Zend_Validate_Interface $validator, $fieldName = '')
 {
     if (!array_key_exists($fieldName, $this->_rules)) {
         $this->_rules[$fieldName] = $validator;
     } else {
         $existingValidator = $this->_rules[$fieldName];
         if (!$existingValidator instanceof \Zend_Validate) {
             $compositeValidator = new \Zend_Validate();
             $compositeValidator->addValidator($existingValidator);
             $this->_rules[$fieldName] = $compositeValidator;
         }
         $this->_rules[$fieldName]->addValidator($validator);
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:23,代码来源:DataObject.php


示例14: isValidText

 public function isValidText($value, $maxLenghtValue)
 {
     $validator = new Zend_Validate();
     // Create a validator chain and add validators to it
     $validator->addValidator(new Zend_Validate_NotEmpty())->addValidator(new Zend_Validate_StringLength(1, $maxLenghtValue));
     // Validate the value
     if ($validator->isValid($value)) {
         return true;
     } else {
         // value failed validation; print reasons
         foreach ($validator->getMessages() as $message) {
             return array('Error' => $message);
         }
     }
 }
开发者ID:roycocup,项目名称:Tests,代码行数:15,代码来源:Validator.php


示例15: authenticateAction

 /**
  * 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);
 }
开发者ID:drunkvegas,项目名称:done,代码行数:33,代码来源:ZendeskController.php


示例16: validate

 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;
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:34,代码来源:SubAccount.php


示例17: checkemailregisterAction

 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);
 }
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:30,代码来源:IndexController.php


示例18: execute

 /**
  * 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');
     }
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:34,代码来源:ForgotPasswordPost.php


示例19: postAction

 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);
     }
 }
开发者ID:bklein01,项目名称:siberian_cms_2,代码行数:29,代码来源:RegisterController.php


示例20: forgotpasswordpostAction

 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);
 }
开发者ID:victorkho,项目名称:telor,代码行数:32,代码来源:AjaxloginController.php



注:本文中的Zend_Validate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Validate_Abstract类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Uri_Http类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap