[freeside-commits] freeside/FS/FS TicketSystem.pm,1.8,1.9
Mark Wells
mark at wavetail.420.am
Fri Jul 8 15:17:31 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv29141/FS/FS
Modified Files:
TicketSystem.pm
Log Message:
auto-create selfservice user in RT, #13199
Index: TicketSystem.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- TicketSystem.pm 13 May 2011 23:20:52 -0000 1.8
+++ TicketSystem.pm 8 Jul 2011 22:17:29 -0000 1.9
@@ -35,8 +35,31 @@
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);
More information about the freeside-commits
mailing list