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

[5.2] Workflow emails #37860

Open
wants to merge 19 commits into
base: 5.2-dev
Choose a base branch
from

Conversation

roland-d
Copy link
Contributor

Pull Request for Issue #37745 #37446 .

Summary of Changes

This change adds the option to select email as a notification type. Users can send notifications to:

  • Private messages (old and default behavior)
  • Email

image

Testing Instructions

First you need to apply this PR. Since there are database changes you will need to run those as well.

For MySQL users run this on your database:

INSERT IGNORE INTO `#__mail_templates` (`template_id`, `extension`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES
('plg_workflow_notification.mail', 'plg_workflow_notification', '', 'PLG_WORKFLOW_NOTIFICATION_EMAIL_ON_TRANSITION_SUBJECT', 'PLG_WORKFLOW_NOTIFICATION_EMAIL_ON_TRANSITION_MSG', '', '', '{"tags":["siteurl","title","performer","transitionName","toStage","extraText"]}');

For Postgres users run this on your database:

INSERT INTO "#__mail_templates" ("template_id", "extension", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES
('plg_workflow_notification.mail', 'plg_workflow_notification', '', 'PLG_WORKFLOW_NOTIFICATION_EMAIL_ON_TRANSITION_SUBJECT', 'PLG_WORKFLOW_NOTIFICATION_EMAIL_ON_TRANSITION_MSG', '', '', '{"tags":["siteurl","title","performer","transitionName","toStage","extraText"]}')
ON CONFLICT DO NOTHING;
  1. Enable Workflows by going to Content -> Articles -> Options -> Integration -> Enable Workflow and set it to Yes
  2. Save the changes
  3. Go to Content -> Workflows
  4. Click on the number 7 (or another number) under Transitions
  5. Click on the Unpublish transition
  6. Click on Notification
  7. Notice there is now the option to select a notification type
  8. The Private Messages is the old and default way of sending notifications. Clicking on the dropdown now also let's you select Email as an option. Multiple options are possible as well
  9. Select a usergroup and/or a user where you want to send the message to
  10. Save the transition
  11. Go got Content -> Articles
  12. Edit an article
  13. Set the transition to Unpublished
  14. Save the article
  15. Check if the message has arrived

Mail templates

The sending of the emails uses the mail templates in Joomla. The mail template can be customized via these steps:

  1. Go to System -> Mail Templates
  2. Filter on workflow
  3. You will see 1 template.
    image
  4. Click on the template to edit it
  5. Modify the template to your needs

Feedback requested

The following questions I have:

  1. The name of the person doing the transition has a placeholder named performer Any suggestions for a better name?
  2. Are there more placeholders wanted for the mail template?

@brianteeman Could you please check the language files?

Final words

Thanks to @bembelimen and @softforge for the idea to add this. Thanks to @brianteeman to point out to use mail templates.

I know this isn't perfect code so looking for feedback to get this into Joomla to make transitions more useful as they are quite neat.

Actual result BEFORE applying this Pull Request

Messages are only sent to users who can receive private messages

Expected result AFTER applying this Pull Request

Messages can now also be send to users with an account and email address.

Documentation Changes Required

Yes, need to document the addition of the email option.

…s to a users email address

Signed-off-by: Roland Dalmulder <contact@rolandd.com>
@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-4.2-dev labels May 22, 2022
@Kostelano
Copy link
Contributor

Great addition.
I tested a little, I'll leave a comment.

The "Additional Message Text" field must be removed. First, we find ourselves in a similar situation, which I described in the issue #37493. Secondly, if we add text in this field and we select both methods of receiving a notification, then we will receive this additional text in personal messages, but we will NOT receive it in email, since this additional text will not be in the letter template. Thirdly, in this field we do not see the real message (only the description), but we see it in the email template.

In short, we really need to leave 1 place for setting the "body" of the notification and this place in the email templates. We can mention this in the description for the "Notification Type" parameter.

@brianteeman
Copy link
Contributor

Doesn't make any sense to keep the old broken behaviour as an option You're introducing a new method that fixes the bugs in the old method but still leave the old method there with its bugs

@brianteeman
Copy link
Contributor

You cannot have a required field that is conditionaly displayed.

You have made the notification type a required field but is only shown when send email is set to yes.

@brianteeman
Copy link
Contributor

I really dont undrstand why you have kept the broken private messages version. There is no explanation or why you would use method email or method private messags and you can still select groups and users to receive private messages which will neveer be sent.

@brianteeman
Copy link
Contributor

It needs to be clearer that you can customise the mail further if you are using the email method by using th email templates BUT that it is a generic template for all transition notification emails and you must put anything specific to the transition in the notification config only.

@brianteeman
Copy link
Contributor

In what scenario would anyone ever send a message by email AND private message?

roland-d and others added 4 commits May 23, 2022 10:48
Co-authored-by: Brian Teeman <brian@teeman.net>
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
@roland-d
Copy link
Contributor Author

@Kostelano

The "Additional Message Text" field must be removed.

This cannot be removed as it will be a backwards compatible break.

Secondly, if we add text in this field and we select both methods of receiving a notification, then we will receive this additional text in personal messages, but we will NOT receive it in email, since this additional text will not be in the letter template.

You can add the additional text to the email. This is a valid point that the extra text should be in the default mail template. I have updated this PR with that change.

Thirdly, in this field we do not see the real message (only the description), but we see it in the email template.

I do not understand this. Can you explain this further?

In short, we really need to leave 1 place for setting the "body" of the notification and this place in the email templates.

That is something I was thinking about but really have no idea how we should do this. First I cannot remove this addition message text due to backwards compatibility break. Second, we could create a mail template for every transition but these cannot be in core because we have no idea which transitions there will be.

@brianteeman

Doesn't make any sense to keep the old broken behaviour as an option

I cannot remove sending messages to private messages because that would be a backwards compatible break. I would not say it is broken but rather limited as we can only send messages to users with access to private messages.

You cannot have a required field that is conditionaly displayed.

Actually you can. The required condition is only active when the field is displayed.

There is no explanation or why you would use method email or method private messags

Any suggestions for a text to add?

you can still select groups and users to receive private messages which will neveer be sent.

I saw your other issue about that but this is not in scope of this PR. I can look at that in a separate PR.

It needs to be clearer that you can customise the mail further if you are using the email method by using th email templates BUT that it is a generic template for all transition notification emails and you must put anything specific to the transition in the notification config only.

See my remark above for Kostelano, he basically says the same thing. Any suggestions on how to improve this are welcome.

In what scenario would anyone ever send a message by email AND private message?

I knew this was coming :) If I chose a single dropdown the request would come to make it multiple, make it multiple and the request will come for a single dropdown. Ghehehehe.

So my reasoning is that the transition message can be send but may not arrive in the mail but you can see it in your private message box. Why limit the options for the user? We can let the user decide what they want to use, we do not have to decide for them.

@brianteeman
Copy link
Contributor

brianteeman commented May 23, 2022

Doesn't make any sense to keep the old broken behaviour as an option

I cannot remove sending messages to private messages because that would be a backwards compatible break. I would not say it is broken but rather limited as we can only send messages to users with access to private messages.

No its not B/C break you are just changing from a completely broken method to a working method

You cannot have a required field that is conditionaly displayed.

Actually you can. The required condition is only active when the field is displayed.

I do not write things just for the sake of writing words. I tested the PR. (and I know that we already have the same bug elsewhere.)

image

image

you can still select groups and users to receive private messages which will neveer be sent.

I saw your other issue about that but this is not in scope of this PR. I can look at that in a separate PR.

Of course it is in the scope of this PR. Otherwise it doesn't fix the bug you state this pr fixes.

@brianteeman
Copy link
Contributor

@Kostelano you need the "additional text" field. Without it you cannot have a unique message for each notification.

Mail templates are for general customisations of all notification emails

Signed-off-by: Roland Dalmulder <contact@rolandd.com>
@roland-d
Copy link
Contributor Author

No its not B/C break you are just changing from a completely broken method to a working method

It works on the site where we are using workflow. Messages go to the private message box.

I do not write things just for the sake of writing words. I tested the PR. (and I know that we already have the same bug elsewhere.)

I also tested this of course but did not read between your lines that there should not be an option selected. I removed the requirement.

@brianteeman
Copy link
Contributor

I have tested this item 🔴 unsuccessfully on a94c821

Does not fix the reported problems


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37860.

@Kostelano
Copy link
Contributor

If you add some text in the transition field, then it will be sent to the mail with a visible br tag, although I just added the text in the field. This is the EMAIL method.

Screenshot_1

There is no br tag in private messages.

Co-authored-by: Brian Teeman <brian@teeman.net>
@brianteeman
Copy link
Contributor

How about updating the text below the selection of the notification type with something like

image

It wont prevent someone trying to send to users who won't receive the private messages email but at least they have been warned

roland-d and others added 2 commits May 27, 2022 20:04
Co-authored-by: Konstantin Kolos <k0nstantinkolos88@gmail.com>
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
@roland-d
Copy link
Contributor Author

roland-d commented Jul 3, 2022

Rebased to 4.3

@Quy Quy removed the PR-4.2-dev label Jul 3, 2022
@spamzini
Copy link

spamzini commented Sep 5, 2022

Hi,

i'v upgraded a CLEAN installation of joomla 4.2.0 to the last one 4.2.2.
I'v upgrade by the file upload (administrator/index.php?option=com_joomlaupdate&view=upload) and not by the automatic update
The check of the database by the internal function .../administrator/index.php?option=com_installer&view=database shows two errors of database:
One of this was the XXXX_mail_templates has MEDIUMTEXT character set.
I solved with this SQL command:

ALTER TABLE XXXX_mail_templates CHANGE htmlbody htmlbody MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37860.

@HLeithner HLeithner removed the psr12 label Oct 23, 2022
@richard67
Copy link
Member

@roland-d As the PR has been rebased to 4.3-dev, the update SQL scripts "4.2.0-2022-05-22.sql" need to be renamed to something later than the up to now latest 4.3 update SQL scripts "4.3.0-2022-09-23.sql". I would suggest "4.3.0-2022-10-23.sql".

@richard67
Copy link
Member

@obuisard Please don't merge this before the update SQL scripts have been renamed, see my previous comment.

@obuisard
Copy link
Contributor

@obuisard Please don't merge this before the update SQL scripts have been renamed, see my previous comment.

No worries Richard, I was not going to merge it as I saw your comments :-)
Thank you for your help!

@Quy Quy added the Updates Requested Indicates that this pull request needs an update from the author and should not be tested. label Jan 11, 2023
@Magnytu2
Copy link

I have tested this item 🔴 unsuccessfully on cd97f4b

Still no mail received after a transition. The private message notification works, but not the email.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37860.

@obuisard obuisard changed the title [4.2] Workflow emails [4.3] Workflow emails Jan 12, 2023
@Hackwar Hackwar added the Feature label Apr 6, 2023
@HLeithner HLeithner changed the base branch from 4.3-dev to 5.0-dev May 8, 2023 15:02
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.0-dev. No new features will be merged into Joomla! 4.3 series. Joomla! 4.4 series is a bridge release to make migration from Joomla! 4 to 5 as smooth as possible.

@micker
Copy link

micker commented Jun 19, 2023

hello i would help to test this but after save my item i have this message "No notifications sent as there are no users to send this message to." bug or need to configure something ?
image
regards

@richard67
Copy link
Member

@micker If there is no other super user besides the one who causes the notification, then there is nobody to send email to. Create another user user and that other one should get the email if the first super user changes something and your email sending is set up right.

@micker
Copy link

micker commented Jun 19, 2023

I have tested this item ✅ successfully on cd97f4b

thanks @richardnet its great now
@roland-d tested and validate !

maybe 2 return 😄

@obuisard obuisard changed the title [4.3] Workflow emails [5.0] Workflow emails Sep 9, 2023
@HLeithner HLeithner changed the base branch from 5.0-dev to 5.1-dev September 30, 2023 22:51
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.1-dev.

@HLeithner HLeithner changed the base branch from 5.1-dev to 5.2-dev April 24, 2024 09:09
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.2-dev.

@HLeithner HLeithner changed the title [5.0] Workflow emails [5.2] Workflow emails Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Conflicting Files Feature Language Change This is for Translators PR-5.0-dev PR-5.2-dev Updates Requested Indicates that this pull request needs an update from the author and should not be tested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet