« Workflow/Activities/Authorities/Standard/PowerUserRole.pm
↑ Summary
Controller/Authorities/AuthoritiesFunction.pm »
| 1 | package Daje::Workflow::Activities::Authorities::Standard::UserRole; | ||
| 2 | use Mojo::Base 'Daje::Workflow::Activities::Authorities::Standard::Base', -base; | ||
| 3 | use v5.42; | ||
| 4 | |||
| 5 | # NAME | ||
| 6 | # ==== | ||
| 7 | # | ||
| 8 | # Daje::Workflow::Activities::Authorities::Standard::PowerUserRole - Daje Role creating activity, | ||
| 9 | # creates a new admin role and attach it to user and company | ||
| 10 | # | ||
| 11 | # SYNOPSIS | ||
| 12 | # ======== | ||
| 13 | # | ||
| 14 | # | ||
| 15 | # DESCRIPTION | ||
| 16 | # =========== | ||
| 17 | # | ||
| 18 | # Daje::Workflow::Activities::Authorities::Standard::PowerUserRole creates a power user role | ||
| 19 | # | ||
| 20 | # METHODS | ||
| 21 | # ======= | ||
| 22 | # | ||
| 23 | # | ||
| 24 | # | ||
| 25 | # | ||
| 26 | # SEE ALSO | ||
| 27 | # ======== | ||
| 28 | # | ||
| 29 | # Mojolicious, Mojolicious::Guides, https://mojolicious.org. | ||
| 30 | # | ||
| 31 | # LICENSE | ||
| 32 | # ======= | ||
| 33 | # | ||
| 34 | # Copyright (C) janeskil1525. | ||
| 35 | # | ||
| 36 | # This library is free software; you can redistribute it and/or modify | ||
| 37 | # it under the same terms as Perl itself. | ||
| 38 | # | ||
| 39 | # AUTHOR | ||
| 40 | # ====== | ||
| 41 | # | ||
| 42 | # janeskil1525 E<lt>janeskil1525@gmail.com | ||
| 43 | # | ||
| 44 | |||
| 45 | |||
| 46 | use Daje::Database::View::vAuthoritiesPluginList; | ||
| 47 | use Daje::Database::View::vAuthoritiesFunction; | ||
| 48 | use Daje::Database::View::vAuthoritiesPermissionsList; | ||
| 49 | |||
| 50 | sub create_normal_role($self) { | ||
| 51 | $self->model->insert_history( | ||
| 52 | "User role for new client", | ||
| 53 | "Daje::Workflow::Activities::Authorities::Standard::UserRole::create_normal_role", | ||
| 54 | 1 | ||
| 55 | ); | ||
| 56 | |||
| 57 | my $authorities_role_pkey = $self->createRole('User', 1); | ||
| 58 | my $plugins = Daje::Database::View::vAuthoritiesPluginList->new( | ||
| 59 | db => $self->db | ||
| 60 | )->load_user_plugins()->{data}; | ||
| 61 | |||
| 62 | my $permissions = Daje::Database::View::vAuthoritiesPermissionsList->new( | ||
| 63 | db => $self->db | ||
| 64 | )->load_user_permissions()->{data}; | ||
| 65 | |||
| 66 | my $length = scalar @{$plugins}; | ||
| 67 | for(my $i = 0; $i < $length; $i++) { | ||
| 68 | my $authorities_plugin_role_pkey = $self->create_role_plugin( | ||
| 69 | $authorities_role_pkey, | ||
| 70 | @{$plugins}[$i]->{authorities_plugin_pkey}, | ||
| 71 | "Autogenerated" | ||
| 72 | ); | ||
| 73 | |||
| 74 | my $functions = Daje::Database::View::vAuthoritiesFunction->new( | ||
| 75 | db => $self->db | ||
| 76 | )->load_authorities_plugin_fkey( | ||
| 77 | @{$plugins}[$i]->{authorities_plugin_pkey} | ||
| 78 | )->{data}; | ||
| 79 | |||
| 80 | my $len = scalar @{$functions}; | ||
| 81 | for(my $j = 0; $j < $len; $j++) { | ||
| 82 | my $authorities_function_plugin_role_pkey = $self->create_function_plugin_role( | ||
| 83 | $authorities_role_pkey, | ||
| 84 | @{$functions}[$j]->{authorities_function_pkey}, | ||
| 85 | @{$plugins}[$i]->{authorities_plugin_pkey}, | ||
| 86 | "Autogenerated" | ||
| 87 | ); | ||
| 88 | my $le = scalar @{$permissions}; | ||
| 89 | for(my $k = 0; $k < $le; $k++) { | ||
| 90 | $self->create_role_permissions( | ||
| 91 | @{$permissions}[$k]->{authorities_permissions_pkey}, | ||
| 92 | $authorities_role_pkey, | ||
| 93 | @{$functions}[$j]->{authorities_function_pkey}, | ||
| 94 | @{$plugins}[$i]->{authorities_plugin_pkey} | ||
| 95 | ); | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | 1; |