Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / rt / etc / upgrade / 4.1.6 / content
1 use strict;
2 use warnings;
3
4 our @Initial = (sub {
5     my $users = RT::Users->new(RT->SystemUser);
6     $users->FindAllRows;
7
8     my $attributes = $users->Join(
9         ALIAS1  => "main",
10         FIELD1  => "id",
11         TABLE2  => RT::Attributes->Table,
12         FIELD2  => "ObjectId",
13     );
14     $users->Limit(
15         ALIAS   => $attributes,
16         FIELD   => "ObjectType",
17         VALUE   => "RT::User",
18     );
19     $users->Limit(
20         ALIAS   => $attributes,
21         FIELD   => "Name",
22         VALUE   => RT::User::_PrefName( RT->System ),
23     );
24
25     # Iterate all users (including disabled), with config preferences set.
26     # Avoids running a query for every user in the system by only selecting
27     # those known to have preferences.
28     while (my $user = $users->Next) {
29         RT->Logger->debug(sprintf "User #%d has config preferences", $user->id);
30
31         my $config = $user->Preferences( RT->System )
32             or next;
33         next unless exists $config->{DeferTransactionLoading};
34
35         $config->{ShowHistory} = delete $config->{DeferTransactionLoading}
36             ? "click" : "delay";
37
38         $user->SetPreferences( RT->System, $config );
39         RT->Logger->debug(sprintf "Updated config Preferences for user %s (#%d)", $user->Name, $user->id);
40     }
41 });
42
43 1;