summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-08-16 02:58:10 +0200
committerlpsolit%gmail.com <>2005-08-16 02:58:10 +0200
commit044848e67b4134b9429f880774c9c6cf577226cc (patch)
tree365261b53d20a19ed440fead50676ac7b421af0c /Bugzilla
parent746013729e6377357efb68de8d7f2fd93e25a07c (diff)
downloadbugzilla-044848e67b4134b9429f880774c9c6cf577226cc.tar.gz
bugzilla-044848e67b4134b9429f880774c9c6cf577226cc.tar.xz
Bug 304660: PerformSubsts() should be in Util.pm instead of BugMail.pm - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=myk
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm2
-rw-r--r--Bugzilla/BugMail.pm30
-rw-r--r--Bugzilla/Util.pm26
3 files changed, 29 insertions, 29 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 4dcb83e6c..f281dbda8 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1079,7 +1079,7 @@ sub RemoveVotes {
$substs{"count"} = $removedvotes . "\n " . $newvotestext;
- my $msg = PerformSubsts(Param("voteremovedmail"), \%substs);
+ my $msg = perform_substs(Param("voteremovedmail"), \%substs);
Bugzilla::BugMail::MessageToMTA($msg);
}
my $votes = $dbh->selectrow_array("SELECT SUM(vote_count) " .
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index dffc98a85..59d4210a1 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -32,11 +32,6 @@ use strict;
package Bugzilla::BugMail;
-use base qw(Exporter);
-@Bugzilla::BugMail::EXPORT = qw(
- PerformSubsts
-);
-
use Bugzilla::DB qw(:deprecated);
use Bugzilla::User;
use Bugzilla::Constants;
@@ -603,7 +598,7 @@ sub sendMail {
my $template = Param("newchangedmail");
- my $msg = PerformSubsts($template, \%substs);
+ my $msg = perform_substs($template, \%substs);
MessageToMTA($msg);
@@ -730,32 +725,11 @@ sub encode_message {
return ($head, $body);
}
-# Performs substitutions for sending out email with variables in it,
-# or for inserting a parameter into some other string.
-#
-# Takes a string and a reference to a hash containing substitution
-# variables and their values.
-#
-# If the hash is not specified, or if we need to substitute something
-# that's not in the hash, then we will use parameters to do the
-# substitution instead.
-#
-# Substitutions are always enclosed with '%' symbols. So they look like:
-# %some_variable_name%. If "some_variable_name" is a key in the hash, then
-# its value will be placed into the string. If it's not a key in the hash,
-# then the value of the parameter called "some_variable_name" will be placed
-# into the string.
-sub PerformSubsts {
- my ($str, $substs) = (@_);
- $str =~ s/%([a-z]*)%/(defined $substs->{$1} ? $substs->{$1} : Param($1))/eg;
- return $str;
-}
-
# Send the login name and password of the newly created account to the user.
sub MailPassword {
my ($login, $password) = (@_);
my $template = Param("passwordmail");
- my $msg = PerformSubsts($template,
+ my $msg = perform_substs($template,
{"mailaddress" => $login . Param('emailsuffix'),
"login" => $login,
"password" => $password});
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 694f6f1c4..f5084e02c 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -37,6 +37,7 @@ use base qw(Exporter);
lsearch max min
diff_arrays diff_strings
trim wrap_comment find_wrap_point
+ perform_substs
format_time format_time_decimal validate_date
file_mod_time is_7bit_clean
bz_crypt validate_email_syntax);
@@ -264,6 +265,12 @@ sub find_wrap_point {
return $wrappoint;
}
+sub perform_substs {
+ my ($str, $substs) = (@_);
+ $str =~ s/%([a-z]*)%/(defined $substs->{$1} ? $substs->{$1} : Param($1))/eg;
+ return $str;
+}
+
sub format_time {
my ($date, $format) = @_;
@@ -418,6 +425,7 @@ Bugzilla::Util - Generic utility functions for bugzilla
$val = trim(" abc ");
($removed, $added) = diff_strings($old, $new);
$wrapped = wrap_comment($comment);
+ $msg = perform_substs($str, $substs);
# Functions for formatting time
format_time($time);
@@ -600,6 +608,24 @@ Search for a comma, a whitespace or a hyphen to split $string, within the first
$maxpos characters. If none of them is found, just split $string at $maxpos.
The search starts at $maxpos and goes back to the beginning of the string.
+=item C<perform_substs($str, $substs)>
+
+Performs substitutions for sending out email with variables in it,
+or for inserting a parameter into some other string.
+
+Takes a string and a reference to a hash containing substitution
+variables and their values.
+
+If the hash is not specified, or if we need to substitute something
+that's not in the hash, then we will use parameters to do the
+substitution instead.
+
+Substitutions are always enclosed with '%' symbols. So they look like:
+%some_variable_name%. If "some_variable_name" is a key in the hash, then
+its value will be placed into the string. If it's not a key in the hash,
+then the value of the parameter called "some_variable_name" will be placed
+into the string.
+
=item C<is_7bit_clean($str)>
Returns true is the string contains only 7-bit characters (ASCII 32 through 126,