OpenInteract2/Manage/Website/CreateSecurity.pm

filter: Statementstmt 60.9% 25 / 41 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 8 / 12 Podpod 0.0% 0 / 4 totaltotal 55.9% 33 / 59 CC 2 SCAR 6.9
CC
2
Cov
58%
check_parameters
6.0
_assign_create_params
2.0
setup_task
2.0
CRAP 2.0
« OpenInteract2/Action/TemplateOnly.pm ↑ Summary OpenInteract2/Manage/Website/ViewSession.pm »
1 package OpenInteract2::Manage::Website::CreateSecurity;
2  
3 # $Id: CreateSecurity.pm,v 1.7 2005/03/18 04:09:50 lachoy Exp $
4  
5 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 87 ▶use base qw( OpenInteract2::Manage::Website );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 87 ▶use Log::Log4perl qw( get_logger );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 87 ▶use OpenInteract2::Constants qw( :log );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 87 ▶use OpenInteract2::Context qw( CTX );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 87 ▶use OpenInteract2::CreateSecurity;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 87 ▶use OpenInteract2::Exception qw( oi_error oi_param_error );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 87 $OpenInteract2::Manage::Website::CreateSecurity::VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/);
14  
15 2 ▶sub get_parameters {
Subroutine get_parameters: called CC=1 SCAR=0.0
Pod undocumented
16 2 my ( $self ) = @_;
17 return {
18 2 scope => {
19 description =>
20 "Scope security setting will have. Must be 'user', " .
21 "'group' or 'world'",
22 is_required => 'yes',
23 },
24 scope_id => {
25 description =>
26 "ID of scope to set. Required if 'scope' is 'user' or 'group'",
27 do_validate => 'yes',
28 },
29 level => {
30 description =>
31 "Security level to set. Must be 'none', 'read' or 'write'.",
32 is_required => 'yes',
33 },
34 };
35 }
36  
37 # VALIDATE
38  
39 # This is a little different than normal -- we're overriding this from
40 # OI2::Manage since the 'CreateSecurity' object validates for us. We
41 # need to create the context and the create-security objects here
42 # (rather than the more appropriate setup_task()) for this reason.
43  
44 0 ▶sub check_parameters {
Subroutine check_parameters: not called CC=2 SCAR=17.9
Pod undocumented
45 0 my ( $self ) = @_;
46 0 $self->_setup_context;
47 0 my $creator = OpenInteract2::CreateSecurity->new({
48 scope => $self->param( 'scope' ),
49 scope_id => $self->param( 'scope_id' ),
50 level => $self->param( 'level' ),
51 website_dir => $self->param( 'website_dir' ),
52 });
53 0 $self->_assign_create_params( $creator );
54 0 ▶ unless ( $creator->validate ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($creator->validate) 0 0 0
55 0 my $errors = $creator->errors_with_params;
56 0 oi_param_error "One or more parameters were invalid",
57 { parameter_fail => $errors };
58 }
59 0 $self->param( creator => $creator );
60 }
61  
62 0 ▶sub _assign_create_params {
Subroutine _assign_create_params: not called CC=1 SCAR=6.9
63 0 my ( $self ) = @_;
64 0 oi_error ref( $self ), " must implement '_assign_create_params()'";
65 }
66  
67 # RUN
68  
69 # DO NOT DELETE: this is a no-op override from OI2::Manage::Website so
70 # we don't setup context again...
71  
72 0 ▶sub setup_task { return }
Subroutine setup_task: not called CC=1 SCAR=6.9
Pod undocumented
73  
74 0 ▶sub run_task {
Subroutine run_task: not called CC=1 SCAR=6.9
Pod undocumented
75 0 my ( $self ) = @_;
76 0 my $creator = $self->param( 'creator' );
77 0 $creator->run;
78 0 my $msg = join( '', "Processed ", $creator->num_processed, " and ",
79 "encountered ", $creator->num_failed, " failures. " );
80 0 $self->_ok( 'create security', $msg );
81 }
82  
83 87 1;
84  
85 __END__
« OpenInteract2/Action/TemplateOnly.pm ↑ Summary OpenInteract2/Manage/Website/ViewSession.pm »