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

powermail_cond and powermail-edit-plugin (pi2) #91

Open
tobiasschaeferptb opened this issue Apr 16, 2024 · 0 comments
Open

powermail_cond and powermail-edit-plugin (pi2) #91

tobiasschaeferptb opened this issue Apr 16, 2024 · 0 comments
Milestone

Comments

@tobiasschaeferptb
Copy link

Hello,

the code in Classes/Controller/ConditionController.php in the buildConditionAction methode only works for the pi1 of powermail.
The edit plugin (pi2) doesn't work with powermail_cond:

    public function buildConditionAction(): ResponseInterface
    {
        $requestBody = $this->request->getParsedBody();
        if (empty($requestBody['tx_powermail_pi1']['mail']['form'])) {
            throw new MissingPowermailParameterException();
        }
        $powermailArguments = $requestBody['tx_powermail_pi1'];

It would work if the code would be like this:

    public function buildConditionAction(): ResponseInterface
    {
        $requestBody = $this->request->getParsedBody();
        if (empty($requestBody['tx_powermail_pi1']['mail']['form']) AND empty($requestBody['tx_powermail_pi2']['mail']['form'])) {
            throw new MissingPowermailParameterException();
        }
        $powermailArguments = $requestBody['tx_powermail_pi1'];
        if (empty($powermailArguments)) {
            $powermailArguments = $requestBody['tx_powermail_pi2'];
        }

The code in Resources/Private/Build/JavaScript/PowermailConditions.js has the same problem:

  #getFieldByMarker(fieldMarker) {
    let fieldName = 'tx_powermail_pi1[field][' + fieldMarker + ']';
    return this.#form.querySelector('[name="' + fieldName +  '"]:not([type="hidden"])') ||
      this.#form.querySelector('[name="' + fieldName +  '[]"]');
  };

This could be a fix:

  #getFieldByMarker(fieldMarker) {
    if (window.location.href.indexOf("tx_powermail_pi2") > -1 ) {
      let fieldName = 'tx_powermail_pi2[field][' + fieldMarker + ']';
    }
    else {
      let fieldName = 'tx_powermail_pi1[field][' + fieldMarker + ']';
    }
    return this.#form.querySelector('[name="' + fieldName +  '"]:not([type="hidden"])') ||
      this.#form.querySelector('[name="' + fieldName +  '[]"]');
  };

Best regards,
Tobias Schaefer

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

No branches or pull requests

3 participants