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

Annotation of /lib/Grep/Model/Feed.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (hide annotations)
Thu Feb 22 17:59:56 2007 UTC (17 years, 2 months ago) by dpavlin
File size: 1726 byte(s)
make models less chatty about current_user_can in debug log
1 dpavlin 2 use strict;
2     use warnings;
3    
4     package Grep::Model::Feed;
5     use Jifty::DBI::Schema;
6    
7 dpavlin 19 use Feed::Find;
8 dpavlin 58 use Scalar::Defer;
9     use Grep::Model::User;
10 dpavlin 19
11 dpavlin 2 use Grep::Record schema {
12    
13     column uri =>
14     type is 'text',
15     label is 'URI',
16 dpavlin 19 hints is 'Replace search string in URI with %s (grep will be replaced automatically)',
17 dpavlin 65 is mandatory;
18 dpavlin 2
19 dpavlin 3 column title =>
20     type is 'text',
21 dpavlin 19 label is 'Title',
22 dpavlin 12 hints is 'Use something descriptive to you',
23 dpavlin 3 since '0.0.2';
24    
25 dpavlin 19 column cookie =>
26     type is 'text',
27     label is 'Cookie',
28     render as 'textarea',
29     hints are 'If you leave Cookie data Grep will impersonate you to feed provider!',
30     since '0.0.3';
31    
32 dpavlin 58 column owner =>
33     refers_to Grep::Model::User by 'id',
34     label is 'Feed owner',
35     default is defer { Jifty->web->current_user->id },
36     since '0.0.5';
37    
38     column created_on =>
39     type is 'timestamp',
40     label is 'Created On',
41     default is defer { DateTime->now },
42     filters are 'Jifty::DBI::Filter::DateTime',
43     since '0.0.5';
44    
45 dpavlin 2 };
46    
47 dpavlin 3 sub since { '0.0.1' }
48    
49 dpavlin 2 # Your model-specific methods go here.
50    
51 dpavlin 19 =head2 search_uri
52    
53     print $feed->search_uri('search string');
54    
55     This function will decode field delimiters C<|!|> into normal C<;>
56     (which are protected to make AJAX validation work)
57    
58     =cut
59    
60     sub search_uri {
61     my $self = shift;
62     my $search = shift;
63    
64     my $uri = $self->uri or die "no uri?";
65     $uri =~ s/\Q|!|\E/;/g;
66     return sprintf( $uri, $search );
67     }
68    
69    
70 dpavlin 37 sub current_user_can {
71     my $self = shift;
72     my $what = shift;
73    
74 dpavlin 58 my $uid = Jifty->web->current_user->id;
75 dpavlin 37
76 dpavlin 58 return 1 if ( $uid && $what eq 'create' );
77    
78     return 1 if ( $uid && ! $self->id );
79    
80 dpavlin 70 # Jifty->log->debug("current_user[$uid]_can($what) on Feed ", $self->id || '???', " owner ", $self->owner->id || '???');
81 dpavlin 58
82     return 1 if ( $uid == $self->owner->id );
83    
84 dpavlin 37 }
85    
86 dpavlin 2 1;
87    

  ViewVC Help
Powered by ViewVC 1.1.26