[Rt-commit] rt branch, 4.0/delete-user-attributes-on-reset, created. rt-4.0.4-116-gfbf9ae9

Jason May jasonmay at bestpractical.com
Thu Feb 9 18:40:24 EST 2012


The branch, 4.0/delete-user-attributes-on-reset has been created
        at  fbf9ae9c00bc6a850f7c100937d7e792b37bb460 (commit)

- Log -----------------------------------------------------------------
commit 2c91955866dd7e7b9da14c216785251f2e5e8dbb
Author: Jason May <jasonmay at bestpractical.com>
Date:   Wed Dec 7 12:24:38 2011 -0500

    Delete the user's Pref-HomepageSettings attribute on Reset
    
    If the user's Pref-HomepageSettings is there but not empty, it won't
    respect any new changes made to the global homepage settings.
    
    However, the fix is still not visible due to referring to session cache
    checks. The preferences are checked in the session before the database,
    so users will still not see homepage changes.

diff --git a/share/html/Prefs/MyRT.html b/share/html/Prefs/MyRT.html
index cfcf315..46848e1 100644
--- a/share/html/Prefs/MyRT.html
+++ b/share/html/Prefs/MyRT.html
@@ -97,7 +97,9 @@ if ( $ARGS{'UpdateSummaryRows'} ) {
 $ARGS{'SummaryRows'} ||= $user->Preferences('SummaryRows', RT->Config->Get('DefaultSummaryRows'));
 
 if ($ARGS{Reset}) {
-    my ($ok, $msg) = $user->SetPreferences('HomepageSettings', {});
+    my $attr = RT::Attribute->new($session{CurrentUser});
+    $attr->LoadByNameAndObject( Object => $user, Name => 'Pref-HomepageSettings' );
+    my ($ok, $msg) = $attr->Delete;
     push @results, $ok ? loc('Preferences saved.') : $msg;
     delete $session{'my_rt_portlets'};
 }

commit 54149fba710aebc3cbbb9f3ca90d3598ddfe0849
Author: Jason May <jasonmay at bestpractical.com>
Date:   Wed Dec 7 19:18:31 2011 -0500

    Stop caching the default system prefs in the session
    
    This lets users blow away their preferences and track the system
    defaults instead of getting a snapshot of the defaults upon reset.

diff --git a/share/html/Elements/MyRT b/share/html/Elements/MyRT
index 37d8976..22a0e7d 100644
--- a/share/html/Elements/MyRT
+++ b/share/html/Elements/MyRT
@@ -70,7 +70,7 @@ my $user = $session{'CurrentUser'}->UserObj;
 $Portlets ||= $session{'my_rt_portlets'};
 unless ( $Portlets ) {
     my ($default_portlets) = RT::System->new($session{'CurrentUser'})->Attributes->Named('HomepageSettings');
-    $Portlets = $session{'my_rt_portlets'} = $user->Preferences(
+    $Portlets = $user->Preferences(
         HomepageSettings => $default_portlets? $default_portlets->Content: {},
     );
 }
diff --git a/share/html/Prefs/MyRT.html b/share/html/Prefs/MyRT.html
index 46848e1..d0f9786 100644
--- a/share/html/Prefs/MyRT.html
+++ b/share/html/Prefs/MyRT.html
@@ -104,12 +104,15 @@ if ($ARGS{Reset}) {
     delete $session{'my_rt_portlets'};
 }
 
-unless (exists $session{'my_rt_portlets'}) {
+my $portlets;
+if (exists $session{'my_rt_portlets'}) {
+    $portlets = $session{'my_rt_portlets'};
+}
+else {
     my ($default_portlets) = RT::System->new($session{'CurrentUser'})->Attributes->Named('HomepageSettings');
-    my $portlets = $default_portlets ? $default_portlets->Content : {};
-    $session{'my_rt_portlets'} = $user->Preferences('HomepageSettings', $portlets);
+    $default_portlets = $default_portlets ? $default_portlets->Content : {};
+    $portlets = $user->Preferences('HomepageSettings', $default_portlets);
 }
-my $portlets = $session{'my_rt_portlets'};
 
 my %seen;
 my @items = map ["component-$_", $_], grep !$seen{$_}++, @{RT->Config->Get('HomepageComponents')};

commit f441126f6c9f43e875923fda7ab603ecf96121b0
Author: Jason May <jasonmay at bestpractical.com>
Date:   Mon Dec 12 15:47:05 2011 -0500

    Delete the Pref-SummaryRows attribute to reset everything on MyRT.html

diff --git a/share/html/Prefs/MyRT.html b/share/html/Prefs/MyRT.html
index d0f9786..dd3e049 100644
--- a/share/html/Prefs/MyRT.html
+++ b/share/html/Prefs/MyRT.html
@@ -99,8 +99,15 @@ $ARGS{'SummaryRows'} ||= $user->Preferences('SummaryRows', RT->Config->Get('Defa
 if ($ARGS{Reset}) {
     my $attr = RT::Attribute->new($session{CurrentUser});
     $attr->LoadByNameAndObject( Object => $user, Name => 'Pref-HomepageSettings' );
-    my ($ok, $msg) = $attr->Delete;
-    push @results, $ok ? loc('Preferences saved.') : $msg;
+    my ($hp_ok, $msg) = $attr->Delete;
+    push @results, $msg unless $hp_ok;
+
+    $attr->LoadByNameAndObject( Object => $user, Name => 'Pref-SummaryRows' );
+    (my $sr_ok, $msg) = $attr->Delete;
+    push @results, $msg unless $sr_ok;
+
+    push @results, loc('Preferences saved.') if $hp_ok and $sr_ok;
+
     delete $session{'my_rt_portlets'};
 }
 

commit fbf9ae9c00bc6a850f7c100937d7e792b37bb460
Author: Jason May <jasonmay at bestpractical.com>
Date:   Thu Feb 9 18:34:58 2012 -0500

    Provide the option to reset saved search adjustments
    
    This provides a way for users to reset their preferences at the
    saved-search level, which causes the preferences to default to the
    system saved search settings.

diff --git a/share/html/Prefs/Search.html b/share/html/Prefs/Search.html
index 0b97e31..2d02eb1 100644
--- a/share/html/Prefs/Search.html
+++ b/share/html/Prefs/Search.html
@@ -68,6 +68,14 @@
 
 </form>
 
+<&|/Widgets/TitleBox, title => loc("Reset adjustments") &>
+<form method="post" action="Search.html">
+<input type="hidden" name="Reset" value="1" />
+<input type="hidden" name="name" value="<%$ARGS{name}%>" class="hidden" />
+<input type="submit" class="button" value="<% loc('Reset to default') %>">
+</form>
+</&>
+
 <%INIT>
 my @actions;
 my $title = loc("Customize").' ';
@@ -81,6 +89,26 @@ Abort('No search specified')
 
 my $search = $class->new ($session{'CurrentUser'});
 $search->LoadById ($id);
+
+# If we are resetting prefs, do so before attempting to load them
+if ($ARGS{'Reset'}) {
+    my $pref = $class->new($session{'CurrentUser'});
+    my ($pref_ok) = $pref->LoadByNameAndObject(
+        Object => $session{'CurrentUser'}->UserObj,
+        Name   => 'Pref-'.$ARGS{'name'},
+    );
+
+    my ($ok, $msg);
+    if ($pref_ok) {
+        ($ok, $msg) = $pref->Delete;
+    }
+    else {
+        # The pref doesn't exist yet, but say it was reset anyway
+        $ok = 1;
+    }
+    push @actions, $ok ? loc('Preferences saved.') : $msg;
+}
+
 $title .= loc ($search->Description, loc ('"N"'));
 my $user = $session{'CurrentUser'}->UserObj;
 my $SearchArg = $user->Preferences($search, $search->Content);

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


More information about the Rt-commit mailing list