示例#1
0
 public function signUpModel($registrationForm)
 {
     $formObjRaw = new FormDTO(REGISTRATION_FORM, $registrationForm);
     $responseDTO = new ResponseDTO(REGISTRATION_FORM);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $validator = new FormValidator(REGISTRATION_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         if (sizeof($validationError) == 0) {
             $hashedPwd = PasswordUtils::getPassword($formDataObj[REGISTRATION_FORM . PASSWORD]);
             $userDTO = new UserDTO(NULL, $formDataObj[REGISTRATION_FORM . USERNAME], $hashedPwd, NULL, USER, NULL, $formDataObj[REGISTRATION_FORM . EMAIL], NULL);
             $userDAO = new UserDAO();
             $existingUser = $userDAO->checkIfUserExist($userDTO);
             if (!is_null($existingUser)) {
                 $responseDTO->setErrField(ERROR_RESPONSE, "Utente già presente con questa mail: " . $userDTO->getEmail() . " o con questo username: "******"Verrà inviata una mail a questo indirizzo: " . $userDTO->getEmail());
                         //                            } else {
                         //                                $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'invio della mail");
                         //                            }
                     } else {
                         $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento dell'album");
                     }
                 } else {
                     $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento dello user");
                 }
             }
         } else {
             if (array_key_exists(USERNAME, $validationError)) {
                 $responseDTO->setErrField(USERNAME, $validationError[USERNAME]);
             }
             if (array_key_exists(PASSWORD, $validationError)) {
                 $responseDTO->setErrField(PASSWORD, $validationError[PASSWORD]);
             }
             if (array_key_exists(CONFIRM_PASSWORD, $validationError)) {
                 $responseDTO->setErrField(CONFIRM_PASSWORD, $validationError[CONFIRM_PASSWORD]);
             }
             if (array_key_exists(EMAIL, $validationError)) {
                 $responseDTO->setErrField(EMAIL, $validationError[EMAIL]);
             }
             SessionUtils::setFormValue($formDataObj);
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }