-sub Save {
- my $self = shift;
- my %args = ('Privacy' => 'RT::User-' . $self->CurrentUser->Id,
- 'Type' => 'Ticket',
- 'Name' => 'new search',
- 'SearchParams' => {},
- @_);
- my $privacy = $args{'Privacy'};
- my $type = $args{'Type'};
- my $name = $args{'Name'};
- my %params = %{$args{'SearchParams'}};
-
- $params{'SearchType'} = $type;
- my $object = $self->_GetObject($privacy);
-
- return (0, $self->loc("Failed to load object for [_1]", $privacy))
- unless $object;
-
- if ( $object->isa('RT::System') ) {
- return ( 0, $self->loc("No permission to save system-wide searches") )
- unless $self->CurrentUser->HasRight(
- Object => $RT::System,
- Right => 'SuperUser'
- );
- }
-
- my ( $att_id, $att_msg ) = $object->AddAttribute(
- 'Name' => 'SavedSearch',
- 'Description' => $name,
- 'Content' => \%params
- );
- if ($att_id) {
- $self->{'Attribute'} = $object->Attributes->WithId($att_id);
- $self->{'Id'} = $att_id;
- $self->{'Privacy'} = $privacy;
- $self->{'Type'} = $type;
- return ( 1, $self->loc( "Saved search [_1]", $name ) );
- }
- else {
- $RT::Logger->error("SavedSearch save failure: $att_msg");
- return ( 0, $self->loc("Failed to create search attribute") );
- }
-}
-
-=head2 Update
-
-Updates the parameters of an existing search. Takes the arguments
-"Name" and "SearchParams"; SearchParams should be a hashref containing
-the new parameters of the search. If Name is not specified, the name
-will not be changed.
-
-=cut