« Workflow/Activities/Authorities/Standard/AdminRole.pm
↑ Summary
Workflow/Activities/Authorities/Standard/PowerUserRole.pm »
| 1 | package Daje::Workflow::Activities::Authorities::Standard::Base; | ||
| 2 | use Mojo::Base 'Daje::Workflow::Common::Activity::Base', -base; | ||
| 3 | use v5.42; | ||
| 4 | |||
| 5 | |||
| 6 | # NAME | ||
| 7 | # ==== | ||
| 8 | # | ||
| 9 | # Daje::Workflow::Activities::Authorities::Standard::Base - Daje Role creating activity base class, | ||
| 10 | # creates a new admin role and attach it to user and company | ||
| 11 | # | ||
| 12 | # SYNOPSIS | ||
| 13 | # ======== | ||
| 14 | # | ||
| 15 | # | ||
| 16 | # DESCRIPTION | ||
| 17 | # =========== | ||
| 18 | # | ||
| 19 | # Daje::Workflow::Activities::Authorities::Standard::Base | ||
| 20 | # | ||
| 21 | # METHODS | ||
| 22 | # ======= | ||
| 23 | # | ||
| 24 | # | ||
| 25 | # | ||
| 26 | # | ||
| 27 | # SEE ALSO | ||
| 28 | # ======== | ||
| 29 | # | ||
| 30 | # Mojolicious, Mojolicious::Guides, https://mojolicious.org. | ||
| 31 | # | ||
| 32 | # LICENSE | ||
| 33 | # ======= | ||
| 34 | # | ||
| 35 | # Copyright (C) janeskil1525. | ||
| 36 | # | ||
| 37 | # This library is free software; you can redistribute it and/or modify | ||
| 38 | # it under the same terms as Perl itself. | ||
| 39 | # | ||
| 40 | # AUTHOR | ||
| 41 | # ====== | ||
| 42 | # | ||
| 43 | # janeskil1525 E<lt>janeskil1525@gmail.com | ||
| 44 | # | ||
| 45 | |||
| 46 | use Daje::Database::Model::AuthoritiesRole; | ||
| 47 | use Daje::Database::Model::AuthoritiesFunctionPluginRole; | ||
| 48 | use Daje::Database::Model::AuthoritiesPluginRole; | ||
| 49 | use Daje::Database::Model::AuthoritiesFunctionPluginRolePermission; | ||
| 50 | |||
| 51 | sub createRole($self, $role, $standard) { | ||
| 52 | |||
| 53 | return Daje::Database::Model::AuthoritiesRole->new( | ||
| 54 | db => $self->db | ||
| 55 | )->insert({ | ||
| 56 | name => $role, | ||
| 57 | authorities_workflow_fkey => $self->context->{context}->{workflow}->{workflow_fkey}, | ||
| 58 | standard => $standard, | ||
| 59 | companies_companies_fkey => $self->context->{context}->{companies_fkey}, | ||
| 60 | description => "Autogenerated system role", | ||
| 61 | })->{data}->{authorities_role_pkey}; | ||
| 62 | |||
| 63 | } | ||
| 64 | |||
| 65 | sub create_role_plugin($self, $authorities_role_pkey, $authorities_plugin_pkey, $description) { | ||
| 66 | return Daje::Database::Model::AuthoritiesPluginRole->new( | ||
| 67 | db => $self->db | ||
| 68 | )->insert({ | ||
| 69 | authorities_role_fkey => $authorities_role_pkey, | ||
| 70 | authorities_plugin_fkey => $authorities_plugin_pkey, | ||
| 71 | description => $description | ||
| 72 | })->{data}->{authorities_plugin_role_pkey}; | ||
| 73 | } | ||
| 74 | |||
| 75 | sub create_function_plugin_role($self, $authorities_role_pkey, $authorities_function_pkey, $authorities_plugin_pkey, $description) { | ||
| 76 | return Daje::Database::Model::AuthoritiesFunctionPluginRole->new( | ||
| 77 | db => $self->db | ||
| 78 | )->insert({ | ||
| 79 | authorities_role_fkey => $authorities_role_pkey, | ||
| 80 | authorities_function_fkey => $authorities_function_pkey, | ||
| 81 | authorities_plugin_fkey => $authorities_plugin_pkey, | ||
| 82 | description => $description, | ||
| 83 | })->{data}->{authorities_function_plugin_role_pkey}; | ||
| 84 | } | ||
| 85 | |||
| 86 | sub create_role_permissions($self, $authorities_permissions_pkey, $authorities_role_pkey, $authorities_function_pkey, $authorities_plugin_pkey) { | ||
| 87 | Daje::Database::Model::AuthoritiesFunctionPluginRolePermission->new( | ||
| 88 | db => $self->db | ||
| 89 | )->insert({ | ||
| 90 | authorities_permissions_fkey => $authorities_permissions_pkey, | ||
| 91 | authorities_role_fkey => $authorities_role_pkey, | ||
| 92 | authorities_function_fkey => $authorities_function_pkey, | ||
| 93 | authorities_plugin_fkey => $authorities_plugin_pkey, | ||
| 94 | }); | ||
| 95 | } | ||
| 96 | 1; |