/[Grep]/lib/Grep/Model/Item.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 /lib/Grep/Model/Item.pm

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

revision 2 by dpavlin, Sat Feb 17 16:17:18 2007 UTC revision 170 by dpavlin, Wed Jul 4 12:52:50 2007 UTC
# Line 33  use Grep::Record schema { Line 33  use Grep::Record schema {
33          column author =>          column author =>
34                  type is 'text';                  type is 'text';
35    
36          column issued =>          column created_on =>
37                  type is 'timestamp',                  type is 'timestamp',
38                    default is defer { DateTime->now },
39                  filters are qw( Jifty::Filter::DateTime Jifty::DBI::Filter::DateTime );                  filters are qw( Jifty::Filter::DateTime Jifty::DBI::Filter::DateTime );
40    
41          column modified =>          column last_update =>
42                  type is 'timestamp',                  type is 'timestamp',
43                    default is defer { DateTime->now },
44                  filters are qw( Jifty::Filter::DateTime Jifty::DBI::Filter::DateTime );                  filters are qw( Jifty::Filter::DateTime Jifty::DBI::Filter::DateTime );
45    
46  };  };
47    
48    sub since { '0.0.1' }
49    
50  # Your model-specific methods go here.  # Your model-specific methods go here.
51    
52    sub current_user_can {
53            my $self = shift;
54            my $what = shift;
55    
56            my $uid = Jifty->web->current_user->id;
57    
58            # superuser
59            return 1 if ( defined $uid && $uid == 0 );
60    
61            return 1 if ( $uid && $what eq 'create' );
62    
63            return 1 if ( $uid && ! $self->id );
64    
65            my $owner_id = $self->in_feed->owner->id;
66    
67    #       Jifty->log->debug("current_user[$uid]_can($what) on Item ", $self->id || '???', " owner ", $owner_id || '???');
68    
69            return 1 if ( $uid && $owner_id && $uid == $owner_id );
70    
71            # system user
72            return 1 if ( defined( $uid ) && $uid == 0 );
73    
74            warn "$uid can't $what";
75    }
76    
77    sub _set {
78            my $self = shift;
79            my ($val, $msg) = $self->SUPER::_set(@_);
80    
81            $self->SUPER::_set(column => 'last_update', value => defer { DateTime->now });
82    
83            return ($val, $msg);
84    }
85    
86  1;  1;
87    

Legend:
Removed from v.2  
changed lines
  Added in v.170

  ViewVC Help
Powered by ViewVC 1.1.26