[Rt-commit] r13271 - in rt/branches/3.8-TESTING: share/html/Search/Elements

elacour at bestpractical.com elacour at bestpractical.com
Fri Jun 13 05:19:26 EDT 2008


Author: elacour
Date: Fri Jun 13 05:19:25 2008
New Revision: 13271

Modified:
   rt/branches/3.8-TESTING/   (props changed)
   rt/branches/3.8-TESTING/share/html/Search/Elements/EditSearches
   rt/branches/3.8-TESTING/share/html/Search/Elements/SelectSearchObject

Log:
 r9506 at datura:  manu | 2008-06-13 11:19:16 +0200
 Allow update of privacy for loaded saved searches.


Modified: rt/branches/3.8-TESTING/share/html/Search/Elements/EditSearches
==============================================================================
--- rt/branches/3.8-TESTING/share/html/Search/Elements/EditSearches	(original)
+++ rt/branches/3.8-TESTING/share/html/Search/Elements/EditSearches	Fri Jun 13 05:19:25 2008
@@ -50,11 +50,7 @@
 %# Hide all the save functionality if the user shouldn't see it.
 % if ( $can_modify ) {
 <&|/l&>Privacy:</&>
-% if ( $Object && $Object->id ) {
-<& SearchPrivacy, Object => $Object->Object &>
-% } else {
-<& SelectSearchObject, Name => 'SavedSearchOwner', Objects => \@Objects &>
-% }
+<& SelectSearchObject, Name => 'SavedSearchOwner', Objects => \@Objects, Object => ( $Object && $Object->id ) ? $Object->Object : '' &>
 <br />
 <&|/l&>Description</&>:
 <input size="25" name="SavedSearchDescription" value="<% $Description || '' %>" />
@@ -145,6 +141,7 @@
 
 $SavedSearch->{'Id'}          = $ARGS{'SavedSearchId'}          || 'new';
 $SavedSearch->{'Description'} = $ARGS{'SavedSearchDescription'} || undef;
+$SavedSearch->{'Privacy'}     = $ARGS{'SavedSearchOwner'}       || undef;
 
 my @results;
 
@@ -212,8 +209,10 @@
 my $obj  = $SavedSearch->{'Object'};
 my $id   = $SavedSearch->{'Id'};
 my $desc = $SavedSearch->{'Description'};
+my $privacy = $SavedSearch->{'Privacy'};
 
 my %params = map { $_ => $Query->{$_} } @SearchFields;
+my ($obj_type, $obj_id) = split(/\-/, ($privacy || ''));
 
 if ( $obj && $obj->id ) {
     # permission check
@@ -226,12 +225,20 @@
 
     $obj->SetSubValues( %params );
     $obj->SetDescription( $desc );
+    if ( $obj_type && $obj_id ) {
+        my ($val, $msg ) = $obj->SetObjectType($obj_type);
+        push @results, loc ('Unable to set privacy object: [_1]', $msg) unless ( $val );
+        ($val, $msg) = $obj->SetObjectId($obj_id);
+        push @results, loc ('Unable to set privacy id: [_1]', $msg) unless ( $val );
+    } else {
+        push @results, loc('Unable to determine object type or id');
+    }
     push @results, loc('Updated saved search "[_1]"', $desc);
 }
 elsif ( $id eq 'new' ) {
     my $saved_search = RT::SavedSearch->new( $session{'CurrentUser'} );
     my ($status, $msg) = $saved_search->Save(
-        Privacy      => $ARGS{'SavedSearchOwner'},
+        Privacy      => $privacy,
         Name         => $desc,
         Type         => $saved_search->{'Type'},
         SearchParams => \%params,

Modified: rt/branches/3.8-TESTING/share/html/Search/Elements/SelectSearchObject
==============================================================================
--- rt/branches/3.8-TESTING/share/html/Search/Elements/SelectSearchObject	(original)
+++ rt/branches/3.8-TESTING/share/html/Search/Elements/SelectSearchObject	Fri Jun 13 05:19:25 2008
@@ -48,13 +48,21 @@
 <%args>
 @Objects => undef
 $Name => undef
+$Object => undef
 </%args>
+<%init>
+my $default_privacy = '';
+if ( $Object && $Object->Id ) {
+    $default_privacy = ref($Object).'-'.$Object->Id;
+}
+</%init>
 <select name="<%$Name%>">
 % foreach my $object (@Objects) {
+% my $privacy = ref($object).'-'.$object->id;
 % if (ref($object) eq 'RT::User' && $object->id == $session{'CurrentUser'}->Id) {
-<option value="<%ref($object)%>-<%$object->id%>"><&|/l&>My saved searches</&></option>
+<option value="<%$privacy%>" <% ( $privacy eq $default_privacy ) ? "selected='selected'" : '' |n %> ><&|/l&>My saved searches</&></option>
 % } else {
-<option value="<%ref($object)%>-<%$object->id%>"><&|/l, $object->Name&>[_1]'s saved searches</&></option>
+<option value="<%$privacy%>" <% ( $privacy eq $default_privacy ) ? "selected='selected'" : '' |n %> ><&|/l, $object->Name&>[_1]'s saved searches</&></option>
 % }
 % }
 </select>


More information about the Rt-commit mailing list