/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 47 by dpavlin, Tue May 30 18:50:16 2006 UTC revision 58 by dpavlin, Mon Jun 5 15:21:18 2006 UTC
# Line 4  use warnings; Line 4  use warnings;
4  package Transports::Model::Destination::Schema;  package Transports::Model::Destination::Schema;
5  use Jifty::DBI::Schema;  use Jifty::DBI::Schema;
6    
7    use Transports::Model::Landscape;
8    
9  column name =>  column name =>
10          type is 'text',          type is 'text',
11          label is 'Destination client',          label is 'Destination client',
12          is mandatory,          is mandatory,
13          since '0.0.7';          since '0.0.7';
14    
15    column landscape =>
16            refers_to Transports::Model::Landscape,
17            label is 'Part of landscape',
18            is mandatory,
19            since '0.0.13';
20    
21  # Your column definitions go here.  See L<Jifty::DBI::Schema> for  # Your column definitions go here.  See L<Jifty::DBI::Schema> for
22  # documentation about how to write column definitions.  # documentation about how to write column definitions.
23    
# Line 20  use base qw/Transports::Record/; Line 28  use base qw/Transports::Record/;
28    
29  =head2 current_user_can ACTION  =head2 current_user_can ACTION
30    
31  Let everybody create, read and update, but not delete.  admin and import can everything, users with permission on landscape can read.
32    
33  =cut  =cut
34    
# Line 28  sub current_user_can { Line 36  sub current_user_can {
36      my $self = shift;      my $self = shift;
37      my $type = shift;      my $type = shift;
38    
39      # We probably want something like this eventually:          return 1 if ($self->current_user->admin || $self->current_user->can_import);
40      if ($type =~ /(?:create|read|update)/i) {  
41          return 1;          if ($type eq 'read') {
42      } else {  
43          return $self->SUPER::current_user_can($type, @_);                  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  }  }
57    
58  1;  1;

Legend:
Removed from v.47  
changed lines
  Added in v.58

  ViewVC Help
Powered by ViewVC 1.1.26