예제 #1
0
 /**
  * action delete
  *
  * @param int $user User UID
  * @param string $hash
  * @return void
  */
 public function deleteAction($user, $hash = NULL)
 {
     $user = $this->userRepository->findByUid($user);
     if (Div::createHash($user->getUsername() . $user->getUid()) === $hash) {
         // write log
         $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.402', 'femanager'), 300, $user);
         // add flashmessage
         $this->addFlashMessage(LocalizationUtility::translate('tx_femanager_domain_model_log.state.402', 'femanager'));
         // send notify email to admin
         if ($this->settings['invitation']['notifyAdminStep1']) {
             $this->sendMail->send('invitationRefused', Div::makeEmailArray($this->settings['invitation']['notifyAdminStep1'], $this->settings['invitation']['email']['invitationRefused']['receiver']['name']['value']), Div::makeEmailArray($user->getEmail(), $user->getUsername()), 'Profile deleted from User after invitation - Step 1', array('user' => $user, 'settings' => $this->settings), $this->config['invitation.']['email.']['invitationRefused.']);
         }
         // delete user
         $this->userRepository->remove($user);
         $this->redirectByAction('invitation', 'redirectDelete');
         $this->redirect('status');
     } else {
         $this->addFlashMessage(LocalizationUtility::translate('tx_femanager_domain_model_log.state.403', 'femanager'), '', FlashMessage::ERROR);
         $this->redirect('status');
     }
 }
예제 #2
0
 /**
  * Update if hash is ok
  *
  * @param \int $user User UID
  * @param \string $hash Given hash
  * @param \string $status
  * 			"userConfirmation", "userConfirmationRefused", "adminConfirmation",
  * 			"adminConfirmationRefused", "adminConfirmationRefusedSilent"
  * @return void
  */
 public function confirmCreateRequestAction($user, $hash, $status = 'adminConfirmation')
 {
     $user = $this->userRepository->findByUid($user);
     // if there is still no user in db
     if ($user === NULL) {
         $this->flashMessageContainer->add(LocalizationUtility::translate('missingUserInDatabase', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         $this->redirect('new');
     }
     switch ($status) {
         // registration confirmed by user
         case 'userConfirmation':
             if (Div::createHash($user->getUsername()) === $hash) {
                 // if user is already confirmed by himself
                 if ($user->getTxFemanagerConfirmedbyuser()) {
                     $this->flashMessageContainer->add(LocalizationUtility::translate('userAlreadyConfirmed', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
                     $this->redirect('new');
                 }
                 $user = $this->div->forceValues($user, $this->config['new.']['forceValues.']['onUserConfirmation.'], $this->cObj);
                 $user->setTxFemanagerConfirmedbyuser(TRUE);
                 $this->userRepository->update($user);
                 $this->persistenceManager->persistAll();
                 $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.102', 'femanager'), 102, $user);
                 // must be still confirmed from admin
                 if (!empty($this->settings['new']['confirmByAdmin']) && !$user->getTxFemanagerConfirmedbyadmin()) {
                     // send email to admin to get this confirmation
                     $this->div->sendEmail('createAdminConfirmation', Div::makeEmailArray($this->settings['new']['confirmByAdmin'], $this->settings['new']['email']['createAdminConfirmation']['receiver']['name']['value']), Div::makeEmailArray($user->getEmail(), $user->getUsername()), 'New Registration request', array('user' => $user, 'hash' => Div::createHash($user->getUsername() . $user->getUid())), $this->config['new.']['email.']['createAdminConfirmation.']);
                     $this->flashMessageContainer->add(LocalizationUtility::translate('createRequestWaitingForAdminConfirm', 'femanager'));
                 } else {
                     $user->setDisable(FALSE);
                     $this->flashMessageContainer->add(LocalizationUtility::translate('create', 'femanager'));
                     $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.101', 'femanager'), 101, $user);
                     $this->finalCreate($user, 'new', 'createStatus', TRUE, $status);
                 }
             } else {
                 $this->flashMessageContainer->add(LocalizationUtility::translate('createFailedProfile', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
                 return;
             }
             break;
         case 'userConfirmationRefused':
             if (Div::createHash($user->getUsername()) === $hash) {
                 $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.104', 'femanager'), 104, $user);
                 $this->flashMessageContainer->add(LocalizationUtility::translate('createProfileDeleted', 'femanager'));
                 $this->userRepository->remove($user);
             } else {
                 $this->flashMessageContainer->add(LocalizationUtility::translate('createFailedProfile', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
                 return;
             }
             break;
         case 'adminConfirmation':
             // registration complete
             if (Div::createHash($user->getUsername() . $user->getUid())) {
                 $user = $this->div->forceValues($user, $this->config['new.']['forceValues.']['onAdminConfirmation.'], $this->cObj);
                 $user->setTxFemanagerConfirmedbyadmin(TRUE);
                 if ($user->getTxFemanagerConfirmedbyuser() || empty($this->settings['new']['confirmByUser'])) {
                     $user->setDisable(FALSE);
                 }
                 $this->flashMessageContainer->add(LocalizationUtility::translate('create', 'femanager'));
                 $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.103', 'femanager'), 103, $user);
                 // send email to user to inform him about his profile confirmation
                 $this->div->sendEmail('createUserNotify', Div::makeEmailArray($user->getEmail(), $user->getFirstName() . ' ' . $user->getLastName()), array('*****@*****.**' => 'Sender Name'), 'Your profile was confirmed', array('user' => $user), $this->config['new.']['email.']['createUserNotify.']);
                 $this->finalCreate($user, 'new', 'createStatus', FALSE);
             } else {
                 $this->flashMessageContainer->add(LocalizationUtility::translate('createFailedProfile', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
                 return;
             }
             break;
         case 'adminConfirmationRefused':
             // Admin refuses profile
         // Admin refuses profile
         case 'adminConfirmationRefusedSilent':
             if (Div::createHash($user->getUsername() . $user->getUid())) {
                 $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.105', 'femanager'), 105, $user);
                 $this->flashMessageContainer->add(LocalizationUtility::translate('createProfileDeleted', 'femanager'));
                 if (!stristr($status, 'silent')) {
                     // send email to user to inform him about his profile confirmation
                     $this->div->sendEmail('CreateUserNotifyRefused', Div::makeEmailArray($user->getEmail(), $user->getFirstName() . ' ' . $user->getLastName()), array('*****@*****.**' => 'Sender Name'), 'Your profile was refused', array('user' => $user), $this->config['new.']['email.']['createUserNotifyRefused.']);
                 }
                 $this->userRepository->remove($user);
             } else {
                 $this->flashMessageContainer->add(LocalizationUtility::translate('createFailedProfile', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
                 return;
             }
             break;
         default:
     }
     /**
      * redirect by TypoScript setting
      * 		[userConfirmation|userConfirmationRefused|adminConfirmation|
      * 		adminConfirmationRefused|adminConfirmationRefusedSilent]Redirect
      */
     $this->redirectByAction('new', $status . 'Redirect');
     $this->redirect('new');
 }
예제 #3
0
 /**
  * Update if hash is ok
  *
  * @param \In2\Femanager\Domain\Model\User $user		User object
  * @param \string $hash									Given hash
  * @param \string $status								"confirm", "refuse", "silentRefuse"
  * @return void
  */
 public function confirmUpdateRequestAction(User $user, $hash, $status = 'confirm')
 {
     $this->view->assign('user', $user);
     // if wrong hash or if no update xml
     if (Div::createHash($user->getUsername() . $user->getUid()) !== $hash || !$user->getTxFemanagerChangerequest()) {
         $this->flashMessageContainer->add(LocalizationUtility::translate('updateFailedProfile', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         return;
     }
     switch ($status) {
         case 'confirm':
             // overwrite properties
             $values = GeneralUtility::xml2array($user->getTxFemanagerChangerequest(), '', 0, 'changes');
             foreach ((array) $values as $field => $value) {
                 if ($field != 'usergroup' && method_exists($user, 'set' . ucfirst($field))) {
                     $user->{'set' . ucfirst($field)}($value['new']);
                 } else {
                     $user->removeAllUsergroups();
                     $usergroupUids = GeneralUtility::trimExplode(',', $value['new'], 1);
                     foreach ($usergroupUids as $usergroupUid) {
                         $user->addUsergroup($this->userGroupRepository->findByUid($usergroupUid));
                     }
                 }
             }
             $user = $this->div->forceValues($user, $this->config['edit.']['forceValues.']['onAdminConfirmation.'], $this->cObj);
             $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.202', 'femanager'), 202, $user);
             $this->flashMessageContainer->add(LocalizationUtility::translate('updateProfile', 'femanager'));
             break;
         case 'refuse':
             // send email to user
             $this->div->sendEmail('updateRequestRefused', Div::makeEmailArray($user->getEmail(), $user->getFirstName() . ' ' . $user->getLastName()), array('*****@*****.**' => 'Sender Name'), 'Your change request was refused', array('user' => $user, 'settings' => $this->settings), $this->config['edit.']['email.']['updateRequestRefused.']);
             $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.203', 'femanager'), 203, $user);
             $this->flashMessageContainer->add(LocalizationUtility::translate('tx_femanager_domain_model_log.state.203', 'femanager'));
             break;
         case 'silentRefuse':
             $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.203', 'femanager'), 203, $user);
             $this->flashMessageContainer->add(LocalizationUtility::translate('tx_femanager_domain_model_log.state.203', 'femanager'));
             break;
         default:
     }
     $user->setTxFemanagerChangerequest('');
     $this->userRepository->update($user);
     $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'AfterPersist', array($user, $hash, $status, $this));
 }
예제 #4
0
 /**
  * Prefix method to updateAction(): Update must be confirmed by Admin
  *
  * @param \In2\Femanager\Domain\Model\User $user
  * @return void
  */
 public function updateRequest($user)
 {
     $dirtyProperties = Div::getDirtyPropertiesFromObject($user);
     $user = Div::rollbackUserWithChangeRequest($user, $dirtyProperties);
     // send email to admin
     $this->div->sendEmail('updateRequest', array($this->settings['edit']['confirmByAdmin'] => $this->settings['edit']['email']['updateRequest']['sender']['name']['value']), Div::makeEmailArray($user->getEmail(), $user->getUsername()), 'New Profile change request', array('user' => $user, 'changes' => $dirtyProperties, 'hash' => Div::createHash($user->getUsername() . $user->getUid())), $this->config['edit.']['email.']['updateRequest.']);
     // write log
     $this->div->log(LocalizationUtility::translate('tx_femanager_domain_model_log.state.204', 'femanager'), 203, $user);
     // redirect if turned on in TypoScript
     $this->redirectByAction('edit', 'requestRedirect');
     // add flashmessage
     $this->flashMessageContainer->add(LocalizationUtility::translate('updateRequest', 'femanager'));
 }