root/branches/release-31/lib/MT/Blocklist.pm @ 1495

Revision 1495, 0.9 kB (checked in by takayama, 21 months ago)

indexe optimized

  • Property svn:keywords set to Author Date Id Revision
Line 
1# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
2# This program is distributed under the terms of the
3# GNU General Public License, version 2.
4#
5# $Id$
6
7package MT::Blocklist;
8use strict;
9
10use MT::Object;
11@MT::Blocklist::ISA = qw( MT::Object );
12__PACKAGE__->install_properties({
13    columns => [
14       'id', 'blog_id', 'text', 'action'
15    ],
16    indexes => {
17        blog_id => 1,
18        text => 1,
19    },
20    audit => 1,
21    datasource => 'blocklist',
22    primary_key => 'id',
23});
24
25# valid 'action' values:
26#  * discard
27#  * moderate
28#  * nothing
29
30sub block_these {
31    my $class = shift;
32    my ($blog_id, $action, @urls) = @_;
33    foreach my $url (@urls) {
34        next if $class->count({blog_id => $blog_id, text => $url});
35        my $this = $class->new();
36        $this->set_values({blog_id => $blog_id, text => $url,
37                           action => $action});
38        $this->save() or return $class->error($this->errstr());
39    }
40    1;
41}
Note: See TracBrowser for help on using the browser.