This commit was generated by cvs2svn to compensate for changes in r3921,
[freeside.git] / rt / lib / RT / Group_Overlay.pm
index 9215025..69ada31 100644 (file)
@@ -1,8 +1,15 @@
-# BEGIN LICENSE BLOCK
+
+# {{{ BEGIN BPS TAGGED BLOCK
+# 
+# COPYRIGHT:
+#  
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
+#                                          <jesse@bestpractical.com>
+# 
+# (Except where explicitly superseded by other copyright notices)
 # 
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
 # 
-# (Except where explictly superceded by other copyright notices)
+# LICENSE:
 # 
 # This work is made available to you under the terms of Version 2 of
 # the GNU General Public License. A copy of that license should have
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # General Public License for more details.
 # 
-# Unless otherwise specified, all modifications, corrections or
-# extensions to this work which alter its source code become the
-# property of Best Practical Solutions, LLC when submitted for
-# inclusion in the work.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# 
+# 
+# CONTRIBUTION SUBMISSION POLICY:
+# 
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
 # 
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
 # 
-# END LICENSE BLOCK
+# }}} END BPS TAGGED BLOCK
 # Released under the terms of version 2 of the GNU Public License
 
 =head1 NAME
@@ -145,7 +168,9 @@ $RIGHTS = {
     AdminGroup           => 'Modify group metadata or delete group',  # loc_pair
     AdminGroupMembership =>
       'Modify membership roster for this group',                      # loc_pair
-    ModifyOwnMembership => 'Join or leave this group'                 # loc_pair
+    ModifyOwnMembership => 'Join or leave this group',                 # loc_pair
+    EditSavedSearches => 'Edit saved searches for this group',        # loc_pair
+    ShowSavedSearches => 'Display saved searches for this group',        # loc_pair
 };
 
 # Tell RT::ACE that this sort of object can get acls granted
@@ -327,8 +352,6 @@ sub LoadSystemInternalGroup {
     my $identifier = shift;
 
         $self->LoadByCols( "Domain" => 'SystemInternal',
-                           "Instance" => '',
-                           "Name" => '',
                            "Type" => $identifier );
 }
 
@@ -350,7 +373,7 @@ Takes a param hash with 2 parameters:
 
 sub LoadTicketRoleGroup {
     my $self       = shift;
-    my %args = (Ticket => undef,
+    my %args = (Ticket => '0',
                 Type => undef,
                 @_);
         $self->LoadByCols( Domain => 'RT::Ticket-Role',
@@ -444,7 +467,7 @@ sub _Create {
         Description => undef,
         Domain      => undef,
         Type        => undef,
-        Instance    => undef,
+        Instance    => '0',
         InsideTransaction => undef,
         @_
     );
@@ -466,7 +489,7 @@ sub _Create {
         Description => $args{'Description'},
         Type        => $args{'Type'},
         Domain      => $args{'Domain'},
-        Instance    => $args{'Instance'}
+        Instance    => ($args{'Instance'} || '0')
     );
     my $id = $self->Id;
     unless ($id) {
@@ -798,22 +821,14 @@ sub UserMembersObj {
     #If we don't have rights, don't include any results
     # TODO XXX  WHY IS THERE NO ACL CHECK HERE?
 
-    my $principals = $users->NewAlias('Principals');
-
-    $users->Join(ALIAS1 => 'main', FIELD1 => 'id',
-                 ALIAS2 => $principals, FIELD2 => 'ObjectId');
-    $users->Limit(ALIAS =>$principals,
-                  FIELD => 'PrincipalType', OPERATOR => '=', VALUE => 'User');
-
     my $cached_members = $users->NewAlias('CachedGroupMembers');
     $users->Join(ALIAS1 => $cached_members, FIELD1 => 'MemberId',
-                 ALIAS2 => $principals, FIELD2 => 'id');
+                 ALIAS2 => $users->PrincipalsAlias, FIELD2 => 'id');
     $users->Limit(ALIAS => $cached_members, 
                   FIELD => 'GroupId',
                   OPERATOR => '=',
                   VALUE => $self->PrincipalId);
 
-
     return ( $users);
 
 }
@@ -1009,6 +1024,10 @@ sub HasMember {
         return(undef);
     }
 
+    unless ($principal->Id) {
+        return(undef);
+    }
+
     my $member_obj = RT::GroupMember->new( $self->CurrentUser );
     $member_obj->LoadByCols( MemberId => $principal->id, 
                              GroupId => $self->PrincipalId );