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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26