diff options
| author | mark <mark> | 2011-05-10 23:21:44 +0000 | 
|---|---|---|
| committer | mark <mark> | 2011-05-10 23:21:44 +0000 | 
| commit | 2f864a9b428d642df650d01a51ffa42b6826d82a (patch) | |
| tree | 505288187660152ddf667cf2cdbc364f59019cf1 | |
| parent | c64541e0cb6307925480669203ff76554f4663fe (diff) | |
replace missing RT scrips on upgrade, #9569
| -rw-r--r-- | FS/FS/TicketSystem.pm | 53 | ||||
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | rt/Makefile | 2 | ||||
| -rw-r--r-- | rt/Makefile.in | 2 | 
4 files changed, 58 insertions, 0 deletions
| diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm index f5c8e7dad..8ea4b03a8 100644 --- a/FS/FS/TicketSystem.pm +++ b/FS/FS/TicketSystem.pm @@ -84,6 +84,59 @@ sub _upgrade_data {      );      die $msg if !$val;    } + +  # Create any missing scrips +  our (@Groups, @Users, @ACL, @Queues, @ScripActions, @ScripConditions, +       @Templates, @CustomFields, @Scrips, @Attributes, @Initial, @Final); +  my $datafile = '%%%RT_PATH%%%/etc/initialdata'; +  eval { require $datafile }; +  if ( $@ ) { +    warn "Couldn't load RT data from '$datafile': $@\n(skipping)\n"; +    return; +  } + +  my $search = RT::ScripConditions->new($CurrentUser); +  $search->UnLimit; +  my %condition = map { lc($_->Name), $_->Id } @{ $search->ItemsArrayRef }; + +  $search = RT::ScripActions->new($CurrentUser); +  $search->UnLimit; +  my %action = map { lc($_->Name), $_->Id } @{ $search->ItemsArrayRef }; + +  $search = RT::Templates->new($CurrentUser); +  $search->UnLimit; +  my %template = map { lc($_->Name), $_->Id } @{ $search->ItemsArrayRef }; + +  my $Scrip = RT::Scrip->new($CurrentUser); +  foreach my $s ( @Scrips ) { +    my $desc = $s->{'Description'}; +    my ($c, $a, $t) = map lc, +      @{ $s }{'ScripCondition', 'ScripAction', 'Template'}; +    if ( !$condition{$c} ) { +      warn "ScripCondition '$c' not found.\n"; +      next; +    } +    if ( !$action{$a} ) { +      warn "ScripAction '$a' not found.\n"; +      next; +    } +    if ( !$template{$t} ) { +      warn "Template '$t' not found.\n"; +      next; +    } +    my %param = ( +      ScripCondition => $condition{$c}, +      ScripAction => $action{$a}, +      Template => $template{$t}, +      Queue => 0, +    ); +    $Scrip->LoadByCols(%param); +    if (!defined($Scrip->Id)) { +      my ($val, $msg) = $Scrip->Create(%param, Description => $desc); +      die $msg if !$val; +    } +  } #foreach (@Scrips) +    return;  } @@ -191,6 +191,7 @@ perl-modules:  	  s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\  	  s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \  	  s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \ +	  s'%%%RT_PATH%%%'${RT_PATH}'g; \  	  s'%%%MASONDATA%%%'${MASONDATA}'g;\  	" blib/lib/FS/*.pm;\  	perl -p -i -e "\ diff --git a/rt/Makefile b/rt/Makefile index 6ba9063e1..8f9202080 100644 --- a/rt/Makefile +++ b/rt/Makefile @@ -327,6 +327,8 @@ fixperms:  	chmod 0440 $(DESTDIR)$(CONFIG_FILE)  	chmod 0640 $(DESTDIR)$(SITE_CONFIG_FILE) +	# Make this externally readable +	chmod 0440 $(DESTDIR)$(RT_ETC_PATH)/initialdata  	# Make the system binaries  	cd $(DESTDIR)$(RT_BIN_PATH) && ( chmod 0755 $(BINARIES) ; chown $(BIN_OWNER) $(BINARIES);  chgrp $(RTGROUP) $(BINARIES)) diff --git a/rt/Makefile.in b/rt/Makefile.in index d41633fff..f963faa25 100644 --- a/rt/Makefile.in +++ b/rt/Makefile.in @@ -327,6 +327,8 @@ fixperms:  	chmod 0440 $(DESTDIR)$(CONFIG_FILE)  	chmod 0640 $(DESTDIR)$(SITE_CONFIG_FILE) +	# Make this externally readable +	chmod 0440 $(DESTDIR)$(RT_ETC_PATH)/initialdata  	# Make the system binaries  	cd $(DESTDIR)$(RT_BIN_PATH) && ( chmod 0755 $(BINARIES) ; chown $(BIN_OWNER) $(BINARIES);  chgrp $(RTGROUP) $(BINARIES)) | 
