/[SQLSession]/trunk/lib/SQLSession/Model/Query.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/SQLSession/Model/Query.pm

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

revision 29 by dpavlin, Thu Dec 7 22:13:56 2006 UTC revision 62 by dpavlin, Thu Jan 25 19:16:18 2007 UTC
# Line 4  use warnings; Line 4  use warnings;
4  package SQLSession::Model::Query;  package SQLSession::Model::Query;
5  use Jifty::DBI::Schema;  use Jifty::DBI::Schema;
6  use SQLSession::Model::Database;  use SQLSession::Model::Database;
7    use Scalar::Defer;
8    
9  use SQLSession::Record schema {  use SQLSession::Record schema {
10          column name =>          column name =>
# Line 30  use SQLSession::Record schema { Line 31  use SQLSession::Record schema {
31                  type is 'text',                  type is 'text',
32                  label is 'Note',                  label is 'Note',
33                  render as 'textarea',                  render as 'textarea',
34                  since 0.0.2;                  since '0.0.2';
35            
36            column visible =>
37                    type is 'boolean',
38                    default is 1,
39                    indexed,
40                    since '0.0.3';
41    
42            column owner =>
43                    refers_to SQLSession::Model::User by 'id',
44                    label is 'Query owner',
45                    default is defer { Jifty->web->current_user->id || 0 },
46                    since '0.0.6';
47    
48            column created_on =>
49                    type is 'timestamp',
50                    label is 'Created On',
51                    default is defer { DateTime->now },
52                    filters are 'Jifty::DBI::Filter::DateTime',
53                    since '0.0.6';
54  };  };
55    
56  # Your model-specific methods go here.  # Your model-specific methods go here.
57    
58  sub current_user_can {  sub current_user_can {
59          return 1;          my $self = shift;
60    
61            my ($action,$item,$name) = @_;
62    
63            # prevent deep recursion for next rule
64            if ( $action && $item && $name &&
65                    $action eq 'read' && $item eq 'column' && ( $name eq 'owner' || $name eq 'visible' )
66            ) {
67                    return 1;
68            }
69    
70            if ( $self->visible || $self->owner == $self->current_user->id ) {
71                    return 1;
72            };
73    
74            return 1 if ($self->current_user->role('edit'));
75    
76            return 0;
77  }  }
78    
79  1;  1;

Legend:
Removed from v.29  
changed lines
  Added in v.62

  ViewVC Help
Powered by ViewVC 1.1.26