[Rt-commit] r6598 - in
rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search: .
ruz at bestpractical.com
ruz at bestpractical.com
Thu Dec 7 23:34:41 EST 2006
Author: ruz
Date: Thu Dec 7 23:34:41 2006
New Revision: 6598
Modified:
rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search/Build.html
rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search/Elements/EditSearches
Log:
* merge bug, saved code for saved searches handling has another location in 3.7
Modified: rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search/Build.html
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search/Build.html (original)
+++ rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search/Build.html Thu Dec 7 23:34:41 2006
@@ -162,63 +162,6 @@
}
}
-# {{{ if we're asked to save the current search, save it
-if ( $ARGS{'Save'} ) {
- if ( $search && $search->id ) {
- # permission check
- if ($search->Object->isa('RT::System')) {
- unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'SuperUser')) {
- Abort("No permission to save system-wide searches");
- }
- }
-
- # This search is based on a previously loaded search -- so
- # just update the current search object with new values
- $search->SetSubValues(
- Format => $Format,
- Query => $Query,
- Order => $Order,
- OrderBy => $OrderBy,
- RowsPerPage => $RowsPerPage,
- );
- $search->SetDescription($Description);
-
- }
- elsif ( $SearchId eq 'new' ) {
- my $saved_search = RT::SavedSearch->new( $session{'CurrentUser'} );
- my ( $ok, $search_msg ) = $saved_search->Save(
- Privacy => $ARGS{'Owner'},
- Name => $Description,
- SearchParams => {
- Format => $Format,
- Query => $Query,
- Order => $Order,
- OrderBy => $OrderBy,
- RowsPerPage => $RowsPerPage } );
-
- if ($ok) {
- $search = $session{'CurrentUser'}->UserObj->Attributes->WithId($saved_search->Id);
- # Build new SearchId
- $SearchId =
- ref( $session{'CurrentUser'}->UserObj ) . '-'
- . $session{'CurrentUser'}->UserObj->Id
- . '-SavedSearch-'
- . $search->Id;
- }
- else {
- push @actions, [ loc("Can't find a saved search to work with").': '.loc($search_msg), 0 ];
- }
- }
- else {
- push @actions, [ loc("Can't save this search"), 0 ];
- }
-
-}
-
-# }}}
-
-
-
my $ParseQuery = sub {
my ($string, $results) = shift;
Modified: rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search/Elements/EditSearches
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search/Elements/EditSearches (original)
+++ rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/html/Search/Elements/EditSearches Thu Dec 7 23:34:41 2006
@@ -188,43 +188,26 @@
$obj->SetSubValues( %$Query );
$obj->SetDescription( $desc );
}
-elsif ( $id eq 'new' && $ARGS{'SavedSearchOwner'} =~ /^(.*?)-(\d+)$/ ) {
- # We're saving a new search
- my $obj_type = $1;
- my $obj_id = $2;
-
- # Find out if we're saving on the user, or a group
- my $container_object = _load_container_object ($obj_type, $obj_id);
-
- if ( $container_object->id ) {
- # permission check
- if ( $container_object->isa('RT::System') ) {
- unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'SuperUser')) {
- push @results, [ loc("No permission to save system-wide searches"), 0 ];
- return @results;
- }
- }
-
- my $name = $obj_type eq 'RT::System' ? "Search - $desc" : 'SavedSearch';
- # If we got one or the other, add the saerch
- my ( $search_id, $search_msg ) = $container_object->AddAttribute(
- Name => $name,
- Description => $desc,
- Content => $Query,
- );
- unless ( $search_id ) {
- push @results, [ loc("Can't find a saved search to work with").': '.loc($search_msg), 0 ];
- return @results;
- }
+elsif ( $id eq 'new' ) {
+ my $saved_search = RT::SavedSearch->new( $session{'CurrentUser'} );
+ my ($status, $msg) = $saved_search->Save(
+ Privacy => $ARGS{'SavedSearchOwner'},
+ Name => $desc,
+ SearchParams => $Query,
+ );
+ if ( $status ) {
$SavedSearch->{'Object'} =
- $session{'CurrentUser'}->UserObj->Attributes->WithId($search_id);
+ $session{'CurrentUser'}->UserObj->Attributes->WithId( $saved_search->Id );
# Build new SearchId
$SavedSearch->{'Id'} =
- ref( $session{'CurrentUser'}->UserObj ) . '-'
- . $session{'CurrentUser'}->UserObj->Id
- . '-SavedSearch-'
- . $SavedSearch->{'Object'}->Id;
+ ref( $session{'CurrentUser'}->UserObj ) . '-'
+ . $session{'CurrentUser'}->UserObj->Id
+ . '-SavedSearch-'
+ . $SavedSearch->{'Object'}->Id;
+ }
+ else {
+ push @results, [ loc("Can't find a saved search to work with").': '.loc($msg), 0 ];
}
}
else {
More information about the Rt-commit
mailing list