X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FTicketSystem.pm;h=c1553f17a2a4c3e535e616e11f61620b9a7ae893;hb=54422869b5d895058a78454ddfc7c01789cb56f7;hp=b6cee41aa20bf792149c028511018b4065836a12;hpb=af22824cb24e024f45403d9c456ef65b2c7c6838;p=freeside.git diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm index b6cee41aa..c1553f17a 100644 --- a/FS/FS/TicketSystem.pm +++ b/FS/FS/TicketSystem.pm @@ -87,29 +87,31 @@ sub _upgrade_data { # 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 - CreateTicket SeeCustomField) ); - foreach (@rights) { - next if $Principal->HasRight( 'Right' => $_, Object => $RT::System ); - my ($val, $msg) = $Principal->GrantRight( - 'Right' => $_, - 'Object' => $RT::System, - ); - die $msg if !$val; - } + # selfservice and cron users + foreach my $username ('%%%SELFSERVICE_USER%%%', 'fs_daily') { + my $User = RT::User->new($CurrentUser); + $User->Load($username); + if (!defined($User->Id)) { + my ($val, $msg) = $User->Create( + 'Name' => $username, + 'Gecos' => $username, + '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 + CreateTicket SeeCustomField) ); + foreach (@rights) { + next if $Principal->HasRight( 'Right' => $_, Object => $RT::System ); + my ($val, $msg) = $Principal->GrantRight( + 'Right' => $_, + 'Object' => $RT::System, + ); + die $msg if !$val; + } + } #foreach $username # EscalateQueue custom field and friends my $CF = RT::CustomField->new($CurrentUser); @@ -134,7 +136,8 @@ sub _upgrade_data { # Load from RT data file our (@Groups, @Users, @ACL, @Queues, @ScripActions, @ScripConditions, - @Templates, @CustomFields, @Scrips, @Attributes, @Initial, @Final); + @Templates, @CustomFields, @Scrips, @Attributes, @Initial, @Final, + %Delete_Scrips); my $datafile = '%%%RT_PATH%%%/etc/initialdata'; eval { require $datafile }; if ( $@ ) { @@ -209,6 +212,11 @@ sub _upgrade_data { my ($val, $msg) = $item->Delete; warn "error deleting scrip: $msg\n" if !$val; } + elsif ( exists $Delete_Scrips{$c}{$a}{$t} and $item->Creator == 1 ) { + warn "Deleting obsolete scrip $c $a [$t]\n"; + my ($val, $msg) = $item->Delete; + warn "error deleting scrip: $msg\n" if !$val; + } else { $scrip{$c}{$a}{$t} = $item->id; }