« blib/lib/OpusVL/AppKit/Plugin/AppKit.pm
↑ Summary
blib/lib/OpusVL/AppKit/Plugin/AppKitControllerSorter.pm »
| 1 | package OpusVL::AppKit::RolesFor::Schema::AppKitAuthDB::Result::Role; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use Moose::Role; | ||
| 5 | |||
| 6 | |||
| 7 | sub setup_authdb | ||
| 8 | { | ||
| 9 | my $class = shift; | ||
| 10 | |||
| 11 | $class->many_to_many( users => 'users_roles', 'user'); | ||
| 12 | $class->many_to_many( aclrules => 'aclrule_roles', 'aclrule_id'); | ||
| 13 | |||
| 14 | } | ||
| 15 | |||
| 16 | |||
| 17 | sub can_change_any_role | ||
| 18 | { | ||
| 19 | my $self = shift; | ||
| 20 | if(@_) | ||
| 21 | { | ||
| 22 | # set it | ||
| 23 | if(shift) | ||
| 24 | { | ||
| 25 | if($self->search_related('role_admin')->count == 0) | ||
| 26 | { | ||
| 27 | $self->create_related('role_admin', {}); | ||
| 28 | } | ||
| 29 | $self->delete_related('roles_allowed_roles'); | ||
| 30 | } | ||
| 31 | else | ||
| 32 | { | ||
| 33 | $self->delete_related('role_admin'); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | else | ||
| 37 | { | ||
| 38 | # return it. | ||
| 39 | return $self->search_related('role_admin')->count > 0; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | 1; | ||
| 44 | |||
| 45 | __END__ | ||
| 46 | |||
| 47 | =pod | ||
| 48 | |||
| 49 | =encoding UTF-8 | ||
| 50 | |||
| 51 | =head1 NAME | ||
| 52 | |||
| 53 | OpusVL::AppKit::RolesFor::Schema::AppKitAuthDB::Result::Role | ||
| 54 | |||
| 55 | =head1 VERSION | ||
| 56 | |||
| 57 | version 2.22 | ||
| 58 | |||
| 59 | =head2 setup_authdb | ||
| 60 | |||
| 61 | =head2 can_change_any_role | ||
| 62 | |||
| 63 | Set the a flag to indicate the role is allowed to modify any other role. | ||
| 64 | |||
| 65 | =head1 AUTHOR | ||
| 66 | |||
| 67 | OpusVL - www.opusvl.com | ||
| 68 | |||
| 69 | =head1 COPYRIGHT AND LICENSE | ||
| 70 | |||
| 71 | This software is copyright (c) 2010 by OpusVL - www.opusvl.com. | ||
| 72 | |||
| 73 | This is free software; you can redistribute it and/or modify it under | ||
| 74 | the same terms as the Perl 5 programming language system itself. | ||
| 75 | |||
| 76 | =cut |