本文整理汇总了PHP中FormValidator::checkAll方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::checkAll方法的具体用法?PHP FormValidator::checkAll怎么用?PHP FormValidator::checkAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::checkAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPhotoModel
function addPhotoModel($photoForm, $albumId)
{
$formObjRaw = new FormDTO(ADD_PHOTO_FORM, $photoForm);
$responseDTO = new ResponseDTO(ADD_PHOTO_FORM);
try {
$formDataObj = $formObjRaw->getFormData();
$validator = new FormValidator(ADD_PHOTO_FORM, $formDataObj);
$validationError = $validator->checkAll();
if (sizeof($validationError) == 0) {
$uploadedPhoto = FileUtils::uploadPhotoModel($formDataObj[ADD_PHOTO_FORM . PHOTO], $albumId, ADD_PHOTO_FORM, $formDataObj[ADD_PHOTO_FORM . LATITUDE], $formDataObj[ADD_PHOTO_FORM . LONGITUDE]);
if (get_class($uploadedPhoto) === PHOTODTO) {
DataModelUtils::notifyAction($uploadedPhoto->getPhotoId() . SEPARATOR . $uploadedPhoto->getPhotoUrl() . SEPARATOR . $albumId, ADD_PHOTO_FORM);
return $uploadedPhoto;
} else {
$responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento della foto");
}
} else {
if (array_key_exists(PHOTO, $validationError)) {
$responseDTO->setErrField(PHOTO, $validationError[PHOTO]);
}
}
return $responseDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
throw $authExp;
} catch (Exception $e) {
throw $e;
}
}
示例2: addAlbumModel
function addAlbumModel($albumForm)
{
$formObjRaw = new FormDTO(ADD_ALBUM_FORM, $albumForm);
$responseDTO = new ResponseDTO(ADD_ALBUM_FORM);
try {
$formDataObj = $formObjRaw->getFormData();
$validator = new FormValidator(ADD_ALBUM_FORM, $formDataObj);
$validationError = $validator->checkAll();
// $validationError = array();
if (sizeof($validationError) == 0) {
$userLogged = SessionUtils::getUserLogged();
$uploadedPhoto = FileUtils::uploadPhotoModel($formDataObj[ADD_ALBUM_FORM . COVER], NULL, ADD_ALBUM_FORM);
if (get_class($uploadedPhoto) === PHOTODTO) {
$userDAO = new UserDAO();
$userDTO = $userDAO->getUserByUserId($userLogged->getUserId());
$albumDAO = new AlbumDAO();
$albumDTO = new AlbumDTO(null, date(DATE_FORMAT), $formDataObj[ADD_ALBUM_FORM . TITLE], $uploadedPhoto, $userDTO);
$albumDTO = $albumDAO->insertNewAlbum($albumDTO);
if ($albumDTO->getAlbumId() != 0) {
$photoAlbumPath = FileUtils::createAlbumDirOnServer($userDTO->getUserId(), $albumDTO->getAlbumId());
DataModelUtils::notifyAction($albumDTO->getCover()->getPhotoId() . SEPARATOR . $albumDTO->getCover()->getPhotoUrl() . SEPARATOR . $albumDTO->getAlbumId() . SEPARATOR . $albumDTO->getTitle(), ADD_ALBUM_FORM);
return $albumDTO;
} else {
$responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento dell'album");
}
} else {
$responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento della foto profilo");
}
} else {
if (array_key_exists(TITLE, $validationError)) {
$responseDTO->setErrField(TITLE, $validationError[TITLE]);
}
if (array_key_exists(PHOTO, $validationError)) {
$responseDTO->setErrField(COVER, $validationError[PHOTO]);
}
SessionUtils::setFormValue($formDataObj);
}
return $responseDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
throw $authExp;
} catch (Exception $e) {
throw $e;
}
}
示例3: forgotPasswordModel
public function forgotPasswordModel($forgotPasswordForm)
{
$formObjRaw = new FormDTO(FORGOT_PWD_FORM, $forgotPasswordForm);
$responseDTO = new ResponseDTO(FORGOT_PWD_FORM);
try {
$formDataObj = $formObjRaw->getFormData();
$validator = new FormValidator(FORGOT_PWD_FORM, $formDataObj);
$validationError = $validator->checkAll();
if (sizeof($validationError) == 0) {
$userDAO = new UserDAO();
$userDTO = $userDAO->getUserByEmail($formDataObj[FORGOT_PWD_FORM . EMAIL]);
if (is_null($userDTO)) {
$responseDTO->setErrField(ERROR_RESPONSE, "Nessun user presente con questa mail");
} else {
$newPassword = PasswordUtils::createRandomicPassword();
$userDTO->setPassword($newPassword);
$resultMail = DataModelUtils::sendMail($userDTO, FORGOT_PWD_FORM);
$hashedPwd = PasswordUtils::getPassword($newPassword);
$userDTO->setPassword($hashedPwd);
$result = $userDAO->updateUserPassword($userDTO);
if ($result != 1) {
$responseDTO->setErrField(ERROR_RESPONSE, "Problema nel cambio della password");
} else {
$responseDTO->setResponseSucc("Verra mandata una mail con una nuova password all'indirizzo " . $userDTO->getEmail());
}
}
} else {
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;
}
}
示例4: searchResourceModel
function searchResourceModel($searchCriteriaForm)
{
$formObjRaw = new FormDTO(SEARCH_USER_FORM, $searchCriteriaForm);
$responseDTO = new ResponseDTO(SEARCH_USER_FORM);
try {
$formDataObj = $formObjRaw->getFormData();
$validator = new FormValidator(SEARCH_USER_FORM, $formDataObj);
$validationError = $validator->checkAll();
if (sizeof($validationError) == 0) {
$userDAO = new UserDAO();
$userDTOList = $userDAO->getUserInfoByCriteria($formDataObj);
return $userDTOList;
} else {
if (array_key_exists(NAME, $validationError)) {
$responseDTO->setErrField(NAME, $validationError[NAME]);
}
return $responseDTO;
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
throw $authExp;
} catch (Exception $e) {
throw $e;
}
}
示例5: commentAPostModel
public function commentAPostModel($commentForm, $postId = NULL)
{
$responseDTO = new ResponseDTO(WRITE_COMMENT_FORM);
$formObjRaw = new FormDTO(WRITE_COMMENT_FORM, $commentForm);
$formObjRaw->setSubElementId($postId);
try {
$formDataObj = $formObjRaw->getFormData();
$responseDTO->setSubElementId($formDataObj[WRITE_COMMENT_FORM . POSTID]);
$validator = new FormValidator(WRITE_COMMENT_FORM, $formDataObj);
$validationError = $validator->checkAll();
if (sizeof($validationError) == 0) {
$timestamp = date(DATE_FORMAT);
$userLogged = SessionUtils::getUserLogged();
$newCommentDTO = new CommentDTO(NULL, $formDataObj[WRITE_COMMENT_FORM . TEXT], $timestamp, $formDataObj[WRITE_COMMENT_FORM . POSTID], $userLogged);
$postDAO = new PostDAO();
$commentDTO = $postDAO->insertNewComment($newCommentDTO);
if ($commentDTO->getCommentid() == 0) {
$responseDTO->setResponseSucc("Non è stato possibile inserire il commento del post");
} else {
DataModelUtils::notifyAction($commentDTO->getCommentid() . SEPARATOR . $formDataObj[WRITE_COMMENT_FORM . POSTID] . SEPARATOR . $userLogged->getUserId() . SEPARATOR . SessionUtils::getDashboardId(), WRITE_COMMENT_FORM);
return $commentDTO;
}
} else {
if (array_key_exists(TEXT, $validationError)) {
$responseDTO->setErrField(TEXT, $validationError[TEXT]);
}
return $responseDTO;
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
throw $authExp;
} catch (Exception $e) {
throw $e;
}
}
示例6: changeUserPwdModel
function changeUserPwdModel($pwdForm)
{
$formObjRaw = new FormDTO(CHANGE_PWD_FORM, $pwdForm);
$responseDTO = new ResponseDTO(CHANGE_PWD_FORM);
try {
$formDataObj = $formObjRaw->getFormData();
$validator = new FormValidator(CHANGE_PWD_FORM, $formDataObj);
$validationError = $validator->checkAll();
if (sizeof($validationError) == 0) {
$userLogged = SessionUtils::getUserLogged();
$hashedPwd = PasswordUtils::getPassword($formDataObj[CHANGE_PWD_FORM . PASSWORD]);
$userDTO = new UserDTO($userLogged->getUserId(), NULL, $hashedPwd, NULL, NULL, NULL, NULL, NULL);
$userDAO = new UserDAO();
$userLoggedDTO = $userDAO->checkPassword($userDTO);
if (is_null($userLoggedDTO)) {
$responseDTO->setResponseSucc("Questa password non esiste");
return $responseDTO;
}
$hashedPwd = PasswordUtils::getPassword($formDataObj[CHANGE_PWD_FORM . NEW_PASSWORD]);
$userDTO->setPassword($hashedPwd);
$userPwdUpdated = $userDAO->updateUserPassword($userDTO);
return $userDTO;
} else {
if (array_key_exists(PASSWORD, $validationError)) {
$responseDTO->setErrField(PASSWORD, $validationError[PASSWORD]);
}
if (array_key_exists(NEW_PASSWORD, $validationError)) {
$responseDTO->setErrField(NEW_PASSWORD, $validationError[NEW_PASSWORD]);
}
if (array_key_exists(CONFIRM_PASSWORD, $validationError)) {
$responseDTO->setErrField(CONFIRM_PASSWORD, $validationError[CONFIRM_PASSWORD]);
}
// var_dump($validationError);
// var_dump($responseDTO);die;
}
return $responseDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
throw $authExp;
} catch (Exception $e) {
throw $e;
}
}