[Rt-commit] r2601 - rt/branches/3.4-RELEASE/lib/RT

tla at bestpractical.com tla at bestpractical.com
Sun Apr 10 19:49:31 EDT 2005


Author: tla
Date: Sun Apr 10 19:49:31 2005
New Revision: 2601

Modified:
   rt/branches/3.4-RELEASE/lib/RT/CustomFields_Overlay.pm
   rt/branches/3.4-RELEASE/lib/RT/Record.pm
   rt/branches/3.4-RELEASE/lib/RT/User_Overlay.pm
Log:
User_Overlay: added OwnGroups method to get a collection of groups of which
the user is a member.
Record: revamped ObjectTypeStr according to suggestions.



Modified: rt/branches/3.4-RELEASE/lib/RT/CustomFields_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/CustomFields_Overlay.pm	(original)
+++ rt/branches/3.4-RELEASE/lib/RT/CustomFields_Overlay.pm	Sun Apr 10 19:49:31 2005
@@ -69,6 +69,7 @@
 
 use strict;
 no warnings qw(redefine);
+use DBIx::SearchBuilder::Unique;
 
 
 sub _OCFAlias {

Modified: rt/branches/3.4-RELEASE/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Record.pm	(original)
+++ rt/branches/3.4-RELEASE/lib/RT/Record.pm	Sun Apr 10 19:49:31 2005
@@ -142,9 +142,11 @@
 
 sub ObjectTypeStr {
     my $self = shift;
-    my $type = ref($self);
-    $type =~ s/^.*::(\w+)$/$1/;
-    return $type;
+    if (ref($self) =~ /^.*::(\w+)$/) {
+	return $self->loc($1);
+    } else {
+	return $self->loc(ref($self));
+    }
 }
 
 =head2 Attributes

Modified: rt/branches/3.4-RELEASE/lib/RT/User_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/User_Overlay.pm	(original)
+++ rt/branches/3.4-RELEASE/lib/RT/User_Overlay.pm	Sun Apr 10 19:49:31 2005
@@ -1265,6 +1265,26 @@
 
 # }}}
 
+# {{{ sub OwnGroups 
+
+=head2 OwnGroups
+
+Returns a group collection object containing the groups of which this
+user is a member.
+
+=cut
+
+sub OwnGroups {
+    my $self = shift;
+    my $groups = RT::Groups->new($self->CurrentUser);
+    $groups->LimitToUserDefinedGroups;
+    $groups->WithMember(PrincipalId => $self->Id, 
+			Recursively => 1);
+    return $groups;
+}
+
+# }}}
+
 # {{{ sub Rights testing
 
 =head2 Rights testing


More information about the Rt-commit mailing list