/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted if ($this->frm->isSubmitted()) { // get fields $txtOldPassword = $this->frm->getField('old_password'); $txtNewPassword = $this->frm->getField('new_password'); // old password filled in? if ($txtOldPassword->isFilled(FL::getError('PasswordIsRequired'))) { // old password correct? if (FrontendProfilesAuthentication::getLoginStatus($this->profile->getEmail(), $txtOldPassword->getValue()) !== FrontendProfilesAuthentication::LOGIN_ACTIVE) { // set error $txtOldPassword->addError(FL::getError('InvalidPassword')); } // new password filled in? $txtNewPassword->isFilled(FL::getError('PasswordIsRequired')); } // no errors if ($this->frm->isCorrect()) { // update password FrontendProfilesAuthentication::updatePassword($this->profile->getId(), $txtNewPassword->getValue()); // trigger event FrontendModel::triggerEvent('profiles', 'after_profile_password', array('id' => $this->profile->getId())); // redirect $this->redirect(SITE_URL . FrontendNavigation::getURLForBlock('profiles', 'profile_password') . '?saved=true'); } else { $this->tpl->assign('updatePasswordHasFormError', true); } } }
/** * Validate the form. */ private function validateForm() { // is the form submitted if ($this->frm->isSubmitted()) { // get fields $txtPassword = $this->frm->getField('password'); $txtEmail = $this->frm->getField('email'); // password filled in? if ($txtPassword->isFilled(FL::getError('PasswordIsRequired'))) { // password correct? if (FrontendProfilesAuthentication::getLoginStatus($this->profile->getEmail(), $txtPassword->getValue()) !== FrontendProfilesAuthentication::LOGIN_ACTIVE) { // set error $txtPassword->addError(FL::getError('InvalidPassword')); } // email filled in? if ($txtEmail->isFilled(FL::getError('EmailIsRequired'))) { // valid email? if ($txtEmail->isEmail(FL::getError('EmailIsInvalid'))) { // email already exists? if (FrontendProfilesModel::existsByEmail($txtEmail->getValue(), $this->profile->getId())) { // set error $txtEmail->setError(FL::getError('EmailExists')); } } } } // no errors if ($this->frm->isCorrect()) { // update email FrontendProfilesModel::update($this->profile->getId(), array('email' => $txtEmail->getValue())); // trigger event FrontendModel::triggerEvent('profiles', 'after_change_email', array('id' => $this->profile->getId())); // redirect $this->redirect(SITE_URL . FrontendNavigation::getURLForBlock('profiles', 'change_email') . '?sent=true'); } else { $this->tpl->assign('updateEmailHasFormError', true); } } }
/** * Validate the form. */ private function validateForm() { // is the form submitted if ($this->frm->isSubmitted()) { // get fields $txtDisplayName = $this->frm->getField('display_name'); $txtFirstName = $this->frm->getField('first_name'); $txtLastName = $this->frm->getField('last_name'); $txtCity = $this->frm->getField('city'); $ddmCountry = $this->frm->getField('country'); $ddmGender = $this->frm->getField('gender'); $ddmDay = $this->frm->getField('day'); $ddmMonth = $this->frm->getField('month'); $ddmYear = $this->frm->getField('year'); // get number of display name changes $nameChanges = (int) FrontendProfilesModel::getSetting($this->profile->getId(), 'display_name_changes'); // has there been a valid display name change request? if ($this->profile->getDisplayName() !== $txtDisplayName->getValue() && $nameChanges <= FrontendProfilesModel::MAX_DISPLAY_NAME_CHANGES) { // display name filled in? if ($txtDisplayName->isFilled(FL::getError('FieldIsRequired'))) { // display name exists? if (FrontendProfilesModel::existsDisplayName($txtDisplayName->getValue(), $this->profile->getId())) { // set error $txtDisplayName->addError(FL::getError('DisplayNameExists')); } } } // birthdate is not required but if one is filled we need all if ($ddmMonth->isFilled() || $ddmDay->isFilled() || $ddmYear->isFilled()) { // valid birth date? if (!checkdate($ddmMonth->getValue(), $ddmDay->getValue(), $ddmYear->getValue())) { // set error $ddmYear->addError(FL::getError('DateIsInvalid')); } } // no errors if ($this->frm->isCorrect()) { // init $values = array(); // has there been a valid display name change request? if ($this->profile->getDisplayName() !== $txtDisplayName->getValue() && $nameChanges <= FrontendProfilesModel::MAX_DISPLAY_NAME_CHANGES) { // get display name value $values['display_name'] = $txtDisplayName->getValue(); // update url based on the new display name $values['url'] = FrontendProfilesModel::getUrl($txtDisplayName->getValue(), $this->profile->getId()); // update display name count $this->profile->setSetting('display_name_changes', $nameChanges + 1); } // update values if (!empty($values)) { FrontendProfilesModel::update($this->profile->getId(), $values); } // bday is filled in if ($ddmYear->isFilled()) { // mysql format $birthDate = $ddmYear->getValue() . '-'; $birthDate .= str_pad($ddmMonth->getValue(), 2, '0', STR_PAD_LEFT) . '-'; $birthDate .= str_pad($ddmDay->getValue(), 2, '0', STR_PAD_LEFT); } else { $birthDate = null; } // update settings $this->profile->setSetting('first_name', $txtFirstName->getValue()); $this->profile->setSetting('last_name', $txtLastName->getValue()); $this->profile->setSetting('city', $txtCity->getValue()); $this->profile->setSetting('country', $ddmCountry->getValue()); $this->profile->setSetting('gender', $ddmGender->getValue()); $this->profile->setSetting('birth_date', $birthDate); // trigger event FrontendModel::triggerEvent('profiles', 'after_saved_settings', array('id' => $this->profile->getId())); // redirect $this->redirect(SITE_URL . FrontendNavigation::getURLForBlock('profiles', 'settings') . '?sent=true'); } else { $this->tpl->assign('updateSettingsHasFormError', true); } } }