cgi-bin/DW/Hooks/Changelog.pm
author fu
Thu Feb 23 02:21:54 2012 +0800
changeset 4315 34b3c4ba3afb
parent 287 afd258f377d2
permissions -rw-r--r--
http://bugs.dwscoalition.org/show_bug.cgi?id=3859

Tweak for grammar / clarity / wording.

Patch by fu.
     1 #
     2 # Hooks to allow posting to Changelog.
     3 #
     4 # Authors:
     5 #      Mark Smith <mark@dreamwidth.org>
     6 #
     7 # Copyright (c) 2009 by Dreamwidth Studios, LLC.
     8 #
     9 # This program is free software; you may redistribute it and/or modify it under
    10 # the same terms as Perl itself.  For a copy of the license, please reference
    11 # 'perldoc perlartistic' or 'perldoc perlgpl'.
    12 #
    13 
    14 package DW::Hooks::Changelog;;
    15 
    16 use strict;
    17 use LJ::Hooks;
    18 
    19 LJ::Hooks::register_hook( 'post_noauth', sub {
    20     my $req = shift;
    21 
    22     # enable or not
    23     return 0 unless $LJ::CHANGELOG{enabled};
    24 
    25     # the user must be posting TO the changelog journal and the
    26     # username must be in the allow list
    27     return 0 unless $req->{usejournal} eq $LJ::CHANGELOG{community};
    28     return 0 unless grep { $_ eq $req->{username} } @{ $LJ::CHANGELOG{allowed_posters} || [] };
    29 
    30     # we also enforce that the IP the request is coming from be one of
    31     # some small list of IPs
    32     my $ip = BML::get_remote_ip();
    33     return 0 unless grep { $_ eq $ip } @{ $LJ::CHANGELOG{allowed_ips} || [] };
    34 
    35     # looks good
    36     return 1;
    37 } );
    38 
    39 1;