Commit e04582df authored by Kevin Falcone's avatar Kevin Falcone
Browse files

Merge branch '4.0/cache-empty-preferences' into 4.0-trunk

parents a8560893 5b707dfe
......@@ -1013,7 +1013,6 @@ sub Get {
my $res;
if ( $user && $user->id && $META{$name}->{'Overridable'} ) {
$user = $user->UserObj if $user->isa('RT::CurrentUser');
my $prefs = $user->Preferences($RT::System);
$res = $prefs->{$name} if $prefs;
}
......
......@@ -1342,10 +1342,8 @@ sub Preferences {
my $name = _PrefName (shift);
my $default = shift;
my $attr = RT::Attribute->new( $self->CurrentUser );
$attr->LoadByNameAndObject( Object => $self, Name => $name );
my $content = $attr->Id ? $attr->Content : undef;
my ($attr) = $self->Attributes->Named( $name );
my $content = $attr ? $attr->Content : undef;
unless ( ref $content eq 'HASH' ) {
return defined $content ? $content : $default;
}
......@@ -1374,9 +1372,8 @@ sub SetPreferences {
return (0, $self->loc("No permission to set preferences"))
unless $self->CurrentUserCanModify('Preferences');
my $attr = RT::Attribute->new( $self->CurrentUser );
$attr->LoadByNameAndObject( Object => $self, Name => $name );
if ( $attr->Id ) {
my ($attr) = $self->Attributes->Named( $name );
if ( $attr ) {
my ($ok, $msg) = $attr->SetContent( $value );
return (1, "No updates made")
if $msg eq "That is already the current value";
......@@ -1399,13 +1396,11 @@ sub DeletePreferences {
return (0, $self->loc("No permission to set preferences"))
unless $self->CurrentUserCanModify('Preferences');
my $attr = RT::Attribute->new( $self->CurrentUser );
$attr->LoadByNameAndObject( Object => $self, Name => $name );
if ( $attr->Id ) {
return $attr->Delete;
}
my ($attr) = $self->DeleteAttribute( $name );
return (0, $self->loc("Preferences were not found"))
unless $attr;
return (0, $self->loc("Preferences were not found"));
return 1;
}
=head2 Stylesheet
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment