/[transports]/trunk/lib/Transports/Model/Source.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/Source.pm

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

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

Legend:
Removed from v.50  
changed lines
  Added in v.51

  ViewVC Help
Powered by ViewVC 1.1.26