|
Revision 2359, 0.9 kB
(checked in by takayama, 19 months ago)
|
|
* Test maintenance
|
-
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 | |
|---|
| 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; |
|---|