2 # BEGIN BPS TAGGED BLOCK {{{
6 # This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
7 # <jesse@bestpractical.com>
9 # (Except where explicitly superseded by other copyright notices)
14 # This work is made available to you under the terms of Version 2 of
15 # the GNU General Public License. A copy of that license should have
16 # been provided with this software, but in any event can be snarfed
19 # This work is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 # General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 # CONTRIBUTION SUBMISSION POLICY:
31 # (The following paragraph is not intended to limit the rights granted
32 # to you to modify and distribute this software under the terms of
33 # the GNU General Public License and is only of importance to you if
34 # you choose to contribute your changes and enhancements to the
35 # community by submitting them to Best Practical Solutions, LLC.)
37 # By intentionally submitting any modifications, corrections or
38 # derivatives to this work, or any other work intended for use with
39 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
40 # you are the copyright holder for those contributions and you grant
41 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
42 # royalty-free, perpetual, license to use, copy, create derivative
43 # works based on those contributions, and sublicense and distribute
44 # those contributions and any derivatives thereof.
46 # END BPS TAGGED BLOCK }}}
48 use lib "@RT_LIB_PATH@";
55 my $LocalOnly = @ARGV ? shift(@ARGV) : 1;
60 id Created Creator LastUpdated LastUpdatedBy
67 my $SystemUserId = $RT::SystemUser->Id;
69 Users Groups Queues ScripActions ScripConditions
70 Templates Scrips ACL CustomFields
72 foreach my $class (@classes) {
73 require "RT/$class.pm";
74 my $objects = "RT::$class"->new($RT::SystemUser);
75 $objects->{find_disabled_rows} = 1;
78 if ($class eq 'CustomFields') {
79 $objects->OrderByCols(
80 { FIELD => 'LookupType' },
81 { FIELD => 'SortOrder' },
86 $objects->OrderBy( FIELD => 'Id' );
90 next if $class eq 'ACL'; # XXX - would go into infinite loop - XXX
91 $objects->Limit( FIELD => 'LastUpdatedBy', OPERATOR => '!=', VALUE => $SystemUserId )
92 unless $class eq 'Groups';
93 $objects->Limit( FIELD => 'Id', OPERATOR => '!=', VALUE => $SystemUserId )
95 $objects->Limit( FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined' )
96 if $class eq 'Groups';
100 while (my $obj = $objects->Next) {
101 next if $obj->can('LastUpdatedBy') and $obj->LastUpdatedBy == $SystemUserId;
104 %fields = map { $_ => 1 } keys %{$obj->_ClassAccessible};
106 @{$Ignore{$class}||=[]},
107 @{$Ignore{All}||=[]},
112 # next if $obj-> # skip default names
113 foreach my $field (sort keys %fields) {
114 my $value = $obj->__Value($field);
115 $rv->{$field} = $value if length($value);
117 delete $rv->{Disabled} unless $rv->{Disabled};
119 foreach my $record (map { /ACL/ ? 'ACE' : substr($_, 0, -1) } @classes) {
120 foreach my $key (map "$record$_", ('', 'Id')) {
121 next unless exists $rv->{$key};
122 my $id = $rv->{$key} or next;
123 my $obj = "RT::$record"->new($RT::SystemUser);
124 $obj->LoadByCols( Id => $id ) or next;
125 $rv->{$key} = $obj->__Value('Name') || 0;
129 if ($class eq 'Users' and defined $obj->Privileged) {
130 $rv->{Privileged} = int($obj->Privileged);
132 elsif ($class eq 'CustomFields') {
133 my $values = $obj->Values;
134 while (my $value = $values->Next) {
135 push @{$rv->{Values}}, {
136 map { ($_ => $value->__Value($_)) } qw(
137 Name Description SortOrder
143 if (eval { require RT::Attributes; 1 }) {
144 my $attributes = $obj->Attributes;
145 while (my $attribute = $attributes->Next) {
146 my $content = $attribute->Content;
147 $rv->{Attributes}{$attribute->Name} = $content if length($content);
151 push @{$RV{$class}}, $rv;
156 no strict; use XML::Simple; *_ = XMLin(do { local \$/; readline(DATA) }, ForceArray => [qw(
158 )], NoAttr => 1, SuppressEmpty => ''); *\$_ = (\$_{\$_} || []) for keys \%_; 1; # vim: ft=xml
163 { map { ($_ => ($RV{$_} || [])) } @classes },
164 RootName => 'InitialData',
167 XMLDecl => '<?xml version="1.0" encoding="UTF-8"?>',