/** * 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); }
public function init() { $this->setAttrib('class', 'form-horizontal'); $login = new Zend_Form_Element_Text('login'); $login->setRequired()->addValidator('StringLength', false, array('max' => 32))->setLabel('Nom d\'utilisateur'); $db = Zend_Db_Table::getDefaultAdapter(); $validator = new Zend_Validate_Db_NoRecordExists(array('adapter' => $db, 'schema' => 'twitter', 'table' => 'membre', 'field' => 'login')); $validator->setMessage("Le login '%value%' est déjà utilisé"); $login->addValidator($validator); $pass = new Zend_Form_Element_Password('pass'); $pass->setLabel('Mot de passe')->setRequired(); $passConfirm = new Zend_Form_Element_Password('confirm'); $passConfirm->setLabel('Confirmer le mot de passe'); $validator = new Zend_Validate_Identical('pass'); $validator->setMessage('La confirmation ne correspond pas au mot de passe'); $passConfirm->addValidator($validator); //$passConfirm->addValidator('Identical', false, array('token')); $hash = new Zend_Form_Element_Hash('hash'); $submit = new Zend_Form_Element_Submit('Inscription'); $cancel = new Zend_Form_Element_Button('Annuler'); $this->addElements(array($login, $pass, $passConfirm, $hash, $submit, $cancel)); // add display group $this->addDisplayGroup(array('login', 'pass', 'confirm', 'Inscription', 'Annuler'), 'users'); $this->getDisplayGroup('users')->setLegend('S\'inscrire'); // set decorators EasyBib_Form_Decorator::setFormDecorator($this, EasyBib_Form_Decorator::BOOTSTRAP, 'Inscription', 'Annuler'); }
/** * 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); }
public function addDBNoRecordExistsValidator() { $email = $this->getElement('email'); $validator = new Zend_Validate_Db_NoRecordExists(array('table' => 'accounts', 'field' => 'email')); $validator->setMessage("This email already exists in our database"); $email->addValidator($validator); }
public function __construct($options = null) { parent::__construct($options); $this->setName('product'); $product_name = new Zend_Form_Element_Text('product_name'); $product_name->setLabel('Product Name: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $id = new Zend_Form_Element_Hidden('id'); $ProductIdExists = new Zend_Validate_Db_NoRecordExists(array('table' => 'products', 'field' => 'product_id')); $ProductIdExists->setMessage('This Product ID is already taken'); $product_id = new Zend_Form_Element_Text('product_id'); $product_id->setLabel('Product ID: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator($ProductIdExists)->addValidator('NotEmpty'); $category = new Category(); $categoriesList = $category->getCategoriesList(); $category_id = new Zend_Form_Element_Select('category_id'); $category_id->setLabel('Category: ')->addMultiOptions($categoriesList)->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $product_desc = new Zend_Form_Element_Text('product_desc'); $product_desc->setLabel('Description ')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $product_img = new Zend_Form_Element_File('product_image'); $product_img->setLabel('Upload an image:')->setDestination(PUBLIC_PATH . '/images'); // ensure only 1 file $product_img->addValidator('Count', false, 1); // limit to 100K $product_img->addValidator('Size', false, 102400); // only JPEG, PNG, and GIFs $product_img->addValidator('Extension', false, 'jpg,png,gif'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $this->setAttrib('enctype', 'multipart/form-data'); $this->addElements(array($product_name, $product_id, $product_desc, $product_img, $id, $category_id, $submit)); }
public function __construct($options = null) { $this->_addSubmitSaveClose = true; parent::__construct($options); $this->setName('page'); //$imageSrc = $options['imageSrc']; $pageID = $options['pageID']; $imageHeaderArray = $options['imageHeaderArray']; // contains the id of the page $id = new Zend_Form_Element_Hidden('id'); $id->removeDecorator('Label'); $id->removeDecorator('HtmlTag'); // input text for the title of the page $title = new Zend_Form_Element_Text('PI_PageTitle'); $title->setLabel($this->getView()->getCibleText('label_titre_page'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => Cible_Translation::getCibleText('error_field_required')))->setAttrib('class', 'stdTextInput')->setAttrib('onBlur', 'javascript:fillInControllerName();'); $lblTit = $title->getDecorator('Label'); $lblTit->setOption('class', $this->_labelCSS); // input text for the index of the page $uniqueIndexValidator = new Zend_Validate_Db_NoRecordExists('PagesIndex', 'PI_PageIndex'); $uniqueIndexValidator->setMessage($this->getView()->getCibleText('label_index_already_exists'), Zend_Validate_Db_NoRecordExists::ERROR_RECORD_FOUND); $reservedWordValidator = new Cible_Validate_Db_NoRecordExists('Modules', 'M_MVCModuleTitle'); $reservedWordValidator->setMessage($this->getView()->getCibleText('label_index_reserved'), Zend_Validate_Db_NoRecordExists::ERROR_RECORD_FOUND); $index = new Zend_Form_Element_Text('PI_PageIndex'); $index->setLabel($this->getView()->getCibleText('label_name_controller'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => Cible_Translation::getCibleText('error_field_required')))->addValidator('stringLength', true, array(1, 50, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => $this->getView()->getCibleText('label_index_more_char'), Zend_Validate_StringLength::TOO_LONG => $this->getView()->getCibleText('label_index_less_char'))))->addValidator('regex', true, array('/^[a-z0-9][a-z0-9_-]*[a-z0-9]$/', 'messages' => $this->getView()->getCibleText('label_only_character_allowed')))->addValidator($uniqueIndexValidator, true)->addValidator($reservedWordValidator, true)->setAttrib('class', 'stdTextInput'); $lblId = $index->getDecorator('Label'); $lblId->setOption('class', $this->_labelCSS); // textarea for the meta and title of the page $metaTitle = new Zend_Form_Element_Textarea('PI_MetaTitle'); $metaTitle->setLabel('Titre (meta)')->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextareaShort'); $lblMetaTitle = $metaTitle->getDecorator('Label'); $lblMetaTitle->setOption('class', $this->_labelCSS); // textarea for the meta description of the page $metaDescription = new Zend_Form_Element_Textarea('PI_MetaDescription'); $metaDescription->setLabel($this->getView()->getCibleText('label_description_meta'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextareaShort'); $lblMetaDescr = $metaDescription->getDecorator('Label'); $lblMetaDescr->setOption('class', $this->_labelCSS); // textarea for the meta keywords of the page $metaKeyWords = new Zend_Form_Element_Textarea('PI_MetaKeywords'); $metaKeyWords->setLabel($this->getView()->getCibleText('label_keywords_meta'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextareaShort'); $lblMetaKey = $metaKeyWords->getDecorator('Label'); $lblMetaKey->setOption('class', $this->_labelCSS); // textarea for the meta keywords of the page $metaOthers = new Zend_Form_Element_Textarea('PI_MetaOther'); $metaOthers->setLabel($this->getView()->getCibleText('label_other_meta'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextareaShort'); $lblMetaOther = $metaOthers->getDecorator('Label'); $lblMetaOther->setOption('class', $this->_labelCSS); // select box for the templates $layout = new Zend_Form_Element_Select('P_LayoutID'); $layout->setLabel($this->getView()->getCibleText('label_layout_page'))->setAttrib('class', 'stdSelect'); // select box for the templates $template = new Zend_Form_Element_Select('P_ViewID'); $template->setLabel($this->getView()->getCibleText('label_model_page'))->setAttrib('class', 'stdSelect'); // checkbox for the status (0 = offline, 1 = online) $status = new Zend_Form_Element_Checkbox('PI_Status'); $status->setValue(1); $status->setLabel($this->getView()->getCibleText('form_check_label_online')); $status->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); // checkbox for the show title of the page (0 = offline, 1 = online) $showTitle = new Zend_Form_Element_Checkbox('P_ShowTitle'); $showTitle->setValue(1); $showTitle->setLabel($this->getView()->getCibleText('form_check_label_show_title')); $showTitle->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); // image group // ImageSrc /*$imageSrc = new Zend_Form_Element_Select('P_BannerGroupID'); $imageSrc->setLabel($this->getView()->getCibleText('form_banner_image_group_extranet'))->setAttrib('class','stdSelect'); $imageSrc->addMultiOption('', 'Sans image'); $group = new GroupObject(); $groupArray = $group->groupCollection(); foreach ($groupArray as $group1) { $imageSrc->addMultiOption($group1['BG_ID'],$group1['BG_Name']); }*/ // page image $imageSrc = new Zend_Form_Element_Select('PI_TitleImageSrc'); $imageSrc->setLabel("Image de l'entête")->setAttrib('class', 'stdSelect'); $imageSrc->addMultiOption('', 'Sans image'); $i = 1; foreach ($imageHeaderArray as $img => $path) { $imageSrc->addMultiOption($path, $path); $i++; } $altImage = new Zend_Form_Element_Text('PI_AltPremiereImage'); $altImage->setLabel($this->getView()->getCibleText('label_altFirstImage'))->setAttrib('class', 'stdTextInput'); // add element to the form $this->addElements(array($title, $index, $status, $showTitle, $layout, $template, $imageSrc, $altImage, $metaTitle, $metaDescription, $metaKeyWords, $metaOthers, $id)); }
protected function _emailValidate($isUnique = '') { $validators = array(); $regexValidate = new Cible_Validate_Email(); $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch'); array_push($validators, $regexValidate); if (!empty($isUnique)) { $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists($this->_object->getDataTableName(), $isUnique); $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound'); array_push($validators, $emailNotFoundInDBValidator); } return $validators; }
public function __construct($options = null) { $this->_disabledDefaultActions = true; parent::__construct($options); $baseDir = $this->getView()->baseUrl(); if (!empty($options['mode']) && $options['mode'] == 'edit') { $this->_mode = 'edit'; } else { $this->_mode = 'add'; } $langId = Zend_Registry::get('languageID'); $this->setAttrib('id', 'accountManagement'); $this->setAttrib('class', 'step3'); // $addressParams = array( // "fieldsValue" => array(), // "display" => array(), // "required" => array(), // ); //Hidden fields for the state and cities id $selectedState = new Zend_Form_Element_Hidden('selectedState'); $selectedState->removeDecorator('label'); $selectedCity = new Zend_Form_Element_Hidden('selectedCity'); $selectedCity->removeDecorator('label'); $this->addElement($selectedState); $this->addElement($selectedCity); // Salutation $salutation = new Zend_Form_Element_Select('salutation'); $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallTextInput')->setOrder(1); $greetings = $this->getView()->getAllSalutation(); foreach ($greetings as $greeting) { $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']); } // language hidden field $language = new Zend_Form_Element_Hidden('language', array('value' => $langId)); $language->removeDecorator('label'); // langauge hidden field // FirstName $firstname = new Zend_Form_Element_Text('firstName'); $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(2); // LastName $lastname = new Zend_Form_Element_Text('lastName'); $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(3); // email $regexValidate = new Cible_Validate_Email(); $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch'); $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email'); $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound'); $email = new Zend_Form_Element_Text('email'); $email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setOrder(4); if ($this->_mode == 'add') { $email->addValidator($emailNotFoundInDBValidator); } // email // password $password = new Zend_Form_Element_Password('password'); if ($this->_mode == 'add') { $password->setLabel($this->getView()->getCibleText('form_label_password')); } else { $password->setLabel($this->getView()->getCibleText('form_label_newPwd')); } $password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setRequired(true)->setOrder(5)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field')))); // password // password confirmation $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation'); if ($this->_mode == 'add') { $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd')); } else { $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd')); } $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(6)->setAttrib('class', 'stdTextInput'); if (!empty($_POST['identification']['password'])) { $passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty')))); $Identical = new Zend_Validate_Identical($_POST['identification']['password']); $Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame'))); $passwordConfirmation->addValidator($Identical); } // password confirmation // Company name $company = new Zend_Form_Element_Text('company'); $company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setOrder(7)->setAttribs(array('class' => 'stdTextInput')); // function in company $functionCompany = new Zend_Form_Element_Text('functionCompany'); $functionCompany->setLabel($this->getView()->getCibleText('form_label_account_function_company'))->setRequired(false)->setOrder(8)->setAttribs(array('class' => 'stdTextInput')); // Are you a retailer $retailer = new Zend_Form_Element_Select('isRetailer'); $retailer->setLabel($this->getView()->getClientText('form_label_retailer'))->setAttrib('class', 'smallTextInput'); $retailer->addMultiOption(0, $this->getView()->getCibleText('button_no')); $retailer->addMultiOption(1, $this->getView()->getCibleText('button_yes')); // Text Subscribe $textSubscribe = $this->getView()->getCibleText('form_label_subscribe'); $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->page_privacy_policy->pageID), $textSubscribe); // Newsletter subscription $newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription'); $newsletterSubscription->setLabel($textSubscribe); if ($this->_mode == 'add') { $newsletterSubscription->setChecked(1); } $newsletterSubscription->setAttrib('class', 'long-text'); $newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); if ($this->_mode == 'add') { $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement'); $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement'))); $termsAgreement->setAttrib('class', 'long-text'); $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $termsAgreement->setRequired(true); $termsAgreement->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'You must agree to the terms'))); } else { $termsAgreement = new Zend_Form_Element_Hidden('termsAgreement', array('value' => 1)); } // Submit button $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel($this->getView()->getCibleText('form_label_next_step_btn'))->setAttrib('class', 'nextStepButton'); // Reference number for the job $txtConnaissance = new Cible_Form_Element_Html('knowYou', array('value' => $this->getView()->getCibleText('form_account_mieux_vous_connaitre_legend'))); $txtConnaissance->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'description left')))); $refJobId = new Zend_Form_Element_Text('refJobId'); $refJobId->setLabel('refJobId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput')); // Reference number for the role $refRoleId = new Zend_Form_Element_Text('refRoleId'); $refRoleId->setLabel('refRoleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput')); // Reference number for the job title $refJobTitleId = new Zend_Form_Element_Text('refJobTitleId'); $refJobTitleId->setLabel('refJobTitleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput')); $refJobTitleId = new Zend_Form_Element_Text('refJobTitleId'); $refJobTitleId->setLabel('refJobTitleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput')); // Provincial tax exemption $noProvTax = new Zend_Form_Element_Checkbox('noProvTax'); $noProvTax->setLabel($this->getView()->getCibleText('form_label_account_provincial_tax')); $noProvTax->setAttrib('class', 'long-text')->setOrder(13); $noProvTax->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); // Provincial tax exemption $noFedTax = new Zend_Form_Element_Checkbox('noFedTax'); $noFedTax->setLabel($this->getView()->getCibleText('form_label_account_federal_tax')); $noFedTax->setAttrib('class', 'long-text')->setOrder(14); $noFedTax->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); /* Identification sub form */ $identificationSub = new Zend_Form_SubForm(); $identificationSub->setName('identification')->removeDecorator('DtDdWrapper'); $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend')); $identificationSub->setAttrib('class', 'identificationClass subFormClass'); $identificationSub->addElement($language); $identificationSub->addElement($salutation); $identificationSub->addElement($lastname); $identificationSub->addElement($firstname); $identificationSub->addElement($email); $identificationSub->addElement($password); $identificationSub->addElement($passwordConfirmation); $identificationSub->addElement($company); $this->addSubForm($identificationSub, 'identification'); // $identificationSub->addElement($functionCompany); $addrContactMedia = new Cible_View_Helper_FormAddress($identificationSub); if ($options['resume']) { $addrContactMedia->setProperty('addScript', false); } $addrContactMedia->enableFields(array('firstTel', 'secondTel', 'fax', 'webSite')); $addrContactMedia->formAddress(); $identificationSub->addElement($noProvTax); $identificationSub->addElement($noFedTax); /* Identification sub form */ /* billing address */ // Billing address $addressFacturationSub = new Zend_Form_SubForm(); $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper'); $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend')); $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormClass'); $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub); $billingAddr->setProperty('addScriptState', false); if ($options['resume']) { $billingAddr->setProperty('addScript', false); } $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel')); $billingAddr->formAddress(); $addrBill = new Zend_Form_Element_Hidden('addrBill'); $addrBill->removeDecorator('label'); $addressFacturationSub->addElement($addrBill); $addressFacturationSub->getElement('AI_SecondAddress')->removeDecorator('label'); $this->addSubForm($addressFacturationSub, 'addressFact'); /* delivery address */ $addrShip = new Zend_Form_Element_Hidden('addrShip'); $addrShip->removeDecorator('label'); $addressShippingSub = new Zend_Form_SubForm(); $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper'); $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend')); $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormClass'); $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub); if ($options['resume']) { $shipAddr->setProperty('addScript', false); } $shipAddr->duplicateAddress($addressShippingSub); $shipAddr->setProperty('addScriptState', false); $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel')); $shipAddr->formAddress(); $addressShippingSub->addElement($addrShip); $this->addSubForm($addressShippingSub, 'addressShipping'); if ($this->_mode == 'edit') { $this->addElement($termsAgreement); } $this->addElement($submit); $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'stepBottomNext')))); if ($this->_mode == 'add') { $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox', 'id' => 'dd-terms-agreement')))); } }
public function __construct($options = null) { $this->_disabledDefaultActions = true; parent::__construct($options); $baseDir = $this->getView()->baseUrl(); if (!empty($options['mode']) && $options['mode'] == 'edit') { $this->_mode = 'edit'; } else { $this->_mode = 'add'; } $langId = Zend_Registry::get('languageID'); $this->setAttrib('id', 'accountManagement'); // $addressParams = array( // "fieldsValue" => array(), // "display" => array(), // "required" => array(), // ); // Salutation $salutation = new Zend_Form_Element_Select('salutation'); $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallSelect')->setAttrib('tabindex', '1')->setOrder(1); $greetings = $this->getView()->getAllSalutation(); foreach ($greetings as $greeting) { $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']); } // Language $languages = new Zend_Form_Element_Select('language'); $languages->setLabel($this->getView()->getCibleText('form_label_language'))->setAttrib('class', 'stdSelect')->setAttrib('tabindex', '9')->setOrder(9); foreach (Cible_FunctionsGeneral::getAllLanguage() as $lang) { $languages->addMultiOption($lang['L_ID'], $lang['L_Title']); } // FirstName $firstname = new Zend_Form_Element_Text('firstName'); $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '2')->setOrder(2); // LastName $lastname = new Zend_Form_Element_Text('lastName'); $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '3')->setOrder(3); // email $regexValidate = new Cible_Validate_Email(); $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch'); $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email'); $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound'); $email = new Zend_Form_Element_Text('email'); $email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setAttrib('tabindex', '5')->setOrder(5); if ($this->_mode == 'add') { $email->addValidator($emailNotFoundInDBValidator); } // email // password $password = new Zend_Form_Element_Password('password'); if ($this->_mode == 'add') { $password->setLabel($this->getView()->getCibleText('form_label_password')); } else { $password->setLabel($this->getView()->getCibleText('form_label_newPwd')); } $password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '6')->setRequired(true)->setOrder(6)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field')))); // password // password confirmation $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation'); if ($this->_mode == 'add') { $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd')); } else { $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd')); } // $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd')); $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(7)->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '7')->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical')))); if (!empty($_POST['identification']['password'])) { $passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty')))); $Identical = new Zend_Validate_Identical($_POST['identification']['password']); $Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame'))); $passwordConfirmation->addValidator($Identical); } // password confirmation // Company name $company = new Zend_Form_Element_Text('company'); $company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setAttrib('tabindex', '4')->setOrder(4)->setAttribs(array('class' => 'stdTextInput')); // Account number $account = new Zend_Form_Element_Text('accountNum'); $account->setLabel($this->getView()->getCibleText('form_label_account'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setOrder(8)->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '8')->setDecorators(array('ViewHelper', 'Errors', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical')))); // Text Subscribe $textSubscribe = $this->getView()->getCibleText('form_label_subscribe'); $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->privacyPolicy->pageId), $textSubscribe); // Newsletter subscription $newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription'); $newsletterSubscription->setLabel($textSubscribe); if ($this->_mode == 'add') { $newsletterSubscription->setChecked(1); } $newsletterSubscription->setAttrib('class', 'long-text'); $newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'subscribeNewsletter', 'class' => 'label_after_checkbox')))); if ($this->_mode == 'add') { $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement'); $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement'))); $termsAgreement->setAttrib('class', 'long-text'); $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $termsAgreement->setRequired(true); $termsAgreement->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'You must agree to the terms'))); } else { $termsAgreement = new Zend_Form_Element_Hidden('termsAgreement', array('value' => 1)); } // Submit button $submit = new Zend_Form_Element_Submit('submit'); $submitLabel = $this->getView()->getCibleText('form_account_button_submit'); if ($this->_mode == 'edit') { $submitLabel = $this->getView()->getCibleText('button_submit'); } $submit->setLabel($submitLabel)->setAttrib('class', 'stdButton subscribeButton1-' . Zend_Registry::get("languageSuffix")); // Captcha // Refresh button $refresh_captcha = new Zend_Form_Element_Button('refresh_captcha'); $refresh_captcha->setLabel($this->getView()->getCibleText('button_refresh_captcha'))->setAttrib('onclick', "refreshCaptcha('captcha-id')")->setAttrib('class', 'stdButton')->removeDecorator('Label')->removeDecorator('DtDdWrapper'); $refresh_captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'dd-refresh-captcha-button')))); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->getView()->getCibleText('form_label_securityCaptcha'), 'captcha' => 'Image', 'captchaOptions' => array('captcha' => 'Word', 'wordLen' => 5, 'fontSize' => 28, 'height' => 67, 'width' => 169, 'timeout' => 300, 'dotNoiseLevel' => 0, 'lineNoiseLevel' => 0, 'font' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/fonts/ARIAL.TTF", 'imgDir' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/tmp", 'imgUrl' => "{$baseDir}/captcha/tmp"))); $captcha->setAttrib('class', 'stdTextInputCatcha'); $captcha->setRequired(true); $captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'dd_captcha'))))->addDecorator('Label', array('class' => 'clear')); $french = array('badCaptcha' => 'Veuillez saisir la chaîne ci-dessus correctement.'); $english = array('badCaptcha' => 'Captcha value is wrong'); $translate = new Zend_Translate('array', $french, 'fr'); $this->setTranslator($translate); $this->getView()->jQuery()->enable(); $script = <<<EOS function refreshCaptcha(id){ \$.getJSON('{$this->getView()->baseUrl()}/newsletter/index/captcha-reload', function(data){ \$("dd#dd_captcha img").attr({src : data['url']}); \$("#"+id).attr({value: data['id']}); }); } EOS; $this->getView()->headScript()->appendScript($script); // Captcha /* Identification sub form */ $identificationSub = new Cible_Form_SubForm(); $identificationSub->setName('identification')->removeDecorator('DtDdWrapper'); $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend')); $identificationSub->setAttrib('class', 'identificationClass subFormClass'); $identificationSub->addElement($languages); $identificationSub->addElement($salutation); $identificationSub->addElement($lastname); $identificationSub->addElement($firstname); $identificationSub->addElement($email); $identificationSub->addElement($password); $identificationSub->addElement($passwordConfirmation); $identificationSub->addElement($company); $identificationSub->addElement($account); $identificationSub->addDisplayGroup(array('salutation', 'firstName', 'company', 'password', 'accountNum'), 'leftColumn'); $identificationSub->addDisplayGroup(array('lastName', 'email', 'passwordConfirmation', 'language'), 'rightColumn')->removeDecorator('DtDdWrapper'); $leftColGroup = $identificationSub->getDisplayGroup('leftColumn'); $rightColGroup = $identificationSub->getDisplayGroup('rightColumn'); $leftColGroup->removeDecorator('DtDdWrapper'); $rightColGroup->removeDecorator('DtDdWrapper'); $this->addSubForm($identificationSub, 'identification'); // Billing address $addressFacturationSub = new Cible_Form_SubForm(); $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper'); $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend')); $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormClass'); $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub); $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax')); $billingAddr->formAddress(); $addrBill = new Zend_Form_Element_Hidden('addrBill'); $addrBill->removeDecorator('label'); $addressFacturationSub->addElement($addrBill); $this->addSubForm($addressFacturationSub, 'addressFact'); /* delivery address */ $addrShip = new Zend_Form_Element_Hidden('addrShip'); $addrShip->removeDecorator('label'); $addressShippingSub = new Cible_Form_SubForm(); $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper'); $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend')); $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormClass'); $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub); $shipAddr->duplicateAddress($addressShippingSub); $shipAddr->setProperty('addScriptState', false); $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax')); $shipAddr->formAddress(); $addressShippingSub->addElement($addrShip); $this->addSubForm($addressShippingSub, 'addressShipping'); if ($this->_mode == 'add') { $this->getView()->jQuery()->enable(); $script = <<<EOS function refreshCaptcha(id){ \$.getJSON('{$this->getView()->baseUrl()}/order/index/captcha-reload', function(data){ \$("dd#dd_captcha img").attr({src : data['url']}); \$("#"+id).attr({value: data['id']}); }); } EOS; // $this->getView()->headScript()->appendScript($script); // $this->addElement($refresh_captcha); // $this->addElement($captcha); $this->addElement($newsletterSubscription); $this->addElement($termsAgreement); } $this->addElement($submit); $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'account-submit')))); if ($this->_mode == 'add') { $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox', 'id' => 'dd-terms-agreement')))); } $captchaError = array('badCaptcha' => $this->getView()->getCibleText('validation_message_captcha_error')); $translate = new Zend_Translate('array', $captchaError, $this->getView()->registryGet('languageSuffix')); $this->setTranslator($translate); }
public function __construct($options = null) { // $this->_disabledDefaultActions = true; // $this->_object = $options['object']; unset($options['object']); parent::__construct($options); $langId = 1; if (!empty($options['mode']) && $options['mode'] == 'edit') { $this->_mode = 'edit'; } if (!empty($options['langId'])) { $langId = $options['langId']; } // $this->getView()->headScript()->appendFile("{$this->getView()->baseUrl()}/js/jquery/jquery.maskedinput-1.2.2.min.js"); // // email $regexValidate = new Cible_Validate_Email(); $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch'); $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email'); $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound'); $email = new Zend_Form_Element_Text('GP_Email'); $email->setLabel($this->getView()->getCibleText('form_label_email'))->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => ' email stdTextInput')); if ($this->_mode == 'add') { $email->addValidator($emailNotFoundInDBValidator); } $this->addElement($email); if ($this->_mode == 'edit') { // Salutation $salutation = new Zend_Form_Element_Select('GP_Salutation'); $salutation->setLabel('Salutation :')->setAttrib('class', 'largeSelect'); $greetings = $this->getView()->getAllSalutation(); foreach ($greetings as $greeting) { $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']); } $this->addElement($salutation); //FirstName $firstname = new Zend_Form_Element_Text('GP_FirstName'); $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('maxlength' => 20, 'class' => 'required stdTextInput')); $this->addElement($firstname); // LastName $lastname = new Zend_Form_Element_Text('GP_LastName'); $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('maxlength' => 20, 'class' => 'required stdTextInput')); $this->addElement($lastname); $languages = new Zend_Form_Element_Select('GP_Language'); $languages->setLabel($this->getView()->getCibleText('form_label_language')); foreach (Cible_FunctionsGeneral::getAllLanguage() as $lang) { $languages->addMultiOption($lang['L_ID'], $lang['L_Title']); } $this->addElement($languages); } // new password $password = new Zend_Form_Element_Password('GP_Password'); $password->setLabel($this->getView()->getCibleText('form_label_newPwd'))->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setAttrib('autocomplete', 'off'); // password confirmation $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation'); $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd'))->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setAttrib('autocomplete', 'off'); if (Zend_Registry::get('pwdOn')) { $this->addElement($password); $this->addElement($passwordConfirmation); } $this->setAttrib('id', 'genericProfile'); }
/** * Create a new account or edit an existing one. * * @return void */ public function becomeclientAction() { // Test if the user is already connected. $account = Cible_FunctionsGeneral::getAuthentication(); // Set the default status to an account creation and not editing one $_edit = false; // Instantiate the user profiles $profile = new MemberProfile(); $newsletterProfile = new NewsletterProfile(); $memberData = array(); $accountValidate = true; //Set Default id for states and cities $config = Zend_Registry::get('config'); $current_state = $config->address->default->states; $currentCity = ''; $notifyAdmin = array(); // Get users data if he is already logged if ($account) { if ($account['status'] == 2 || $this->_request->isPost()) { $_edit = true; $memberData = $profile->findMember(array('email' => $account['email'])); $newsletterData = $newsletterProfile->findMember(array('email' => $account['email'])); $oAddress = new AddressObject(); if (!empty($memberData['addrBill'])) { $billAddr = $oAddress->populate($memberData['addrBill'], $this->_defaultInterfaceLanguage); } if (!empty($memberData['addrShip'])) { $shipAddr = $oAddress->populate($memberData['addrShip'], $this->_defaultInterfaceLanguage); } $oRetailer = new RetailersObject(); $onWeb = $oRetailer->getRetailerInfos($memberData['member_id'], $this->_defaultInterfaceLanguage); $memberData['AI_FirstTel'] = $billAddr['AI_FirstTel']; $memberData['AI_SecondTel'] = $billAddr['AI_SecondTel']; $memberData['A_Fax'] = $billAddr['A_Fax']; if (isset($billAddr['AI_WebSite'])) { $memberData['AI_WebSite'] = $billAddr['AI_WebSite']; } $memberData['addressFact'] = $billAddr; if (!$shipAddr['A_Duplicate']) { $shipAddr['duplicate'] = 0; } $memberData['addressShipping'] = $shipAddr; $current_state = $billAddr['A_StateId'] . self::SEPARATOR . $shipAddr['A_StateId'] . self::SEPARATOR; $currentCity = $billAddr['A_CityId'] . self::SEPARATOR . $shipAddr['A_CityId'] . self::SEPARATOR; if ($onWeb && !empty($onWeb['R_AddressId'])) { $webAddr = $oAddress->populate($onWeb['R_AddressId'], $this->_defaultInterfaceLanguage); $webAddr['isDistributeur'] = $onWeb['R_Status']; $memberData['addressDetaillant'] = $webAddr; $current_state .= $webAddr['A_StateId'] . '||'; $currentCity .= $webAddr['A_CityId'] . '||'; } // if (empty($this->view->step)) $this->view->headTitle($this->view->getClientText('account_modify_page_title')); } } $this->view->assign('accountValidate', $accountValidate); $options = $_edit ? array('mode' => 'edit') : array(); $_edit ? $this->view->assign('mode', 'edit') : $this->view->assign('mode', 'add'); // Instantiate the form for account management $form = new FormBecomeClient($options); //$_captcha = $form->getElement('captcha'); $countries = Cible_FunctionsGeneral::getCountries(); $addressFields = array(); $return = $this->_getParam('return'); if ($return && isset($_COOKIE['returnUrl'])) { $returnUrl = $_COOKIE['returnUrl']; $this->view->assign('return', $returnUrl); } $this->view->assign('selectedCity', $currentCity); $this->view->assign('selectedState', $current_state); $addressFields = array_unique($addressFields); // Test if the users has ticked the aggreement checkbox $agreementError = isset($_POST['termsAgreement']) && $_POST['termsAgreement'] != 1 ? true : false; if ($_edit) { $agreementError = false; } $this->view->assign('agreementError', $agreementError); // Actions when form is submitted if ($this->_request->isPost() && array_key_exists('submit', $_POST)) { $formData = $this->_request->getPost(); // Test if the email already exists and password is the same if ($_edit) { $subFormI = $form->getSubForm('identification'); if ($formData['identification']['email'] != $memberData['email']) { $findEmail = $profile->findMember(array('email' => $formData['identification']['email'])); if ($findEmail) { $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email'); $emailNotFoundInDBValidator->setMessage($this->view->getClientText('validation_message_email_already_exists'), 'recordFound'); $subFormI->getElement('email')->addValidator($emailNotFoundInDBValidator); } } if (empty($formData['identification']['password']) && empty($formData['identification']['passwordConfirmation'])) { $subFormI->getElement('password')->clearValidators()->setRequired(false); $subFormI->getElement('passwordConfirmation')->clearValidators()->setRequired(false); } } $oAddress = new AddressObject(); // Get the addresses data to insert $addressFact = $formData['addressFact']; $addressShipping = $formData['addressShipping']; // $addressRetailer = $formData['addressDetaillant']; //Remove data form form if the shipping address is the same as bill if ($addressShipping['duplicate'] == 1) { $subFormShip = $form->getSubForm('addressShipping'); foreach ($subFormShip as $key => $value) { $value->clearValidators()->setRequired(false); } unset($formData['addressShipping']); } //If customer doesn't want to add data on website, set to false the field name // if ($addressRetailer['isDistributeur'] == 1) // $form->getSubForm('addressDetaillant')->getElement('AI_Name')->clearValidators()->setRequired(false); if ($form->isValid($formData) && !$agreementError) { //remove addresses unset($formData['addressFact'], $formData['addressShipping'], $formData['addressDetaillant']); // merge all subform fields for the member profile table $formData = $this->_mergeFormData($formData); //get the last data to merge in the billing address // $addressFact['A_Fax'] = $formData['A_Fax']; // $addressFact['AI_FirstTel'] = $formData['AI_FirstTel']; // $addressFact['AI_SecondTel'] = $formData['AI_SecondTel']; // $addressFact['AI_WebSite'] = $formData['AI_WebSite']; if (!empty($formData['password'])) { $password = $formData['password']; $formData['password'] = md5($password); } if (!$_edit) { // Do the processing here $validatedEmail = Cible_FunctionsGeneral::generatePassword(); $path = Zend_Registry::get('web_root') . '/'; $hash = md5(session_id()); $duration = 0; $cookie = array('lastName' => utf8_encode($formData['lastName']), 'firstName' => utf8_encode($formData['firstName']), 'email' => $formData['email'], 'hash' => $hash, 'status' => 0); $formData['hash'] = $hash; $formData['validatedEmail'] = $validatedEmail; /// $this->save($memberId, $data); //Add addresses process and retrive id for memberProfiles $idBillingAddr = $oAddress->insert($addressFact, $this->_defaultInterfaceLanguage); if ($addressShipping['duplicate'] == 1) { $addressFact['A_Duplicate'] = $idBillingAddr; $idShippingAddr = $oAddress->insert($addressFact, $this->_defaultInterfaceLanguage); } else { $idShippingAddr = $oAddress->insert($addressShipping, $this->_defaultInterfaceLanguage); } $formData['addrBill'] = $idBillingAddr; $formData['addrShip'] = $idShippingAddr; $profile->addMember($formData); $memberData = $profile->findMember(array('email' => $formData['email'])); $idMember = $memberData['member_id']; // if ($addressRetailer['isDistributeur'] == 2) // { // $oRetailer = new RetailersObject(); // $idRetailerAddr = $oAddress->insert($addressRetailer, $this->_defaultInterfaceLanguage); // // $retailerData = array( // 'R_GenericProfileId' => $idMember, // 'R_AddressId' => $idRetailAddr, // 'R_Status' => $addressRetailer['isDistributeur'] // ); // // $oRetailer->insert($retailerData, $this->_defaultInterfaceLanguage); // } setcookie("authentication", json_encode($cookie), $duration, $path); $data = array('firstName' => $memberData['firstName'], 'lastName' => $memberData['lastName'], 'email' => $memberData['email'], 'language' => $formData['language'], 'validatedEmail' => $formData['validatedEmail'], 'password' => $password); $options = array('send' => true, 'isHtml' => true, 'to' => $formData['email'], 'moduleId' => $this->_moduleID, 'event' => 'newAccount', 'type' => 'email', 'recipient' => 'client', 'data' => $data); $oNotification = new Cible_Notifications_Email($options); // $notifyAdmin = array(); $this->view->assign('needConfirm', true); $this->renderScript('index/confirm-email.phtml'); } else { if (empty($formData['password'])) { unset($formData['password']); } $oAddress->save($billAddr['A_AddressId'], $addressFact, $this->_defaultInterfaceLanguage); if ($addressShipping['duplicate'] == 1) { $addressFact['A_Duplicate'] = $billAddr['A_AddressId']; $oAddress->save($shipAddr['A_AddressId'], $addressFact, $this->_defaultInterfaceLanguage); } else { $addressShipping['A_Duplicate'] = 0; $oAddress->save($shipAddr['A_AddressId'], $addressShipping, $this->_defaultInterfaceLanguage); } // $retailerData = array( // 'R_Status' => $addressRetailer['isDistributeur']); // // switch ($addressRetailer['isDistributeur']) // { // case 1: // if (!empty($onWeb)) // { // $retailerData = array( // 'R_Status' => $addressRetailer['isDistributeur']); // $oRetailer->save($onWeb['R_ID'], $retailerData, $this->_defaultInterfaceLanguage); // } // break; // case 2: // if (!empty($webAddr)) // { // $retailerData = array( // 'R_Status' => $addressRetailer['isDistributeur']); // $oAddress->save($webAddr['A_AddressId'], $addressRetailer, $this->_defaultInterfaceLanguage); // $oRetailer->save($onWeb['R_ID'], $retailerData, $this->_defaultInterfaceLanguage); // } // else // { // $addressId = $oAddress->insert($addressRetailer, $this->_defaultInterfaceLanguage); // $retailerData = array( // 'R_GenericProfileId' => $memberID, // 'R_AddressId' => $addressId, // 'R_Status' => $addressRetailer['isDistributeur'] // ); // $oRetailer->insert($retailerData, $this->_defaultInterfaceLanguage); // } // break; // default: // break; // } $profile->updateMember($memberData['member_id'], $formData); if ($formData['email'] != $memberData['email']) { $validatedEmail = Cible_FunctionsGeneral::generatePassword(); $formData['validatedEmail'] = $validatedEmail; $profile->updateMember($memberData['member_id'], $formData); $data = array('firstName' => $formData['firstName'], 'lastName' => $formData['lastName'], 'email' => $formData['email'], 'language' => $formData['language'], 'validatedEmail' => $formData['validatedEmail']); $options = array('send' => true, 'isHtml' => true, 'to' => $formData['email'], 'moduleId' => $this->_moduleID, 'event' => 'editResend', 'type' => 'email', 'recipient' => 'client', 'data' => $data); $oNotification = new Cible_Notifications_Email($options); $this->view->assign('needConfirm', true); $this->renderScript('index/confirm-email.phtml'); } else { $authentication = json_decode($_COOKIE['authentication'], true); $path = Zend_Registry::get('web_root') . '/'; $duration = 0; $cookie = array('lastName' => utf8_encode($formData['lastName']), 'firstName' => utf8_encode($formData['firstName']), 'email' => $authentication['email'], 'language' => $formData['language'], 'hash' => $authentication['hash'], 'status' => 2); setcookie("authentication", json_encode($cookie), $duration, $path); $this->view->assign('messages', array($this->view->getCibleText('form_account_modified_message'))); $this->view->assign('updatedName', $formData['firstName']); } $data = array('identification' => $memberData, 'addressFact' => $billAddr, 'addressShipping' => $shipAddr); $notifyAdmin = $this->_testDataForNotification($this->_request->getPost(), $data); // Notify admin if (count($notifyAdmin) > 0) { $data = array('firstName' => $formData['firstName'], 'lastName' => $formData['lastName'], 'email' => $formData['email'], 'NEWID' => $memberData['member_id'], 'language' => $formData['language'], 'validatedEmail' => $formData['validatedEmail'], 'form' => $form->populate($_POST), 'notifyAdmin' => $notifyAdmin); $options = array('send' => true, 'isHtml' => true, 'moduleId' => $this->_moduleID, 'event' => 'editAccount', 'type' => 'email', 'recipient' => 'admin', 'data' => $data); $oNotification = new Cible_Notifications_Email($options); } $this->_redirect(Cible_FunctionsCategories::getPagePerCategoryView(0, 'modify_inscription', $this->_moduleID)); } if (!empty($formData['newsletterSubscription'])) { $newsletterCategory = $formData['newsletterSubscription'] ? $this->_config->newsletter->default->categoryID : ''; $newsletterProfile->updateMember($memberData['member_id'], array('newsletter_categories' => $newsletterCategory)); } } else { $form->populate($_POST); } } else { if ($_edit && empty($this->view->step)) { if (!empty($newsletterData['newsletter_categories'])) { $memberData['newsletterSubscription'] = 1; } $form->populate($memberData); } } $this->view->assign('form', $form); }