[TYPO3-mvc] update hidden / disabled records

typo3 at litedesigns.nl typo3 at litedesigns.nl
Mon Apr 2 14:56:16 CEST 2012


Hi Frank,

Thanks for your suggestion, but this does not seem to work (i have set
setRespectEnableFields(FALSE) in my createQuery() of my
CompanyRepository). Was this not the correct way to use
setRespectEnableFields?

A little more detailed info about my model:

Company
- fieldA
- fieldB
- ...
- activationHash
- frontendUser => this is the 1:1 relation to fe_users table.

After i created the Company and FrontendUser i send the visitor an email
with a link (with the activationHash) to activate the Company and
FrontendUser.

In my Controller i have this function to activate the account:

public function activateAccountAction($activationHash)
{
	// the findByActivationHash() uses setRespectEnableFields(FALSE) to find
the hidden company
	$company =
$this->companyRepository->findByActivationHash(trim($activationHash));

	if ($company instanceof Tx_MyExt_Domain_Model_Company)
	{
		// unhide the company
		$company->setHidden(0); // so far so good, this works!

		// get frontend user from company
		$frontendUser = $company->getFrontendUser(); // frontendUser is never
returned

		if ($frontendUser instanceof Tx_Extbase_Domain_Model_FrontendUser)
		{
			$frontendUser->setDisable(0);
		}
	}
}

Since i don't have my own repository for the FrontendUsers, i try to fetch
the FrontendUser by:
$frontendUser = $company->getFrontendUser();
This works fine though if the FrontendUser is not hidden!

But Extbase immediately tries to convert this to an Object instead of
returning the FrontendUser.uid (as expected), but the FrontendUser object
is never created since it has disable=1 set...

And because i can't get the FrontendUser.uid, i can't write my own
function in my CompanyRepository to find the Company with an findByUid()
and set setRespectEnableFields(FALSE) in this function.

That's why i proposed the solution to add a redundant field named
'fe_user_id' to my Company model, which is of type 'int' and not of type
'Tx_Extbase_Domain_Model_FrontendUser'.

With this redundant field i could write my own
CompanyRepository->findFeUsersByUidEvenIfHidden($uid) function. But as in
my original question, i'm not sure if this is the best / easiest approach.

It is a known problem: http://forge.typo3.org/issues/8483#note-4 (comment
by Alexander Stehlik)

Any ideas are appreciated.

Kind regards,
Tim


> Hi,
>
> you can try
>   ' $query->getQuerySettings()->setRespectEnableFields(FALSE);'
> In your repository, this should disable the enable-field query.
>
> Best regards,
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
> [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
> typo3 at litedesigns.nl
> Gesendet: Montag, 2. April 2012 13:18
> An: typo3-project-typo3v4mvc at lists.typo3.org
> Betreff: [TYPO3-mvc] update hidden / disabled records
>
> Hi List,
>
> I have a question about updating hidden records (based on http://forge:
> http://forge.typo3.org/issues/8483) and i'm looking for an (temporary)
> workaround.
>
> I have a Company with a 1:1 relation to a FrontendUser. Visitors can
> create
> their own account, this is a single form with both Company and
> FrontendUser
> fields. But i want to send the visitor an activation email with a link to
> activate their account.
>
> Therefor i set the FrontendUser to 'disable=1' (fe_users table) upon
> creating the Company and FrontendUser. This way they can't login yet
> before
> they have activated their account via the activation email.
>
> But how can i retrieve my FrontendUser in my Controller when the
> FrontendUser is still disabled?
>
> $company->getFrontendUser() does not return anything because of the
> 'enableFields' in the persistence layers of extbase.
>
> Should i add an extra field in my Company model, something like
> fe_user_id?
> This then should be an integer, opposed to company.fe_user which is a
> foreign key relation to the fe_users table. Because fe_user_id is an
> integer, i can retrieve the id of the fe_user with
> $company->getFeUserId() and then in my repository i can set
> $querySettings->setRespectEnableFields(FALSE); to retrieve my FrontendUser
> object. And if i change the disable to 0 (false), will it be saved or will
> Extbase not update the FrontendUser because it is disabled?
>
> Is this the easiest solution or does anyone have another approach?
>
> Kind regards,
> Tim
>
>
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>



More information about the TYPO3-project-typo3v4mvc mailing list