/** * Prefix method to createAction(): Create must be confirmed by Admin or User * * @param User $user * @return void */ public function createRequest(\Gigabonus\Gbfemanager\Domain\Model\User $user) { $this->userRepository->add($user); $this->persistenceManager->persistAll(); $this->addFlashMessage(LocalizationUtility::translate('create')); LogUtility::log(Log::STATUS_NEWREGISTRATION, $user); if (!empty($this->settings['new']['confirmByUser'])) { $this->createUserConfirmationRequest($user); } $this->finalCreate($user, 'new', 'createStatus'); }
/** * action update * * @param \In2code\Femanager\Domain\Model\User $user * @validate $user In2code\Femanager\Domain\Validator\ServersideValidator * @validate $user In2code\Femanager\Domain\Validator\PasswordValidator * @return void */ public function updateAction($user) { $this->addFlashMessage(LocalizationUtility::translate('createAndInvitedFinished')); LogUtility::log(Log::STATUS_INVITATIONPROFILEENABLED, $user); if ($this->settings['invitation']['notifyAdmin']) { $this->sendMailService->send('invitationNotify', StringUtility::makeEmailArray($this->settings['invitation']['notifyAdmin'], $this->settings['invitation']['email']['invitationAdminNotify']['receiver']['name']['value']), StringUtility::makeEmailArray($user->getEmail(), $user->getUsername()), 'Profile creation with invitation - Final', ['user' => $user, 'settings' => $this->settings], $this->config['invitation.']['email.']['invitationAdminNotify.']); } $user = UserUtility::overrideUserGroup($user, $this->settings, 'invitation'); UserUtility::hashPassword($user, $this->settings['invitation']['misc']['passwordSave']); $this->userRepository->update($user); $this->persistenceManager->persistAll(); $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'AfterPersist', [$user, $this]); $this->redirectByAction('invitation', 'redirectPasswordChanged'); $this->redirect('status'); }
/** * Init * * @return void */ public function initializeAction() { $this->databaseConnection = $GLOBALS['TYPO3_DB']; $this->controllerContext = $this->buildControllerContext(); $this->user = UserUtility::getCurrentUser(); $this->contentObject = $this->configurationManager->getContentObject(); $this->pluginVariables = $this->request->getArguments(); $this->allConfig = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $this->config = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $this->config = $this->config['plugin.']['tx_femanager.']['settings.']; $controllerName = strtolower($this->controllerContext->getRequest()->getControllerName()); $removeFromUserGroupSelection = $this->settings[$controllerName]['misc']['removeFromUserGroupSelection']; $this->allUserGroups = $this->userGroupRepository->findAllForFrontendSelection($removeFromUserGroupSelection); if (isset($this->arguments['user'])) { $this->arguments['user']->getPropertyMappingConfiguration()->forProperty('dateOfBirth')->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', DateTimeConverter::CONFIGURATION_DATE_FORMAT, LocalizationUtility::translate('tx_femanager_domain_model_user.dateFormat')); } // check if ts is included if ($this->settings['_TypoScriptIncluded'] !== '1' && !GeneralUtility::_GP('eID') && TYPO3_MODE !== 'BE') { $this->addFlashMessage(LocalizationUtility::translate('error_no_typoscript'), '', FlashMessage::ERROR); } // check if storage pid was set if ((int) $this->allConfig['persistence']['storagePid'] === 0 && !GeneralUtility::_GP('eID') && TYPO3_MODE !== 'BE') { $this->addFlashMessage(LocalizationUtility::translate('error_no_storagepid'), '', FlashMessage::ERROR); } }
/** * Status action: Admin refused profile creation (normal or silent) * * @param User $user * @param $hash * @param $status * @return bool allow further functions * @throws IllegalObjectTypeException */ protected function statusAdminConfirmationRefused(User $user, $hash, $status) { if (HashUtility::validHash($hash, $user)) { LogUtility::log(Log::STATUS_REGISTRATIONREFUSEDADMIN, $user); $this->addFlashMessage(LocalizationUtility::translate('createProfileDeleted')); if ($status !== 'adminConfirmationRefusedSilent') { $this->sendMailService->send('CreateUserNotifyRefused', StringUtility::makeEmailArray($user->getEmail(), $user->getFirstName() . ' ' . $user->getLastName()), ['*****@*****.**' => 'Sender Name'], 'Your profile was refused', ['user' => $user], $this->config['new.']['email.']['createUserNotifyRefused.']); } $this->userRepository->remove($user); } else { $this->addFlashMessage(LocalizationUtility::translate('createFailedProfile'), '', FlashMessage::ERROR); return false; } return true; }
/** * Simulate frontenduser login for backend adminstrators only * * @param User $user * @throws UnauthorizedException * @return void */ public function loginAsAction(User $user) { if (!BackendUserUtility::isAdminAuthentication()) { throw new UnauthorizedException(LocalizationUtility::translate('error_not_authorized')); } UserUtility::login($user); $this->redirectByAction('loginAs', 'redirect'); $this->redirectToUri('/'); }
/** * Check: If there are no changes, simple redirect back * * @param User $user * @return void * @throws UnsupportedRequestTypeException */ protected function redirectIfDirtyObject(User $user) { if (!ObjectUtility::isDirtyObject($user)) { $this->addFlashMessage(LocalizationUtility::translate('noChanges'), '', FlashMessage::NOTICE); $this->redirect('edit'); } }
/** * Validate Field * * @return bool */ public function validateField() { $validationSettings = GeneralUtility::trimExplode(',', $this->validationSettingsString, true); $validationSettings = str_replace('|', ',', $validationSettings); foreach ($validationSettings as $validationSetting) { switch ($validationSetting) { case 'required': if (!$this->validateRequired($this->getValue())) { $this->addMessage('validationErrorRequired'); $this->isValid = false; } break; case 'email': if ($this->getValue() && !$this->validateEmail($this->getValue())) { $this->addMessage('validationErrorEmail'); $this->isValid = false; } break; case stristr($validationSetting, 'min('): if ($this->getValue() && !$this->validateMin($this->getValue(), StringUtility::getValuesInBrackets($validationSetting))) { $this->addMessage('validationErrorMin'); $this->isValid = false; } break; case stristr($validationSetting, 'max('): if ($this->getValue() && !$this->validateMax($this->getValue(), StringUtility::getValuesInBrackets($validationSetting))) { $this->addMessage('validationErrorMax'); $this->isValid = false; } break; case 'intOnly': if ($this->getValue() && !$this->validateInt($this->getValue())) { $this->addMessage('validationErrorInt'); $this->isValid = false; } break; case 'lettersOnly': if ($this->getValue() && !$this->validateLetters($this->getValue())) { $this->addMessage('validationErrorLetters'); $this->isValid = false; } break; case 'uniqueInPage': if ($this->getValue() && !$this->validateUniquePage($this->getValue(), $this->getFieldName(), $this->getUser())) { $this->addMessage('validationErrorUniquePage'); $this->isValid = false; } break; case 'uniqueInDb': if ($this->getValue() && !$this->validateUniqueDb($this->getValue(), $this->getFieldName(), $this->getUser())) { $this->addMessage('validationErrorUniqueDb'); $this->isValid = false; } break; case stristr($validationSetting, 'mustInclude('): if ($this->getValue() && !$this->validateMustInclude($this->getValue(), StringUtility::getValuesInBrackets($validationSetting))) { $this->addMessage('validationErrorMustInclude'); $this->isValid = false; } break; case stristr($validationSetting, 'mustNotInclude('): if ($this->getValue() && !$this->validateMustNotInclude($this->getValue(), StringUtility::getValuesInBrackets($validationSetting))) { $this->addMessage('validationErrorMustNotInclude'); $this->isValid = false; } break; case stristr($validationSetting, 'inList('): if (!$this->validateInList($this->getValue(), StringUtility::getValuesInBrackets($validationSetting))) { $this->addMessage('validationErrorInList'); $this->isValid = false; } break; case stristr($validationSetting, 'sameAs('): if (!$this->validateSameAs($this->getValue(), $this->getAdditionalValue())) { $this->addMessage('validationErrorSameAs'); $this->isValid = false; } break; case 'date': if ($this->getValue() && !$this->validateDate($this->getValue(), LocalizationUtility::translate('tx_femanager_domain_model_user.dateFormat'))) { $this->addMessage('validationErrorDate'); $this->isValid = false; } break; default: // e.g. search for method validateCustom() $mainSetting = StringUtility::getValuesBeforeBrackets($validationSetting); if (method_exists($this, 'validate' . ucfirst($mainSetting))) { if (!$this->{'validate' . ucfirst($mainSetting)}($this->getValue(), StringUtility::getValuesInBrackets($validationSetting))) { $this->addMessage('validationError' . ucfirst($mainSetting)); $this->isValid = false; } } } } return $this->isValid; }