[Rt-commit] rt branch, 4.2/deprecate-type-column-in-groups, created. rt-4.1.8-150-g2834875
Ruslan Zakirov
ruz at bestpractical.com
Thu Apr 18 09:26:07 EDT 2013
The branch, 4.2/deprecate-type-column-in-groups has been created
at 2834875149330373042edfd9e3f1c5dc4a37a831 (commit)
- Log -----------------------------------------------------------------
commit 2834875149330373042edfd9e3f1c5dc4a37a831
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Apr 15 20:40:41 2013 +0400
stab
diff --git a/etc/upgrade/4.1.4/content b/etc/upgrade/4.1.4/content
index b3f59f6..b320695 100644
--- a/etc/upgrade/4.1.4/content
+++ b/etc/upgrade/4.1.4/content
@@ -11,7 +11,7 @@ push @Final, sub {
my $group = RT::Group->new( RT->SystemUser );
my ($ok, $msg) = $group->LoadRoleGroup(
Object => RT->System,
- Type => $role,
+ Name => $role,
);
unless ($group->id) {
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index 11f7e66..57d041d 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -190,23 +190,23 @@ sub SelfDescription {
return $self->loc("group '[_1]'",$self->Name);
}
elsif ($self->Domain eq 'RT::System-Role') {
- return $self->loc("system [_1]",$self->Type);
+ return $self->loc("system [_1]",$self->Name);
}
elsif ($self->Domain eq 'RT::Queue-Role') {
my $queue = RT::Queue->new($self->CurrentUser);
$queue->Load($self->Instance);
- return $self->loc("queue [_1] [_2]",$queue->Name, $self->Type);
+ return $self->loc("queue [_1] [_2]",$queue->Name, $self->Name);
}
elsif ($self->Domain eq 'RT::Ticket-Role') {
- return $self->loc("ticket #[_1] [_2]",$self->Instance, $self->Type);
+ return $self->loc("ticket #[_1] [_2]",$self->Instance, $self->Name);
}
elsif ($self->RoleClass) {
my $class = lc $self->RoleClass;
$class =~ s/^RT:://i;
- return $self->loc("[_1] #[_2] [_3]", $self->loc($class), $self->Instance, $self->Type);
+ return $self->loc("[_1] #[_2] [_3]", $self->loc($class), $self->Instance, $self->Name);
}
elsif ($self->Domain eq 'SystemInternal') {
- return $self->loc("system group '[_1]'",$self->Type);
+ return $self->loc("system group '[_1]'",$self->Name);
}
else {
return $self->loc("undescribed group [_1]",$self->Id);
@@ -283,7 +283,7 @@ sub LoadACLEquivalenceGroup {
return $self->LoadByCols(
Domain => 'ACLEquivalence',
- Type => 'UserEquiv',
+ Name => 'UserEquiv',
Instance => $principal,
);
}
@@ -305,13 +305,13 @@ sub LoadSystemInternalGroup {
return $self->LoadByCols(
Domain => 'SystemInternal',
- Type => $identifier,
+ Name => $identifier,
);
}
=head2 LoadRoleGroup
-Takes a paramhash of Object and Type and attempts to load the suitable role
+Takes a paramhash of Object and Name and attempts to load the suitable role
group for said object.
=cut
@@ -320,7 +320,7 @@ sub LoadRoleGroup {
my $self = shift;
my %args = (
Object => undef,
- Type => undef,
+ Name => undef,
@_
);
@@ -337,7 +337,7 @@ sub LoadRoleGroup {
}
-=head2 LoadTicketRoleGroup { Ticket => TICKET_ID, Type => TYPE }
+=head2 LoadTicketRoleGroup { Ticket => TICKET_ID, Name => TYPE }
Deprecated in favor of L</LoadRoleGroup> or L<RT::Record/RoleGroup>.
@@ -347,17 +347,18 @@ sub LoadTicketRoleGroup {
my $self = shift;
my %args = (
Ticket => '0',
- Type => undef,
+ Name => undef,
@_,
);
RT->Deprecated(
Instead => "RT::Group->LoadRoleGroup or RT::Ticket->RoleGroup",
Remove => "4.4",
);
+ $args{'Name'} = $args{'Type'} if exists $args{'Type'};
$self->LoadByCols(
Domain => 'RT::Ticket-Role',
Instance => $args{'Ticket'},
- Type => $args{'Type'},
+ Name => $args{'Name'},
);
}
@@ -373,23 +374,24 @@ sub LoadQueueRoleGroup {
my $self = shift;
my %args = (
Queue => undef,
- Type => undef,
+ Name => undef,
@_,
);
RT->Deprecated(
Instead => "RT::Group->LoadRoleGroup or RT::Queue->RoleGroup",
Remove => "4.4",
);
+ $args{'Name'} = $args{'Type'} if exists $args{'Type'};
$self->LoadByCols(
Domain => 'RT::Queue-Role',
Instance => $args{'Queue'},
- Type => $args{'Type'},
+ Name => $args{'Name'},
);
}
-=head2 LoadSystemRoleGroup Type
+=head2 LoadSystemRoleGroup Name
Deprecated in favor of L</LoadRoleGroup> or L<RT::Record/RoleGroup>.
@@ -404,10 +406,20 @@ sub LoadSystemRoleGroup {
);
$self->LoadByCols(
Domain => 'RT::System-Role',
- Type => $type
+ Name => $type
);
}
+sub LoadByCols {
+ my $self = shift;
+ my %args = ( @_ );
+ if ( exists $args{'Type'} ) {
+ RT->Logger->warning("Type is deprecated in favor of Name" . Carp::longmess("boo"));
+ $args{'Name'} = $args{'Type'};
+ }
+ return $self->SUPER::LoadByCols( %args );
+}
+
=head2 Create
@@ -439,12 +451,17 @@ sub _Create {
Name => undef,
Description => undef,
Domain => undef,
- Type => undef,
Instance => '0',
InsideTransaction => undef,
_RecordTransaction => 1,
@_
);
+ if ( $args{'Type'} ) {
+ RT->Logger->warning("Type is deprecated in favor of Name" . Carp::longmess("boo"));
+ $args{'Name'} = $args{'Type'};
+ } else {
+ $args{'Type'} = $args{'Name'};
+ }
# Enforce uniqueness on user defined group names
if ($args{'Domain'} and $args{'Domain'} eq 'UserDefined') {
@@ -522,7 +539,7 @@ sub CreateUserDefinedGroup {
return ( 0, $self->loc('Permission Denied') );
}
- return($self->_Create( Domain => 'UserDefined', Type => '', Instance => '', @_));
+ return($self->_Create( Domain => 'UserDefined', Instance => '', @_));
}
=head2 ValidateName VALUE
@@ -576,8 +593,7 @@ sub _CreateACLEquivalenceGroup {
my $princ = shift;
my $id = $self->_Create( Domain => 'ACLEquivalence',
- Type => 'UserEquiv',
- Name => 'User '. $princ->Object->Id,
+ Name => 'UserEquiv',
Description => 'ACL equiv. for user '.$princ->Object->Id,
Instance => $princ->Id,
InsideTransaction => 1,
@@ -617,7 +633,7 @@ Takes a paramhash of:
=over 4
-=item Type
+=item Name
Required. RT's core role types are C<Requestor>, C<Cc>, C<AdminCc>, and
C<Owner>. Extensions may add their own.
@@ -660,7 +676,7 @@ Message should contain an error string.
sub CreateRoleGroup {
my $self = shift;
my %args = ( Instance => undef,
- Type => undef,
+ Name => undef,
Domain => undef,
Object => undef,
InsideTransaction => 1,
@@ -678,10 +694,10 @@ sub CreateRoleGroup {
}
unless ($self->ValidateRoleGroup(%args)) {
- return ( 0, $self->loc("Invalid Group Type and Domain") );
+ return ( 0, $self->loc("Invalid Group Name and Domain") );
}
- my %create = map { $_ => $args{$_} } qw(Domain Instance Type);
+ my %create = map { $_ => $args{$_} } qw(Domain Instance Name);
my $duplicate = RT::Group->new( RT->SystemUser );
$duplicate->LoadByCols( %create );
@@ -725,12 +741,12 @@ registered role on the specified Domain. Otherwise returns false.
sub ValidateRoleGroup {
my $self = shift;
my %args = (@_);
- return 0 unless $args{Domain} and $args{Type};
+ return 0 unless $args{Domain} and ($args{Type} or $args{'Name'});
my $class = $self->RoleClass($args{Domain});
return 0 unless $class;
- return $class->HasRole($args{Type});
+ return $class->HasRole($args{Type}||$args{'Name'});
}
=head2 SingleMemberRoleGroup
@@ -741,7 +757,7 @@ sub SingleMemberRoleGroup {
my $self = shift;
my $class = $self->RoleClass;
return unless $class;
- return $class->Role($self->Type)->{Single};
+ return $class->Role($self->Name)->{Single};
}
sub SingleMemberRoleGroupColumn {
@@ -749,7 +765,7 @@ sub SingleMemberRoleGroupColumn {
my ($class) = $self->Domain =~ /^(.+)-Role$/;
return unless $class;
- my $role = $class->Role($self->Type);
+ my $role = $class->Role($self->Name);
return unless $role->{Class} eq $class;
return $role->{Column};
}
@@ -763,6 +779,33 @@ sub RoleGroupObject {
return $obj;
}
+sub Type {
+ my $self = shift;
+ RT->Logger->warning("Type is deprecated in favor of Name" . Carp::longmess("boo"));
+ return $self->Name(@_);
+}
+
+sub SetType {
+ my $self = shift;
+ RT->Logger->warning("Type is deprecated in favor of Name" . Carp::longmess("boo"));
+ return $self->SetName(@_);
+}
+
+sub SetName {
+ my $self = shift;
+ my $value = shift;
+
+ my ($status, $msg) = $self->_Set( Field => 'Name', Value => $value );
+ return ($status, $msg) unless $status;
+
+ {
+ my ($status, $msg) = $self->__Set( Field => 'Type', Value => $value );
+ RT->Logger->error("Couldn't set Type: $msg") unless $status;
+ }
+
+ return ($status, $msg);
+}
+
=head2 Delete
Delete this object
@@ -1142,13 +1185,13 @@ sub _AddMember {
Type => 'SetWatcher',
OldValue => $old_member_id,
NewValue => $new_member_obj->Id,
- Field => $self->Type,
+ Field => $self->Name,
);
} else {
$obj->_NewTransaction(
Type => 'AddWatcher', # use "watcher" for history's sake
NewValue => $new_member_obj->Id,
- Field => $self->Type,
+ Field => $self->Name,
);
}
}
@@ -1311,7 +1354,7 @@ sub _DeleteMember {
if ($self->RoleClass) {
my %txn = (
OldValue => $old_member,
- Field => $self->Type,
+ Field => $self->Name,
);
if ($self->SingleMemberRoleGroup) {
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index a546f17..6f2272f 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -671,10 +671,9 @@ sub InsertInitialData {
$group = RT::Group->new( RT->SystemUser );
my ( $val, $msg ) = $group->_Create(
- Type => $name,
Domain => 'SystemInternal',
Description => 'Pseudogroup for internal use', # loc
- Name => '',
+ Name => $name,
Instance => '',
);
return ($val, $msg) unless $val;
@@ -722,7 +721,7 @@ sub InsertInitialData {
$group = RT::Group->new( RT->SystemUser );
my ( $val, $msg ) = $group->CreateRoleGroup(
- Type => $name,
+ Name => $name,
Object => RT->System,
Description => 'SystemRolegroup for internal use', # loc
InsideTransaction => 0,
@@ -973,11 +972,11 @@ sub InsertData {
} elsif ( $item->{'GroupDomain'} eq 'SystemInternal' ) {
$princ->LoadSystemInternalGroup( $item->{'GroupType'} );
} elsif ( $item->{'GroupDomain'} eq 'RT::System-Role' ) {
- $princ->LoadRoleGroup( Object => RT->System, Type => $item->{'GroupType'} );
+ $princ->LoadRoleGroup( Object => RT->System, Name => $item->{'GroupType'} );
} elsif ( $item->{'GroupDomain'} eq 'RT::Queue-Role' &&
$item->{'Queue'} )
{
- $princ->LoadRoleGroup( Object => $object, Type => $item->{'GroupType'} );
+ $princ->LoadRoleGroup( Object => $object, Name => $item->{'GroupType'} );
} else {
$princ->Load( $item->{'GroupId'} );
}
diff --git a/lib/RT/Record/Role/Roles.pm b/lib/RT/Record/Role/Roles.pm
index 2d2c8e9..6b27623 100644
--- a/lib/RT/Record/Role/Roles.pm
+++ b/lib/RT/Record/Role/Roles.pm
@@ -293,13 +293,13 @@ L<RT::Group> object on failure.
sub RoleGroup {
my $self = shift;
- my $type = shift;
+ my $name = shift;
my $group = RT::Group->new( $self->CurrentUser );
- if ($self->HasRole($type)) {
+ if ($self->HasRole($name)) {
$group->LoadRoleGroup(
Object => $self,
- Type => $type,
+ Name => $name,
);
}
return $group;
@@ -567,15 +567,15 @@ sub _ResolveRoles {
sub _CreateRoleGroups {
my $self = shift;
my %args = (@_);
- for my $type ($self->Roles) {
+ for my $name ($self->Roles) {
my $type_obj = RT::Group->new($self->CurrentUser);
my ($id, $msg) = $type_obj->CreateRoleGroup(
- Type => $type,
+ Name => $name,
Object => $self,
%args,
);
unless ($id) {
- $RT::Logger->error("Couldn't create a role group of type '$type' for ".ref($self)." ".
+ $RT::Logger->error("Couldn't create a role group of type '$name' for ".ref($self)." ".
$self->id.": ".$msg);
return(undef);
}
diff --git a/lib/RT/Shredder/GroupMember.pm b/lib/RT/Shredder/GroupMember.pm
index 9495ff5..ab34537 100644
--- a/lib/RT/Shredder/GroupMember.pm
+++ b/lib/RT/Shredder/GroupMember.pm
@@ -87,7 +87,7 @@ sub __DependsOn
my $group = $self->GroupObj->Object;
# XXX: If we delete member of the ticket owner role group then we should also
# fix ticket object, but only if we don't plan to delete group itself!
- unless( ($group->Type || '') eq 'Owner' &&
+ unless( ($group->Name || '') eq 'Owner' &&
($group->Domain || '') eq 'RT::Ticket-Role' ) {
return $self->SUPER::__DependsOn( %args );
}
@@ -106,7 +106,7 @@ sub __DependsOn
my %args = (@_);
my $group = $args{'TargetObject'};
return if $args{'Shredder'}->GetState( Object => $group ) & (WIPED|IN_WIPING);
- return unless ($group->Type || '') eq 'Owner';
+ return unless ($group->Name || '') eq 'Owner';
return unless ($group->Domain || '') eq 'RT::Ticket-Role';
return if $group->MembersObj->Count > 1;
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 97ab94a..4496d05 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -919,7 +919,7 @@ sub store_rights {
my @res;
while ( my $ace = $acl->Next ) {
my $obj = $ace->PrincipalObj->Object;
- if ( $obj->isa('RT::Group') && $obj->Type eq 'UserEquiv' && $obj->Instance == RT->Nobody->id ) {
+ if ( $obj->isa('RT::Group') && $obj->Domain eq 'ACLEquivalence' && $obj->Instance == RT->Nobody->id ) {
next;
}
@@ -952,7 +952,7 @@ sub set_rights {
$acl->Limit( FIELD => 'RightName', OPERATOR => '!=', VALUE => 'SuperUser' );
while ( my $ace = $acl->Next ) {
my $obj = $ace->PrincipalObj->Object;
- if ( $obj->isa('RT::Group') && $obj->Type eq 'UserEquiv' && $obj->Instance == RT->Nobody->id ) {
+ if ( $obj->isa('RT::Group') && $obj->Domain eq 'ACLEquivalence' && $obj->Instance == RT->Nobody->id ) {
next;
}
$ace->Delete;
@@ -976,7 +976,7 @@ sub add_rights {
$principal = RT::Group->new( RT->SystemUser );
$principal->LoadRoleGroup(
Object => ($e->{'Object'} || RT->System),
- Type => $type
+ Name => $type
);
}
die "Principal is not an object nor the name of a system or role group"
diff --git a/share/html/Elements/ShowMemberships b/share/html/Elements/ShowMemberships
index 0dbe67c..1985302 100644
--- a/share/html/Elements/ShowMemberships
+++ b/share/html/Elements/ShowMemberships
@@ -52,7 +52,7 @@
% if ($Group->Domain eq 'UserDefined') {
<li><a href="<%RT->Config->Get('WebPath')%>/Admin/Groups/Modify.html?id=<% $Group->Id %>"><% $Group->Name %></a></li>
% } elsif ($Group->Domain eq 'SystemInternal') {
-<li><em><% loc($Group->Type) %></em></li>
+<li><em><% loc($Group->Name) %></em></li>
% }
% }
</ul>
diff --git a/t/api/system-available-rights.t b/t/api/system-available-rights.t
index 9c374d6..d7b6f5e 100644
--- a/t/api/system-available-rights.t
+++ b/t/api/system-available-rights.t
@@ -12,7 +12,7 @@ local $SIG{__WARN__} = sub {
my $requestor = RT::Group->new( RT->SystemUser );
$requestor->LoadRoleGroup(
Object => RT->System,
- Type => "Requestor",
+ Name => "Requestor",
);
ok $requestor->id, "Loaded global requestor role group";
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list