Ejemplo n.º 1
0
 /**
  * Validates the personal informations
  *
  * @return array - personal data with error flags and msg
  */
 public function validatePersonal()
 {
     $this->admin->sSYSTEM->_POST = $this->post['personal'];
     $result = array();
     $checkData = $this->admin->sValidateStep1();
     if (!empty($checkData['sErrorMessages'])) {
         $result = $checkData;
     }
     $rules = array('customer_type' => array('required' => 0), 'salutation' => array('required' => 1), 'firstname' => array('required' => 1), 'lastname' => array('required' => 1), 'phone' => array('required' => intval(Shopware()->Config()->get('requirePhoneField'))), 'fax' => array('required' => 0), 'text1' => array('required' => 0), 'text2' => array('required' => 0), 'text3' => array('required' => 0), 'text4' => array('required' => 0), 'text5' => array('required' => 0), 'text6' => array('required' => 0), 'sValidation' => array('required' => 0), 'birthyear' => array('required' => 0), 'birthmonth' => array('required' => 0), 'birthday' => array('required' => 0), 'dpacheckbox' => array('required' => Shopware()->Config()->get('ACTDPRCHECK') ? 1 : 0));
     $rules = Enlight()->Events()->filter('Shopware_Controllers_Frontend_Register_validatePersonal_FilterRules', $rules, array('subject' => $this));
     $checkData = $this->admin->sValidateStep2($rules);
     if (!empty($checkData['sErrorMessages'])) {
         $result = array_merge_recursive($result, $checkData);
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Save account action
  *
  * Save account address data and create error messages
  *
  */
 public function saveAccountAction()
 {
     if ($this->Request()->isPost()) {
         $checkData = $this->admin->sValidateStep1(true);
         if (!empty($checkData["sErrorMessages"])) {
             foreach ($checkData["sErrorMessages"] as $key => $error_message) {
                 $checkData["sErrorMessages"][$key] = $this->View()->fetch('string:' . $error_message);
             }
         }
         if (empty($checkData['sErrorMessages'])) {
             $this->admin->sUpdateAccount();
             $this->View()->sSuccessAction = 'account';
         } else {
             $this->View()->sErrorFlag = $checkData['sErrorFlag'];
             $this->View()->sErrorMessages = $checkData['sErrorMessages'];
         }
     }
     $this->forward('index');
 }
Ejemplo n.º 3
0
 /**
  * @covers sAdmin::sValidateStep1
  */
 public function testsValidateStep1WithEdit()
 {
     $customer = $this->createDummyCustomer();
     // Test with no data
     $result = $this->module->sValidateStep1(true);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('sErrorFlag', $result);
     $this->assertArrayHasKey('sErrorMessages', $result);
     $this->assertCount(1, $result['sErrorMessages']);
     $this->assertContains('Das aktuelle Passwort stimmt nicht!', $result['sErrorMessages']);
     $this->assertCount(2, $result['sErrorFlag']);
     $this->assertArrayHasKey('email', $result['sErrorFlag']);
     $this->assertArrayHasKey('currentPassword', $result['sErrorFlag']);
     // Test with correct basic data, wrong password
     // First, hack session data with correct data
     $this->session->offsetSet('sUserMail', $customer->getEmail());
     $this->session->offsetSet("sUserPassword", Shopware()->PasswordEncoder()->encodePassword("fooobar", 'bcrypt'));
     // Then set post with wrong data
     $this->front->Request()->setPost(array('email' => $customer->getEmail(), 'currentPassword' => 'password'));
     $result = $this->module->sValidateStep1(true);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('sErrorFlag', $result);
     $this->assertArrayHasKey('sErrorMessages', $result);
     $this->assertCount(1, $result['sErrorMessages']);
     $this->assertContains('Das aktuelle Passwort stimmt nicht!', $result['sErrorMessages']);
     $this->assertCount(2, $result['sErrorFlag']);
     $this->assertArrayHasKey('email', $result['sErrorFlag']);
     $this->assertArrayHasKey('currentPassword', $result['sErrorFlag']);
     // Now use correct data to test correct behavior
     $this->front->Request()->setPost('currentPassword', 'fooobar');
     $result = $this->module->sValidateStep1(true);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('sErrorFlag', $result);
     $this->assertArrayHasKey('sErrorMessages', $result);
     $this->assertNull($result['sErrorMessages']);
     $this->assertNull($result['sErrorFlag']);
     $this->deleteDummyCustomer($customer);
 }