/**
  * @param Typo3OrgSsoToken $authenticationToken
  * @return bool
  */
 public function authenticate(Typo3OrgSsoToken $authenticationToken)
 {
     /** @var $account FrontendUser */
     $account = null;
     $credentials = $authenticationToken->getCredentials();
     if (is_array($credentials) && isset($credentials['username'])) {
         $account = $this->frontendUserRepository->findOneByUsername($credentials['username']);
     }
     $authenticated = false;
     $authenticationData = 'version=' . $credentials['version'] . '&user='******'username'] . '&tpa_id=' . $credentials['tpaId'] . '&expires=' . $credentials['expires'] . '&action=' . $credentials['action'] . '&flags=' . $credentials['flags'] . '&userdata=' . $credentials['userdata'];
     $authenticationDataIsValid = $this->verifySignature($authenticationData, $credentials['signature']);
     if ($authenticationDataIsValid && $credentials['expires'] > time()) {
         $userdata = $this->parseUserdata($credentials['userdata']);
         if (!is_object($account)) {
             $account = $this->createAccount($userdata);
             $this->frontendUserRepository->add($account);
         } elseif (is_object($account)) {
             $account = $this->updateAccount($account, $userdata);
             $this->frontendUserRepository->update($account);
         }
         $this->persistenceManager->persistAll();
         $this->authenticationService->registerSession($account);
         $authenticated = true;
     }
     return $authenticated;
 }
Esempio n. 2
0
 /**
  * @param array $entry
  *
  * @return int|void
  */
 public function processEntry(array $entry)
 {
     $configuration = $this->getConfiguration();
     $this->repository = $this->objectManager->get($configuration['repository']);
     $model = $this->mapModel($this->getModel(), $configuration['mapping'], $entry);
     $this->repository->add($model);
     $this->persistenceManager->persistAll();
     if (isset($configuration['language']) && is_array($configuration['language'])) {
         $this->processLanguageEntries($configuration['language'], $model, $entry);
     }
     $this->persistenceManager->persistAll();
     return TargetInterface::RESULT_INSERT;
 }
 /**
  * Creates a new entity of the given type and relates it with the given imported record.
  *
  * @param RepositoryInterface $repository
  * @param string $entityClass
  * @param array $importedRecord
  * @return \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
  */
 protected function createEntityAndStoreImportedUid($repository, $entityClass, array $importedRecord)
 {
     $entity = $this->objectManager->get($entityClass);
     if (!$entity instanceof \TYPO3\CMS\Extbase\DomainObject\AbstractEntity) {
         throw new \RuntimeException('The entity class must be an instance of AbstractEntity');
     }
     if (isset($importedRecord['pid'])) {
         $entity->setPid($importedRecord['pid']);
     }
     $repository->add($entity);
     $this->persistenceManager->persistAll();
     $entityTableName = $this->dataMapper->getDataMap($entityClass)->getTableName();
     $this->getDatabaseConnection()->exec_UPDATEquery($entityTableName, 'uid=' . (int) $entity->getUid(), ['tx_czsimplecalimportercal_imported_uid' => (int) $importedRecord['uid']]);
     return $entity;
 }
Esempio n. 4
0
 /**
  * action delete
  *
  * @param int $uid uid
  * @param string $hash hash
  * @param bool $ajax is ajax request?
  * @param string $settings settings
  * @return void
  */
 public function deleteAction($uid = 0, $hash = "", $ajax = FALSE, $settings = NULL)
 {
     if ($uid > 0) {
         $item = $this->commentRepository->findByUid($uid);
         if (is_object($item)) {
             if ($hash == $item->getHash()) {
                 $redirectUri = $item->getUrlForeign() . "#commentform";
                 // remove item from database
                 $this->commentRepository->remove($item);
                 $this->persistenceManager->persistAll();
                 // add message
                 $messages[] = ["icon" => '<span class="glyphicon glyphicon-ok icon-alert" aria-hidden="true"></span>', "title" => LocalizationUtility::translate(self::LLPATH . 'pi1.action_delete', $this->extensionName), "text" => LocalizationUtility::translate(self::LLPATH . 'pi1.action_delete.success', $this->extensionName), "type" => FlashMessage::OK];
                 // set flash messages
                 $this->helperService->setFlashMessages($this, $messages);
                 // end request
                 if (!$ajax) {
                     // redirect to target url
                     $this->redirectToUri($redirectUri);
                 }
             }
         } else {
             $this->view = NULL;
         }
     } else {
         $this->view = NULL;
     }
 }
Esempio n. 5
0
 /**
  * @param $flag
  * @param $enabled
  * @throws Tx_FeatureFlag_Service_Exception_FeatureNotFound
  * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
  */
 public function updateFeatureFlag($flag, $enabled)
 {
     $flagModel = $this->getFeatureFlag($flag);
     $flagModel->setEnabled($enabled);
     $this->featureFlagRepository->update($flagModel);
     $this->persistenceManager->persistAll();
     $this->cachedFlags[$flag] = $flagModel;
 }
Esempio n. 6
0
 /**
  * @param string                               $filepath
  * @param \HDNET\Importr\Domain\Model\Strategy $strategy
  * @param array                                $configuration
  */
 public function addToQueue($filepath, Strategy $strategy, array $configuration = [])
 {
     $import = $this->objectManager->get(Import::class);
     $start = 'now';
     if (isset($configuration['start'])) {
         $start = $configuration['start'];
     }
     try {
         $startTime = new \DateTime($start);
     } catch (\Exception $e) {
         $startTime = new \DateTime();
     }
     $import->setStarttime($startTime);
     $import->setFilepath($filepath);
     $import->setStrategy($strategy);
     $this->importRepository->add($import);
     $this->persistenceManager->persistAll();
 }
Esempio n. 7
0
 /**
  * Generates new temporary user
  *
  * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
  *
  * @return \Abra\Cadabra\Domain\Model\FrontendUser
  */
 protected function createTemporaryUser()
 {
     $username = $this->createUniqueUserName();
     $user = new \Abra\Cadabra\Domain\Model\FrontendUser();
     $user->setUsername($username);
     $user->setPassword(sha1(time()));
     $userGroupId = $this->settings['frontendUser']['temporaryFrontendUserGroupId'];
     /** @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup $userGroup */
     $userGroup = $this->frontendUserGroupRepository->findByIdentifier($userGroupId);
     $user->addUsergroup($userGroup);
     $user->setTemporaryUser(true);
     $this->frontendUserRepository->add($user);
     $this->persistenceManager->persistAll();
     return $user;
 }
Esempio n. 8
0
 /**
  * @param \Abra\Cadabra\Domain\Model\Article $article
  * @param integer $amount
  *
  * @return void
  */
 public function addArticleAction($article, $amount = 1)
 {
     $positions = $this->basket->getPositions();
     /** @var \Abra\Cadabra\Domain\Model\Ordering\BasketEntry $position */
     foreach ($positions as $position) {
         if ($position->getUid() === $article->getUid()) {
         }
     }
     $basketEntry = new \Abra\Cadabra\Domain\Model\Ordering\BasketEntry();
     $basketEntry->setArticle($article);
     $basketEntry->setAmount($amount);
     $basketEntry->setBasket($this->basket);
     $this->basket->addPosition($basketEntry);
     $this->basketRepository->update($this->basket);
     $this->persistenceManager->persistAll();
     $pageId = $this->settings['basket']['basketPageId'] ? $this->settings['basket']['basketPageId'] : null;
     $this->redirect('show', 'Basket', 'cadabra', null, $pageId);
 }
Esempio n. 9
0
 /**
  * Deletes a topic and all posts contained in it.
  *
  * @param Topic $topic
  */
 public function deleteTopic(Topic $topic)
 {
     foreach ($topic->getPosts() as $post) {
         /** @var $post Post */
         $post->getAuthor()->decreasePostCount();
         $post->getAuthor()->decreasePoints((int) $this->settings['rankScore']['newPost']);
         $this->frontendUserRepository->update($post->getAuthor());
     }
     $forum = $topic->getForum();
     $forum->removeTopic($topic);
     $this->topicRepository->remove($topic);
     $this->persistenceManager->persistAll();
     $user = $this->getCurrentUser();
     if (!$user->isAnonymous()) {
         $user->decreaseTopicCount();
         if ($topic->getQuestion() == 1) {
             $user->decreaseQuestionCount();
         }
         $this->frontendUserRepository->update($user);
     }
 }