]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 256135: Parameter 'movers' is handled differently in Bug.pm and buglist.cgi ...
authorlpsolit%gmail.com <>
Fri, 9 Sep 2005 06:50:29 +0000 (06:50 +0000)
committerlpsolit%gmail.com <>
Fri, 9 Sep 2005 06:50:29 +0000 (06:50 +0000)
Bugzilla/Bug.pm
Bugzilla/User.pm
buglist.cgi
move.pl
process_bug.cgi
template/en/default/list/edit-multiple.html.tmpl

index a35b23fb20c97391e4d9701244ddf204edfc3af5..48572c7ed13408061074b7dee157da8d5724ff92 100755 (executable)
@@ -396,12 +396,9 @@ sub user {
 
     $self->{'user'} = {};
 
-    my $movers = Param("movers");
-    $movers =~ s/\s?,\s?/|/g;
-    $movers =~ s/@/\@/g;
-    $self->{'user'}->{'canmove'} = Param("move-enabled") 
-      && (defined $::COOKIE{"Bugzilla_login"}) 
-        && ($::COOKIE{"Bugzilla_login"} =~ /$movers/);
+    $self->{'user'}->{'canmove'} = Param('move-enabled')
+                                   && $::userid
+                                   && Bugzilla->user->is_mover;
 
     # In the below, if the person hasn't logged in ($::userid == 0), then
     # we treat them as if they can do anything.  That's because we don't
index 101305a81f44561a1d7a38ca6d0c4616cfc710a7..046efbc671a2883a1e2cee4911b01d0ffb70ec65 100644 (file)
@@ -698,6 +698,17 @@ sub email_prefs {
     return $self->{email_prefs};
 }
 
+sub is_mover {
+    my $self = shift;
+
+    if (!defined $self->{'is_mover'}) {
+        my @movers = map { trim($_) } split(',', Param('movers'));
+        $self->{'is_mover'} = ($self->id
+                               && lsearch(\@movers, $self->login) != -1);
+    }
+    return $self->{'is_mover'};
+}
+
 1;
 
 __END__
@@ -850,6 +861,12 @@ all MySQL supported, this will go away.
 
 Returns C<1> if the user can bless at least one group. Otherwise returns C<0>.
 
+=item C<is_mover>
+
+Returns true if the user is in the list of users allowed to move bugs
+to another database. Note that this method doesn't check whether bug
+moving is enabled.
+
 =back
 
 =head1 SEE ALSO
index e9408f23bc3ddf3b9c8d4d910cb348c21e9b900f..7b2eed3f681b663319cb12d109e7ad3f263cb9f5 100755 (executable)
@@ -876,18 +876,8 @@ $vars->{'closedstates'} = ['CLOSED', 'VERIFIED', 'RESOLVED'];
 $vars->{'urlquerypart'} = $::buffer;
 $vars->{'urlquerypart'} =~ s/(order|cmdtype)=[^&]*&?//g;
 $vars->{'order'} = $order;
-
-# The user's login account name (i.e. email address).
-my $login = $::COOKIE{'Bugzilla_login'};
-
 $vars->{'caneditbugs'} = UserInGroup('editbugs');
 
-# Whether or not this user is authorized to move bugs to another installation.
-$vars->{'ismover'} = 1
-  if Param('move-enabled')
-    && defined($login)
-      && Param('movers') =~ /^(\Q$login\E[,\s])|([,\s]\Q$login\E[,\s]+)/;
-
 my @bugowners = keys %$bugowners;
 if (scalar(@bugowners) > 1 && UserInGroup('editbugs')) {
     my $suffix = Param('emailsuffix');
diff --git a/move.pl b/move.pl
index e6d18d3c1b300f1dc1da14a3cd784097eafba105..5f6d7a8bcaf17e3ee6b7c39310f7d81fc602d8d9 100755 (executable)
--- a/move.pl
+++ b/move.pl
@@ -38,15 +38,18 @@ use Bugzilla::BugMail;
 
 $::lockcount = 0;
 
+my $cgi = Bugzilla->cgi;
+
 unless ( Param("move-enabled") ) {
+  print $cgi->header();
+  PutHeader("Move Bugs");
   print "\n<P>Sorry. Bug moving is not enabled here. ";
   print "If you need to move a bug, contact " . Param("maintainer");
+  PutFooter();
   exit;
 }
 
-Bugzilla->login(LOGIN_REQUIRED);
-
-my $cgi = Bugzilla->cgi;
+my $user = Bugzilla->login(LOGIN_REQUIRED);
 
 sub Log {
     my ($str) = (@_);
@@ -90,11 +93,7 @@ if (!defined $cgi->param('buglist')) {
   exit;
 }
 
-my $exporter = Bugzilla->user->login;
-my $movers = Param("movers");
-$movers =~ s/\s?,\s?/|/g;
-$movers =~ s/@/\@/g;
-unless ($exporter =~ /($movers)/) {
+unless ($user->is_mover) {
   print $cgi->header();
   PutHeader("Move Bugs");
   print "<P>You do not have permission to move bugs<P>\n";
@@ -103,14 +102,15 @@ unless ($exporter =~ /($movers)/) {
 }
 
 my @bugs;
+my $exporterid = $user->id;
+
+print $cgi->header();
+PutHeader("Move Bugs");
 
-print "<P>\n";
 foreach my $id (split(/:/, scalar($cgi->param('buglist')))) {
-  my $bug = new Bugzilla::Bug($id, $::userid);
+  my $bug = new Bugzilla::Bug($id, $exporterid);
   push @bugs, $bug;
   if (!$bug->error) {
-    my $exporterid = DBNameToIdAndCheck($exporter);
-
     my $fieldid = GetFieldID("bug_status");
     my $cur_status= $bug->bug_status;
     SendSQL("INSERT INTO bugs_activity " .
@@ -130,7 +130,7 @@ foreach my $id (split(/:/, scalar($cgi->param('buglist')))) {
         $comment .= $cgi->param('comment') . "\n\n";
     }
     $comment .= "Bug moved to " . Param("move-to-url") . ".\n\n";
-    $comment .= "If the move succeeded, $exporter will receive a mail\n";
+    $comment .= "If the move succeeded, " . $user->login . " will receive a mail\n";
     $comment .= "containing the number of the new bug in the other database.\n";
     $comment .= "If all went well,  please mark this bug verified, and paste\n";
     $comment .= "in a link to the new bug. Otherwise, reopen this bug.\n";
@@ -138,10 +138,9 @@ foreach my $id (split(/:/, scalar($cgi->param('buglist')))) {
         "($id,  $exporterid, now(), " . SqlQuote($comment) . ")");
 
     print "<P>Bug $id moved to " . Param("move-to-url") . ".<BR>\n";
-    Bugzilla::BugMail::Send($id, { 'changer' => $exporter });
+    Bugzilla::BugMail::Send($id, { 'changer' => $user->login });
   }
 }
-print "<P>\n";
 
 my $buglist = $cgi->param('buglist');
 $buglist =~ s/:/,/g;
@@ -172,3 +171,4 @@ Bugzilla::BugMail::MessageToMTA($msg, $to);
 
 my $logstr = "XML: bugs $buglist sent to $to";
 Log($logstr);
+PutFooter();
index cf1046b69c485747a59157975640d174750e24ac..bb455ec2f6db0a309eb4d4a97d165988c4527dcb 100755 (executable)
@@ -569,10 +569,9 @@ my $action = '';
 if (defined $::FORM{action}) {
   $action = trim($::FORM{action});
 }
-if (Param("move-enabled") && $action eq Param("move-button-text")) {
+if ($action eq Param("move-button-text")) {
   $cgi->param('buglist', join (":", @idlist));
   do "move.pl" || die "Error executing move.cgi: $!";
-  PutFooter();
   exit;
 }
 
index b2be4104650366b2813007250d71cffc9881a238..eda6d2fa183b506f84600a2caafa8ad64585c127 100644 (file)
 
 <input type="submit" value="Commit">
 
-[% IF ismover %]
+[% IF Param('move-enabled') && user.is_mover %]
   <input type="submit" name="action" value="[% Param('move-button-text') %]">
 [% END %]