[Rt-commit] rt branch, 4.2/memberships-page-for-groups, created. rt-4.0.4-377-g87afda5
Ruslan Zakirov
ruz at bestpractical.com
Fri Jan 20 16:11:00 EST 2012
The branch, 4.2/memberships-page-for-groups has been created
at 87afda59229a127ae090071429a7d75aa6ece89d (commit)
- Log -----------------------------------------------------------------
commit 87afda59229a127ae090071429a7d75aa6ece89d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 21 00:54:58 2012 +0400
Memberships page for Groups
diff --git a/share/html/Admin/Users/Memberships.html b/share/html/Admin/Elements/MembershipsPage
similarity index 81%
copy from share/html/Admin/Users/Memberships.html
copy to share/html/Admin/Elements/MembershipsPage
index 443e189..d283fae 100644
--- a/share/html/Admin/Users/Memberships.html
+++ b/share/html/Admin/Elements/MembershipsPage
@@ -47,13 +47,12 @@
%# END BPS TAGGED BLOCK }}}
<& /Admin/Elements/Header, Title => $title &>
<& /Elements/Tabs &>
-
-<& /Elements/ListActions, actions => \@results &>
+<& /Elements/ListActions &>
<form method="post" action="">
<input type="hidden" id="<% $id %>" />
-<h2><&|/l&>Groups the user is member of (check box to delete)</&></h2>
+<h2><&|/l&>Groups the principal is member of (check box to delete)</&></h2>
<& /Elements/CollectionList,
OrderBy => 'Name',
@@ -67,7 +66,7 @@
PassArguments => [qw(Format Rows Page Order OrderBy id)],
&>
-<h2><&|/l&>Groups the user is not member of (check box to add)</&></h2>
+<h2><&|/l&>Groups the principal is not member of (check box to add)</&></h2>
<& /Elements/CollectionList,
OrderBy => 'Name',
@@ -86,13 +85,14 @@
</form>
<%INIT>
-my $UserObj = RT::User->new($session{'CurrentUser'});
-$UserObj->Load( $id ) || Abort("Couldn't load user '$id'");
+my $principal = RT::Principal->new( $session{'CurrentUser'} );
+$principal->Load( $id ) || Abort(loc("Couldn't load principal #[_1]", $id));
-my $title = loc("Memberships of the user [_1]", $UserObj->Name);
+my $object = $principal->Object;
+$id = $object->id;
-my @results;
if ( $Update ) {
+ my @results;
foreach my $gid( @Add ) {
my $group = RT::Group->new( $session{'CurrentUser'} );
$group->LoadUserDefinedGroup( $gid );
@@ -113,17 +113,32 @@ if ( $Update ) {
my ($status, $msg) = $group->DeleteMember( $id );
push @results, $msg;
}
+ MaybeRedirectForResults(
+ Arguments => { id => $id },
+ Actions => \@results,
+ );
}
my $is_member = RT::Groups->new( $session{'CurrentUser'} );
$is_member->LimitToUserDefinedGroups;
-$is_member->WithMember( PrincipalId => $UserObj->Id );
+$is_member->WithMember( PrincipalId => $id );
my $is_not_member = RT::Groups->new( $session{'CurrentUser'} );
$is_not_member->LimitToUserDefinedGroups;
-$is_not_member->WithoutMember( PrincipalId => $UserObj->Id );
+$is_not_member->WithoutMember( PrincipalId => $id );
+$is_not_member->Limit( FIELD => 'id', OPERATOR => '!=', VALUE => $id );
$Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Groups'};
+
+my $title;
+if ( $principal->IsUser ) {
+ $title = loc("Memberships of the user [_1]", $object->Name);
+} elsif ( $principal->IsGroup ) {
+ $title = loc("Memberships of the group [_1]", $object->Name);
+} else {
+ $title = loc("Memberships of the principal #[_1]", $id);
+}
+
</%INIT>
<%ARGS>
$id => undef
diff --git a/share/html/Admin/Groups/Memberships.html b/share/html/Admin/Groups/Memberships.html
new file mode 100644
index 0000000..dab15c7
--- /dev/null
+++ b/share/html/Admin/Groups/Memberships.html
@@ -0,0 +1 @@
+<& /Admin/Elements/MembershipsPage, %ARGS &>
diff --git a/share/html/Admin/Users/Memberships.html b/share/html/Admin/Users/Memberships.html
index 443e189..05cae21 100644
--- a/share/html/Admin/Users/Memberships.html
+++ b/share/html/Admin/Users/Memberships.html
@@ -45,92 +45,4 @@
%# 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,
- at Add => (),
- at Delete => (),
-
-$Format => undef
-</%ARGS>
+<& /Admin/Elements/MembershipsPage, %ARGS &>
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 2c434d3..9d41b86 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -329,6 +329,7 @@ my $build_admin_menu = sub {
my $tabs = PageMenu();
$tabs->child( basics => title => loc('Basics'), path => "/Admin/Groups/Modify.html?id=" . $obj->id );
$tabs->child( members => title => loc('Members'), path => "/Admin/Groups/Members.html?id=" . $obj->id );
+ $tabs->child( memberships => title => loc('Memberships'), path => "/Admin/Groups/Memberships.html?id=" . $obj->id );
$tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Groups/GroupRights.html?id=" . $obj->id );
$tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Groups/UserRights.html?id=" . $obj->id );
$tabs->child( history => title => loc('History'), path => "/Admin/Groups/History.html?id=" . $obj->id );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list