1 |
dpavlin |
23 |
use strict; |
2 |
|
|
use warnings; |
3 |
|
|
|
4 |
|
|
=head1 NAME |
5 |
|
|
|
6 |
|
|
Arh::Action::ToggleEdit |
7 |
|
|
|
8 |
|
|
=cut |
9 |
|
|
|
10 |
|
|
package Arh::Action::ToggleEdit; |
11 |
|
|
use base qw/Arh::Action Jifty::Action/; |
12 |
|
|
|
13 |
|
|
use Data::Dump qw/dump/; |
14 |
|
|
|
15 |
|
|
use Jifty::Param::Schema; |
16 |
|
|
use Jifty::Action schema { |
17 |
|
|
|
18 |
|
|
}; |
19 |
|
|
|
20 |
|
|
=head2 take_action |
21 |
|
|
|
22 |
|
|
=cut |
23 |
|
|
|
24 |
|
|
sub take_action { |
25 |
|
|
my $self = shift; |
26 |
|
|
|
27 |
|
|
my $editing = $self->current_user->editing; |
28 |
|
|
|
29 |
|
|
# warn "user = ",dump( $self->current_user->user_object->as_hash ); |
30 |
|
|
|
31 |
|
|
if ( ! $self->current_user->id ) { |
32 |
|
|
$self->result->error( _('You need to login') ); |
33 |
|
|
warn "not logged in!"; |
34 |
|
|
return 0; |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
$editing = ! $editing; |
38 |
|
|
$self->current_user->user_object->set_editing( $editing ); |
39 |
|
|
|
40 |
|
|
$self->result->message( _('Edit mode is now '), $editing ? _('on') : _("off") ); |
41 |
|
|
|
42 |
|
|
warn "editing $editing for ", $self->current_user->id; |
43 |
|
|
|
44 |
|
|
return 1; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
|
48 |
|
|
1; |
49 |
|
|
|