/[transports]/trunk/lib/Transports/Model/Destination.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/Transports/Model/Destination.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 68 - (hide annotations)
Sun Jun 11 12:09:33 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 1160 byte(s)
add SUPER::current_user_can for bootstrap
1 dpavlin 1 use strict;
2     use warnings;
3    
4     package Transports::Model::Destination::Schema;
5     use Jifty::DBI::Schema;
6    
7 dpavlin 51 use Transports::Model::Landscape;
8    
9 dpavlin 1 column name =>
10     type is 'text',
11     label is 'Destination client',
12     is mandatory,
13     since '0.0.7';
14    
15 dpavlin 51 column landscape =>
16     refers_to Transports::Model::Landscape,
17     label is 'Part of landscape',
18     is mandatory,
19     since '0.0.13';
20    
21 dpavlin 1 # Your column definitions go here. See L<Jifty::DBI::Schema> for
22     # documentation about how to write column definitions.
23    
24     package Transports::Model::Destination;
25     use base qw/Transports::Record/;
26    
27     # Your model-specific methods go here.
28    
29 dpavlin 22 =head2 current_user_can ACTION
30    
31 dpavlin 58 admin and import can everything, users with permission on landscape can read.
32 dpavlin 22
33     =cut
34    
35     sub current_user_can {
36     my $self = shift;
37     my $type = shift;
38    
39 dpavlin 58 return 1 if ($self->current_user->admin || $self->current_user->can_import);
40    
41     if ($type eq 'read') {
42    
43     my $l = Transports::Model::UserOnLandscape->new();
44     $l->load_by_cols(
45     user_on => $self->current_user->id,
46     landscape => $self->landscape->id,
47     );
48    
49     if ($l->id) {
50     return 1;
51     } else {
52     return undef;
53     }
54     }
55    
56 dpavlin 68 return $self->SUPER::current_user_can($type, @_);
57 dpavlin 22 }
58    
59 dpavlin 1 1;
60    

  ViewVC Help
Powered by ViewVC 1.1.26