Commit 69eff8b8 authored by Andreas Wolf's avatar Andreas Wolf Committed by Thomas Löffler
Browse files

[CLEANUP] Move user repository from t3o_ajaxlogin

Change-Id: I90d57014bafd2c4dd882e09658c09bf40872de45
Reviewed-on: https://review.typo3.org/50618


Reviewed-by: Thomas Löffler's avatarThomas Löffler <loeffler@spooner-web.de>
Tested-by: Thomas Löffler's avatarThomas Löffler <loeffler@spooner-web.de>
parent 62cc0d96
...@@ -70,7 +70,7 @@ class Tx_TerFe2_Controller_ExtensionController extends Tx_TerFe2_Controller_Abst ...@@ -70,7 +70,7 @@ class Tx_TerFe2_Controller_ExtensionController extends Tx_TerFe2_Controller_Abst
protected $persistenceManager; protected $persistenceManager;
/** /**
* @var Tx_T3oAjaxlogin_Domain_Repository_UserRepository * @var Tx_TerFe2_Domain_Repository_UserRepository
*/ */
protected $ownerRepository; protected $ownerRepository;
...@@ -91,7 +91,7 @@ class Tx_TerFe2_Controller_ExtensionController extends Tx_TerFe2_Controller_Abst ...@@ -91,7 +91,7 @@ class Tx_TerFe2_Controller_ExtensionController extends Tx_TerFe2_Controller_Abst
$this->tagRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_TagRepository'); $this->tagRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_TagRepository');
$this->versionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_VersionRepository'); $this->versionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_VersionRepository');
$this->authorRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_AuthorRepository'); $this->authorRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_AuthorRepository');
$this->ownerRepository = $this->objectManager->get('Tx_T3oAjaxlogin_Domain_Repository_UserRepository'); $this->ownerRepository = $this->objectManager->get(Tx_TerFe2_Domain_Repository_UserRepository::class);
$this->providerManager = $this->objectManager->get('Tx_TerFe2_Provider_ProviderManager'); $this->providerManager = $this->objectManager->get('Tx_TerFe2_Provider_ProviderManager');
$this->session = $this->objectManager->get('Tx_TerFe2_Persistence_Session'); $this->session = $this->objectManager->get('Tx_TerFe2_Persistence_Session');
$this->persistenceManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class); $this->persistenceManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
......
...@@ -47,7 +47,7 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab ...@@ -47,7 +47,7 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
protected $categoryRepository; protected $categoryRepository;
/** /**
* @var Tx_Ajaxlogin_Domain_Repository_UserRepository * @var Tx_TerFe2_Domain_Repository_UserRepository
*/ */
protected $userRepository; protected $userRepository;
...@@ -61,7 +61,7 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab ...@@ -61,7 +61,7 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository'); $this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->versionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_VersionRepository'); $this->versionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_VersionRepository');
$this->categoryRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_CategoryRepository'); $this->categoryRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->userRepository = $this->objectManager->get('Tx_Ajaxlogin_Domain_Repository_UserRepository'); $this->userRepository = $this->objectManager->get(Tx_TerFe2_Domain_Repository_UserRepository::class);
} }
/** /**
......
<?php
class Tx_TerFe2_Domain_Repository_UserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
{
/**
* Find an Object using the UID of the current fe_user
* @return Tx_Ajaxlogin_Domain_Model_User the current fe_user or null if none
*/
public function findCurrent()
{
$fe_user = $GLOBALS['TSFE']->fe_user->user;
if (!empty($fe_user)) {
$query = $this->createQuery();
$query->matching($query->equals('uid', intval($fe_user['uid'])));
return $query->execute()->getFirst();
}
return null;
}
/**
* Find an Object using the UID of the current fe_user
* @return Tx_Ajaxlogin_Domain_Model_User
*/
public function findOneByForgotHashAndEmail($forgotHash, $email)
{
$query = $this->createQuery();
$constraints = array(
$query->equals('forgotHash', $forgotHash),
$query->equals('email', $email),
// check for validity is done in controller to have better error messages
//$query->greaterThan('forgotHashValid', time())
);
$query->matching($query->logicalAnd($constraints));
return $query->execute()->getFirst();
}
/**
* Find an Object using the UID of the current fe_user
* @return Tx_Ajaxlogin_Domain_Model_User
*/
public function findOneByVerificationHashAndEmail($verificationHash, $email)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectEnableFields(FALSE);
$constraints = array(
$query->equals('deleted', 0),
$query->equals('verificationHash', $verificationHash),
$query->equals('email', $email)
);
$query->matching($query->logicalAnd($constraints));
return $query->execute()->getFirst();
}
/**
* @return Tx_Ajaxlogin_Domain_Model_User
*/
public function findOneByEmail($email)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectEnableFields(FALSE);
$constraints = array(
$query->equals('deleted', 0),
$query->equals('email', $email)
);
$query->matching($query->logicalAnd($constraints));
return $query->execute()->getFirst();
}
/**
* @return Tx_Ajaxlogin_Domain_Model_User
*/
public function findOneByUsername($username)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectEnableFields(FALSE);
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$constraints = array(
$query->equals('deleted', 0),
$query->equals('username', $username)
);
$query->matching($query->logicalAnd($constraints));
return $query->execute()->getFirst();
}
/**
* Find an Object using the UID of the current fe_user
* @return Tx_Ajaxlogin_Domain_Model_User
*/
public function findOneByEnableHash($enableHash)
{
$query = $this->createQuery();
$constraints = array(
$query->equals('enableHash', $enableHash),
$query->equals('disable', 0)
);
$query->matching($query->logicalAnd($constraints));
return $query->execute()->getFirst();
}
/**
* Find all users which not approved yet.
*
* @return array|Tx_Extbase_Persistence_QueryResultInterface
*/
public function findAllToApprove()
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectEnableFields(FALSE);
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$constraints = array(
$query->equals('deleted', 0),
$query->equals('disable', 1),
$query->equals('verificationHash', ''),
$query->equals('newUser', 1)
);
$query->matching($query->logicalAnd($constraints));
return $query->execute();
}
/**
* @param $uid
*
* @return Tx_Ajaxlogin_Domain_Model_User
*/
public function findUserByUid($uid)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectEnableFields(FALSE);
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$query->matching($query->equals('uid', $uid));
return $query->execute()->getFirst();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment