[Rt-commit] r2754 - in rt/branches/QUEBEC-EXPERIMENTAL: . lib/RT lib/t/regression

jesse at bestpractical.com jesse at bestpractical.com
Sun Apr 17 23:13:08 EDT 2005


Author: jesse
Date: Sun Apr 17 23:13:08 2005
New Revision: 2754

Modified:
   rt/branches/QUEBEC-EXPERIMENTAL/   (props changed)
   rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/SavedSearch.pm
   rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/20savedsearch.t
Log:
 r12963 at hualien:  jesse | 2005-04-15 17:46:02 -0400
  r12958 at hualien:  jesse | 2005-04-15 17:30:30 -0400
   r12957 at hualien (orig r2634):  tla | 2005-04-15 17:21:25 -0400
   Added ability to update name as well as search parameters.
   
  
 


Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/SavedSearch.pm
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/SavedSearch.pm	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/SavedSearch.pm	Sun Apr 17 23:13:08 2005
@@ -170,23 +170,27 @@
 
 =head2 Update
 
-Updates the parameters of an existing search.  Takes a hashref with
-the new parameters.
+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
 
 sub Update {
     my $self = shift;
-    my $params = shift;
+    my %args = ('Name' => '',
+		'SearchParams' => {},
+		@_);
     
     return(0, $self->loc("No search loaded")) unless $self->Id;
     return(0, $self->loc("Could not load search attribute"))
 	unless $self->{'Attribute'}->Id;
-    my ($status, $msg) = $self->{'Attribute'}->SetSubValues(%{$params});
-    if ($status) {
-	# Update all the accessor variables.
-	return ($status, $self->loc("Search update: [_1]", $msg));
+    my ($status, $msg) = $self->{'Attribute'}->SetSubValues(%{$args{'SearchParams'}});
+    if ($status && $args{'Name'}) {
+	($status, $msg) = $self->{'Attribute'}->SetDescription($args{'Name'});
     }
+    return ($status, $self->loc("Search update: [_1]", $msg));
 }
 
 =head2 Delete

Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/20savedsearch.t
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/20savedsearch.t	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/20savedsearch.t	Sun Apr 17 23:13:08 2005
@@ -147,8 +147,8 @@
 isnt($loadedsearch4->Id, $othersearch->Id, "Did not load othersearch");
 
 # Try to update an existing search.
-$loadedsearch1->Update({'Format' => $format,
-			'Query' => "Queue = '" . $queue->Name . "'" });
+$loadedsearch1->Update(	SearchParams => {'Format' => $format,
+			'Query' => "Queue = '" . $queue->Name . "'" } );
 like($loadedsearch1->GetParameter('Query'), qr/Queue/,
      "Updated mysearch parameter");
 is($loadedsearch1->Type, 'Ticket', "mysearch is still for tickets");


More information about the Rt-commit mailing list