RSS

trunk : 6107

lpsolit%gmail.com
2008-06-28 19:01:44
Revision ID: cvs-1:lpsolitgmail.com-20080629000144-u49ds36p8xc25oy6
Bug 428440: Move code to set new product and related groups from process_bug.cgi to new function $bug->set_all - Patch by Noura Elhawary <nelhawar@redhat.com> r=LpSolit r=mkanat a=mkanat

collapse all collapse all

added added

removed removed

501
    return $params;
501
    return $params;
502
}
502
}
503
 
503
 
 
 
504
sub set_all {
 
 
505
    my ($self, $args) = @_;
 
 
506
 
 
 
507
    # For security purposes, and because lots of other checks depend on it,
 
 
508
    # we set the product first before anything else.
 
 
509
    my $product_change = 0;
 
 
510
    if ($args->{product}) {
 
 
511
        my $changed = $self->set_product($args->{product},
 
 
512
                                        { component => $args->{component},
 
 
513
                                          version   => $args->{version},
 
 
514
                                          target_milestone => $args->{target_milestone},
 
 
515
                                          change_confirmed => $args->{confirm_product_change},
 
 
516
                                          other_bugs => $args->{other_bugs},
 
 
517
                                        });
 
 
518
        # that will be used later to check strict isolation
 
 
519
        $product_change = $changed;
 
 
520
    }
 
 
521
 
 
 
522
    # add/remove groups
 
 
523
    $self->remove_group($_) foreach @{$args->{remove_group}};
 
 
524
    $self->add_group($_) foreach @{$args->{add_group}};
 
 
525
 
 
 
526
    # this is temporary until all related code is moved from
 
 
527
    # process_bug.cgi to set_all
 
 
528
    return $product_change;
 
 
529
}
 
 
530
 
504
sub update {
531
sub update {
505
    my $self = shift;
532
    my $self = shift;
506
 
533
 
241
    }
241
    }
242
}
242
}
243
 
243
 
244
# For security purposes, and because lots of other checks depend on it,
244
my $product_change;
245
# we set the product first before anything else.
245
foreach my $bug (@bug_objects) {
246
my $product_change; # Used only for strict_isolation checks, right now.
246
    my $args;
247
if (should_set('product')) {
247
    if (should_set('product')) {
248
    foreach my $b (@bug_objects) {
248
        $args->{product} = scalar $cgi->param('product');
249
        my $changed = $b->set_product(scalar $cgi->param('product'),
249
        $args->{component} = scalar $cgi->param('component');
250
            { component        => scalar $cgi->param('component'),
250
        $args->{version} = scalar $cgi->param('version');
251
              version          => scalar $cgi->param('version'),
251
        $args->{target_milestone} = scalar $cgi->param('target_milestone');
252
              target_milestone => scalar $cgi->param('target_milestone'),
252
        $args->{confirm_product_change} =  scalar $cgi->param('confirm_product_change');
253
              change_confirmed => scalar $cgi->param('confirm_product_change'),
253
        $args->{other_bugs} = \@bug_objects;
254
              other_bugs => \@bug_objects,
 
 
255
            });
 
 
256
        $product_change ||= $changed;
 
 
257
    }
254
    }
258
}
255
 
259
        
256
    foreach my $group (@{$bug->product_obj->groups_valid}) {
260
# strict_isolation checks mean that we should set the groups
 
 
261
# immediately after changing the product.
 
 
262
foreach my $b (@bug_objects) {
 
 
263
    foreach my $group (@{$b->product_obj->groups_valid}) {
 
 
264
        my $gid = $group->id;
257
        my $gid = $group->id;
265
        if (should_set("bit-$gid", 1)) {
258
        if (should_set("bit-$gid", 1)) {
266
            # Check ! first to avoid having to check defined below.
259
            # Check ! first to avoid having to check defined below.
267
            if (!$cgi->param("bit-$gid")) {
260
            if (!$cgi->param("bit-$gid")) {
268
                $b->remove_group($gid);
261
                push (@{$args->{remove_group}}, $gid);
269
            }
262
            }
270
            # "== 1" is important because mass-change uses -1 to mean
263
            # "== 1" is important because mass-change uses -1 to mean
271
            # "don't change this restriction"
264
            # "don't change this restriction"
272
            elsif ($cgi->param("bit-$gid") == 1) {
265
            elsif ($cgi->param("bit-$gid") == 1) {
273
                $b->add_group($gid);
266
               push (@{$args->{add_group}}, $gid);
274
            }
267
            }
275
        }
268
        }
276
    }
269
    }
 
 
270
 
 
 
271
    # this will be deleted later when code moves to $bug->set_all
 
 
272
    my $changed = $bug->set_all($args);
 
 
273
    $product_change ||= $changed;
277
}
274
}
278
 
275
 
279
if ($cgi->param('id') && (defined $cgi->param('dependson')
276
if ($cgi->param('id') && (defined $cgi->param('dependson')

Loggerhead runs on Bazaar branches