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

Contents of /trunk/lib/Transports/Model/Source.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations)
Sat May 27 15:23:10 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 1123 byte(s)
for logged users show only sources which are available at UserOnSource
1 use strict;
2 use warnings;
3
4 package Transports::Model::Source::Schema;
5 use Jifty::DBI::Schema;
6
7 # Your column definitions go here. See L<Jifty::DBI::Schema> for
8 # documentation about how to write column definitions.
9
10 column name =>
11 type is 'text',
12 label is 'Source client',
13 is mandatory,
14 since '0.0.6';
15
16 package Transports::Model::Source;
17 use base qw/Transports::Record/;
18
19 # Your model-specific methods go here.
20
21 =head1 available_values
22
23 return all names
24
25 =cut
26
27 sub available_values {
28 my $self = shift;
29 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 # We probably want something like this eventually:
43 if ($type =~ /(?:create|read|update)/i) {
44
45 my $uos = Transports::Model::UserOnSource->new();
46 $uos->load_by_cols(
47 user_on => $self->current_user->id,
48 source => $self->id
49 );
50 return undef if ($self->current_user->id && ! $uos->id);
51
52 return 1;
53 } else {
54 return $self->SUPER::current_user_can($type, @_);
55 }
56 }
57
58 1;
59

  ViewVC Help
Powered by ViewVC 1.1.26