ModifyUserPreferences: Difference between revisions
Jump to navigation
Jump to search
(Changing a user's email frequency preference) |
m (1 revision imported) |
||
(No difference)
| |||
Latest revision as of 16:15, 6 April 2016
I had a situation where a once-privileged user had been made non-privileged, since they had left our institute, but they had email preference settings set to weekly batch.
Unfortunately, the GUI has no interface to change a user's preferences, other than having the user do it themselves. Fortunately, it wasn't too difficult to write a small perl script to delete a named user's email preference setting:
#!/usr/bin/perl -w
use strict;
use lib qw(/opt/rt3/lib /opt/rt3/local/lib);
use Getopt::Long;
use RT;
use RT::Interface::CLI qw/GetCurrentUser/;
RT::LoadConfig;
RT::Init;
my $name;
GetOptions("name=s" => \$name);
die "Usage: $0 --name=bloggs\n" unless ($name);
my $u = RT::User->new($RT::SystemUser);
my ($id, $err) = $u->LoadByCol('Name' => $name);
die("Couldn't load user '$name': $err\n") unless ($id > 0);
my $p = $u->Preferences( $RT::System );
delete($p->{'EmailFrequency'});
$u->SetPreferences( $RT::System, $p);