private function ValidateUserInput(UserSVC $userSVC) { //Verifying mandatory fields if (!Validator::validateNotEmpty($this->getRequestParam("username"))) { $this->addError("username_required"); } //Check email only for mFirst accounts if (intval(trim($this->getRequestParam("accountType"))) == 1) { if (!Validator::validateNotEmpty($this->getRequestParam("email"))) { $this->addError("email_required"); } } //Get Session User details $sessionUser = $this->getSessionParam("session_user"); $password = ""; if (intval(trim($this->getRequestParam("accountType"))) == 1) { //Password Change if (trim($this->getRequestParam("password")) != "") { if (md5($this->getRequestParam("password")) == $sessionUser->password) { if (!Validator::validateNotEmpty($this->getRequestParam("newPassword"))) { $this->addError("new_password_required"); } if (!Validator::validateNotEmpty($this->getRequestParam("confirmPassword"))) { $this->addError("confirm_password_required"); } if (trim($this->getRequestParam("newPassword")) == trim($this->getRequestParam("confirmPassword"))) { $password = md5(trim($this->getRequestParam("newPassword"))); } else { $this->addError("password_mismatch"); } } else { $this->addError("password_incorrect"); } } else { if (trim($this->getRequestParam("newPassword")) != "" || trim($this->getRequestParam("confirmPassword")) != "") { $this->addError("old_password_required"); } else { $password = $sessionUser->password; } } } //Prepare selected country array $addressCountryArray = array(); $selectedCountryId = $this->getRequestParam("addressCountry"); $countryResponse = MongoUtils::GetSelectedCountryDetails("id", $selectedCountryId); if (is_array($countryResponse) && count($countryResponse) > 0) { $addressCountryArray = array("id" => $countryResponse["id"]['$id'], "name" => $countryResponse["name"], "code" => $countryResponse["code"], "alias" => $countryResponse["alias"]); } /* Populate object */ $userSVC->email = trim($this->getRequestParam("email")); $userSVC->username = trim($this->getRequestParam("username")); $userSVC->password = $password; $userSVC->firstname = trim($this->getRequestParam("firstname")); $userSVC->lastname = trim($this->getRequestParam("lastname")); $userSVC->gender = trim($this->getRequestParam("gender")); $userSVC->yearOfBirth = trim($this->getRequestParam("yearOfBirth")); $userSVC->phone = trim($this->getRequestParam("phoneNo")); $userSVC->mobile = trim($this->getRequestParam("mobile")); $userSVC->addressLine1 = trim($this->getRequestParam("addressLine1")); $userSVC->addressLine2 = trim($this->getRequestParam("addressLine2")); $userSVC->addressCity = trim($this->getRequestParam("addressCity")); $userSVC->addressState = trim($this->getRequestParam("addressState")); $userSVC->addressCountry = $addressCountryArray; $userSVC->addressZipCode = trim($this->getRequestParam("addressZipCode")); $userSVC->interests = trim($this->getRequestParam("interests")); $userSVC->newsletters = $this->getRequestParam("newsletters") ? $this->getRequestParam("newsletters") : 0; //Check availability of the email entered $profileId = 0; $userId = $userSVC->id; $checkAvailability = json_decode($userSVC->CheckEmailAvailability($profileId, $userId), true); if ($checkAvailability["response"]["responseArray"]["mFirstAccountExists"] == 1) { $this->addError("email_duplicate"); } //Check if username already exists $checkAvailability = json_decode($userSVC->CheckUsernameAvailability($userSVC->id), true); if ($checkAvailability["response"]["responseArray"]["usernameExists"] == 1) { $this->addError("username_exists"); } if ($this->hasErrors()) { return false; } else { return true; } }