Custom alerts

Technical chat for the techies and development testers
Post Reply
paullanders
Posts: 92
Joined: Thu Sep 04, 2008 9:48 pm

Custom alerts

Post by paullanders » Thu Sep 25, 2008 5:32 pm

Hi Dave.

I know you may eventually add customizable alert messages, but in the meantime could this be achieved temporarily by a code hack? I would like to send alerts to end users and they phreak out with the verbage ***FREENATS ALERT***, etc

Thanks!

dave
Site Admin
Posts: 260
Joined: Fri May 30, 2008 9:09 pm
Location: UK
Contact:

Re: Custom alerts

Post by dave » Thu Sep 25, 2008 5:52 pm

Hi Paul,

This bit is well due a rewrite to make it more configurable etc. But yes a code hack can be done for the moment.

In server/base/freenats.inc.php - from line 187 onwards in the current version is this code:

Code: Select all

		if ($row['atype']=="email")
			{
			if ($row['esubject']==0) $sub="";
			else if ($row['esubject']==1) $sub="FreeNATS Alert";
			else $sub="** FreeNATS Alert **";
			$body="";
			if ($row['etype']==0) $body=$row['mdata'];
			else $body="FreeNATS Alert,\r\n".$row['mdata']."\r\n--FreeNATS @ ".nicedt(time());
The $row['esubject'] checks are for blank (0), short (1) or long (2).

As for the body - the actual alerts themselves are stored in $row['mdata'] and if the type is short (0) then they are just put in, otherwise it pads them with the header etc.

I can very easily implement some config variables to replace these i.e. site.alert.shortsubject site.alert.longsubject etc or I could make them configurable on a per-action basis in the interface (take a bit longer).

Cheers,

Dave.

paullanders
Posts: 92
Joined: Thu Sep 04, 2008 9:48 pm

Re: Custom alerts

Post by paullanders » Tue Oct 21, 2008 10:26 pm

Hi Dave.

I think the variables would be fine, especially if I'm the only one requesting this mod. In the meantime I just hacked my code.

Thanks again!

Paul

dave
Site Admin
Posts: 260
Joined: Fri May 30, 2008 9:09 pm
Location: UK
Contact:

Re: Custom alerts

Post by dave » Wed Oct 29, 2008 7:15 pm

Hi,

This has been done in the latest dev version (1.01.10a) now available for download. I'll update the wiki but for the moment...

alert.subject.long and alert.subject.short define the long and short subjects in email alerts (default to "FreeNATS Alert" and "** FreeNATS Alert **" repectively)

alert.body.header is the very top of a long email with a few newlines after it before the alerts themselves (defaults to "FreeNATS Alert,")

alert.body.footer is an optional footer added after the alerts in a long email (defaults to nothing)

Cheers,

Dave.

Post Reply