Skip to content

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

Description

@tobiasschaeferptb

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions