/[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 143 by dpavlin, Tue May 8 13:54:20 2007 UTC
# Line 43  use Grep::Record schema { Line 43  use Grep::Record schema {
43    
44  };  };
45    
46    sub since { '0.0.1' }
47    
48  # Your model-specific methods go here.  # Your model-specific methods go here.
49    
50    sub current_user_can {
51            my $self = shift;
52            my $what = shift;
53    
54            my $uid = Jifty->web->current_user->id;
55    
56            # superuser
57            return 1 if ( defined $uid && $uid == 0 );
58    
59            return 1 if ( $uid && $what eq 'create' );
60    
61            return 1 if ( $uid && ! $self->id );
62    
63            my $owner_id = $self->in_feed->owner->id;
64    
65    #       Jifty->log->debug("current_user[$uid]_can($what) on Item ", $self->id || '???', " owner ", $owner_id || '???');
66    
67            return 1 if ( $uid && $owner_id && $uid == $owner_id );
68    
69            # system user
70            return 1 if ( defined( $uid ) && $uid == 0 );
71    
72            warn "$uid can't $what";
73    }
74    
75    =for TODO
76    
77    sub after_create {
78            my $self                    = shift;
79            my $insert_return_value_ref = shift;
80    
81            return unless $$insert_return_value_ref;    # bail if insert failed
82            $self->load($$insert_return_value_ref);     # load ourselves from db
83    
84            # Do whatever needs to be done here
85    
86    #       use Data::Dump qw/dump/;
87    #       warn "after_create ", dump( $self->as_hash );
88    
89            return; # return value is ignored
90    }
91    
92    =cut
93    
94  1;  1;
95    

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

  ViewVC Help
Powered by ViewVC 1.1.26