]> git.uio.no Git - usit-rt.git/blobdiff - etc/upgrade/3.8.9/content
Upgrade 4.0.17 clean.
[usit-rt.git] / etc / upgrade / 3.8.9 / content
diff --git a/etc/upgrade/3.8.9/content b/etc/upgrade/3.8.9/content
new file mode 100644 (file)
index 0000000..898c19e
--- /dev/null
@@ -0,0 +1,63 @@
+@Initial = (
+    sub {
+        use strict;
+        $RT::Logger->debug('Make sure local links are local');
+
+        use RT::URI::fsck_com_rt;
+        my $prefix = RT::URI::fsck_com_rt->LocalURIPrefix . '/ticket/';
+
+        foreach my $dir (qw(Target Base)) {
+            my $found;
+            do {
+                $found = 0;
+                my $links = RT::Links->new( RT->SystemUser );
+                $links->Limit( FIELD => $dir, OPERATOR => 'STARTSWITH', VALUE => $prefix );
+                $links->Limit( FIELD => 'Local'.$dir, VALUE => 0 );
+                $links->Limit(
+                    ENTRYAGGREGATOR => 'OR',
+                    FIELD => 'Local'.$dir,
+                    OPERATOR => 'IS',
+                    VALUE => 'NULL',
+                );
+                $links->RowsPerPage( 1000 );
+                while ( my $link = $links->Next ) {
+                    $found++;
+                    my $uri = $link->$dir();
+                    $uri =~ s/^\Q$prefix//;
+                    if ( int($uri) eq $uri && $uri > 0 ) {
+                        my $method = 'SetLocal'. $dir;
+                        my ($status, $msg) = $link->$method( $uri );
+                        unless ( $status ) {
+                            die "Couldn't change local $dir: $msg";
+                        }
+                    } else {
+                        die "$dir URI looks like local, but is not parseable";
+                    }
+                }
+            } while $found == 1000;
+        }
+    },
+    sub {
+        my $queue = RT::Queue->new( $RT::SystemUser );
+        $queue->Load('___Approvals');
+        return unless $queue->id;
+
+        for my $name (
+            'All Approvals Passed', 'Approval Passed', 'Approval Rejected'
+          )
+        {
+            my $template = RT::Template->new($RT::SystemUser);
+            $template->LoadQueueTemplate( Name => $name, Queue => $queue->id );
+            next unless $template->id;
+            my $content = $template->Content;
+
+            # there is only one OwnerObj->Name normally, so no need /g
+            if ( $content =~
+s!(?<=Your ticket has been (?:approved|rejected) by { eval { )\$Approval->OwnerObj->Name!\$Approver->Name!
+              )
+            {
+                $template->SetContent($content);
+            }
+        }
+    },
+);