Exemple #1
0
 /**
  * @param int $state State to log
  * @param User $user Related User
  * @param array $additionalProperties for individual logging
  * @return void
  */
 public static function log($state, User $user, array $additionalProperties = [])
 {
     if (!ConfigurationUtility::isDisableLogActive()) {
         $log = self::getLog();
         $log->setTitle(LocalizationUtility::translateByState($state));
         $log->setState($state);
         $log->setUser($user);
         self::getLogRepository()->add($log);
     }
     self::getDispatcher()->dispatch(__CLASS__, __FUNCTION__ . 'Custom', [$state, $user, $additionalProperties]);
 }
Exemple #2
0
 /**
  * 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');
 }
 /**
  * Check if user is allowed to see this action
  *
  * @return bool
  */
 protected function allowedUserForInvitationNewAndCreate()
 {
     if (empty($this->settings['invitation']['allowedUserGroups'])) {
         return true;
     }
     $allowedUsergroupUids = GeneralUtility::trimExplode(',', $this->settings['invitation']['allowedUserGroups'], true);
     $currentUsergroupUids = UserUtility::getCurrentUsergroupUids();
     // compare allowedUsergroups with currentUsergroups
     if (count(array_intersect($allowedUsergroupUids, $currentUsergroupUids))) {
         return true;
     }
     // current user is not allowed
     $this->addFlashMessage(LocalizationUtility::translateByState(Log::STATUS_INVITATIONRESTRICTEDPAGE), '', FlashMessage::ERROR);
     $this->forward('status');
     return false;
 }
 /**
  * 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);
     }
 }
Exemple #5
0
 /**
  * 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;
 }
Exemple #6
0
 /**
  * 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('/');
 }
Exemple #7
0
 /**
  * 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;
 }