/**
  * Add options to FlexForm Selection - Options can be defined in TSConfig
  *
  * @param array $params
  * @return void
  */
 public function addOptions(&$params)
 {
     $this->initialize();
     $tSconfig = BackendUtility::getPagesTSconfig($this->getPid());
     $this->addCaptchaOption($params);
     $tab = $params['config']['itemsProcFuncTab'] . '.';
     if (!empty($tSconfig['tx_femanager.']['flexForm.'][$tab]['addFieldOptions.'])) {
         $options = $tSconfig['tx_femanager.']['flexForm.'][$tab]['addFieldOptions.'];
         foreach ((array) $options as $value => $label) {
             $params['items'][] = [StringUtility::startsWith($label, 'LLL:') ? $this->languageService->sL($label) : $label, $value];
         }
     }
 }
Example #2
0
 /**
  * Some additional actions after profile creation
  *
  * @param User $user
  * @param string $action
  * @param string $redirectByActionName Action to redirect
  * @param bool $login Login after creation
  * @param string $status
  * @return void
  */
 public function finalCreate($user, $action, $redirectByActionName, $login = true, $status = '')
 {
     $this->loginPreflight($user, $login);
     $variables = ['user' => $user, 'settings' => $this->settings];
     // send notify email to admin
     if ($this->settings['new']['notifyAdmin']) {
         $this->sendMailService->send('createNotify', StringUtility::makeEmailArray($this->settings['new']['notifyAdmin'], $this->settings['new']['email']['createAdminNotify']['receiver']['name']['value']), StringUtility::makeEmailArray($user->getEmail(), $user->getUsername()), 'Profile creation', $variables, $this->config['new.']['email.']['createAdminNotify.']);
     }
     $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'AfterPersist', [$user, $action, $this]);
     $this->finisherRunner->callFinishers($user, $this->actionMethodName, $this->settings, $this->contentObject);
     $this->redirectByAction($action, $status ? $status . 'Redirect' : 'redirect');
     $this->redirect($redirectByActionName);
 }
Example #3
0
 /**
  * Upload file from $_FILES['qqfile']
  *
  * @return string|bool false or filename like "file.png"
  */
 public static function uploadFile()
 {
     $files = self::getFilesArray();
     if (!is_array($files['qqfile'])) {
         return false;
     }
     if (empty($files['qqfile']['name']) || !self::checkExtension($files['qqfile']['name'])) {
         return false;
     }
     // create new filename and upload it
     $basicFileFunctions = self::getObjectManager()->get(BasicFileUtility::class);
     $filename = StringUtility::cleanString($files['qqfile']['name']);
     $newFile = $basicFileFunctions->getUniqueName($filename, GeneralUtility::getFileAbsFileName(self::getUploadFolderFromTca()));
     if (GeneralUtility::upload_copy_move($files['qqfile']['tmp_name'], $newFile)) {
         $fileInfo = pathinfo($newFile);
         return $fileInfo['basename'];
     }
     return false;
 }
 /**
  * action delete
  *
  * @param int $user User UID
  * @param string $hash
  * @return void
  */
 public function deleteAction($user, $hash = null)
 {
     $user = $this->userRepository->findByUid($user);
     if (HashUtility::validHash($hash, $user)) {
         LogUtility::log(Log::STATUS_PROFILEDELETE, $user);
         $this->addFlashMessage(LocalizationUtility::translateByState(Log::STATUS_INVITATIONPROFILEDELETEDUSER));
         // send notify email to admin
         if ($this->settings['invitation']['notifyAdminStep1']) {
             $this->sendMailService->send('invitationRefused', StringUtility::makeEmailArray($this->settings['invitation']['notifyAdminStep1'], $this->settings['invitation']['email']['invitationRefused']['receiver']['name']['value']), StringUtility::makeEmailArray($user->getEmail(), $user->getUsername()), 'Profile deleted from User after invitation - Step 1', ['user' => $user, 'settings' => $this->settings], $this->config['invitation.']['email.']['invitationRefused.']);
         }
         $this->userRepository->remove($user);
         $this->redirectByAction('invitation', 'redirectDelete');
         $this->redirect('status');
     } else {
         $this->addFlashMessage(LocalizationUtility::translateByState(Log::STATUS_INVITATIONHASHERROR), '', FlashMessage::ERROR);
         $this->redirect('status');
     }
 }
 /**
  * Should this key skipped because it starts with _ or ends with .
  *
  * @param string $key
  * @return bool
  */
 protected function isSkippedKey($key)
 {
     return StringUtility::startsWith($key, '_') || StringUtility::endsWith($key, '.');
 }
Example #6
0
 /**
  * Call methods in finisher class
  *
  * @param AbstractFinisher $finisher
  * @return void
  */
 protected function callFinisherMethods(AbstractFinisher $finisher)
 {
     foreach (get_class_methods($finisher) as $method) {
         if (!StringUtility::endsWith($method, 'Finisher') || strpos($method, 'initialize') === 0) {
             continue;
         }
         $this->callInitializeFinisherMethod($finisher, $method);
         $finisher->{$method}();
     }
 }
Example #7
0
 /**
  * Redirect by TypoScript setting
  *        [userConfirmation|userConfirmationRefused|adminConfirmation|
  *        adminConfirmationRefused|adminConfirmationRefusedSilent]Redirect
  *
  * @param string $action "new", "edit"
  * @param string $category "redirect", "requestRedirect" value from TypoScript
  * @return void
  */
 protected function redirectByAction($action = 'new', $category = 'redirect')
 {
     $target = null;
     // redirect from TypoScript cObject
     if ($this->contentObject->cObjGetSingle($this->config[$action . '.'][$category], $this->config[$action . '.'][$category . '.'])) {
         $target = $this->contentObject->cObjGetSingle($this->config[$action . '.'][$category], $this->config[$action . '.'][$category . '.']);
     }
     // if redirect target
     if ($target) {
         $this->uriBuilder->setTargetPageUid($target);
         $this->uriBuilder->setLinkAccessRestrictedPages(true);
         $link = $this->uriBuilder->build();
         $this->redirectToUri(StringUtility::removeDoubleSlashes($link));
     }
 }
Example #8
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;
 }
Example #9
0
 /**
  * Status update refused
  *
  * @param User $user
  * @return void
  */
 protected function statusRefuse(User $user)
 {
     $this->sendMailService->send('updateRequestRefused', StringUtility::makeEmailArray($user->getEmail(), $user->getFirstName() . ' ' . $user->getLastName()), ['*****@*****.**' => 'Sender Name'], 'Your change request was refused', ['user' => $user, 'settings' => $this->settings], $this->config['edit.']['email.']['updateRequestRefused.']);
     LogUtility::log(Log::STATUS_PROFILEUPDATEREFUSEDADMIN, $user);
     $this->addFlashMessage(LocalizationUtility::translateByState(Log::STATUS_PROFILEUPDATEREFUSEDADMIN));
 }
Example #10
0
 /**
  * getUpperCharactersString Test
  *
  * @return void
  * @test
  */
 public function getUpperCharactersStringReturnsStrings()
 {
     $this->assertSame('ABCDEFGHIJKLMNOPQRSTUVWXYZ', StringUtility::getUpperCharactersString());
 }
Example #11
0
 /**
  * Autogenerate username and password if it's empty
  *
  * @param User $user
  * @return User $user
  */
 public static function fallbackUsernameAndPassword(User $user)
 {
     $settings = self::getConfigurationManager()->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
     $autogenerateSettings = $settings['new']['misc']['autogenerate'];
     if (!$user->getUsername()) {
         $user->setUsername(StringUtility::getRandomString($autogenerateSettings['username']['length'], $autogenerateSettings['username']['addUpperCase'], $autogenerateSettings['username']['addSpecialCharacters']));
         if ($user->getEmail()) {
             $user->setUsername($user->getEmail());
         }
     }
     if (!$user->getPassword()) {
         $password = StringUtility::getRandomString($autogenerateSettings['password']['length'], $autogenerateSettings['password']['addUpperCase'], $autogenerateSettings['password']['addSpecialCharacters']);
         $user->setPassword($password);
         $user->setPasswordAutoGenerated($password);
     }
     return $user;
 }
Example #12
0
 /**
  * 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;
 }
 /**
  * Send email to user for confirmation
  *
  * @param \Gigabonus\Gbfemanager\Domain\Model\User $user
  * @return void
  * @throws UnsupportedRequestTypeException
  */
 protected function createUserConfirmationRequest(\Gigabonus\Gbfemanager\Domain\Model\User $user)
 {
     $this->sendMailService->send('createUserConfirmation', StringUtility::makeEmailArray($user->getEmail(), $user->getUsername()), [$this->settings['new']['email']['createUserConfirmation']['sender']['email']['value'] => $this->settings['settings']['new']['email']['createUserConfirmation']['sender']['name']['value']], 'Confirm your profile creation request', ['user' => $user, 'hash' => HashUtility::createHashForUser($user), 'registrationPageId' => 4], $this->config['new.']['email.']['createUserConfirmation.']);
 }