]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 304660: PerformSubsts() should be in Util.pm instead of BugMail.pm - Patch by...
authorlpsolit%gmail.com <>
Tue, 16 Aug 2005 00:58:10 +0000 (00:58 +0000)
committerlpsolit%gmail.com <>
Tue, 16 Aug 2005 00:58:10 +0000 (00:58 +0000)
Bugzilla/Bug.pm
Bugzilla/BugMail.pm
Bugzilla/Util.pm
globals.pl
showdependencygraph.cgi
whineatnews.pl

index 4dcb83e6c8d8bc47e5b9cc1c12698b8ab628e6e7..f281dbda8286d539c3fcd22de30055079639d018 100755 (executable)
@@ -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) " .
index dffc98a854377f72313901293202e45b234fb0aa..59d4210a1f270d30e503bdd2ef14e94e9ae10849 100644 (file)
@@ -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});
index 694f6f1c4019f42d091ff03a53236262226a98c3..f5084e02c6d2798f8c7c1c208d963fb8578e9ad2 100644 (file)
@@ -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,
index ed4159335f73d149cfb51c692fe56f4a681fa239..17174540a3a1201c83d974ceebc2d7f7dff2c888 100644 (file)
@@ -35,7 +35,6 @@ use Bugzilla::Constants;
 use Bugzilla::Util;
 # Bring ChmodDataFile in until this is all moved to the module
 use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir);
-use Bugzilla::BugMail;
 use Bugzilla::User;
 use Bugzilla::Error;
 
index 4339bb3e595f65dfd46b23ca70377926aacbad04..01ac1e2e32b90c99a7294c8051a3dfc57df8d9d7 100755 (executable)
@@ -29,7 +29,6 @@ use File::Temp;
 use Bugzilla;
 use Bugzilla::Config qw(:DEFAULT $webdotdir);
 use Bugzilla::Util;
-use Bugzilla::BugMail;
 use Bugzilla::Bug;
 
 require "globals.pl";
@@ -221,7 +220,7 @@ my $webdotbase = Param('webdotbase');
 
 if ($webdotbase =~ /^https?:/) {
      # Remote dot server
-     my $url = PerformSubsts($webdotbase) . $filename;
+     my $url = perform_substs($webdotbase) . $filename;
      $vars->{'image_url'} = $url . ".gif";
      $vars->{'map_url'} = $url . ".map";
 } else {
index ae2121303b1c7e3f029d315e7d9385c8e10db998..50e06383eb3a5cd40162db3c8d85cfb2c968facf 100755 (executable)
@@ -33,6 +33,7 @@ use lib '.';
 require "globals.pl";
 
 use Bugzilla::BugMail;
+use Bugzilla::Util;
 
 # Whining is disabled if whinedays is zero
 exit unless Param('whinedays') >= 1;
@@ -71,7 +72,7 @@ foreach my $email (sort (keys %bugs)) {
     my %substs;
     $substs{'email'} = $email . $emailsuffix;
     $substs{'userid'} = $email;
-    my $msg = PerformSubsts($template, \%substs);
+    my $msg = perform_substs($template, \%substs);
 
     foreach my $i (@{$bugs{$email}}) {
         $msg .= "  " . shift(@{$desc{$email}}) . "\n";