lib/MojoMojo/Controller/PageAdmin.pm

filter: Statementstmt 54.4% 85 / 156 Branchbran 36.4% 27 / 74 Conditioncond 23.0% 9 / 39 MC/DCmcdc 7.6% 2 / 26 Subroutinesub 80.0% 12 / 15 Podpod 100% 5 / 5 totaltotal 44.4% 140 / 315 CC 55 SCAR 43.0
CC
55
Cov
45%
permissions
210.0
edit
63.6
auto
35.0
CRAP 73.7
« lib/MojoMojo/Formatter/DocBook/Colorize.pm ↑ Summary lib/MojoMojo/Formatter/RSS.pm »
1 package MojoMojo::Controller::PageAdmin;
2 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use parent 'Catalyst::Controller::HTML::FormFu';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 35 eval {require Syntax::Highlight::Engine::Kate};
7 35 my $kate_installed = !$@;
8  
9 =head1 NAME
10  
11 MojoMojo::Controller::PageAdmin - MojoMojo Page Administration
12  
13 =head1 SYNOPSIS
14  
15 See L<MojoMojo>
16  
17 =head1 DESCRIPTION
18  
19 Methods for updating pages: edit, rollback, permissions change, rename.
20  
21 =head1 METHODS
22  
23 =head2 auto
24  
25 Check that user is logged in and has rights to this page.
26  
27 =cut
28  
29 =head2 unauthorized
30  
31 Private action to return a 403 with an explanatory template.
32  
33 =cut
34  
35 2 ▶sub unauthorized : Private {
Subroutine unauthorized: called CC=4 SCAR=17.2
36 2 my ( $self, $c, $operation ) = @_;
37 2 $c->stash->{template} = 'message.tt';
38 2 ▶ $c->stash->{message} ||= $c->loc('No permissions to x this page', $operation || $c->loc('update'));
Condition16%1/6
$c->stash->{"message"} ||= $c->loc("No permissions to x this page", $operation || $c->loc("update"))
l!l&&r!l&&!r
200
$operation || $c->loc('update')
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->stash->{"message"} ||= $c->loc("No permissions to x this page", $operation || $c->loc("update"))
$c->stash->{"message"} $c->loc("No permissions to x this page", $operation || $c->loc("update"))
MC/DC0%0/2
$operation || $c->loc('update')
$operation $c->loc('update')
Truth table33%1/3
A ||= B
A= $c->stash->{"message"}B= $c->loc("No permissions to x this page", $operation || $c->loc("update"))
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $operationB= $c->loc('update')
ABresult
1X1
011
000
39 2 ▶ $c->response->status(403) unless $c->response->status; # 403 Forbidden
Branch: 1 branch
BranchTrueFalseTotal
unless $c->response->status 0 2 2
40 2 return 0;
41 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 20 ▶sub auto : Private {
Subroutine auto: called CC=8 SCAR=35.6
Pod documented
44 20 my ( $self, $c ) = @_;
45 $c->forward('/user/login')
46 if $c->req->params->{pass} # XXX use case?
47 20 ▶ && !$c->stash->{user};
Branch: 1 branch
BranchTrueFalseTotal
if $c->req->params->{"pass"} and not $c->stash->{"user"} 0 20 20
Condition33%1/3
$c->req->params->{"pass"} and not $c->stash->{"user"}
!ll&&!rl&&r
2000
MC/DC0%0/2
$c->req->params->{"pass"} and not $c->stash->{"user"}
$c->req->params->{"pass"} not $c->stash->{"user"}
Truth table33%1/3
A and not(B)
A= $c->req->params->{"pass"}B= not $c->stash->{"user"}
ABresult
0X0
100
111
48  
49 # everyone can edit with anon mode enabled.
50 20 ▶ return 1 if MojoMojo->pref('anonymous_user');
Branch: 1 branch
BranchTrueFalseTotal
if "MojoMojo"->pref("anonymous_user") 20 0 20
51 0 my $user = $c->stash->{user};
52 0 ▶ return 1 if $user && $user->can_edit( $c->stash->{path} );
Branch: 1 branch
BranchTrueFalseTotal
if $user and $user->can_edit($c->stash->{"path"}) 0 0 0
Condition0%0/3
$user and $user->can_edit($c->stash->{"path"})
!ll&&!rl&&r
000
MC/DC0%0/2
$user and $user->can_edit($c->stash->{"path"})
$user $user->can_edit($c->stash->{"path"})
Truth table0%0/3
A and B
A= $userB= $user->can_edit($c->stash->{"path"})
ABresult
0X0
100
111
53 0 ▶ return 1 if $user && !$c->pref('restricted_user');
Branch: 1 branch
BranchTrueFalseTotal
if $user and not $c->pref("restricted_user") 0 0 0
Condition0%0/3
$user and not $c->pref("restricted_user")
!ll&&!rl&&r
000
MC/DC0%0/2
$user and not $c->pref("restricted_user")
$user not $c->pref("restricted_user")
Truth table0%0/3
A and not(B)
A= $userB= not $c->pref("restricted_user")
ABresult
0X0
100
111
54 0 $c->detach('unauthorized', [$c->loc('edit')]);
55 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 =head2 edit
58  
59 This action will display the edit form, then save the previous
60 revision, and create a new one based on the posted content.
61 After saving, it will forward to the highlight action.
62  
63 =cut
64  
65 20 ▶sub edit : Global FormConfig {
Subroutine edit: called CC=27 SCAR=41.5
Pod documented
66 20 my ( $self, $c, $path ) = @_;
67  
68 # Set up the basics. Log in if there's a user.
69 20 my $form = $c->stash->{form};
70 20 my $stash = $c->stash;
71 20 $stash->{template} = 'page/edit.tt';
72  
73 20 ▶ my $user_id = $c->user_exists ? $c->user->obj->id : 1; # Anon edit
Branch: 1 branch
BranchTrueFalseTotal
$c->user_exists ? : 20 0 20
74  
75 20 my ( $path_pages, $proto_pages ) = @$stash{qw/ path_pages proto_pages /};
76  
77 # we should always have at least "/" in path pages. if we don't,
78 # we must not have had these structures in the stash
79 20 ▶ unless ($path_pages) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($path_pages) 0 20 20
80 0 ( $path_pages, $proto_pages ) =
81 $c->model('DBIC::Page')->path_pages($path);
82 }
83  
84 # the page we're editing is at the end of either path_pages or
85 # proto_pages, depending on whether or not the page already exists
86 20 ▶ my $page = (
Branch: 1 branch
BranchTrueFalseTotal
@$proto_pages > 0 ? : 8 12 20
87 @$proto_pages > 0
88 ? $proto_pages->[-1]
89 : $path_pages->[-1]
90 );
91 20 @$stash{qw/ path_pages proto_pages /} = ( $path_pages, $proto_pages );
92  
93 my $perms =
94 20 ▶ $c->check_permissions( $stash->{'path'}, $c->user_exists ? $c->user->obj : undef );
Branch: 1 branch
BranchTrueFalseTotal
$c->user_exists ? : 20 0 20
95 20 ▶ my $permtocheck = ( @$proto_pages > 0 ? 'create' : 'edit' );
Branch: 1 branch
BranchTrueFalseTotal
@$proto_pages > 0 ? : 8 12 20
96 20 ▶ my $loc_permtocheck = $permtocheck eq 'create'
Branch: 1 branch
BranchTrueFalseTotal
$permtocheck eq 'create' ? : 8 12 20
97 ? $c->loc('create')
98 : $c->loc('edit');
99  
100 # TODO this should be caught in the auto action. To reproduce, disable "Edit allowed by default"
101 # in Site settings, then go to /.edit
102 20 ▶ if ( !$perms->{$permtocheck} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($perms->{$permtocheck}) 0 20 20
103 0 ▶ my $name = ref($page) eq 'HASH' ? $page->{name} : $page->name;
Branch: 1 branch
BranchTrueFalseTotal
ref $page eq 'HASH' ? : 0 0 0
104 $stash->{message} =
105 0 $c->loc( 'Permission denied to x x', [ $loc_permtocheck, $name ] );
106 0 $c->detach('unauthorized');
107 }
108 # TODO in the use case above, the message below should be displayed. However, that never happens
109 20 ▶ if ( $user_id == 1 && !$c->pref('anonymous_user') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user_id == 1 and not $c->pref("anonymous_user")) 0 20 20
Condition33%1/3
$user_id == 1 and not $c->pref("anonymous_user")
!ll&&!rl&&r
2000
MC/DC0%0/2
$user_id == 1 and not $c->pref("anonymous_user")
$user_id == 1 not $c->pref("anonymous_user")
Truth table33%1/3
A and not(B)
A= $user_id == 1B= not $c->pref("anonymous_user")
ABresult
0X0
100
111
110 0 $c->stash->{message} = $c->loc('Anonymous edit disabled');
111 0 $c->detach('unauthorized');
112 }
113  
114 # for anonymous users, use CAPTCHA, if enabled
115 20 ▶ if ( $user_id == 1 && $c->pref('use_captcha') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user_id == 1 and $c->pref("use_captcha")) 0 20 20
Condition33%1/3
$user_id == 1 and $c->pref("use_captcha")
!ll&&!rl&&r
2000
MC/DC0%0/2
$user_id == 1 and $c->pref("use_captcha")
$user_id == 1 $c->pref("use_captcha")
Truth table33%1/3
A and B
A= $user_id == 1B= $c->pref("use_captcha")
ABresult
0X0
100
111
116 0 ▶ my $captcha_lang = $c->session->{lang} || $c->pref('default_lang') ;
Condition0%0/3
$c->session->{'lang'} || $c->pref('default_lang')
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->session->{'lang'} || $c->pref('default_lang')
$c->session->{'lang'} $c->pref('default_lang')
Truth table0%0/3
A || B
A= $c->session->{'lang'}B= $c->pref('default_lang')
ABresult
1X1
011
000
117 0 $c->stash->{captcha} = $form->element({
118 type => 'reCAPTCHA',
119 name => 'captcha',
120 recaptcha_options => {
121 lang => $captcha_lang,
122 theme => 'white'
123 }
124 });
125 0 $form->process;
126 }
127  
128 # prepare the list of available syntax highlighters
129 20 ▶ if ($kate_installed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kate_installed) 20 0 20
130 20 my $syntax = new Syntax::Highlight::Engine::Kate;
131 # 'Alerts' is a hidden Kate module, so delete it from list
132 20 $c->stash->{syntax_formatters} = [ grep ( !/^Alerts$/ , $syntax->languageList() ) ];
133 }
134  
135 20 ▶ if ( $form->submitted_and_valid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) { } 6 14 20
136  
137 6 my $valid = $form->params;
138 6 $valid->{creator} = $user_id;
139  
140 6 ▶ if (@$proto_pages) { # page doesn't exist yet
Branch: 1 branch
BranchTrueFalseTotal
if (@$proto_pages) 4 2 6
141  
142 4 $path_pages = $c->model('DBIC::Page')->create_path_pages(
143 path_pages => $path_pages,
144 proto_pages => $proto_pages,
145 creator => $user_id,
146 );
147 4 $page = $path_pages->[-1];
148
149  
150 # update the pages that wanted the new one
151  
152 }
153  
154 6 $stash->{content} = $page->content;
155 6 $c->model("DBIC::Page")->set_paths(@$path_pages);
156  
157 # setup redirect back to edits or view page mode.
158 6 my $redirect = $c->uri_for( $c->stash->{path} );
159 6 ▶ if ( $form->params->{submit} eq $c->localize('Save') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($form->params->{"submit"} eq $c->localize("Save")) 6 0 6
160 6 $redirect .= '.edit';
161 }
162
163 # No need to update if we have no difference between browser and db.
164 6 ▶ if ( $c->stash->{content} && ($c->stash->{content}->body eq $form->params->{body}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->stash->{"content"} and $c->stash->{"content"}->body eq $form->params->{"body"}) 1 5 6
Condition100%3/3
$c->stash->{"content"} and $c->stash->{"content"}->body eq $form->params->{"body"}
!ll&&!rl&&r
411
MC/DC100%2/2
$c->stash->{"content"} and $c->stash->{"content"}->body eq $form->params->{"body"}
$c->stash->{"content"} $c->stash->{"content"}->body eq $form->params->{"body"}
Truth table100%3/3
A and B
A= $c->stash->{"content"}B= $c->stash->{"content"}->body eq $form->params->{"body"}
ABresult
0X0
100
111
165 1 $c->res->redirect($redirect);
166 1 return;
167 }
168
169 # If we get here it means we have some difference between wiki page in browser and db.
170 # TODO: Is the discard_changes necessary? Why are we discarding local changes?
171 # Are there even any local changes to $page?
172 5 $page->discard_changes;
173  
174 # Check for changes made by another user to the same base revision.
175 5 ▶ if( $c->stash->{content} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($c->stash->{"content"} and $c->req->params->{"version"} != $c->stash->{"content"}->version) 0 5 5
Condition66%2/3
$c->stash->{"content"} and $c->req->params->{"version"} != $c->stash->{"content"}->version
!ll&&!rl&&r
410
MC/DC0%0/2
$c->stash->{"content"} and $c->req->params->{"version"} != $c->stash->{"content"}->version
$c->stash->{"content"} $c->req->params->{"version"} != $c->stash->{"content"}->version
Truth table66%2/3
A and B
A= $c->stash->{"content"}B= $c->req->params->{"version"} != $c->stash->{"content"}->version
ABresult
0X0
100
111
176 $c->req->params->{version} != $c->stash->{content}->version ) {
177 0 $c->stash->{message}=$c->loc('Someone else changed the page while you edited. Your changes has been merged. Please review and save again');
178 my $orig_content = $c->model("DBIC::Content")->find(
179 {
180 page => $page->id,
181 version => $c->req->params->{version},
182 }
183 0 );
184 $c->stash->{merged_body} ||= $orig_content->merge_content(
185 $c->stash->{content},
186 $form->params->{body},
187 0 ▶ $c->loc('THEIR CHANGES'),
Condition0%0/3
$c->stash->{"merged_body"} ||= $orig_content->merge_content($c->stash->{"content"}, $form->params->{"body"}, $c->loc("THEIR CHANGES"), $c->loc("YOUR CHANGES"), $c->loc("END OF CONFLICT"))
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->stash->{"merged_body"} ||= $orig_content->merge_content($c->stash->{"content"}, $form->params->{"body"}, $c->loc("THEIR CHANGES"), $c->loc("YOUR CHANGES"), $c->loc("END OF CONFLICT"))
$c->stash->{"merged_body"} $orig_content->merge_content($c->stash->{"content"}, $form->params->{"body"}, $c->loc("THEIR CHANGES"), $c->loc("YOUR CHANGES"), $c->loc("END OF CONFLICT"))
Truth table0%0/3
A ||= B
A= $c->stash->{"merged_body"}B= $orig_content->merge_content($c->stash->{"content"}, $form->params->{"body"}, $c->loc("THEIR CHANGES"), $c->loc("YOUR CHANGES"), $c->loc("END OF CONFLICT"))
ABresult
1X1
011
000
188 $c->loc('YOUR CHANGES'),
189 $c->loc('END OF CONFLICT'));
190 0 return;
191 }
192  
193 # Format content body and store the result in content.precompiled
194 # This speeds up MojoMojo page rendering on /.view actions
195 5 my $precompiled_body = $valid->{'body'};
196 5 MojoMojo->call_plugins( 'format_content', \$precompiled_body, $c, $page );
197  
198 # Make precompiled empty when we have any of: redirect, comment or include
199 5 ▶ $valid->{'precompiled'} = $c->stash->{precompile_off} ? '' : $precompiled_body;
Branch: 1 branch
BranchTrueFalseTotal
$c->stash->{'precompile_off'} ? : 0 5 5
200  
201 5 $page->update_content(%$valid);
202  
203 # update the search index with the new content
204 5 $c->model("DBIC::Page")->set_paths($page);
205 5 ▶ $c->model('Search')->index_page($page)
Branch: 1 branch
BranchTrueFalseTotal
unless $c->pref("disable_search") 5 0 5
206 unless $c->pref('disable_search');
207 5 $page->content->store_links();
208  
209 5 $c->res->redirect($redirect);
210 }
211 else {
212  
213 # if we have missing or invalid fields, display the edit form.
214 # this will always happen on the initial request
215 14 $stash->{page} = $page;
216  
217 # Insert an attachment, or inline an image.
218 14 my %attachment_template = (
219 insert_attachment => 'page/insert.tt',
220 inline_image_attachment => 'page/inline_image.tt',
221 );
222 14 foreach my $attachment_action ( keys %attachment_template ) {
223 28 ▶ if (my $attachment_id = $c->req->query_params->{$attachment_action} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $attachment_id = $c->req->query_params->{$attachment_action}) 0 28 28
224 0 my $saved_stash = $stash;
225  
226 0 my $attachment = $c->model("DBIC::Attachment")
227 ->find( { id => $attachment_id } );
228  
229 0 $c->stash( { att => $attachment } );
230  
231 0 my $insert_text = $c->view('TT')->render( $c, $attachment_template{$attachment_action} );
232 0 $insert_text =~ s/^\s+|\s+$//;
233  
234 0 $c->stash($saved_stash);
235  
236 0 $page->content->body( $page->content->body . "\n\n" . $insert_text . "\n\n" );
237 }
238 }
239 }
240 35 ▶} # end sub edit
Subroutine BEGIN: called CC=1 SCAR=0.0
241  
242  
243 =head2 permissions
244  
245 This action allows page permissions to be displayed and edited.
246  
247 =cut
248  
249 0 ▶sub permissions : Global {
Subroutine permissions: not called CC=14 SCAR=53.5
Pod documented
250 0 my ( $self, $c, $path ) = @_;
251  
252 0 my $stash = $c->stash;
253 0 $stash->{template} = 'page/permissions.tt';
254  
255 0 my @path_elements = $c->_expand_path_elements( $stash->{path} );
256 0 my $current_path = pop @path_elements;
257  
258 0 my $data = $c->get_permissions_data( $current_path, \@path_elements );
259 my $current_data =
260 0 ▶ exists $data->{$current_path} ? $data->{$current_path} : {};
Branch: 1 branch
BranchTrueFalseTotal
exists $data->{$current_path} ? : 0 0 0
261  
262 0 my @roles = $c->model('DBIC::Role')->active_roles->all;
263 0 my %roles = map { $_->id => $_->name } @roles;
264  
265 0 my %current;
266  
267 # build current page permissions hash for each role
268 0 for my $role (@roles) {
269 $current{ $role->name } =
270 exists $current_data->{ $role->id }
271 0 ▶ ? $current_data->{ $role->id }
Branch: 1 branch
BranchTrueFalseTotal
exists $$current_data{$role->id} ? : 0 0 0
272 : undef;
273 }
274  
275 # same as above: sort elements to avoid nasty TT code
276 $stash->{current_perms} = [
277 map {
278 0 {
279 role_name => $_,
280 inherited => $current{$_} ? 1 : 0,
281 perms => $current{$_} && $current{$_}->{page},
282 subpages => exists $current{$_}->{subpages}
283 0 ▶ ? 1
Branch: 2 branches
BranchTrueFalseTotal
$current{$_} ? : 0 0 0
exists $current{$_}{'subpages'} ? : 0 0 0
Condition0%0/3
$current{$_} && $current{$_}{'page'}
!ll&&!rl&&r
000
MC/DC0%0/2
$current{$_} && $current{$_}{'page'}
$current{$_} $current{$_}{'page'}
Truth table0%0/3
A && B
A= $current{$_}B= $current{$_}{'page'}
ABresult
0X0
100
111
284 : 0
285 }
286 }
287 sort keys %current
288 ];
289  
290 0 my %inherited;
291 0 my $parent_path = $path_elements[-1];
292  
293 # build inherited permissions hash
294 0 for my $path ( keys %$data ) {
295  
296 # might have additional data (if cached)
297 0 ▶ next unless ($parent_path && $parent_path =~ /^$path/);
Branch: 1 branch
BranchTrueFalseTotal
unless $parent_path and $parent_path =~ /^$path/ 0 0 0
Condition0%0/3
$parent_path and $parent_path =~ /^$path/
!ll&&!rl&&r
000
MC/DC0%0/2
$parent_path and $parent_path =~ /^$path/
$parent_path $parent_path =~ /^$path/
Truth table0%0/3
A and B
A= $parent_pathB= $parent_path =~ /^$path/
ABresult
0X0
100
111
298 0 ▶ next if $path eq $current_path;
Branch: 1 branch
BranchTrueFalseTotal
if $path eq $current_path 0 0 0
299 0 my $path_perms = $data->{$path};
300 0 for my $role ( keys %$path_perms ) {
301 0 ▶ next unless exists $roles{$role};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $roles{$role} 0 0 0
302 0 my $role_perms = $path_perms->{$role};
303 $inherited{$path}{ $roles{$role} } = $role_perms->{subpages}
304 0 ▶ if exists $role_perms->{subpages};
Branch: 1 branch
BranchTrueFalseTotal
if exists $role_perms->{"subpages"} 0 0 0
305 }
306 }
307  
308 # sort elements to avoid nasty TT code
309 $stash->{inherited_perms} = [
310 0 map { { path => $_, perms => $inherited{$_} } }
311 0 sort { length $a <=> length $b } keys %inherited
312 ];
313 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
314  
315 =head2 rollback
316  
317 This action will revert a page to a older revision.
318  
319 =cut
320  
321 0 ▶sub rollback : Global {
Subroutine rollback: not called CC=3 SCAR=24.8
Pod documented
322 0 my ( $self, $c, $page ) = @_;
323 0 ▶ if ($c->req->method ne 'POST') {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->req->method ne "POST") 0 0 0
324 # general error - we want a POST
325 0 $c->res->status(400);
326 0 $c->detach('unauthorized', [$c->loc('rollback')]);
327 }
328  
329 0 ▶ if ( $c->req->param('rev') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->req->param("rev")) 0 0 0
330 # TODO this needs to do a proper versioned rollback, via
331 # $page->add_version( content_version => $c->req->param('rev')
332 # The problem is that the page_version table doesn't have a content_version field
333 # We could cannibalize the parent_version field, which is dummily always '1'
334 0 $c->stash->{page}->content_version( $c->req->param('rev') );
335 0 $c->stash->{page}->update;
336 0 undef $c->req->params->{rev};
337 0 $c->forward('/page/view');
338 }
339 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
340  
341 =head2 title ( .info/title )
342  
343 AJAX method for renaming a page. Creates a new
344 L<PageVersion|MojoMojo::Schema::Result::PageVersion> with the rename,
345 so that the renaming itself could in the future be shown in the page
346 history.
347  
348 =cut
349  
350 0 ▶sub title : Path('/info/title') {
Subroutine title: not called CC=4 SCAR=30.0
Pod documented
351 0 my ( $self, $c ) = @_;
352 0 my $page = $c->stash->{page};
353 0 ▶ my $user_id = $c->user_exists ? $c->user->obj->id : 1; # Anon edit
Branch: 1 branch
BranchTrueFalseTotal
$c->user_exists ? : 0 0 0
354
355 0 ▶ if ($c->req->method ne 'POST') {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->req->method ne "POST") 0 0 0
356 # general error - we want a POST
357 0 $c->res->status(400);
358 0 $c->detach('unauthorized', [$c->loc('rename via non-POST method')]);
359 }
360
361 0 ▶ if ( $c->req->param('update_value') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->req->param('update_value')) { } 0 0 0
362 0 my $page_version_new = $page->add_version(
363 creator => $user_id,
364 name_orig => $c->req->param('update_value'),
365 );
366 0 $c->res->body( $page_version_new->name_orig );
367 } else {
368 # User attempted to rename the page to ''. Deny that.
369 0 $c->res->body( $page->name_orig );
370 }
371
372 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
373 =head1 AUTHOR
374  
375 Marcus Ramberg <mramberg@cpan.org>
376  
377 =head1 LICENSE
378  
379 This library is free software. You can redistribute it and/or modify
380 it under the same terms as Perl itself.
381  
382 =cut
383  
384 35 1;
« lib/MojoMojo/Formatter/DocBook/Colorize.pm ↑ Summary lib/MojoMojo/Formatter/RSS.pm »