#32049 – Suppress postNotifiable when importing

Posted in ‘Akeeba Ticket System’
This is a public ticket. Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Wednesday, 27 November 2019 12:46 CST

I have made an importer from EasyDiscuss to ATS. It's roughly based on fetch-by-email as the context seemed similar.

It works fine but I have one issue before actually running it on live site: I cannot seem to prevent ATS to send email notifications when adding the posts.

It's done in /administrator/components/com_ats/Model/Posts.php, in the onAfterSave event handler: there are calls to


which I cannot seem to disable programmatically.

I ended up (on staging server) commenting out those 2 lines for the duration of the import or disabling the posteail plugin. I'd prefer a more reliable solution, is there a way to disable thos events programmatically?


Custom Fields

Joomla! version (in x.y.z format) 3.9.13
PHP version (in x.y.z format) 7.2.24
Akeeba Ticket System version (x.y.z format) 3.0.4
Thursday, 28 November 2019 00:37 CST
You cannot suppress the plugin event from being triggered and you shouldn't be able to. Joomla is designed around the ability to control the subscribers to events, not the events themselves. ATS itself is based around the idea that a new ticket must be communicated to the user. Therefore and as you said, you can disable the “Akeeba Ticket System - New post notification emails” plugin to suppress the emails.

There are a few things of varying complication (and implications) that you can do to suppress the emails selectively.

If you do not want to send new ticket emails at all you can go to Akeeba Ticket System, Setup, Email templates and unpublish the owner-private-new and owner-public-new templates. Since no email template is found no email is send out. However, this applies to all new tickets, even those created from the frontend or backend of the site.

If your import script runs fairly fast and outside busy hours you could disable the plugin, run your import and re-enable the plugin programmatically. The downside is that any tickets and ticket replies filed at that time won't be notified by email.

Since you're a competent Joomla extensions developer I trust you with this alternative: insert into ATS' database tables directly. However, you may not want to do this because it's a pain in the rear. I've only done that to convert from our old ticket and forum systems into ATS.

You can be sneaky, but I only recommend this for CLI or plugins guaranteed to only execute under specific conditions / specially crafted requests as opposed to plugins which can execute whenever (including when a user files a ticket or posts a reply). You can load any plugin group except 'ats' before you initialize ATS' container. At this point Joomla's PluginHelper goes through load() to get information on all activated plugins (if it hasn't done so already) but has not assigned the 'ats' group's plugin methods as observers in its event dispatcher. Using Reflection you can peek into PluginHelper::$plugins and remove the ats useremails plugin. When the postNotifiable() method is called it will try to load the 'ats' group. Since the plugins cache is already loaded PluginHelper won't go through load() again. Therefore Joomla won't "see" the email plugin. It will register the observers of the other ats plugins just fine. Since the user email plugin is not loaded it won't send any emails. If you're not sure what I mean look at this code I wrote for DataCompliance a while ago. At the end of the highlighted section $refPlugins can be used to read the internal Joomla cache of plugins, manipulate it and write back to it.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native

🇬🇧English: excellent

🇫🇷French: basic

Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Thursday, 28 November 2019 01:41 CST

Thanks for the thorough answer. I did not want to write direct to DB as there might be some work done inside the model when saving a ticket that I would have to look at and possibly reproduce. Funny thing is that eventually I had to step through and look at the details of the implementation.

The solutions here are too involved for the use case. I'll just disable the email plugin to avoid sending emails to customers for a short while.

The downside is that any tickets and ticket replies filed at that time won't be notified by email.
We just won't reply during the import so customers won't need to be notified. And on our side, we use the "unassigned" posts list anyway with slack/glip notifications so that won't be an issue.

Closing now.


This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.

Support Information

Working hours: Typically we work Monday to Friday, 9am to 7pm Cyprus timezone (EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets, but we cannot respond to them, outside of our working hours.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!