~ubuntu-branches/debian/squeeze/movabletype-opensource/squeeze

« back to all changes in this revision

Viewing changes to lib/MT/CMS/BanList.pm

  • Committer: Bazaar Package Importer
  • Author(s): Dominic Hargreaves
  • Date: 2008-06-13 23:28:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080613232840-ya4jfxv1jgl45a3d
Tags: 4.2~rc2-1
* New upstream release candidate
* Update Standards-Version (no changes)
* Ensure that schema upgrade message is always seen

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package MT::CMS::BanList;
 
2
 
 
3
use strict;
 
4
 
 
5
sub can_save {
 
6
    my ( $eh, $app, $id ) = @_;
 
7
    my $perms = $app->permissions;
 
8
    return $perms
 
9
      && ( $perms->can_edit_config || $perms->can_manage_feedback );
 
10
}
 
11
 
 
12
sub save_filter {
 
13
    my $eh    = shift;
 
14
    my ($app) = @_;
 
15
    my $ip    = $app->param('ip');
 
16
    $ip =~ s/(^\s+|\s+$)//g;
 
17
    return $eh->error(
 
18
        MT->translate("You did not enter an IP address to ban.") )
 
19
      if ( '' eq $ip );
 
20
    my $blog_id = $app->param('blog_id');
 
21
    require MT::IPBanList;
 
22
    my $existing =
 
23
      MT::IPBanList->load( { 'ip' => $ip, 'blog_id' => $blog_id } );
 
24
    my $id = $app->param('id');
 
25
 
 
26
    if ( $existing && ( !$id || $existing->id != $id ) ) {
 
27
        return $eh->error(
 
28
            $app->translate(
 
29
                "The IP you entered is already banned for this blog.")
 
30
        );
 
31
    }
 
32
    return 1;
 
33
}
 
34
 
 
35
1;