1 |
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 |
# warn "## user_object = ",dump( $self->current_user->user_object->as_hash ); |
28 |
|
29 |
if ( ! $self->current_user->id ) { |
30 |
$self->result->error( _('You need to login') ); |
31 |
warn "not logged in!"; |
32 |
return 0; |
33 |
} |
34 |
|
35 |
my $editing = $self->current_user->user_object->editing ? 0 : 1; |
36 |
$self->current_user->user_object->set_editing( $editing ); |
37 |
|
38 |
$self->result->message( _('Edit mode is now ') . ( $editing ? _('on') : _("off") ) ); |
39 |
|
40 |
warn "## editing $editing for ", $self->current_user->id; |
41 |
|
42 |
return 1; |
43 |
} |
44 |
|
45 |
|
46 |
1; |
47 |
|