[Rt-commit] rt branch, 4.4/asset-custom-roles, repushed

? sunnavy sunnavy at bestpractical.com
Thu May 20 17:11:15 EDT 2021


The branch 4.4/asset-custom-roles was deleted and repushed:
       was 61c0b65f89c177394f16d71ccb7273677af01b13
       now d95fe2d665bb12ba6af73c1607b409aee856d3fa

 1: 3eabe161b0 =  1: 614bf65559 Add CustomRoleObj method for loading by GroupType
 2: 1729648931 =  2: 28e3352c0a Add RT::Asset->RoleAddresses
 3: 26e7d74b22 !  3: 9e0411e950 Factor out a LookupType role from CustomFields
    @@ -130,8 +130,8 @@
     -
     -sub CollectionClassFromLookupType {
     -    my $self = shift;
    --
    --    my $record_class = $self->RecordClassFromLookupType;
    +-    my $record_class = shift || $self->RecordClassFromLookupType;
    +-
     -    return undef unless $record_class;
     -
     -    my $collection_class;
    @@ -214,7 +214,7 @@
     +#
     +# COPYRIGHT:
     +#
    -+# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
    ++# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
     +#                                          <sales at bestpractical.com>
     +#
     +# (Except where explicitly superseded by other copyright notices)
    @@ -385,7 +385,7 @@
     +    unless ( $class ) {
     +        if (blessed($self) and $self->LookupType eq $type) {
     +            $RT::Logger->error(
    -+                "Custom Field #". $self->id
    ++                blessed($self) . " #". $self->id
     +                ." has incorrect LookupType '$type'"
     +            );
     +        } else {
    @@ -428,7 +428,7 @@
     +sub CollectionClassFromLookupType {
     +    my $self = shift;
     +
    -+    my $record_class = $self->RecordClassFromLookupType;
    ++    my $record_class = shift || $self->RecordClassFromLookupType;
     +    return undef unless $record_class;
     +
     +    my $collection_class;
    @@ -478,39 +478,6 @@
      </td></tr>
      
     
    -diff --git a/share/html/Admin/CustomRoles/Modify.html b/share/html/Admin/CustomRoles/Modify.html
    ---- a/share/html/Admin/CustomRoles/Modify.html
    -+++ b/share/html/Admin/CustomRoles/Modify.html
    -@@
    - <td colspan="3"><input name="Description" value="<% $Create ? "" : $RoleObj->Description || $Description || '' %>" size="60" /></td>
    - </tr>
    - 
    -+<tr><td align="right"><&|/l&>Applies to</&></td>
    -+<td><& /Admin/Elements/SelectLookupType,
    -+    Name    => "LookupType",
    -+    Object  => $RoleObj,
    -+    Default => $RoleObj->LookupType || $LookupType,
    -+&></td></tr>
    -+
    - <tr><td align="right"><&|/l&>Entry Hint</&>:</td>
    - <td colspan="3"><input name="EntryHint" value="<% $Create ? "" : $RoleObj->EntryHint || $EntryHint || '' %>" size="60" /></td>
    - </tr>
    -@@
    - 
    - if ( $RoleObj->Id ) {
    -     $title = loc('Configuration for role [_1]', $RoleObj->Name );
    --    my @attribs = qw(Description Name EntryHint Disabled);
    -+    my @attribs = qw(Description Name EntryHint LookupType Disabled);
    - 
    -     # we just created the role
    -     if (!$id || $id eq 'new') {
    -@@
    - $SetMultiple => undef
    - $Multiple => undef
    - $Enabled => undef
    -+$LookupType => RT::Ticket->CustomFieldLookupType
    - </%ARGS>
    -
     diff --git a/share/html/Admin/Elements/SelectCustomFieldLookupType b/share/html/Admin/Elements/SelectCustomFieldLookupType
     --- a/share/html/Admin/Elements/SelectCustomFieldLookupType
     +++ b/share/html/Admin/Elements/SelectCustomFieldLookupType
    @@ -547,7 +514,7 @@
     +%#
     +%# COPYRIGHT:
     +%#
    -+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
    ++%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
     +%#                                          <sales at bestpractical.com>
     +%#
     +%# (Except where explicitly superseded by other copyright notices)
 4: 396a5fd16a !  4: 68af85feb7 Allow RegisterLookupType to provide options besides just FriendlyName
    @@ -1,6 +1,9 @@
     Author: Shawn M Moore <shawn at bestpractical.com>
     
         Allow RegisterLookupType to provide options besides just FriendlyName
    +    
    +    We are going to add new options including "CreateGroupPredicate",
    +    "AppliesToObjectPredicate" and also "Subgroups".
     
     diff --git a/lib/RT/Record/Role/LookupType.pm b/lib/RT/Record/Role/LookupType.pm
     --- a/lib/RT/Record/Role/LookupType.pm
 5: 4b228a095a !  5: 49740f1d40 Add support for LookupType to custom roles
    @@ -53,34 +53,34 @@
        Creator integer NOT NULL DEFAULT 0  ,
        Created DATETIME NULL  ,
     
    -diff --git a/etc/upgrade/4.4.2/schema.Oracle b/etc/upgrade/4.4.2/schema.Oracle
    +diff --git a/etc/upgrade/4.4.5/schema.Oracle b/etc/upgrade/4.4.5/schema.Oracle
     new file mode 100644
     --- /dev/null
    -+++ b/etc/upgrade/4.4.2/schema.Oracle
    ++++ b/etc/upgrade/4.4.5/schema.Oracle
     @@
     +ALTER TABLE CustomRoles ADD LookupType VARCHAR2(255);
     +UPDATE CustomRoles SET LookupType='RT::Queue-RT::Ticket';
     
    -diff --git a/etc/upgrade/4.4.2/schema.Pg b/etc/upgrade/4.4.2/schema.Pg
    +diff --git a/etc/upgrade/4.4.5/schema.Pg b/etc/upgrade/4.4.5/schema.Pg
     new file mode 100644
     --- /dev/null
    -+++ b/etc/upgrade/4.4.2/schema.Pg
    ++++ b/etc/upgrade/4.4.5/schema.Pg
     @@
     +ALTER TABLE CustomRoles ADD COLUMN LookupType VARCHAR(255);
     +UPDATE CustomRoles SET LookupType='RT::Queue-RT::Ticket';
     
    -diff --git a/etc/upgrade/4.4.2/schema.SQLite b/etc/upgrade/4.4.2/schema.SQLite
    +diff --git a/etc/upgrade/4.4.5/schema.SQLite b/etc/upgrade/4.4.5/schema.SQLite
     new file mode 100644
     --- /dev/null
    -+++ b/etc/upgrade/4.4.2/schema.SQLite
    ++++ b/etc/upgrade/4.4.5/schema.SQLite
     @@
     +ALTER TABLE CustomRoles ADD COLUMN LookupType VARCHAR(255) collate NOCASE;
     +UPDATE CustomRoles SET LookupType='RT::Queue-RT::Ticket';
     
    -diff --git a/etc/upgrade/4.4.2/schema.mysql b/etc/upgrade/4.4.2/schema.mysql
    +diff --git a/etc/upgrade/4.4.5/schema.mysql b/etc/upgrade/4.4.5/schema.mysql
     new file mode 100644
     --- /dev/null
    -+++ b/etc/upgrade/4.4.2/schema.mysql
    ++++ b/etc/upgrade/4.4.5/schema.mysql
     @@
     +ALTER TABLE CustomRoles ADD COLUMN LookupType varchar(255) CHARACTER SET ascii;
     +UPDATE CustomRoles SET LookupType='RT::Queue-RT::Ticket';
    @@ -149,9 +149,9 @@
                  $role->Load($id);
      
     -            if ($object->isa('RT::Queue')) {
    --                # there's no way to apply the custom
    --                # role to a queue before that queue is created
    --                return 0;
    +-                # In case queue level custom role groups got deleted
    +-                # somehow.  Allow to re-create them like default ones.
    +-                return $role->IsAdded($object->id);
     -            }
     -            elsif ($object->isa('RT::Ticket')) {
     -                # see if the role has been applied to the ticket's queue
    @@ -165,17 +165,19 @@
      
                  return 0;
     @@
    -                 return 1;
    -             }
    - 
    --            # custom roles apply to queues, so canonicalize a ticket
    --            # into its queue
    --            if ($object->isa('RT::Ticket')) {
    --                $object = $object->QueueObj;
    --            }
    +             my $role = RT::CustomRole->new(RT->SystemUser);
    +             $role->Load($id);
    + 
    +-            if ( $object->isa('RT::Ticket') || $object->isa('RT::Queue') ) {
    +-                return 0 unless $object->CurrentUserHasRight('SeeQueue');
     -
    --            if ($object->isa('RT::Queue')) {
    --                return $role->IsAdded($object->Id);
    +-                # custom roles apply to queues, so canonicalize a ticket
    +-                # into its queue
    +-                if ( $object->isa('RT::Ticket') ) {
    +-                    $object = $object->QueueObj;
    +-                }
    +-
    +-                return $role->IsAdded( $object->Id );
     +            if (my $predicate = $role->LookupTypeRegistration($role->LookupType, 'AppliesToObjectPredicate')) {
     +                return $predicate->($object, $role);
                  }
    @@ -230,10 +232,15 @@
          return ( 0, $self->loc('Permission Denied') )
     -        unless $queue->CurrentUserHasRight('AdminCustomRoles');
     +        unless $object->CurrentUserHasRight('AdminCustomRoles');
    - 
    ++
          my $rec = RT::ObjectCustomRole->new( $self->CurrentUser );
    -     return $rec->Add( %args, CustomRole => $self );
    -@@
    +     my ( $status, $add ) = $rec->Add( %args, CustomRole => $self );
    +     my $msg;
    +-    $msg = $self->loc("[_1] added to queue [_2]", $self->Name, $queue->Name) if $status;
    ++    $msg = $self->loc("[_1] added to queue [_2]", $self->Name, $object->Name) if $status;
    + 
    +     return ( $add, $msg );
    + }
      
      =head2 RemoveFromObject
      
    @@ -272,9 +279,17 @@
          return ( 0, $self->loc('Permission Denied') )
     -        unless $queue->CurrentUserHasRight('AdminCustomRoles');
     +        unless $object->CurrentUserHasRight('AdminCustomRoles');
    - 
    ++
          my $rec = RT::ObjectCustomRole->new( $self->CurrentUser );
          $rec->LoadByCols( CustomRole => $self->id, ObjectId => $args{'ObjectId'} );
    +     return (0, $self->loc('Custom role is not added') ) unless $rec->id;
    +     my ( $status, $delete ) = $rec->Delete;
    +     my $msg;
    +-    $msg = $self->loc("[_1] removed from queue [_2]", $self->Name, $queue->Name) if $status;
    ++    $msg = $self->loc("[_1] removed from queue [_2]", $self->Name, $object->Name) if $status;
    + 
    +     return ( $delete, $msg );
    + }
     @@
          return ($ok, $msg);
      }
    @@ -355,11 +370,7 @@
      
     -    # disable each existant ticket group
     -    my $ticket_groups = RT::Groups->new($self->CurrentUser);
    -+    my $subgroup_config = $self->LookupTypeRegistration($self->LookupType, 'Subgroup');
    -+    if ($subgroup_config) {
    -+        # disable each existant ticket group
    -+        my $groups = RT::Groups->new($self->CurrentUser);
    - 
    +-
     -    if ($value) {
     -        $ticket_groups->LimitToEnabled;
     -    }
    @@ -369,7 +380,11 @@
     -
     -    $ticket_groups->Limit(FIELD => 'Domain', OPERATOR => 'LIKE', VALUE => "RT::Ticket-Role", CASESENSITIVE => 0 );
     -    $ticket_groups->Limit(FIELD => 'Name', OPERATOR => '=', VALUE => $self->GroupType, CASESENSITIVE => 0);
    --
    ++    my $subgroup_config = $self->LookupTypeRegistration($self->LookupType, 'Subgroup');
    ++    if ($subgroup_config) {
    ++        # disable each existant ticket group
    ++        my $groups = RT::Groups->new($self->CurrentUser);
    + 
     -    my $tickets = $ticket_groups->Join(
     -        ALIAS1 => 'main',
     -        FIELD1 => 'Instance',
    @@ -420,19 +435,6 @@
          }
      }
     @@
    -     # if you add a role to queues A and B, add users and privileges and
    -     # tickets on both, remove the role from B, disable the role, then re-enable
    -     # the role, we shouldn't re-enable B because it's still removed
    --    my $queues = $self->AddedTo;
    --    while (my $queue = $queues->Next) {
    --        $self->_SetGroupsDisabledForQueue($value, $queue);
    -+    my $objects = $self->AddedTo;
    -+    while (my $object = $objects->Next) {
    -+        $self->_SetGroupsDisabledForObject($value, $object);
    -     }
    - 
    -     $RT::Handle->Commit();
    -@@
              {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
              EntryHint =>
              {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
    @@ -559,16 +561,7 @@
          );
      
          if ($existing->Id) {
    --        # there already was a role group for this queue, which means
    -+        # there already was a role group for this object, which means
    -         # this was previously added, then removed, and is now being re-added,
    --        # which means we have to re-enable the queue group and all the
    --        # ticket groups
    --        $role->_SetGroupsDisabledForQueue(0, $queue);
    -+        # which means we have to re-enable the group
    -+        $role->_SetGroupsDisabledForObject(0, $object);
    -     }
    -     else {
    +@@
              my $group = RT::Group->new($self->CurrentUser);
              my ($ok, $msg) = $group->CreateRoleGroup(
                  Name   => $role->GroupType,
    @@ -586,15 +579,6 @@
      
      =cut
      
    -@@
    - 
    -     $RT::Handle->BeginTransaction;
    - 
    --    $self->CustomRoleObj->_SetGroupsDisabledForQueue(1, $self->QueueObj);
    -+    $self->CustomRoleObj->_SetGroupsDisabledForObject(1, $self->Object);
    - 
    -     # remove the ObjectCustomRole record
    -     my ($ok, $msg) = $self->SUPER::Delete(@_);
     
     diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
     --- a/lib/RT/Queue.pm
    @@ -606,7 +590,7 @@
     +        $roles->LimitToLookupType(RT::Ticket->CustomFieldLookupType);
              $roles->ApplySortOrder;
          }
    -     return ($roles);
    +     else {
     @@
          # Object Custom Roles
          $objs = RT::ObjectCustomRoles->new( $self->CurrentUser );
    @@ -629,9 +613,9 @@
     +        CreateGroupPredicate => sub {
     +            my ($object, $role) = @_;
     +            if ($object->isa('RT::Queue')) {
    -+                # there's no way to apply the custom
    -+                # role to a queue before that queue is created
    -+                return 0;
    ++                # In case queue level custom role groups got deleted
    ++                # somehow.  Allow to re-create them like default ones.
    ++                return $role->IsAdded($object->id);
     +            }
     +            elsif ($object->isa('RT::Ticket')) {
     +                # see if the role has been applied to the ticket's queue
    @@ -645,6 +629,8 @@
     +        },
     +        AppliesToObjectPredicate => sub {
     +            my ($object, $role) = @_;
    ++            return 0 unless $object->CurrentUserHasRight('SeeQueue');
    ++
     +            # custom roles apply to queues, so canonicalize a ticket
     +            # into its queue
     +            if ($object->isa('RT::Ticket')) {
    @@ -669,6 +655,39 @@
          effective => {},
          merged => {},
     
    +diff --git a/share/html/Admin/CustomRoles/Modify.html b/share/html/Admin/CustomRoles/Modify.html
    +--- a/share/html/Admin/CustomRoles/Modify.html
    ++++ b/share/html/Admin/CustomRoles/Modify.html
    +@@
    + <td colspan="3"><input name="Description" value="<% $Create ? "" : $RoleObj->Description || $Description || '' %>" size="60" /></td>
    + </tr>
    + 
    ++<tr><td align="right"><&|/l&>Applies to</&></td>
    ++<td><& /Admin/Elements/SelectLookupType,
    ++    Name    => "LookupType",
    ++    Object  => $RoleObj,
    ++    Default => $RoleObj->LookupType || $LookupType,
    ++&></td></tr>
    ++
    + <tr><td align="right"><&|/l&>Entry Hint</&>:</td>
    + <td colspan="3"><input name="EntryHint" value="<% $Create ? "" : $RoleObj->EntryHint || $EntryHint || '' %>" size="60" /></td>
    + </tr>
    +@@
    + 
    + if ( $RoleObj->Id ) {
    +     $title = loc('Configuration for role [_1]', $RoleObj->Name );
    +-    my @attribs = qw(Description Name EntryHint Disabled);
    ++    my @attribs = qw(Description Name EntryHint LookupType Disabled);
    + 
    +     # we just created the role
    +     if (!$id || $id eq 'new') {
    +@@
    + $SetMultiple => undef
    + $Multiple => undef
    + $Enabled => undef
    ++$LookupType => RT::Ticket->CustomFieldLookupType
    + </%ARGS>
    +
     diff --git a/share/html/Admin/CustomRoles/Objects.html b/share/html/Admin/CustomRoles/Objects.html
     --- a/share/html/Admin/CustomRoles/Objects.html
     +++ b/share/html/Admin/CustomRoles/Objects.html
 6: 9247b2c4e7 !  6: d32c3c0340 Add custom roles to assets
    @@ -15,9 +15,9 @@
     +        CreateGroupPredicate => sub {
     +            my ($object, $role) = @_;
     +            if ($object->isa('RT::Catalog')) {
    -+                # there's no way to apply the custom
    -+                # role to a catalog before that catalog is created
    -+                return 0;
    ++                # In case catalog level custom role groups got deleted
    ++                # somehow.  Allow to re-create them like default ones.
    ++                return $role->IsAdded($object->id);
     +            }
     +            elsif ($object->isa('RT::Asset')) {
     +                # see if the role has been applied to the asset's catalog
    @@ -29,6 +29,8 @@
     +        },
     +        AppliesToObjectPredicate => sub {
     +            my ($object, $role) = @_;
    ++            return 0 unless $object->CurrentUserHasRight('ShowCatalog');
    ++
     +            # custom roles apply to catalogs, so canonicalize an asset
     +            # into its catalog
     +            if ($object->isa('RT::Asset')) {
    @@ -52,6 +54,99 @@
      =head1 DESCRIPTION
      
      An Asset is a small record object upon which zero to many custom fields are
    +@@
    +     }
    + 
    +     my $roles = {};
    +-    my @errors = $self->_ResolveRoles( $roles, %args );
    ++    my @errors = $catalog->_ResolveRoles( $roles, %args );
    +     return (0, @errors) if @errors;
    + 
    +     RT->DatabaseHandle->BeginTransaction();
    +
    +diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
    +--- a/lib/RT/Interface/Web.pm
    ++++ b/lib/RT/Interface/Web.pm
    +@@
    +         elsif ($arg =~ /^SetRoleMember-(.+)$/) {
    +             my $role = $1;
    +             my $group = $object->RoleGroup($role);
    ++            if ( !$group->id ) {
    ++                $group = $object->_CreateRoleGroup($role);
    ++            }
    +             next unless $group->id and $group->SingleMemberRoleGroup;
    +-            next if $ARGS{$arg} eq $group->UserMembersObj->First->Name;
    ++            my $original_user = $group->UserMembersObj->First || RT->Nobody;
    ++            $ARGS{$arg} ||= 'Nobody';
    ++            next if $ARGS{$arg} eq $original_user->Name;
    +             my ($ok, $msg) = $object->AddRoleMember(
    +                 Type => $role,
    +-                User => $ARGS{$arg} || 'Nobody',
    ++                User => $ARGS{$arg},
    +             );
    +             push @results, $msg;
    +         }
    +
    +diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
    +--- a/lib/RT/Principal.pm
    ++++ b/lib/RT/Principal.pm
    +@@
    +             if ( $custom_role->id && !$custom_role->Disabled ) {
    +                 my $added;
    +                 for my $object ( @{ $args{'EquivObjects'} } ) {
    +-                    next unless $object->isa('RT::Queue');
    ++                    next unless $object->isa('RT::Queue') || $object->isa('RT::Catalog');
    +                     if ( $custom_role->IsAdded( $object->id ) ) {
    +                         $added = 1;
    +                         last;
    +@@
    +             if ( $custom_role->id && !$custom_role->Disabled ) {
    +                 my $added;
    +                 for my $object ( @{ $args{'EquivObjects'} } ) {
    +-                    next unless $object->isa('RT::Queue');
    ++                    next unless $object->isa('RT::Queue') || $object->isa('RT::Catalog');
    +                     if ( $custom_role->IsAdded( $object->id ) ) {
    +                         $added = 1;
    +                         last;
    +
    +diff --git a/lib/RT/Record/Role/Roles.pm b/lib/RT/Record/Role/Roles.pm
    +--- a/lib/RT/Record/Role/Roles.pm
    ++++ b/lib/RT/Record/Role/Roles.pm
    +@@
    +              map { [ $_, $self->_ROLES->{$_} ] }
    +             keys %{ $self->_ROLES };
    + 
    +-    # Cache at ticket/queue object level mainly to reduce calls of
    +-    # custom role's AppliesToObjectPredicate for performance.
    +-    if ( ref($self) =~ /RT::(?:Ticket|Queue)/ ) {
    ++    # Cache at object level mainly to reduce calls of custom role's
    ++    # AppliesToObjectPredicate for performance.
    ++    if ( ref($self) =~ /RT::(?:Ticket|Queue|Asset|Catalog)/ ) {
    +         $self->{_Roles}{$key} = \@roles;
    +     }
    +     return @roles;
    +
    +diff --git a/share/html/Asset/Create.html b/share/html/Asset/Create.html
    +--- a/share/html/Asset/Create.html
    ++++ b/share/html/Asset/Create.html
    +@@
    +   </&>
    + 
    +   <&| /Widgets/TitleBox, title => loc("People"), class => "asset-people", title_class => "inverse" &>
    +-    <& Elements/EditPeople, %ARGS, AssetObj => $asset &>
    ++    <& Elements/EditPeople, %ARGS, AssetObj => $asset, CatalogObj => $catalog &>
    +   </&>
    +   </td><td>
    +   <&| /Widgets/TitleBox, title => loc("Links"), class => "asset-links", title_class => "inverse" &>
    +@@
    +             ProcessLinksForCreate( ARGSRef => \%ARGS ),
    +             map {
    +                 $_ => $ARGS{$_}
    +-            } $asset->Roles,
    ++            } $catalog->Roles,
    +         );
    + 
    +         # Handle basic fields
     
     diff --git a/share/html/Asset/Elements/AssetSearchPeople b/share/html/Asset/Elements/AssetSearchPeople
     --- a/share/html/Asset/Elements/AssetSearchPeople
    @@ -77,23 +172,30 @@
      % for my $role ($Object->Roles( ACLOnly => 0 )) {
      <div class="role-<% CSSClass($role) %> role">
     -  <h3><% loc($role) %></h3>
    +-  <& EditRoleMembers, Group => $Object->RoleGroup($role) &>
     +  <h3><% $Object->LabelForRole($role) %></h3>
    -   <& EditRoleMembers, Group => $Object->RoleGroup($role) &>
    ++  <& EditRoleMembers, Object => $Object, Role => $role &>
      </div>
      % }
    + <em><&|/l&>(Check box to delete)</&></em>
     
     diff --git a/share/html/Asset/Elements/EditPeople b/share/html/Asset/Elements/EditPeople
     --- a/share/html/Asset/Elements/EditPeople
     +++ b/share/html/Asset/Elements/EditPeople
     @@
    - % for my $role ( $AssetObj->Roles ) {
    + %#
    + %# END BPS TAGGED BLOCK }}}
    + <table border="0" cellpadding="0" cellspacing="0">
    +-% for my $role ( $AssetObj->Roles ) {
    ++% for my $role ( ($AssetObj->Id ? $AssetObj->Id : $CatalogObj)->Roles ) {
      <tr class="asset-people-<% CSSClass($role) %>">
      <td class="label">
     -<% loc($role) %>:
    -+<% $AssetObj->LabelForRole($role) %>:
    ++<% ($AssetObj->Id ? $AssetObj->Id : $CatalogObj)->LabelForRole($role) %>:
      </td>
      <td class="value" colspan="5">
    - <& /Elements/EmailInput, Name => $role, Size => undef, Default => $ARGS{$role}, Autocomplete => 1 &>
    +-<& /Elements/EmailInput, Name => $role, Size => undef, Default => $ARGS{$role}, Autocomplete => 1, ($AssetObj->Role($role)->{Single} ? () : (AutocompleteType => 'Principals', AutocompleteMultiple => 1)) &>
    ++<& /Elements/EmailInput, Name => $role, Size => undef, Default => $ARGS{$role}, Autocomplete => 1, (($AssetObj->Id ? $AssetObj->Id : $CatalogObj)->Role($role)->{Single} ? () : (AutocompleteType => 'Principals', AutocompleteMultiple => 1)) &>
      </td>
      </tr>
     +
    @@ -111,6 +213,38 @@
      % }
      
      </table>
    + 
    + <%args>
    + $AssetObj
    ++$CatalogObj
    + </%args>
    +
    +diff --git a/share/html/Asset/Elements/EditRoleMembers b/share/html/Asset/Elements/EditRoleMembers
    +--- a/share/html/Asset/Elements/EditRoleMembers
    ++++ b/share/html/Asset/Elements/EditRoleMembers
    +@@
    + %#
    + %# END BPS TAGGED BLOCK }}}
    + <%args>
    +-$Group       => undef
    ++$Object
    ++$Role
    + $Recursively => 0
    + </%args>
    + <%init>
    ++my $Group = $Object->RoleGroup($Role);
    + my $field_name = "RemoveRoleMember-" . $Group->Name;
    + </%init>
    + <ul class="role-members">
    + % my $Users = $Group->UserMembersObj( Recursively => $Recursively );
    +-% if ($Group->SingleMemberRoleGroup) {
    +-<input type="text" value="<% $Users->First->Name %>" name="SetRoleMember-<% $Group->Name %>" id="SetRoleMember-<% $Group->Name %>" data-autocomplete="Users" data-autocomplete-return="Name" /><br />
    ++% if ($Object->Role($Role)->{Single}) {
    ++% my $user = $Users->First || RT->Nobody;
    ++<input type="text" value="<% $user->Name %>" name="SetRoleMember-<% $Role %>" id="SetRoleMember-<% $Role %>" data-autocomplete="Users" data-autocomplete-return="Name" /><br />
    + % } else {
    + % while ( my $user = $Users->Next ) {
    + <li>
     
     diff --git a/share/html/Asset/Elements/SelectRoleType b/share/html/Asset/Elements/SelectRoleType
     --- a/share/html/Asset/Elements/SelectRoleType
    @@ -136,4 +270,9 @@
      % if ($AssetObj->Role($role)->{Single}) {
      %      my $users = $AssetObj->RoleGroup($role)->UserMembersObj(Recursively => 0);
      %      $users->FindAllRows;
    -
    +-%      my $user = $users->Next;
    ++%      my $user = $users->Next || RT->Nobody;
    + <& /Elements/ShowUser, User => $user, Link => 1 &></td></tr>
    + %      next if $user->id == RT->Nobody->id;
    + <tr><td>
    +
 7: d09f361f29 < --:  ------- Support custom roles on asset creation
 8: d0c69db663 !  7: f955f75884 Add API and web tests for interacting with custom roles on assets
    @@ -391,7 +391,7 @@
     +        },
     +        button => 'Update',
     +    }, "submitted applies to form");
    -+    $m->text_like(qr/Object created/, "Found update message");
    ++    $m->text_contains('Licensee added to queue Software', "Found update message");
     +
     +    # refresh cache
     +    RT::CustomRoles->RegisterRoles;
    @@ -436,12 +436,12 @@
     +
     +    my $acl_id = $catalog->RoleGroup($role->GroupType)->Id;
     +
    -+    $m->submit_form_ok({
    -+        with_fields => {
    -+            "SetRights-" . $acl_id . '-RT::Catalog-' . $catalog->id => 'ShowAsset',
    -+        },
    -+    }, "submitted rights form");
    ++    $m->form_name('ModifyGroupRights');
    ++    $m->tick("SetRights-" . $acl_id . '-RT::Catalog-' . $catalog->id, 'ShowAsset');
    ++    $m->tick("SetRights-" . $acl_id . '-RT::Catalog-' . $catalog->id, 'ShowCatalog');
    ++    $m->submit;
     +    $m->text_contains("Granted right 'ShowAsset' to Licensee");
    ++    $m->text_contains("Granted right 'ShowCatalog' to Licensee");
     +
     +    RT::Principal::InvalidateACLCache();
     +}
    @@ -534,6 +534,9 @@
     +    is $role->Name, "Licensee", "Name matches";
     +    ok $role->Disabled, "now disabled";
     +
    ++    my $catalog_id = $catalog->Id;
    ++    $catalog = RT::Catalog->new( RT->SystemUser );
    ++    $catalog->Load($catalog_id);
     +    is_deeply([sort $catalog->Roles], [sort 'Contact', 'HeldBy', 'Owner'], '->Roles no longer includes Licensee');
     +}
     +
    @@ -583,6 +586,5 @@
     +    is $asset3->RoleAddresses($role->GroupType), '', "No Licensee";
     +}
     +
    -+undef $m;
     +done_testing;
     
 9: bb684f6f65 =  8: 5a4779e924 Relax requirements about role names
10: 03ded03043 =  9: 1a28f7faee Add lookup type to custom role admin page listing
11: 8e35aa6f6f ! 10: fb08f55e8c Exclude asset custom roles from ticket search
    @@ -38,7 +38,7 @@
     --- a/share/html/Search/Bulk.html
     +++ b/share/html/Search/Bulk.html
     @@
    - <td class="value"> <& /Elements/EmailInput, Name => "DeleteAdminCc", Size=> 20, Default => $ARGS{DeleteAdminCc} &> </td></tr>
    + <td class="value"> <& /Elements/EmailInput, Name => "DeleteAdminCc", Size=> 20, Default => $ARGS{DeleteAdminCc}, AutocompleteType => 'Principals' &> </td></tr>
      
      % my $single_roles = RT::CustomRoles->new($session{CurrentUser});
     +% $single_roles->LimitToLookupType(RT::Ticket->CustomFieldLookupType);
12: c61e0684d2 ! 11: dff04c7492 Remove custom role name uniqueness restriction
    @@ -17,9 +17,9 @@
     --- a/lib/RT/Action/Notify.pm
     +++ b/lib/RT/Action/Notify.pm
     @@
    -                  || $name eq 'OtherRecipients'
    -                  || $name eq 'AlwaysNotifyActor';
    - 
    +             $role->Load( $id );
    +         }
    +         else {
     -            my $roles = RT::CustomRoles->new( $self->CurrentUser );
     +            my $roles = $self->TicketObj->QueueObj->CustomRoles;
                  $roles->Limit( FIELD => 'Name', VALUE => $name, CASESENSITIVE => 0 );
    @@ -37,7 +37,7 @@
     +                }
                  }
              }
    -         else {
    + 
     
     diff --git a/lib/RT/CustomRole.pm b/lib/RT/CustomRole.pm
     --- a/lib/RT/CustomRole.pm
13: 61c0b65f89 < --:  ------- Confirm the user object loaded a user before accessing id
--:  ------- > 12: 4ae2bd7ac2 Clear old data when registering the whole custom roles
--:  ------- > 13: d95fe2d665 Show single custom role's name in the result message of adding members



More information about the rt-commit mailing list