The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

CatalystX::Usul::Model::Roles - Manage the roles and their members

Version

Describes v0.16.$Rev: 1 $

Synopsis

   package YourApp::Model::Roles;

   use CatalystX::Usul::Moose;

   extends q(CatalystX::Usul::Model::Roles);

Description

Manage the roles and their members

Configuration and Environment

Defines the following list of attributes

user_model_class

A required non empty simple string. Passed by "build_per_context_instance" to the Catalyst model method

Subroutines/Methods

build_per_context_instance

Sets our domain model to that of our user model's, domain model's roles object

add_roles_to_user

   $role_obj->add_roles_to_user( $args );

Adds the user to one or more roles. The user is passed in $args->{user} and $args->{field} is the field to extract from the request object. Calls f_add_user_to_role in the factory subclass to add one user to one role. A suitable message from the stash $s is added to the result div upon success

add_users_to_role

   $role_obj->add_users_to_role( $args );

Adds one or more users to the specified role. The role is passed in $args->{role} and $args->{field} is the field to extract from the request object. Calls f_add_user_to_role in the factory subclass to add one user to one role. A suitable message from the stash $s is added to the result div upon success

create

   $role_obj->create;

Creates a new role. The name field from the request object is passed to f_create in the factory subclass. A suitable message from the stash $s is added to the result div upon success

delete

   $role_obj->delete;

Deletes an existing role. The role field from the request object is passed to the f_delete method in the factory subclass. A suitable message from the stash $s is added to the result div

get_member_list

   @members = $role_obj->get_member_list( $role );

Returns the list of members of a given role. Exposes method in the domain model

get_roles

   @roles = $role_obj->get_roles( $user, $rid );

Returns the list of roles that the given user is a member of. Exposes method in the domain model

is_role

   $bool = $role_obj->is_role( $role );

Returns true if $role exists, false otherwise. Exposes method in the domain model

remove_roles_from_user

   $role_obj->remove_roles_from_user( $args );

Removes a user from one or more roles

remove_users_from_role

   $role_obj->remove_users_from_role( $args );

Removes one or more users from a role

role_manager_form

   $role_obj->role_form;

Adds data to the stash which displays the role management screen

update_roles

   $role_obj->update_roles;

Called as an action from the the management screen. This method determines if roles have been added and/or removed from the selected user and calls "add_roles_to_user" and/or "remove_roles_from_user" as appropriate

update_users

   $role_obj->update_users;

Called as an action from the the management screen. This method determines if users have been added and/or removed from the selected role and calls "add_users_to_role" and/or "remove_users_from_role" as appropriate

Diagnostics

None

Dependencies

CatalystX::Usul::Model
CatalystX::Usul::TraitFor::Model::QueryingRequest
CatalystX::Usul::TraitFor::Model::StashHelper

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

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

Author

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

License and Copyright

Copyright (c) 2014 Peter Flanigan. All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic

This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE