Result of Method Bugzilla::User->groups?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Result of Method Bugzilla::User->groups?

FrankSCH
Hi all,
when cloning a bug I want to add a certain group to the bug_group_map in order to avoid other users reading these clones. For this I use the $user->groups method (Bugzilla::User->groups)  in order to get this additional groups's id and description in the enter_bug.cgi script and push it into the $group array:

enter_bug.cgi:

use Bugzilla::Group;

[...]
foreach my $row (@$grouplist) {
    my $group;
   
    if ( ($cloned_bug_id) &&
         ($product->name eq $cloned_bug->product ) ) {  
       
        if ($user->in_group('internal_group')) {
            foreach my $in_group ($user->groups){
                if (@$in_group->name == 'internal_group') {
                    $group = {
                        'bit' => @$in_group->id ,
                        'checked' => 1 ,
                        'description' => @$in_group->description ,
                        'name' => @$in_group->name
                    };
                    push @groups, $group;
                }
            }
        }
       
        foreach my $i (0..(@{$cloned_bug->groups} - 1) ) {
            if ($cloned_bug->groups->[$i]->{'bit'} == $id) {
                $check = $cloned_bug->groups->[$i]->{'ison'};
            }
        }
    }
    elsif(formvalue("maketemplate") ne "") {
        $check = formvalue("bit-$id", 0);
    }
    else {
        # Checkbox is checked by default if $control is a default state.
        $check = (($membercontrol == CONTROLMAPDEFAULT)
                 || (($othercontrol == CONTROLMAPDEFAULT)
                      && (!Bugzilla->user->in_group($groupname))));
    }

    $group =
    {
        'bit' => $id ,
        'checked' => $check ,
        'description' => $description ,
        'name' => $groupname
    };

    push @groups, $group;
}
[...]

 I get an error "Can't call method "name" without a package or object reference [...]" although I put an use statement for the Bugzilla::Group class into the script header.

Is there anyone who has an idea what is going wrong?

-Thanks in advance!
Frank
Reply | Threaded
Open this post in threaded view
|

Re: Result of Method Bugzilla::User->groups?

FrankSCH
Got it! - Should have used the notation of the foreach iteration below (I just oversaw it ):
[...]
            foreach my $j (0..(@{$user->groups} - 1) ) {
                if ($user->groups->[$j]->name == 'internal_group') > -1) {
                    $group = {
                        'bit' => $user->groups->[$j]->id ,
                        'checked' => 1 ,
                        'description' => $user->groups->[$j]->description ,
                        'name' => $user->groups->[$j]->name
                    };
                    push @groups, $group;
                }
            }
[...]