27 |
|
|
28 |
=head2 current_user_can ACTION |
=head2 current_user_can ACTION |
29 |
|
|
30 |
Everybody can read, admin and import can everything else. |
admin and import can everything, users with permission on landscape can read. |
31 |
|
|
32 |
=cut |
=cut |
33 |
|
|
35 |
my $self = shift; |
my $self = shift; |
36 |
my $type = shift; |
my $type = shift; |
37 |
|
|
38 |
return 1 if ($type eq 'read' || $self->current_user->admin || $self->current_user->can_import); |
return 1 if ($self->current_user->admin || $self->current_user->can_import); |
39 |
|
|
40 |
|
if ($type eq 'read') { |
41 |
|
|
42 |
|
my $l = Transports::Model::UserOnLandscape->new(); |
43 |
|
$l->load_by_cols( |
44 |
|
user_on => $self->current_user->id, |
45 |
|
landscape => $self->landscape->id, |
46 |
|
); |
47 |
|
|
48 |
|
if ($l->id) { |
49 |
|
return 1; |
50 |
|
} else { |
51 |
|
return undef; |
52 |
|
} |
53 |
|
} |
54 |
|
|
55 |
return $self->SUPER::current_user_can($type, @_); |
return $self->SUPER::current_user_can($type, @_); |
56 |
} |
} |