]> git.uio.no Git - usit-rt.git/blobdiff - docs/initialdata.pod
Upgrade to 4.2.8
[usit-rt.git] / docs / initialdata.pod
index c649b622157a147cbdc3e408f4be4a24e8fa1509..ac55dcf170c9319aa826d4fc65e34591d719ad35 100644 (file)
@@ -78,58 +78,21 @@ For a full list of fields, read the documentation for L<RT::User/Create>.
 =head2 C<@Groups>
 
     push @Groups, {
-        Domain      => 'UserDefined',
         Name        => 'Example Employees',
         Description => 'All of the employees of my company',
+        Members     => { Users =>  [ qw/ alexmv trs falcone / ],
+                         Groups => [ qw/ extras / ] },
     };
 
 Creates a new L<RT::Group> for each hashref.  In almost all cases you'll want
 to follow the example above to create a group just as if you had done it from
-the admin interface.  B<Do not> omit the C<< Domain => 'UserDefined' >> line.
+the admin interface.
 
-Additionally, the C<MemberOf> field is specially handled to make it easier to
-add the new group to other groups.  C<MemberOf> may be a single value or an
-array ref.  Each value should be a user-defined group name or hashref to pass
-into L<RT::Group/LoadByCols>.  Each group found will have the new group
-added as a member.
-
-Unfortunately you can't specify the I<members> of a group at this time.  As a
-workaround, you can push a subref into C<@Final> which adds members to your new
-groups.  An example, using a convenience function to avoid repeating yourself:
-
-    push @Final, sub {
-        add_members('My New Group Name' => qw(trs alex ruslan));
-        add_members('My Second Group'   => qw(jesse kevin sunnavy jim));
-    };
-
-    sub add_members {
-        my $group_name = shift;
-        my @members    = @_;
-
-        my $group = RT::Group->new( RT->SystemUser );
-        $group->LoadUserDefinedGroup($group_name);
-
-        if ($group->id) {
-            for my $name (@members) {
-                my $member = RT::User->new( RT->SystemUser );
-                $member->LoadByCols( Name => $name );
-
-                unless ($member->Id) {
-                    RT->Logger->error("Unable to find user '$name'");
-                    next;
-                }
-
-                my ($ok, $msg) = $group->AddMember( $member->PrincipalObj->Id );
-                if ($ok) {
-                    RT->Logger->info("Added member $name to $group_name");
-                } else {
-                    RT->Logger->error("Unable to AddMember $name to $group_name: $msg");
-                }
-            }
-        } else {
-            RT->Logger->error("Unable to find group '$group_name'!");
-        }
-    }
+In addition to the C<Members> option shown above, which can take both
+users and groups, the C<MemberOf> field may be a single value or an
+array ref.  Each value should be a user-defined group name or hashref to
+pass into L<RT::Group/LoadByCols>.  Each group found will have the new
+group added as a member.
 
 =head2 C<@Queues>
 
@@ -145,7 +108,6 @@ L<RT::Queue/Create> for the fields you can use.
 =head2 C<@CustomFields>
 
     push @CustomFields, {
-        Queue       => 0,
         Name        => 'Favorite color',
         Type        => 'FreeformSingle',
         LookupType  => 'RT::Queue-RT::Ticket',
@@ -164,10 +126,15 @@ The name of this CF as displayed in RT.
 
 A short summary of what this CF is for.
 
-=item C<Queue>
+=item C<ApplyTo>
+
+May be a single value, or an array reference of such; each should be
+either an ID or Name.  If omitted, the CF is applied globally.  This
+should not be used for User or Group custom fields.
 
-May be a Name or ID.  The single queue or array ref of queues to apply this CF
-to.  This does not apply when C<LookupType> does not start with C<RT::Queue>.
+This argument may also be passed via C<Queue>, for backwards
+compatibility, which also defaults the C<LookupType> to
+C<RT::Queue-RT::Ticket>.
 
 =item C<Type>
 
@@ -215,6 +182,7 @@ is for Tickets, Transactions, Users, Groups, or Queues.  Possible values:
     RT::User                                # Users
     RT::Group                               # Groups
     RT::Queue                               # Queues
+    RT::Class-RT::Article                   # Articles
 
 Ticket CFs are the most common, meaning C<RT::Queue-RT::Ticket> is the most
 common C<LookupType>.
@@ -247,7 +215,6 @@ field.  This only makes sense for "Select" CFs.  An example:
 
     my $i = 1;
     push @CustomFields, {
-        Queue       => 0,                       # Globally applied
         LookupType  => 'RT::Queue-RT::Ticket',  # for Tickets
         Name        => 'Type of food',
         Type        => 'SelectSingle',  # SelectSingle is the same as: Type => 'Select', MaxValues => 1
@@ -301,6 +268,7 @@ granted.  This is B<different> than the user/group/role receiving the right.
 =item Granted on a custom field by name (or ID), potentially a global or queue
 
     CF => 'Name',
+    LookupType => 'RT::User',  # optional, in case you need to disambiguate
 
 =item Granted on a queue
 
@@ -311,6 +279,19 @@ granted.  This is B<different> than the user/group/role receiving the right.
     CF      => 'Name',
     Queue   => 'Name',
 
+=item Granted on a custom field applied to some other object
+
+    # This finds the CF named "Name" applied to Articles in the
+    # "Responses" class
+    CF         => 'Name',
+    LookupType => RT::Article->CustomFieldLookupType,
+    ObjectId   => 'Responses',
+
+=item Granted on some other object (article Classes, etc)
+
+    ObjectType => 'RT::Class',
+    ObjectId   => 'Name',
+
 =item Granted globally
 
 Specifying none of the above will get you a global right.
@@ -446,8 +427,33 @@ L<RT::Template/Create> for the fields you can use.
 
 An array of L<RT::Attribute>s to create.  You likely don't need to mess with
 this.  If you do, know that the key C<Object> is expected to be an
-L<RT::Record> object on which to call C<AddAttribute>.  If you don't provide
-C<Object> or it's undefined, C<< RT->System >> will be used.
+L<RT::Record> object or a subroutine reference that returns an object on which
+to call C<AddAttribute>.  If you don't provide C<Object> or it's undefined,
+C<< RT->System >> will be used.
+
+Here is an example of using a subroutine reference as a value for Object:
+
+    @Attributes = ({
+        Name        => 'SavedSearch',
+        Description => 'New Tickets in SomeQueue',
+        Object      => sub {
+            my $GroupName = 'SomeQueue Group';
+            my $group     = RT::Group->new( RT->SystemUser );
+    
+            my( $ret, $msg ) = $group->LoadUserDefinedGroup( $GroupName );
+            die $msg unless $ret;
+    
+            return $group;
+        },
+        Content     => {
+            Format =>  <<'        END_OF_FORMAT',
+    ....
+            END_OF_FORMAT
+            Query   => "Status = 'new' AND Queue = 'SomeQueue'",
+            OrderBy => 'id',
+            Order   => 'DESC'
+        },
+    });
 
 =head2 C<@Initial>