Bug 254 - Split out email subject and body config.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1934 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
cbe11fb17c
commit
188ca65ca5
|
@ -73,8 +73,6 @@ if ( ZM_OPT_UPLOAD )
|
|||
require Net::FTP;
|
||||
}
|
||||
|
||||
my $email_subject;
|
||||
my $email_body;
|
||||
if ( ZM_OPT_EMAIL )
|
||||
{
|
||||
if ( ZM_NEW_MAIL_MODULES )
|
||||
|
@ -86,11 +84,8 @@ if ( ZM_OPT_EMAIL )
|
|||
{
|
||||
require MIME::Entity;
|
||||
}
|
||||
( $email_subject, $email_body ) = ZM_EMAIL_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
|
||||
}
|
||||
|
||||
my $message_subject;
|
||||
my $message_body;
|
||||
if ( ZM_OPT_MESSAGE )
|
||||
{
|
||||
if ( ZM_NEW_MAIL_MODULES )
|
||||
|
@ -102,8 +97,6 @@ if ( ZM_OPT_MESSAGE )
|
|||
{
|
||||
require MIME::Entity;
|
||||
}
|
||||
|
||||
( $message_subject, $message_body ) = ZM_MESSAGE_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
|
||||
}
|
||||
|
||||
|
||||
|
@ -880,10 +873,10 @@ sub sendEmail
|
|||
|
||||
Info( "Creating notification email\n" );
|
||||
|
||||
my $subject = substituteTags( $email_subject, $filter, $event );
|
||||
my $subject = substituteTags( ZM_EMAIL_SUBJECT, $filter, $event );
|
||||
return( 0 ) if ( !$subject );
|
||||
my @attachments;
|
||||
my $body = substituteTags( $email_body, $filter, $event, \@attachments );
|
||||
my $body = substituteTags( ZM_EMAIL_BODY, $filter, $event, \@attachments );
|
||||
return( 0 ) if ( !$body );
|
||||
|
||||
Info( "Sending notification email '$subject'\n" );
|
||||
|
@ -974,10 +967,10 @@ sub sendMessage
|
|||
|
||||
Info( "Creating notification message\n" );
|
||||
|
||||
my $subject = substituteTags( $message_subject, $filter, $event );
|
||||
my $subject = substituteTags( ZM_MESSAGE_SUBJECT, $filter, $event );
|
||||
return( 0 ) if ( !$subject );
|
||||
my @attachments;
|
||||
my $body = substituteTags( $message_body, $filter, $event, \@attachments );
|
||||
my $body = substituteTags( ZM_MESSAGE_BODY, $filter, $event, \@attachments );
|
||||
return( 0 ) if ( !$body );
|
||||
|
||||
Info( "Sending notification message '$subject'\n" );
|
||||
|
|
|
@ -574,7 +574,6 @@ if ( $version )
|
|||
# Check for maximum FPS setting and update alarm max fps settings
|
||||
{
|
||||
print( "Updating monitors. Please wait.\n" );
|
||||
|
||||
if ( defined(&ZM_NO_MAX_FPS_ON_ALARM) && &ZM_NO_MAX_FPS_ON_ALARM )
|
||||
{
|
||||
# Update the individual monitor settings to match the previous global one
|
||||
|
@ -590,7 +589,30 @@ if ( $version )
|
|||
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
print( "Updating mail configuration. Please wait.\n" );
|
||||
my ( $sql, $sth, $res );
|
||||
if ( defined(&ZM_EMAIL_TEXT) && &ZM_EMAIL_TEXT )
|
||||
{
|
||||
my ( $email_subject, $email_body ) = ZM_EMAIL_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"?$/ms;
|
||||
$sql = "replace into Config set Id = 0, Name = 'ZM_EMAIL_SUBJECT', Value = '".$email_subject."', Type = 'string', DefaultValue = 'ZoneMinder: Alarm - %MN%-%EI% (%ESM% - %ESA% %EFA%)', Hint = 'string', Pattern = '(?-xism:^(.+)\$)', Format = ' \$1 ', Prompt = 'The subject of the email used to send matching event details', Help = 'This option is used to define the subject of the email that is sent for any events that match the appropriate filters.', Category = 'mail', Readonly = '0', Requires = 'ZM_OPT_EMAIL=1'";
|
||||
$sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
$res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||
$sql = "replace into Config set Id = 0, Name = 'ZM_EMAIL_BODY', Value = '".$email_body."', Hint = 'free text', Pattern = '(?-xism:^(.+)\$)', Format = ' \$1 ', Prompt = 'The body of the email used to send matching event details', Help = 'This option is used to define the content of the email that is sent for any events that match the appropriate filters.', Category = 'mail', Readonly = '0', Requires = 'ZM_OPT_EMAIL=1'";
|
||||
$sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
$res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||
}
|
||||
if ( defined(&ZM_MESSAGE_TEXT) && &ZM_MESSAGE_TEXT )
|
||||
{
|
||||
my ( $message_subject, $message_body ) = ZM_MESSAGE_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"?$/ms;
|
||||
$sql = "replace into Config set Id = 0, Name = 'ZM_MESSAGE_SUBJECT', Value = '".$message_subject."', Type = 'string', DefaultValue = 'ZoneMinder: Alarm - %MN%-%EI%', Hint = 'string', Pattern = '(?-xism:^(.+)\$)', Format = ' \$1 ', Prompt = 'The subject of the message used to send matching event details', Help = 'This option is used to define the subject of the message that is sent for any events that match the appropriate filters.', Category = 'mail', Readonly = '0', Requires = 'ZM_OPT_MESSAGE=1'";
|
||||
$sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
$res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||
$sql = "replace into Config set Id = 0, Name = 'ZM_MESSAGE_BODY', Value = '".$message_body."', Type = 'text', DefaultValue = 'ZM alarm detected - %ED% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% score.', Hint = 'free text', Pattern = '(?-xism:^(.+)\$)', Format = ' \$1 ', Prompt = 'The body of the message used to send matching event details', Help = 'This option is used to define the content of the message that is sent for any events that match the appropriate filters.', Category = 'mail', Readonly = '0', Requires = 'ZM_OPT_MESSAGE=1'";
|
||||
$sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
$res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||
}
|
||||
}
|
||||
$cascade = !undef;
|
||||
}
|
||||
if ( $cascade )
|
||||
|
|
Loading…
Reference in New Issue