[Rt-commit] rt branch, admin_ui, updated. 670bd315c0ba97cd1ddf88f3f64a0e6c805eb3d6

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Dec 1 00:49:37 EST 2009


The branch, admin_ui has been updated
       via  670bd315c0ba97cd1ddf88f3f64a0e6c805eb3d6 (commit)
      from  f7d92cc4a63437c527a1951caa6ac60555882747 (commit)

Summary of changes:
 lib/RT/Action/EditGroupRights.pm |   69 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100644 lib/RT/Action/EditGroupRights.pm

- Log -----------------------------------------------------------------
commit 670bd315c0ba97cd1ddf88f3f64a0e6c805eb3d6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Dec 1 13:49:07 2009 +0800

    add EditGroupRights action

diff --git a/lib/RT/Action/EditGroupRights.pm b/lib/RT/Action/EditGroupRights.pm
new file mode 100644
index 0000000..4c63e32
--- /dev/null
+++ b/lib/RT/Action/EditGroupRights.pm
@@ -0,0 +1,69 @@
+
+use strict;
+use warnings;
+
+package RT::Action::EditGroupRights;
+use base qw/RT::Action::EditRights/;
+use Scalar::Defer;
+
+sub arguments {
+    my $self = shift;
+    return {} unless $self->object;
+    my $args = {};
+    $args->{object_id} = {
+        render_as     => 'hidden',
+        default_value => $self->object->id,
+    };
+    $args->{object_type} = {
+        render_as     => 'hidden',
+        default_value => ref $self->object,
+    };
+
+    my @groups;
+
+    {
+        my $groups =
+          RT::Model::GroupCollection->new(
+            current_user => Jifty->web->current_user );
+        $groups->limit_to_system_internal_groups();
+        while ( my $group = $groups->next ) {
+            push @groups, $group;
+        }
+    }
+
+    {
+        my $groups =
+          RT::Model::GroupCollection->new(
+            current_user => Jifty->web->current_user );
+        $groups->limit_to_user_defined_groups();
+        while ( my $group = $groups->next ) {
+            push @groups, $group;
+        }
+    }
+
+    {
+        my $groups =
+          RT::Model::GroupCollection->new(
+            current_user => Jifty->web->current_user );
+        $groups->limit_to_roles( object => $self->object );
+        while ( my $group = $groups->next ) {
+            push @groups, $group;
+        }
+    }
+
+    for my $group ( @groups ) {
+        my $name = 'rights_' . $group->principal_id;
+        $args->{$name} = {
+            default_value    => defer {
+                $self->default_value($group->principal_id) },
+            available_values => defer { $self->available_values },
+            render_as        => 'Checkboxes',
+            multiple         => 1,
+            label => $group->name || $group->type,
+        };
+    }
+    return $args;
+}
+
+1;
+

-----------------------------------------------------------------------


More information about the Rt-commit mailing list