[TYPO3-mvc] setting Usergroup
Claus Due
claus at wildside.dk
Tue Jan 17 10:39:38 CET 2012
Ah, d'oh! I see the problem: bad, bad naming conventions. Shame on you, TYPO3!
$user->setUsergroup() should be called $user->setUsergroups().
You need:
$userGroups = $this->objectManager->get('Tx_Extbase_Persistence_ObjectStorage');
$userGroups->attach($this->frontendUserRepository->findByUid($this->settings['accrgroup']));
$user->setUsergroup($userGroups);
$this->frontendUserRepository->update($user);
It's really a shame that in TYPO3, the usergroup field is akwardly named "usergroup" but is a multivalued field…
Cheers,
Claus
On Jan 17, 2012, at 10:32 AM, Johannes C. Schulz - EnzephaloN IT-Solutions wrote:
> Hello Claus
>
> It's a frondend-plugin.
> I tried your code, but same error message :-(
> Best regards
> Johannes
>
>
> -----Ursprüngliche Nachricht-----
> Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
> [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
> Claus Due
> Gesendet: Dienstag, 17. Januar 2012 10:27
> An: TYPO3 v4 MVC project
> Betreff: Re: [TYPO3-mvc] setting Usergroup
>
> Hi Johannes,
>
> What is the context - FE/BE/CLI?
>
> If you use the typoscript object browser is the storage page UID set?
>
> What happens if you instead do….
>
> $query = $this->frontendUserGroupRepository->createQuery();
> $query->getQuerySettings()->setRespectStoragePage(FALSE);
> $query->matching($query->equals('uid', $this->settings['accrgroup']));
> $group = $query->execute()->getFirst();
>
> Cheers,
> Claus
>
> On Jan 17, 2012, at 10:18 AM, Johannes C. Schulz - EnzephaloN IT-Solutions
> wrote:
>
>> Hello Claus
>> Thanks for your answers!
>> The record_type within the group is set to
>> Tx_Extbase_Domain_Model_FrontEndUserGroup.
>> storagePid is set by constants (all objects are stored in one folder:
>> user, group and my objects):
>> plugin.tx_psoaaccredit.persistence{
>> storagePid =
>> {$plugin.tx_psoaaccredit.persistence.storagePid}
>> }
>> Is something more to do in the controller?
>>
>> Best regards
>> Johannes
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
>> [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag
>> von Claus Due
>> Gesendet: Dienstag, 17. Januar 2012 10:10
>> An: TYPO3 v4 MVC project
>> Betreff: Re: [TYPO3-mvc] setting Usergroup
>>
>> Hi Johannes,
>>
>> Shooting from the hip: set the "record type" of your fe_group record
>> to Tx_Extbase_Domain_Model_FrontendUserGroup and/or make sure you have
>> the storage page UID set ;)
>>
>> Cheers,
>> Claus
>>
>> On Jan 17, 2012, at 9:56 AM, Johannes C. Schulz - EnzephaloN
>> IT-Solutions
>> wrote:
>>
>>> Hello typo3-community
>>>
>>> Several problems with my new extensions are solved, some new came.
>>> The plan is, to add a new feuser. Now it seems to work, instead the
>>> setting of the usergroup. Therefor I made an instance of
>>> Tx_Extbase_Domain_Repository_FrontendUserGroupRepository and tried this:
>>>
>>> $usergroup =
>>> $this->usergroupRepository->findByUid($this->settings['accrgroup']);
>>> //from constants, searching the right usergroup
>>> $user->setUsergroup($usergroup); //assigning.
>>>
>>> But this throws an error, the given object is NULL and not
>>> Tx_Extbase_Persistence_ObjectStorage.
>>> How do I right?
>>>
>>>
>>>
>>> Thanks
>>>
>>> Johannes
>>>
>>> _______________________________________________
>>> TYPO3-project-typo3v4mvc mailing list
>>> TYPO3-project-typo3v4mvc at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4
>>> m
>>> vc
>>
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4m
>> vc
>>
>>
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4m
>> vc
>
> _______________________________________________
> 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