push @Groups, {
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.
-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>
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',
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>