| 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 | |
|---|
| 7 | package MT::Blocklist; |
|---|
| 8 | use strict; |
|---|
| 9 | |
|---|
| 10 | use 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 | |
|---|
| 30 | sub block_these { |
|---|
| 31 | my $class = shift; |
|---|
| 32 | my ($blog_id, $action, @urls) = @_; |
|---|
| 33 | foreach my $url (@urls) { |
|---|
| 34 | next if $class->exist({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 | } |
|---|
| 42 | |
|---|
| 43 | 1; |
|---|
| 44 | |
|---|
| 45 | __END__ |
|---|
| 46 | |
|---|
| 47 | =head1 NAME |
|---|
| 48 | |
|---|
| 49 | MT::Blocklist - MT object class for storing rules for filtering content. |
|---|
| 50 | |
|---|
| 51 | =head1 METHODS |
|---|
| 52 | |
|---|
| 53 | =head2 MT::Blocklist->block_these($blog_id, $action, @urls) |
|---|
| 54 | |
|---|
| 55 | Adds the specified URLs to the blocklist table with the specified I<$action> |
|---|
| 56 | and for the specified I<$blog_id>. |
|---|
| 57 | |
|---|
| 58 | =head1 LICENSE |
|---|
| 59 | |
|---|
| 60 | The license that applies is the one you agreed to when downloading |
|---|
| 61 | Movable Type. |
|---|
| 62 | |
|---|
| 63 | =head1 AUTHOR & COPYRIGHT |
|---|
| 64 | |
|---|
| 65 | Except where otherwise noted, MT is Copyright 2001-2008 Six Apart. |
|---|
| 66 | All rights reserved. |
|---|
| 67 | |
|---|
| 68 | =cut |
|---|