CatalystX::Usul::Controller::Admin::RoleManager - Maintains role membership


CatalystX-Usul documentation Contained in the CatalystX-Usul distribution.

Index


Code Index:

Name

Top

CatalystX::Usul::Controller::Admin::RoleManager - Maintains role membership

Version

Top

0.3.$Revision: 576 $

Synopsis

Top

   package MyApp::Controller::Admin;

   use base qw(CatalystX::Usul::Controller::Admin);

   __PACKAGE__->build_subcontrollers;

Description

Top

Adds/removes users to/from roles (groups). Works for multiple authentication realms

Subroutines/Methods

Top

roles_base

Midpoint that stashes the models used by the endpoints

role_manager

Displays the list of all users and the list of users in the currently selected role. Allows users to be moved from one list to the other

role_manager_delete

Deletes the selected role

role_manager_insert

Creates a new role

role_manager_update

Updates the membership list for the selected role

Diagnostics

Top

None

Configuration and Environment

Top

None

Dependencies

Top

CatalystX::Usul::Controller

Incompatibilities

Top

There are no known incompatibilities in this module

Bugs and Limitations

Top

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Top

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Top


CatalystX-Usul documentation Contained in the CatalystX-Usul distribution.

# @(#)$Id: RoleManager.pm 576 2009-06-09 23:23:46Z pjf $

package CatalystX::Usul::Controller::Admin::RoleManager;

use strict;
use warnings;
use version; our $VERSION = qv( sprintf '0.3.%d', q$Rev: 576 $ =~ /\d+/gmx );
use parent qw(CatalystX::Usul::Controller);

__PACKAGE__->config( namespace => q(admin), realm_class => q(IdentityUnix) );

__PACKAGE__->mk_accessors( qw(realm_class) );

sub roles_base : Chained(common) PathPart(users) CaptureArgs(0) {
   my ($self, $c) = @_; my $s = $c->stash;

   my $model = $c->model( $self->realm_class );
   my $realm = $self->get_key( $c, q(realm) ) || $model->default_realm;
   my $class = $realm ? $model->auth_realms->{ $realm } : $self->realm_class;

   $s->{role_model} = $c->model( $class )->roles;

   my $role  = $self->get_key( $c, q(role) );

   if ($role && $role ne $s->{newtag} && !$s->{role_model}->is_role( $role )) {
      $self->set_key( $c, q(role), q() );
   }

   return;
}

sub role_manager : Chained(roles_base) Args HasActions {
   my ($self, $c, $realm, $role) = @_;

   $realm = $self->set_key( $c, q(realm), $realm );
   $role  = $self->set_key( $c, q(role),  $role  );
   $c->stash->{role_model}->form( $realm, $role );
   return;
}

sub role_manager_delete : ActionFor(role_manager.delete) {
   my ($self, $c) = @_;

   $c->stash->{role_model}->delete;
   $self->set_key( $c, q(role), $c->stash->{newtag} );
   return 1;
}

sub role_manager_insert : ActionFor(role_manager.insert) {
   my ($self, $c) = @_;

   my $role = $c->stash->{role_model}->create;

   $self->set_key( $c, q(role), $role );
   return 1;
}

sub role_manager_update : ActionFor(role_manager.update) {
   my ($self, $c) = @_;

   $c->stash->{role_model}->update( $self->get_key( $c, q(role) ) );
   return 1;
}

1;

__END__

# Local Variables:
# mode: perl
# tab-width: 3
# End: