Skip to content
Snippets Groups Projects
Commit ca61ecfb authored by Ruslan Zakirov's avatar Ruslan Zakirov Committed by Alex Vandiver
Browse files

upgrade script for old quicksearch preferences

parent 057302c7
No related branches found
No related tags found
No related merge requests found
use strict;
use warnings;
our @Initial = (sub {
my $pref_name = 'QuickSearch';
my $users = RT::Users->new(RT->SystemUser);
$users->FindAllRows;
my $attributes = $users->Join(
ALIAS1 => "main",
FIELD1 => "id",
TABLE2 => RT::Attributes->Table,
FIELD2 => "ObjectId",
);
$users->Limit(
ALIAS => $attributes,
FIELD => "ObjectType",
VALUE => "RT::User",
);
$users->Limit(
ALIAS => $attributes,
FIELD => "Name",
VALUE => RT::User::_PrefName( $pref_name ),
);
# Iterate all users (including disabled), with Quicksearch preferences set.
# Avoids running a query for every user in the system by only selecting
# those known to have preferences.
while (my $user = $users->Next) {
RT->Logger->debug(sprintf "User #%d has $pref_name preferences", $user->id);
my $config = $user->Preferences( $pref_name )
or next;
$user->SetPreferences( $pref_name, { Unwanted => $config } );
RT->Logger->debug(sprintf "Updated $pref_name preferences for user %s (#%d)", $user->Name, $user->id);
}
});
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment