# Preparations
# login to Admin Console
# go to {nav Configuration > Website > Advanced} section
# enable `Use Cron to run Scheduled Tasks` setting and save changes
# go to {nav Configuration > Website > Scheduled Tasks} section
# disable all scheduled tasks (Select All > Decline)
# enable scheduled task with `email-queue:OnProcess` event
# go to {nav User Management > Mailings} section and click on `Email Queue` tab
# if there are records present in grid, then delete them
# go to {nav User Management > Users} section
# create approved user record
# Part 1 (existing code, system setting = queue, ajax)
# login to Admin Console
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Email Queue` and save changes
# go to {nav User Management > Users} section
# press `Approve` or `Decline` toolbar button to invert user status
# go to {nav User Management > Mailings} section and click on `Email Queue` tab
# confirm, that:
* a record for user status change email was created
* email wasn't sent yet to user's email address
# press `Process Queue` toolbar button
# confirm, that:
* a record for user status change email was removed
* email was sent to user's email address
# go to {Logs & Reports > System Log} section
# confirm, that no new records about deprecations were created
# Part 2 (existing code, system setting = immediate, ajax)
# login to Admin Console
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Immediate` and save changes
# go to {nav User Management > Users} section
# press `Approve` or `Decline` toolbar button to invert user status
# go to {nav User Management > Mailings} section and click on `Email Queue` tab
# confirm, that:
* no record for user status change email was created
* email was sent to user's email address
# go to {Logs & Reports > System Log} section
# confirm, that no new records about deprecations were created
# Part 3 (existing code, system setting = immediate, cron)
# login to Admin Console
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Email Queue` and save changes
# go to {nav User Management > Users} section
# press `Approve` or `Decline` toolbar button to invert user status
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Immediate` and save changes
# go to {nav User Management > Mailings} section and click on `Email Queue` tab
# confirm, that:
* a record for user status change email was created
* email wasn't sent yet to user's email address
# in CLI run `php tools/cron.php` command
# reload page
# confirm, that:
* a record for user status change email was removed
* email was sent to user's email address
# go to {Logs & Reports > System Log} section
# confirm, that no new records about deprecations were created
# Part 4 (deprecated code, system setting = queue, ajax)
# in IDE:
* open `/core/admin_templates/mailing_lists/send_queue.tpl` file for editing
* replace `email-queue_event="OnProcessAjax"` with `email-template_event="OnProcessEmailQueue"`
* replace `pass="m,email-queue"` with `pass="m,email-template"`
* save changes
# login to Admin Console
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Email Queue` and save changes
# go to {nav User Management > Users} section
# press `Approve` or `Decline` toolbar button to invert user status
# go to {nav User Management > Mailings} section and click on `Email Queue` tab
# confirm, that:
* a record for user status change email was created
* email wasn't sent yet to user's email address
# press `Process Queue` toolbar button
# confirm, that:
* a record for user status change email was removed
* email was sent to user's email address
# go to {Logs & Reports > System Log} section
# confirm, that new record about deprecation was created
# rollback changes made to `/core/admin_templates/mailing_lists/send_queue.tpl` file
# Part 5 (deprecated code, system setting = immediate, cron)
# login to Admin Console
# go to {nav Configuration > Website > Scheduled Tasks} section
# disable scheduled task with `email-queue:OnProcess` event
# create new scheduled task with these settings:
* name: `process_email_queue2`
* event: `mailing-list:OnProcessEmailQueue`
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Email Queue` and save changes
# go to {nav User Management > Users} section
# press `Approve` or `Decline` toolbar button to invert user status
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Immediate` and save changes
# go to {nav User Management > Mailings} section and click on `Email Queue` tab
# confirm, that:
* a record for user status change email was created
* email wasn't sent yet to user's email address
# in CLI run `php tools/cron.php` command
# reload page
# confirm, that:
* a record for user status change email was removed
* email was sent to user's email address
# go to {Logs & Reports > System Log} section
# confirm, that no new records about deprecations were created (in future if we implement http://community.in-portal.org/x/WIFYAQ they might be created)
# delete scheduled task with `mailing-list:OnProcessEmailQueue` event
# enable scheduled task with `email-queue:OnProcess` event
# Part 6 (the "$immediate_send" param usage)
# in IDE:
* open `\kApplication::_email` method for editing
* in the call to `\kEmail::send` specify `true` for `$immediate_send` argument
* save changes
# login to Admin Console
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Email Queue` and save changes
# go to {nav User Management > Users} section
# press `Approve` or `Decline` toolbar button to invert user status
# go to {nav User Management > Mailings} section and click on `Email Queue` tab
# confirm, that:
* no record for user status change email was created
* email was sent to user's email address
# go to {Logs & Reports > System Log} section
# confirm, that no new records about deprecations were created
# in IDE: revert changes to `\kApplication::_email` method
# Part 7 (the "processQueue" messages override)
```
lang=php
$messages = $mailing_list_helper->getMessages();
if ( count($messages) > 0 ) {
array_pop($messages);
}
$message_count = $mailing_list_helper->processQueue($messages);
```
# in IDE:
* open `\EmailQueueEventHandler::OnProcessAjax` method for editing
* change `$message_count = $mailing_list_helper->processQueue();` line into code snipper shown above
* save changes
# login to Admin Console
# go to {nav Configuration > Website > Advanced} section
# set `Email Delivery` setting to `Email Queue` and save changes
# go to {nav User Management > Users} section
# press `Approve` or `Decline` toolbar button to invert user status (first time)
# press `Approve` or `Decline` toolbar button to invert user status (second time)
# go to {nav User Management > Mailings} section and click on `Email Queue` tab
# confirm, that:
* two records for user status change email were created
* emails weren't sent yet to user's email address
# press `Process Queue` toolbar button
# confirm, that:
* one record for user status change email was removed
* one email was sent to user's email address
# go to {Logs & Reports > System Log} section
# confirm, that new record about deprecation was created
# rollback changes to the `\EmailQueueEventHandler::OnProcessAjax` method
# Part 8 (the "_ensureDefault" method)
```
lang=php
/** @var MailingListHelper $mailing_list_helper */
$mailing_list_helper = $this->Application->recallObject('MailingListHelper');
$a = $this->_ensureDefault('MailingListSendPerStep');
$b = $mailing_list_helper->getSetting('MailingListSendPerStep');
die(var_dump($a === $b));
```
# in IDE:
* open `\MailingListEventHandler::OnPreCreate` method for editing
* add code from snippet above to it
# login to Admin Console
# go to {nav User Management > Mailings} section
# press `Add` button on toolbar
# confirm, that:
* popup/modal window was opened
* it has `true` word in it
# in IDE: rollback changes to `\MailingListEventHandler::OnPreCreate` method