[Rt-commit] rt branch, 4.0/preferences-errors, created. rt-4.0.4-127-g9f0d33e

Alex Vandiver alexmv at bestpractical.com
Fri Dec 9 20:56:48 EST 2011


The branch, 4.0/preferences-errors has been created
        at  9f0d33e1285b33388f0f9960c40c30a79acc5d14 (commit)

- Log -----------------------------------------------------------------
commit 55fe932d8ad21c0291eedcbceede347a0ceaf410
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Dec 9 20:54:03 2011 -0500

    ->FirstAttribute returns an object, not the attribute's content
    
    Thus, every update would produce "That is already the current value" if
    you had GPG enabled.

diff --git a/share/html/Prefs/Other.html b/share/html/Prefs/Other.html
index 33b0382..dbe9a6c 100644
--- a/share/html/Prefs/Other.html
+++ b/share/html/Prefs/Other.html
@@ -81,7 +81,8 @@ my $title = loc("Settings");
 my $UserObj = $session{'CurrentUser'}->UserObj;
 my $preferences = $UserObj->Preferences( $RT::System );
 
-if ((defined $PreferredKey) && $PreferredKey ne $UserObj->FirstAttribute('PreferredKey')) {
+if (defined($PreferredKey) and (not $UserObj->FirstAttribute('PreferredKey')
+        or $PreferredKey ne $UserObj->FirstAttribute('PreferredKey')->Content)) {
     my ($code, $msg) = $UserObj->SetAttribute(Name => 'PreferredKey', Content => $PreferredKey);
     push @results, loc('Preferred Key: [_1]', loc_fuzzy($msg));
 }

commit e57061b18fd6225f88318211d58b6d1b6353d6ab
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Dec 9 20:54:59 2011 -0500

    Stop calling out "preferred key" as being somehow different from other prefs
    
    Unless, of course, the update fails for some reason.

diff --git a/share/html/Prefs/Other.html b/share/html/Prefs/Other.html
index dbe9a6c..daa3341 100644
--- a/share/html/Prefs/Other.html
+++ b/share/html/Prefs/Other.html
@@ -84,7 +84,7 @@ my $preferences = $UserObj->Preferences( $RT::System );
 if (defined($PreferredKey) and (not $UserObj->FirstAttribute('PreferredKey')
         or $PreferredKey ne $UserObj->FirstAttribute('PreferredKey')->Content)) {
     my ($code, $msg) = $UserObj->SetAttribute(Name => 'PreferredKey', Content => $PreferredKey);
-    push @results, loc('Preferred Key: [_1]', loc_fuzzy($msg));
+    push @results, loc('Preferred Key: [_1]', $msg) unless $code;
 }
 
 if ( $Update ) {

commit 9f0d33e1285b33388f0f9960c40c30a79acc5d14
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Dec 9 20:55:41 2011 -0500

    Setting preferences to their current value is not an error
    
    Otherwise, pressing submit on the preferences page would show the
    baffling "That is already the current value" if no changes were made.

diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index cbc1a8f..04f7a60 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -1314,7 +1314,10 @@ sub SetPreferences {
     my $attr = RT::Attribute->new( $self->CurrentUser );
     $attr->LoadByNameAndObject( Object => $self, Name => $name );
     if ( $attr->Id ) {
-        return $attr->SetContent( $value );
+        my ($ok, $msg) = $attr->SetContent( $value );
+        return (1, "No updates made")
+            if $msg eq "That is already the current value";
+        return ($ok, $msg);
     } else {
         return $self->AddAttribute( Name => $name, Content => $value );
     }

-----------------------------------------------------------------------


More information about the Rt-commit mailing list