Beispiel #1
0
 function updateProfilePhotoModel($photoId, $filename)
 {
     $responseDTO = new ResponseDTO(UPDATE_PROFILE_PHOTO_FORM);
     try {
         $photoDAO = new PhotoDAO();
         $photoDTO = new PhotoDTO($photoId, $filename);
         $updateProfilePhoto = $photoDAO->updateProfilePhoto($photoDTO);
         $userLogged = SessionUtils::getUserLogged();
         $userLogged->setProfilePhoto($photoDTO);
         SessionUtils::setUserLogged($userLogged);
         $responseDTO->setResponseSucc("Foto profilo aggiornata con successo!");
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
 function changeUserProfilePhoto($photoForm)
 {
     $formObjRaw = new FormDTO(PROFILE_SETTINGS_PHOTO_FORM, $photoForm);
     $responseDTO = new ResponseDTO(PROFILE_SETTINGS_PHOTO_FORM);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $validator = new FormValidator(PROFILE_SETTINGS_PHOTO_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         if (sizeof($validationError) == 0) {
             $userLogged = SessionUtils::getUserLogged();
             $uploadedPhoto = FileUtils::uploadPhotoModel($formDataObj[PROFILE_SETTINGS_PHOTO_FORM . PHOTO], $userLogged->getDefaultAlbumId(), PROFILE_SETTINGS_PHOTO_FORM);
             if (get_class($uploadedPhoto) === PHOTODTO) {
                 $photoDAO = new PhotoDAO();
                 $updateProfilePhoto = $photoDAO->updateProfilePhoto($uploadedPhoto);
                 $userLogged = SessionUtils::getUserLogged();
                 $userLogged->setProfilePhoto($uploadedPhoto);
                 SessionUtils::setUserLogged($userLogged);
                 return $uploadedPhoto;
             } else {
                 $responseDTO->setResponseSucc("Errore durante l'inserimento della foto profilo");
             }
         } 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;
     }
 }