[Rt-commit] rt branch, 4.2/remove-attributes-withid, created. rt-4.0.1-240-g5c02e40
Alex Vandiver
alexmv at bestpractical.com
Fri Jul 22 16:06:15 EDT 2011
The branch, 4.2/remove-attributes-withid has been created
at 5c02e409b6369ab6a2ad9557dd51a0a015951955 (commit)
- Log -----------------------------------------------------------------
commit 5c02e409b6369ab6a2ad9557dd51a0a015951955
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Jul 22 16:05:49 2011 -0400
Replace RT::Attributes->WithId with the clearer ->new and ->Load
Having an RT::Attributes method which ignores all properties of the
collection, and returns a single unrelated item is rather odd. Use the
straightforward ->new and ->Load() instead.
diff --git a/lib/RT/Attributes.pm b/lib/RT/Attributes.pm
index e9f8bc5..2cacbd5 100644
--- a/lib/RT/Attributes.pm
+++ b/lib/RT/Attributes.pm
@@ -140,23 +140,6 @@ sub Named {
return (@attributes);
}
-=head2 WithId ID
-
-Returns the RT::Attribute objects with the id ID
-
-XXX TODO XXX THIS NEEDS A BETTER ACL CHECK
-
-=cut
-
-sub WithId {
- my $self = shift;
- my $id = shift;
-
- my $attr = RT::Attribute->new($self->CurrentUser);
- $attr->LoadByCols( id => $id );
- return($attr);
-}
-
=head2 DeleteEntry { Name => Content => , id => }
Deletes attributes with
diff --git a/lib/RT/SharedSetting.pm b/lib/RT/SharedSetting.pm
index a9bcc61..ef1571c 100644
--- a/lib/RT/SharedSetting.pm
+++ b/lib/RT/SharedSetting.pm
@@ -103,7 +103,8 @@ sub Load {
my $object = $self->_GetObject($privacy);
if ($object) {
- $self->{'Attribute'} = $object->Attributes->WithId($id);
+ $self->{'Attribute'} = RT::Attribute->new($self->CurrentUser);
+ $self->{'Attribute'}->Load( $id );
if ($self->{'Attribute'}->Id) {
$self->{'Id'} = $self->{'Attribute'}->Id;
$self->{'Privacy'} = $privacy;
@@ -207,7 +208,8 @@ sub Save {
my ($att_id, $att_msg) = $self->SaveAttribute($object, \%args);
if ($att_id) {
- $self->{'Attribute'} = $object->Attributes->WithId($att_id);
+ $self->{'Attribute'} = RT::Attribute->new($self->CurrentUser);
+ $self->{'Attribute'}->Load( $att_id );
$self->{'Id'} = $att_id;
$self->{'Privacy'} = $privacy;
return ( 1, $self->loc( "Saved [_1] [_2]", $self->ObjectName, $name ) );
diff --git a/share/html/Elements/ShowSearch b/share/html/Elements/ShowSearch
index 9d8dcf3..64f3f13 100644
--- a/share/html/Elements/ShowSearch
+++ b/share/html/Elements/ShowSearch
@@ -67,7 +67,8 @@ if ($SavedSearch) {
$m->out(loc("Either you have no rights to view saved search [_1] or identifier is incorrect", $SavedSearch));
return;
}
- $search = $container_object->Attributes->WithId($search_id);
+ $search = RT::Attribute->new( $session{'CurrentUser'} );
+ $search->Load($search_id);
unless ( $search->Id && ref( $SearchArg = $search->Content ) eq 'HASH' ) {
$m->out(loc("Saved search [_1] not found", $SavedSearch)) unless $IgnoreMissing;
return;
diff --git a/share/html/Search/Elements/EditSearches b/share/html/Search/Elements/EditSearches
index 7f2f9f6..93010d3 100644
--- a/share/html/Search/Elements/EditSearches
+++ b/share/html/Search/Elements/EditSearches
@@ -158,7 +158,8 @@ if ( $ARGS{'SavedSearchRevert'} ) {
if ( $ARGS{'SavedSearchLoad'} ) {
my ($container, $id ) = _parse_saved_search ($ARGS{'SavedSearchLoad'});
if ( $container ) {
- my $search = $container->Attributes->WithId( $id );
+ my $search = RT::Attribute->new( $session{'CurrentUser'} );
+ $search->Load( $id );
$SavedSearch->{'Id'} = $ARGS{'SavedSearchLoad'};
$SavedSearch->{'Object'} = $search;
$SavedSearch->{'Description'} = $search->Description;
@@ -194,7 +195,8 @@ elsif ( $ARGS{'SavedSearchDelete'} ) {
}
elsif ( $ARGS{'SavedSearchCopy'} ) {
my ($container, $id ) = _parse_saved_search( $ARGS{'SavedSearchId'} );
- $SavedSearch->{'Object'} = $container->Attributes->WithId( $id );
+ $SavedSearch->{'Object'} = RT::Attribute->new( $session{'CurrentUser'} );
+ $SavedSearch->{'Object'}->Load( $id );
if ( $ARGS{'SavedSearchDescription'} && $ARGS{'SavedSearchDescription'} ne $SavedSearch->{'Object'}->Description ) {
$SavedSearch->{'Description'} = $ARGS{'SavedSearchDescription'};
} else {
@@ -208,7 +210,8 @@ if ( $SavedSearch->{'Id'} && $SavedSearch->{'Id'} ne 'new'
&& !$SavedSearch->{'Object'} )
{
my ($container, $id ) = _parse_saved_search( $ARGS{'SavedSearchId'} );
- $SavedSearch->{'Object'} = $container->Attributes->WithId( $id );
+ $SavedSearch->{'Object'} = RT::Attribute->new( $session{'CurrentUser'} );
+ $SavedSearch->{'Object'}->Load( $id );
$SavedSearch->{'Description'} ||= $SavedSearch->{'Object'}->Description;
}
@@ -300,8 +303,8 @@ elsif ( $id eq 'new' ) {
);
if ( $status ) {
- $SavedSearch->{'Object'} =
- $session{'CurrentUser'}->UserObj->Attributes->WithId( $saved_search->Id );
+ $SavedSearch->{'Object'} = RT::Attribute->new( $session{'CurrentUser'} );
+ $SavedSearch->{'Object'}->Load( $saved_search->Id );
# Build new SearchId
$SavedSearch->{'Id'} =
ref( $session{'CurrentUser'}->UserObj ) . '-'
diff --git a/share/html/Widgets/SavedSearch b/share/html/Widgets/SavedSearch
index 0516492..670ddfe 100644
--- a/share/html/Widgets/SavedSearch
+++ b/share/html/Widgets/SavedSearch
@@ -61,7 +61,8 @@ my $SearchParams = { map { $_ => $args->{$_} } @{$self->{SearchFields}} };
if ( my ( $container_object, $search_id ) = _parse_saved_search(
$args->{'SavedSearchLoad'} || $args->{'SavedChartSearchId'} ) ) {
- my $search = $container_object->Attributes->WithId($search_id);
+ my $search = RT::Attribute->new( $session{'CurrentUser'} );
+ $search->Load($search_id);
# We have a $search and now; import the others
$self->{SearchId} = $args->{'SavedSearchLoad'} ||
$args->{'SavedChartSearchId'};
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list