%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<& /Admin/Elements/Header, Title => $title &>
-<& /Elements/Tabs &>
-
-<& /Elements/ListActions, actions => \@results &>
-
-<form method="post" action="">
-<input type="hidden" id="<% $id %>" />
-
-<h2><&|/l&>Groups the user is member of (check box to delete)</&></h2>
-
-<& /Elements/CollectionList,
- OrderBy => 'Name',
- Order => 'ASC',
- %ARGS,
- Rows => 20,
- DisplayFormat => "__CheckBox.{Delete}__,$Format",
- Format => $Format,
- Collection => $is_member,
- AllowSorting => 1,
- PassArguments => [qw(Format Rows Page Order OrderBy id)],
-&>
-
-<h2><&|/l&>Groups the user is not member of (check box to add)</&></h2>
-
-<& /Elements/CollectionList,
- OrderBy => 'Name',
- Order => 'ASC',
- Rows => 20,
- %ARGS,
- DisplayFormat => "__CheckBox.{Add}__,'__HasMemberRecursively.{$id}__/TITLE:Recursive',$Format",
- Format => $Format,
- Collection => $is_not_member,
- AllowSorting => 1,
- PassArguments => [qw(Format Rows Page Order OrderBy id)],
-&>
-
-<& /Elements/Submit, Label => loc('Update'), Name => 'Update' &>
-
-</form>
-
-<%INIT>
-my $UserObj = RT::User->new($session{'CurrentUser'});
-$UserObj->Load( $id ) || Abort("Couldn't load user '$id'");
-
-my $title = loc("Memberships of the user [_1]", $UserObj->Name);
-
-my @results;
-if ( $Update ) {
- foreach my $gid( @Add ) {
- my $group = RT::Group->new( $session{'CurrentUser'} );
- $group->LoadUserDefinedGroup( $gid );
- unless ( $group->id ) {
- push @results, loc( "Couldn't load group #[_1]", $gid );
- next;
- }
- my ($status, $msg) = $group->AddMember( $id );
- push @results, $msg;
- }
- foreach my $gid( @Delete ) {
- my $group = RT::Group->new( $session{'CurrentUser'} );
- $group->LoadUserDefinedGroup( $gid );
- unless ( $group->id ) {
- push @results, loc( "Couldn't load group #[_1]", $gid );
- next;
- }
- my ($status, $msg) = $group->DeleteMember( $id );
- push @results, $msg;
- }
-}
-
-my $is_member = RT::Groups->new( $session{'CurrentUser'} );
-$is_member->LimitToUserDefinedGroups;
-$is_member->WithMember( PrincipalId => $UserObj->Id );
-
-my $is_not_member = RT::Groups->new( $session{'CurrentUser'} );
-$is_not_member->LimitToUserDefinedGroups;
-$is_not_member->WithoutMember( PrincipalId => $UserObj->Id );
-
-$Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Groups'};
-</%INIT>
-<%ARGS>
-$id => undef
-
-$Update => 0,
-@Add => (),
-@Delete => (),
-
-$Format => undef
-</%ARGS>
+<& /Admin/Elements/MembershipsPage, %ARGS &>