Tuesday, January 25, 2011

Adding prefix in subject of FengOffice notification emails

FengOffice sends notifications to users on various occasions. But the issue is, FengOffice does not use any subject prefix for notification. So, it is very hard to differentiate among regular emails and FengOffice notifications in email inbox. And, absence of subject prefix makes it very hard create an appropriate filter rule.

So, a configuration option to add a subject prefix will be very much helpful.
But unfortunately, there is no such configuration option in FengOffice (In the latest version while writing this post, may be this will be added in a future version)

In 'application/models/notifier/Notifier.class.php', I found that there are scope for hooks that can be used in this purpose:

Hook::fire('notifier_email_subject', $subject, $subject);


So, I created a the hook 'notifier_email_subject' to add subject prefix.

I created a new file 'application/hooks/notifier_hooks.php' with the following contents:


<?php

function fengoffice_notifier_email_subject($subject, &$ret) {
$ret = '[FengOffice] ' . $subject;
}

?>



So, [FengOffice] prefix will be added to all notification emails. Because of using hooks, I did not have to modify the core FengOffice code.

The advantage would be, when we update FengOffice version in future, the notifier will not be effected. If I had changed core code, that would be lost because of update.

1 comment:

Daniel Kling said...

Thanks for this solution. Do you have an idea to include the assigned workspace name as subject?