summaryrefslogtreecommitdiff
path: root/FS/FS/TicketSystem.pm
diff options
context:
space:
mode:
authormark <mark>2011-07-08 22:17:29 +0000
committermark <mark>2011-07-08 22:17:29 +0000
commitc58b5c1cef23066263aae5c506824310866ef64b (patch)
tree28043c79ec0a1d465b2f147bebd2f74e99ba8061 /FS/FS/TicketSystem.pm
parent3f8dd846e92d44fc461d91d5fd5e012a770370d1 (diff)
auto-create selfservice user in RT, #13199
Diffstat (limited to 'FS/FS/TicketSystem.pm')
-rw-r--r--FS/FS/TicketSystem.pm27
1 files changed, 25 insertions, 2 deletions
diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm
index 9d11ff4..a6daf7e 100644
--- a/FS/FS/TicketSystem.pm
+++ b/FS/FS/TicketSystem.pm
@@ -35,8 +35,31 @@ sub _upgrade_data {
FS::TicketSystem->init;
my $session = FS::TicketSystem->session();
- my $CurrentUser = $session->{'CurrentUser'}
- or die 'freeside-upgrade must run as a valid RT user';
+ # bypass RT ACLs--we're going to do lots of things
+ my $CurrentUser = $RT::SystemUser;
+
+ # selfservice user
+ my $User = RT::User->new($CurrentUser);
+ $User->Load('%%%SELFSERVICE_USER%%%');
+ if (!defined($User->Id)) {
+ my ($val, $msg) = $User->Create(
+ 'Name' => '%%%SELFSERVICE_USER%%%',
+ 'Gecos' => '%%%SELFSERVICE_USER%%%',
+ 'Privileged' => 1,
+ # any other fields needed?
+ );
+ die $msg if !$val;
+ }
+ my $Principal = $User->PrincipalObj; # can this ever fail?
+ my @rights = ( qw(ShowTicket SeeQueue ModifyTicket ReplyToTicket) );
+ foreach (@rights) {
+ next if $Principal->HasRight( 'Right' => $_, Object => $RT::System );
+ my ($val, $msg) = $Principal->GrantRight(
+ 'Right' => $_,
+ 'Object' => $RT::System,
+ );
+ die $msg if !$val;
+ }
# EscalateQueue custom field and friends
my $CF = RT::CustomField->new($CurrentUser);