18 |
|
|
19 |
# Your model-specific methods go here. |
# Your model-specific methods go here. |
20 |
|
|
21 |
|
=head1 available_values |
22 |
|
|
23 |
|
return all names |
24 |
|
|
25 |
|
=cut |
26 |
|
|
27 |
sub available_values { |
sub available_values { |
28 |
my $self = shift; |
my $self = shift; |
29 |
return $self->column("name")->valid_values; |
return $self->column("name")->valid_values; |
30 |
} |
} |
31 |
|
|
32 |
|
=head2 current_user_can ACTION |
33 |
|
|
34 |
|
Let everybody create, read and update, but not delete. |
35 |
|
|
36 |
|
=cut |
37 |
|
|
38 |
|
sub current_user_can { |
39 |
|
my $self = shift; |
40 |
|
my $type = shift; |
41 |
|
|
42 |
|
return 1 if ($self->current_user->admin); |
43 |
|
|
44 |
|
# We probably want something like this eventually: |
45 |
|
if ($type =~ /(?:create|read|update)/i) { |
46 |
|
|
47 |
|
my $uos = Transports::Model::UserOnSource->new(); |
48 |
|
$uos->load_by_cols( |
49 |
|
user_on => $self->current_user->id, |
50 |
|
source => $self->id |
51 |
|
); |
52 |
|
return undef if ($self->current_user->id && ! $uos->id); |
53 |
|
|
54 |
|
return 1; |
55 |
|
} else { |
56 |
|
return $self->SUPER::current_user_can($type, @_); |
57 |
|
} |
58 |
|
} |
59 |
|
|
60 |
1; |
1; |
61 |
|
|