[otrs-cvs] CVS: otrs/Kernel/System Group.pm,1.37,1.38

cvs-log at otrs.org cvs-log at otrs.org
Tue Jul 11 14:14:25 CEST 2006


Update of /home/cvs/otrs/Kernel/System
In directory lancelot:/tmp/cvs-serv24533/Kernel/System

Modified Files:
	Group.pm 
Log Message:
add GroupMemberInvolvedList(), extend GroupGroupMemberList() GroupRoleMemberList() GroupUserRoleMemberList() for better performance

Index: Group.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/Group.pm,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -r1.37 -r1.38
*** Group.pm	5 Jun 2006 14:16:51 -0000	1.37
--- Group.pm	11 Jul 2006 11:14:23 -0000	1.38
***************
*** 457,481 ****
          # get roles of user
          if ($Param{UserID}) {
!             my %Member = $Self->GroupUserRoleMemberList(
                  UserID => $Param{UserID},
!                 Result => 'HASH',
              );
!             foreach (keys %Member) {
! #                print STDERR "asd $_ \n";
!                 push (@Result, $Self->GroupRoleMemberList(%Param, RoleID => $_));
              }
          }
          # get roles of group
          elsif ($Param{GroupID}) {
!             my %Roles = $Self->GroupRoleMemberList(
                  GroupID => $Param{GroupID},
                  Type => $Param{Type},
!                 Result => 'HASH',
              );
!             foreach (keys %Roles) {
!                 push (@Result, $Self->GroupUserRoleMemberList(
                      %Param,
!                     RoleID => $_,
!                 ));
              }
          }
--- 457,489 ----
          # get roles of user
          if ($Param{UserID}) {
!             my @Member = $Self->GroupUserRoleMemberList(
                  UserID => $Param{UserID},
!                 Result => 'ID',
              );
!             if (@Member) {
!                 my @ResultGroupRole = $Self->GroupRoleMemberList(
!                     %Param,
!                     RoleIDs => \@Member,
!                 );
!                 foreach (@ResultGroupRole) {
!                     push (@Result, $_);
!                 }
              }
          }
          # get roles of group
          elsif ($Param{GroupID}) {
!             my @Roles = $Self->GroupRoleMemberList(
                  GroupID => $Param{GroupID},
                  Type => $Param{Type},
!                 Result => 'ID',
              );
!             if (@Roles) {
!                 my @ResultGroupUserRole = $Self->GroupUserRoleMemberList(
                      %Param,
!                     RoleIDs => \@Roles,
!                 );
!                 foreach (@ResultGroupUserRole) {
!                     push (@Result, $_);
!                 }
              }
          }
***************
*** 488,512 ****
          # get roles of user
          if ($Param{UserID}) {
!             my %Member = $Self->GroupUserRoleMemberList(
                  UserID => $Param{UserID},
!                 Result => 'HASH',
              );
!             foreach (keys %Member) {
! #                print STDERR "asd $_ \n";
!                 %Result = (%Result, $Self->GroupRoleMemberList(%Param, RoleID => $_));
              }
          }
          # get roles of group
          elsif ($Param{GroupID}) {
!             my %Roles = $Self->GroupRoleMemberList(
                  GroupID => $Param{GroupID},
                  Type => $Param{Type},
!                 Result => 'HASH',
              );
!             foreach (keys %Roles) {
!                 %Result = (%Result, $Self->GroupUserRoleMemberList(
!                     RoleID => $_,
!                     Result => 'HASH',
!                 ));
              }
          }
--- 496,525 ----
          # get roles of user
          if ($Param{UserID}) {
!             my @Member = $Self->GroupUserRoleMemberList(
                  UserID => $Param{UserID},
!                 Result => 'ID',
              );
! 
!             if (@Member) {
!                 my %ResultGroupRole = $Self->GroupRoleMemberList(
!                     %Param,
!                     RoleIDs => \@Member,
!                 );
!                 %Result = (%Result, %ResultGroupRole);
              }
          }
          # get roles of group
          elsif ($Param{GroupID}) {
!             my @Roles = $Self->GroupRoleMemberList(
                  GroupID => $Param{GroupID},
                  Type => $Param{Type},
!                 Result => 'ID',
              );
!             if (@Roles) {
!                 my %ResultGroupUserRole = $Self->GroupUserRoleMemberList(
!                     %Param,
!                     RoleIDs => \@Roles,
!                 );
!                 %Result = (%Result, %ResultGroupUserRole);
              }
          }
***************
*** 517,520 ****
--- 530,639 ----
  }
  
+ =item GroupMemberInvolvedList()
+ 
+ returns a list of users/groups with ro/move_into/create/owner/priority/rw permissions
+ 
+   @Users = $GroupObject->GroupMemberInvolvedList(
+       UserID => $ID,
+       Type => 'move_into',
+   );
+ 
+ =cut
+ 
+ sub GroupMemberInvolvedList {
+     my $Self = shift;
+     my %Param = @_;
+     # check needed stuff
+     foreach (qw(UserID Type)) {
+         if (!$Param{$_}) {
+             $Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!");
+             return;
+         }
+     }
+     # quote
+     foreach (qw(Type)) {
+         $Param{$_} = $Self->{DBObject}->Quote($Param{$_});
+     }
+     foreach (qw(UserID)) {
+         $Param{$_} = $Self->{DBObject}->Quote($Param{$_}, 'Integer');
+     }
+     # get valid ids
+     my $ValidID = join (', ', $Self->{DBObject}->GetValidIDs());
+ 
+     # get all groups of the given user
+     my %Groups;
+     my $SQL = "SELECT DISTINCT(g.id) FROM groups g, group_user gu " .
+         "WHERE g.valid_id IN ($ValidID) AND g.id = gu.group_id AND " .
+         "gu.permission_value = 1 AND gu.permission_key IN ('$Param{Type}', 'rw') AND " .
+         "gu.user_id = " . $Param{UserID};
+     $Self->{DBObject}->Prepare(SQL => $SQL);
+     while (my @Row = $Self->{DBObject}->FetchrowArray()) {
+         $Groups{$Row[0]} = 1;
+     }
+     # get all roles of the given user
+     $SQL = "SELECT DISTINCT(ru.role_id) FROM role_user ru, roles r " .
+         "WHERE r.valid_id in ($ValidID) AND r.id = ru.role_id AND ru.user_id = " . $Param{UserID};
+     $Self->{DBObject}->Prepare(SQL => $SQL);
+     my @Roles;
+     while (my @Row = $Self->{DBObject}->FetchrowArray()) {
+         push (@Roles, $Row[0]);
+     }
+ 
+     if (@Roles) {
+         # get all groups of the roles of the given user
+         my $StringRoles = join (',', @Roles);
+         $SQL = "SELECT DISTINCT(g.id) FROM groups g, group_role gu " .
+             "WHERE g.valid_id in ($ValidID) AND g.id = gu.group_id AND gu.permission_value = 1 AND " .
+             "gu.permission_key IN ('$Param{Type}', 'rw') AND gu.role_id IN ($StringRoles)";
+         $Self->{DBObject}->Prepare(SQL => $SQL);
+         while (my @Row = $Self->{DBObject}->FetchrowArray()) {
+             $Groups{$Row[0]} = 1;
+         }
+     }
+ 
+     my @ArrayGroups;
+     foreach (keys %Groups) {
+        push (@ArrayGroups, $_);
+     }
+     my %AllUsers;
+     if (@ArrayGroups) {
+         # get all users of the groups
+         my $StringGroups = join(',', @ArrayGroups);
+         $SQL = "SELECT DISTINCT(gu.user_id) FROM groups g, group_user gu WHERE " .
+             "g.valid_id in ($ValidID) AND g.id = gu.group_id AND gu.permission_value = 1 AND " .
+             "gu.permission_key IN ('$Param{Type}', 'rw') AND gu.group_id IN ($StringGroups)";
+         $Self->{DBObject}->Prepare(SQL => $SQL);
+         while (my @Row = $Self->{DBObject}->FetchrowArray()) {
+             $AllUsers{$Row[0]} = 1;
+         }
+         # get all roles of the groups
+         my @AllRoles;
+         $SQL = "SELECT DISTINCT(gu.role_id) FROM groups g, group_role gu WHERE " .
+             "g.valid_id in ($ValidID) AND g.id = gu.group_id AND gu.permission_value = 1 AND " .
+             "gu.permission_key IN ('$Param{Type}', 'rw') AND gu.group_id IN ($StringGroups)";
+         $Self->{DBObject}->Prepare(SQL => $SQL);
+         while (my @Row = $Self->{DBObject}->FetchrowArray()) {
+             push (@AllRoles, $Row[0]);
+         }
+         if (@AllRoles) {
+             # get all users of the roles
+             my $StringAllRoles = join (',', @AllRoles);
+             $SQL = "SELECT DISTINCT(ru.user_id) FROM role_user ru, roles r WHERE " .
+                 "r.valid_id in ($ValidID) AND r.id = ru.role_id AND ru.role_id IN ($StringAllRoles)";
+             $Self->{DBObject}->Prepare(SQL => $SQL);
+             while (my @Row = $Self->{DBObject}->FetchrowArray()) {
+                 $AllUsers{$Row[0]} = 1;
+             }
+         }
+     }
+ 
+     my @Return;
+     foreach (keys %AllUsers) {
+         push (@Return, $_);
+     }
+ 
+     return @Return;
+ }
+ 
  =item GroupGroupMemberList()
  
***************
*** 523,526 ****
--- 642,647 ----
    UserID: user id
    GroupID: group id
+   UserIDs: user ids (array ref)
+   GroupIDs: group ids (array ref)
  
    Type: ro|move_into|priority|create|rw
***************
*** 552,555 ****
--- 673,678 ----
      my $Self = shift;
      my %Param = @_;
+     my @UserIDs;
+     my @GroupIDs;
      # check needed stuff
      foreach (qw(Result Type)) {
***************
*** 559,564 ****
          }
      }
!     if (!$Param{UserID} && !$Param{GroupID}) {
!         $Self->{LogObject}->Log(Priority => 'error', Message => "Need UserID or GroupID!");
          return;
      }
--- 682,687 ----
          }
      }
!     if (!$Param{UserID} && !$Param{GroupID} && !$Param{UserIDs} && !$Param{GroupIDs}) {
!         $Self->{LogObject}->Log(Priority => 'error', Message => "Need UserID or GroupID or UserIDs or GroupIDs!");
          return;
      }
***************
*** 568,586 ****
          $CacheKey .= 'UserID::'.$Param{UserID};
      }
!     else {
          $CacheKey .= 'GroupID::'.$Param{GroupID};
      }
  #print STDERR "$CacheKey -\n";
      # check cache
  #$Param{Cached} = 1;
!     if ($Self->{ForceCache}) {
!         $Param{Cached} = $Self->{ForceCache};
!     }
!     if ($Param{Cached} && $Self->{$CacheKey}) {
!         if (ref($Self->{$CacheKey}) eq 'ARRAY') {
!             return @{$Self->{$CacheKey}};
!         }
!         elsif (ref($Self->{$CacheKey}) eq 'HASH') {
!             return %{$Self->{$CacheKey}};
          }
      }
--- 691,717 ----
          $CacheKey .= 'UserID::'.$Param{UserID};
      }
!     elsif ($Param{GroupID}) {
          $CacheKey .= 'GroupID::'.$Param{GroupID};
      }
+     elsif ($Param{UserIDs}) {
+         @UserIDs = sort(@{$Param{UserIDs}});
+     }
+     elsif ($Param{GroupIDs}) {
+         @GroupIDs = sort(@{$Param{GroupIDs}});
+     }
  #print STDERR "$CacheKey -\n";
      # check cache
  #$Param{Cached} = 1;
!     if ($Param{UserID} || $Param{GroupID}) {
!         if ($Self->{ForceCache}) {
!             $Param{Cached} = $Self->{ForceCache};
!         }
!         if ($Param{Cached} && $Self->{$CacheKey}) {
!             if (ref($Self->{$CacheKey}) eq 'ARRAY') {
!                 return @{$Self->{$CacheKey}};
!             }
!             elsif (ref($Self->{$CacheKey}) eq 'HASH') {
!                 return %{$Self->{$CacheKey}};
!             }
          }
      }
***************
*** 610,616 ****
          $SQL .= " gu.user_id = ".$Self->{DBObject}->Quote($Param{UserID}, 'Integer');
      }
!     else {
          $SQL .= " gu.group_id = ".$Self->{DBObject}->Quote($Param{GroupID}, 'Integer');
      }
  #print STDERR "SQL: $Param{Type}::$Param{Result} $SQL\n";
      $Self->{DBObject}->Prepare(SQL => $SQL);
--- 741,763 ----
          $SQL .= " gu.user_id = ".$Self->{DBObject}->Quote($Param{UserID}, 'Integer');
      }
!     elsif ($Param{GroupID}) {
          $SQL .= " gu.group_id = ".$Self->{DBObject}->Quote($Param{GroupID}, 'Integer');
      }
+     elsif ($Param{UserIDs}) {
+         my @UserIDsQuote;
+         foreach (@UserIDs) {
+             push (@UserIDsQuote, $Self->{DBObject}->Quote($_, 'Integer'));
+         }
+         my $UserString = join(',', @UserIDsQuote);
+         $SQL .= " ru.user_id IN ($UserString)";
+     }
+     elsif ($Param{GroupIDs}) {
+         my @GroupIDsQuote;
+         foreach (@GroupIDs) {
+             push (@GroupIDsQuote, $Self->{DBObject}->Quote($_, 'Integer'));
+         }
+         my $GroupString = join(',', @GroupIDsQuote);
+         $SQL .= " gu.group_id IN ($GroupString)";
+     }
  #print STDERR "SQL: $Param{Type}::$Param{Result} $SQL\n";
      $Self->{DBObject}->Prepare(SQL => $SQL);
***************
*** 618,622 ****
          my $Key = '';
          my $Value = '';
!         if ($Param{UserID}) {
              $Key = $Row[0];
              $Value = $Row[1];
--- 765,769 ----
          my $Key = '';
          my $Value = '';
!         if ($Param{UserID} || $Param{UserIDs}) {
              $Key = $Row[0];
              $Value = $Row[1];
***************
*** 637,652 ****
      # return result
      if ($Param{Result} && $Param{Result} eq 'ID') {
!         # cache result
!         $Self->{$CacheKey} = \@ID;
          return @ID;
      }
      if ($Param{Result} && $Param{Result} eq 'Name') {
!         # cache result
!         $Self->{$CacheKey} = \@Name;
          return @Name;
      }
      else {
!         # cache result
!         $Self->{$CacheKey} = \%Data;
          return %Data;
      }
--- 784,805 ----
      # return result
      if ($Param{Result} && $Param{Result} eq 'ID') {
!         if ($Param{UserID} || $Param{GroupID}) {
!             # cache result
!             $Self->{$CacheKey} = \@ID;
!         }
          return @ID;
      }
      if ($Param{Result} && $Param{Result} eq 'Name') {
!         if ($Param{UserID} || $Param{GroupID}) {
!             # cache result
!             $Self->{$CacheKey} = \@Name;
!         }
          return @Name;
      }
      else {
!         if ($Param{UserID} || $Param{GroupID}) {
!             # cache result
!             $Self->{$CacheKey} = \%Data;
!         }
          return %Data;
      }
***************
*** 659,662 ****
--- 812,817 ----
    RoleID: role id
    GroupID: group id
+   RoleIDs: role id (array ref)
+   GroupIDs: group id (array ref)
  
    Type: ro|move_into|priority|create|rw
***************
*** 688,691 ****
--- 843,848 ----
      my $Self = shift;
      my %Param = @_;
+     my @RoleIDs;
+     my @GroupIDs;
      # check needed stuff
      foreach (qw(Result Type)) {
***************
*** 695,700 ****
          }
      }
!     if (!$Param{RoleID} && !$Param{GroupID}) {
!         $Self->{LogObject}->Log(Priority => 'error', Message => "Need RoleID or GroupID!");
          return;
      }
--- 852,857 ----
          }
      }
!     if (!$Param{RoleID} && !$Param{GroupID} && !$Param{RoleIDs} && !$Param{GroupIDs}) {
!         $Self->{LogObject}->Log(Priority => 'error', Message => "Need RoleID or GroupID or RoleIDs or GroupIDs!");
          return;
      }
***************
*** 704,722 ****
          $CacheKey .= 'RoleID::'.$Param{RoleID};
      }
!     else {
          $CacheKey .= 'GroupID::'.$Param{GroupID};
      }
  #print STDERR "$CacheKey -\n";
      # check cache
  #$Param{Cached} = 1;
!     if ($Self->{ForceCache}) {
!         $Param{Cached} = $Self->{ForceCache};
!     }
!     if ($Param{Cached} && $Self->{$CacheKey}) {
!         if (ref($Self->{$CacheKey}) eq 'ARRAY') {
!             return @{$Self->{$CacheKey}};
!         }
!         elsif (ref($Self->{$CacheKey}) eq 'HASH') {
!             return %{$Self->{$CacheKey}};
          }
      }
--- 861,887 ----
          $CacheKey .= 'RoleID::'.$Param{RoleID};
      }
!     elsif ($Param{GroupID}) {
          $CacheKey .= 'GroupID::'.$Param{GroupID};
      }
+     elsif ($Param{RoleIDs}) {
+         @RoleIDs = sort(@{$Param{RoleIDs}});
+     }
+     elsif ($Param{GroupIDs}) {
+         @GroupIDs = sort(@{$Param{GroupIDs}});
+     }
  #print STDERR "$CacheKey -\n";
      # check cache
  #$Param{Cached} = 1;
!     if ($Param{RoleID} || $Param{GroupID}) {
!         if ($Self->{ForceCache}) {
!             $Param{Cached} = $Self->{ForceCache};
!         }
!         if ($Param{Cached} && $Self->{$CacheKey}) {
!             if (ref($Self->{$CacheKey}) eq 'ARRAY') {
!                 return @{$Self->{$CacheKey}};
!             }
!             elsif (ref($Self->{$CacheKey}) eq 'HASH') {
!                 return %{$Self->{$CacheKey}};
!             }
          }
      }
***************
*** 746,752 ****
          $SQL .= " gu.role_id = ".$Self->{DBObject}->Quote($Param{RoleID}, 'Integer');
      }
!     else {
          $SQL .= " gu.group_id = ".$Self->{DBObject}->Quote($Param{GroupID}, 'Integer');
      }
  #print STDERR "SQL: $Param{Type}::$Param{Result} $SQL\n";
      $Self->{DBObject}->Prepare(SQL => $SQL);
--- 911,933 ----
          $SQL .= " gu.role_id = ".$Self->{DBObject}->Quote($Param{RoleID}, 'Integer');
      }
!     elsif ($Param{GroupID}) {
          $SQL .= " gu.group_id = ".$Self->{DBObject}->Quote($Param{GroupID}, 'Integer');
      }
+     elsif ($Param{RoleIDs}) {
+         my @RoleIDsQuote;
+         foreach (@RoleIDs) {
+             push (@RoleIDsQuote, $Self->{DBObject}->Quote($_, 'Integer'));
+         }
+         my $RoleString = join(',', @RoleIDsQuote);
+         $SQL .= " gu.role_id IN ($RoleString)";
+     }
+     elsif ($Param{GroupIDs}) {
+         my @GroupIDsQuote;
+         foreach (@GroupIDs) {
+             push (@GroupIDsQuote, $Self->{DBObject}->Quote($_, 'Integer'));
+         }
+         my $GroupString = join(',', @GroupIDsQuote);
+         $SQL .= " gu.group_id IN ($GroupString)";
+     }
  #print STDERR "SQL: $Param{Type}::$Param{Result} $SQL\n";
      $Self->{DBObject}->Prepare(SQL => $SQL);
***************
*** 754,758 ****
          my $Key = '';
          my $Value = '';
!         if ($Param{RoleID}) {
              $Key = $Row[0];
              $Value = $Row[1];
--- 935,939 ----
          my $Key = '';
          my $Value = '';
!         if ($Param{RoleID} || $Param{RoleIDs}) {
              $Key = $Row[0];
              $Value = $Row[1];
***************
*** 773,788 ****
      # return result
      if ($Param{Result} && $Param{Result} eq 'ID') {
!         # cache result
!         $Self->{$CacheKey} = \@ID;
          return @ID;
      }
      if ($Param{Result} && $Param{Result} eq 'Name') {
!         # cache result
!         $Self->{$CacheKey} = \@Name;
          return @Name;
      }
      else {
!         # cache result
!         $Self->{$CacheKey} = \%Data;
          return %Data;
      }
--- 954,975 ----
      # return result
      if ($Param{Result} && $Param{Result} eq 'ID') {
!         if ($Param{RoleID} || $Param{GroupID}) {
!             # cache result
!             $Self->{$CacheKey} = \@ID;
!         }
          return @ID;
      }
      if ($Param{Result} && $Param{Result} eq 'Name') {
!         if ($Param{RoleID} || $Param{GroupID}) {
!             # cache result
!             $Self->{$CacheKey} = \@Name;
!         }
          return @Name;
      }
      else {
!         if ($Param{RoleID} || $Param{GroupID}) {
!             # cache result
!             $Self->{$CacheKey} = \%Data;
!         }
          return %Data;
      }
***************
*** 888,891 ****
--- 1075,1080 ----
    RoleID: role id
    UserID: user id
+   RoleIDs: role ids (array ref)
+   UserIDs: user ids (array ref)
  
  
***************
*** 913,916 ****
--- 1102,1107 ----
      my $Self = shift;
      my %Param = @_;
+     my @RoleIDs;
+     my @UserIDs;
      # check needed stuff
      foreach (qw(Result)) {
***************
*** 920,925 ****
          }
      }
!     if (!$Param{RoleID} && !$Param{UserID}) {
!         $Self->{LogObject}->Log(Priority => 'error', Message => "Need RoleID or UserID!");
          return;
      }
--- 1111,1116 ----
          }
      }
!     if (!$Param{RoleID} && !$Param{UserID} && !$Param{RoleIDs} && !$Param{UserIDs}) {
!         $Self->{LogObject}->Log(Priority => 'error', Message => "Need RoleID or UserID or RoleIDs or UserIDs!");
          return;
      }
***************
*** 936,954 ****
          $CacheKey .= 'RoleID::'.$Param{RoleID};
      }
!     else {
          $CacheKey .= 'UserID::'.$Param{UserID};
      }
  #print STDERR "$CacheKey -\n";
      # check cache
  #$Param{Cached} = 1;
!     if ($Self->{ForceCache}) {
!          $Param{Cached} = $Self->{ForceCache};
!     }
!     if ($Param{Cached} && $Self->{$CacheKey}) {
!         if (ref($Self->{$CacheKey}) eq 'ARRAY') {
!             return @{$Self->{$CacheKey}};
!         }
!         elsif (ref($Self->{$CacheKey}) eq 'HASH') {
!             return %{$Self->{$CacheKey}};
          }
      }
--- 1127,1153 ----
          $CacheKey .= 'RoleID::'.$Param{RoleID};
      }
!     elsif ($Param{UserID}) {
          $CacheKey .= 'UserID::'.$Param{UserID};
      }
+     elsif ($Param{RoleIDs}) {
+         @RoleIDs = sort(@{$Param{RoleIDs}});
+     }
+     elsif ($Param{UserIDs}) {
+         @UserIDs = sort(@{$Param{UserIDs}});
+     }
  #print STDERR "$CacheKey -\n";
      # check cache
  #$Param{Cached} = 1;
!     if ($Param{RoleID} || $Param{UserID}) {
!         if ($Self->{ForceCache}) {
!              $Param{Cached} = $Self->{ForceCache};
!         }
!         if ($Param{Cached} && $Self->{$CacheKey}) {
!             if (ref($Self->{$CacheKey}) eq 'ARRAY') {
!                 return @{$Self->{$CacheKey}};
!             }
!             elsif (ref($Self->{$CacheKey}) eq 'HASH') {
!                 return %{$Self->{$CacheKey}};
!             }
          }
      }
***************
*** 969,975 ****
          $SQL .= " ru.role_id = $Param{RoleID}";
      }
!     else {
          $SQL .= " ru.user_id = $Param{UserID}";
      }
  #print STDERR "SQL: $Param{Result} $SQL\n";
      $Self->{DBObject}->Prepare(SQL => $SQL);
--- 1168,1190 ----
          $SQL .= " ru.role_id = $Param{RoleID}";
      }
!     elsif ($Param{UserID}) {
          $SQL .= " ru.user_id = $Param{UserID}";
      }
+     elsif ($Param{RoleIDs}) {
+         my @RoleIDsQuote;
+         foreach (@RoleIDs) {
+             push (@RoleIDsQuote, $Self->{DBObject}->Quote($_, 'Integer'));
+         }
+         my $RoleString = join(',', @RoleIDsQuote);
+         $SQL .= " ru.role_id IN ($RoleString)";
+     }
+     elsif ($Param{UserIDs}) {
+         my @UserIDsQuote;
+         foreach (@UserIDs) {
+             push (@UserIDsQuote, $Self->{DBObject}->Quote($_, 'Integer'));
+         }
+         my $UserString = join(',', @UserIDsQuote);
+         $SQL .= " ru.user_id IN ($UserString)";
+     }
  #print STDERR "SQL: $Param{Result} $SQL\n";
      $Self->{DBObject}->Prepare(SQL => $SQL);
***************
*** 977,981 ****
          my $Key = '';
          my $Value = '';
!         if ($Param{RoleID}) {
              $Key = $Row[1];
              $Value = $Row[0];
--- 1192,1196 ----
          my $Key = '';
          my $Value = '';
!         if ($Param{RoleID} || $Param{RoleIDs}) {
              $Key = $Row[1];
              $Value = $Row[0];
***************
*** 996,1011 ****
      # return result
      if ($Param{Result} && $Param{Result} eq 'ID') {
!         # cache result
!         $Self->{$CacheKey} = \@ID;
          return @ID;
      }
      if ($Param{Result} && $Param{Result} eq 'Name') {
!         # cache result
!         $Self->{$CacheKey} = \@Name;
          return @Name;
      }
      else {
!         # cache result
!         $Self->{$CacheKey} = \%Data;
          return %Data;
      }
--- 1211,1232 ----
      # return result
      if ($Param{Result} && $Param{Result} eq 'ID') {
!         if ($Param{RoleID} || $Param{UserID}) {
!             # cache result
!             $Self->{$CacheKey} = \@ID;
!         }
          return @ID;
      }
      if ($Param{Result} && $Param{Result} eq 'Name') {
!         if ($Param{RoleID} || $Param{UserID}) {
!             # cache result
!             $Self->{$CacheKey} = \@Name;
!         }
          return @Name;
      }
      else {
!         if ($Param{RoleID} || $Param{UserID}) {
!             # cache result
!             $Self->{$CacheKey} = \%Data;
!         }
          return %Data;
      }



More information about the cvs-log mailing list