diff options
| -rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 2 | ||||
| -rw-r--r-- | FS/FS/TicketSystem.pm | 27 | ||||
| -rw-r--r-- | Makefile | 1 | 
3 files changed, 27 insertions, 3 deletions
| diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index a788a5c05..014434a05 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -321,7 +321,7 @@ sub customer_info {      $return{'require_address2'} = '';    } -  if ( $conf->exists('ticket_system') ) { +  if ( $FS::TicketSystem::system ) {      warn "$me customer_info: initializing ticket system\n" if $DEBUG;      FS::TicketSystem->init();    } diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm index 9d11ff47b..a6daf7e06 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); @@ -193,6 +193,7 @@ perl-modules:  	  s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \  	  s'%%%RT_PATH%%%'${RT_PATH}'g; \  	  s'%%%MASONDATA%%%'${MASONDATA}'g;\ +	  s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\  	" blib/lib/FS/*.pm;\  	perl -p -i -e "\  	  s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\ | 
