Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM-4.3.5 on T3-8.7.9: Optin-Mail and Optin-Confirmation-Page: {powermail_all} not substituted #213

Closed
realJustmike opened this issue Jan 3, 2018 · 5 comments

Comments

@realJustmike
Copy link

When using OptIn on translated pages, the {powermail_all} marker in the 2nd mail and 2nd confirmation page (after clicking the confirmation-link) is empty. Reason: The answers of the mail are not loaded in other languages than the default one.

I "solved" the issue quick and dirty by adding the function 'gugler_addAnswers' to the FormController. This function is called in FormController->optinConfirmAction():

public function optinConfirmAction($mail, $hash)  {
        $this->signalDispatch(__CLASS__, __FUNCTION__ . 'BeforeRenderView', [$mail, $hash, $this]);
        $mail = $this->mailRepository->findByUid($mail);
        $this->forwardIfFormParamsDoNotMatchForOptinConfirm($mail);
        $labelKey = 'failed';

        if ($mail !== null && OptinUtility::checkOptinHash($hash, $mail)) {
            if($GLOBALS['TSFE']->sys_language_uid === 1) {
                $mail = $this->gugler_addAnswers($mail,$mail->getUid());
            }
            if ($mail->getHidden()) {
                $mail->setHidden(false);
                $this->mailRepository->update($mail);
                $this->persistenceManager->persistAll();

                $this->forward('create', null, null, ['mail' => $mail, 'hash' => $hash]);
            }
            $labelKey = 'done';
        }
        $this->view->assign('labelKey', $labelKey);
    }

public function gugler_addAnswers($mail, $uid) {
        $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
        $answerRepository = $objectManager->get('In2code\\Powermail\\Domain\\Repository\\AnswerRepository');
        
        $querySettings = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
        $querySettings->setStoragePageIds(array(45));
        $querySettings->setLanguageMode(null);
        $answerRepository->setDefaultQuerySettings($querySettings);

        $objectStorage = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\ObjectStorage');
        $answers = $answerRepository->findByMail($uid);
        if (NULL !== $answers) {
            foreach($answers AS $object) {
                $objectStorage->attach($object);
            }
        }

        $mail->setAnswers($objectStorage);
        return $mail;
    }
@einpraegsam
Copy link
Collaborator

Thx for the hint. I already heard about that issue together with language_mode=strict. At the moment this issue is not yet solved. I think about a solution where the mails are stored with sys_language_uid=-1 - that should help.

@Max-LAB
Copy link

Max-LAB commented Apr 18, 2018

Hi all sorry for writting on a closed issue, I also have a same probelm. I tried this fix, but hve stucked.

@realJustmike what did you did inside findByMail($uid) function? It should return array so you can do a foreach here. Can you please post your solution in full.

@einpraegsam do you have any idea about this? Im not sure what should be in my &object that I attach to $objectStorage. Any help would be appreciated

@davidjakob
Copy link

I think anyway a mail should be untranslatable? Or is there a case where someone would or should translate a Mail?

@r0bin
Copy link

r0bin commented Aug 10, 2018

We provide a fix for this now: powermail_optin_fix

@Schweriner
Copy link

The extension from @r0bin fixes the problem confirmed also for powermail version 7.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants