CatalystX::Usul::Roles - Manage the roles and their members
Describes v0.17.$Rev: 1 $
use CatalystX::Usul::Roles::DBIC; use Class::Usul; my $usul = Class::Usul->new; my $user_obj = CatalystX::Usul::Users::DBIC->new( builder => $usul ); my $role_obj = CatalystX::Usul::Roles::DBIC->new( builder => $usul, users => $user_obj );
Implements the base class for role data stores. Each factory subclass should inherit from this and implement the required list of methods
Defines the following attributes
Hash ref which defaults to { _dirty => TRUE }
A CatalystX::Usul::Users object which is required
$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
$args->{user}
$args->{field}
f_add_user_to_role
$s
$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
$args->{role}
$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
f_create
$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
f_delete
@members = $role_obj->get_member_list( $role );
Returns the list of members of a given role
$role = $role_obj->get_name( $rid );
Returns the role name of the given role id
$rid = $role_obj->get_rid( $role );
Returns the role id of the given role name
@roles = $role_obj->get_roles( $user, $rid );
Returns the list of roles that the given user is a member of. If the user all is specified then a list of all roles is returned. If a specific user is passed then the $rid will be used as that users primary role id. If $rid is not specified then the primary role id will be looked up via the user object
$rid
$bool = $role_obj->is_member_of_role( $role, $user );
Returns true if the given user is a member of the given role, returns false otherwise
$bool = $role_obj->is_role( $role );
Returns true if $role exists, false otherwise
$role
$role_obj->remove_roles_from_user( $args );
Removes a user from one or more roles
$role_obj->remove_users_from_role( $args );
Removes one or more users from a role
$role_obj->role_form;
Adds data to the stash which displays the role management screen
$role_obj->update;
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
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Peter Flanigan, <Support at RoxSoft.co.uk>
<Support at RoxSoft.co.uk>
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
To install CatalystX::Usul, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::Usul
CPAN shell
perl -MCPAN -e shell install CatalystX::Usul
For more information on module installation, please visit the detailed CPAN module installation guide.