Changeset 1240
- Timestamp:
- 10/20/08 00:24:51 (23 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 modified
-
Build.PL (modified) (1 diff)
-
Changes (modified) (1 diff)
-
MANIFEST (modified) (1 diff)
-
lib/OpenGuides.pm (modified) (2 diffs)
-
lib/OpenGuides/Config.pm (modified) (4 diffs)
-
lib/OpenGuides/Test.pm (modified) (1 diff)
-
lib/OpenGuides/Utils.pm (modified) (2 diffs)
-
t/81_node_moderate_whitelist.t (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Build.PL
r1239 r1240 312 312 'XML::RSS' => 0, 313 313 'Data::Validate::URI' => 0, 314 'Net::Netmask' => 0, 315 'List::Utils' => 0, 314 316 }, 315 317 build_requires => { -
trunk/Changes
r1238 r1240 17 17 Add an admin navbar, to be displayed if the user requests (#261) 18 18 Move the node image outside the metadata div, to aid styling (#222) 19 Add the ability to whitelist hosts who can change moderated nodes 20 without explicit moderation (#203) 19 21 20 22 0.63 16 August 2008 -
trunk/MANIFEST
r1236 r1240 146 146 t/78_about.t 147 147 t/79_host_blacklist.t 148 t/81_node_moderate_whitelist.t 148 149 t/85_universal_edit_link.t 149 150 t/templates/15_test.tt -
trunk/lib/OpenGuides.pm
r1228 r1240 1557 1557 # they've been moderated 1558 1558 my $needs_moderation = $wiki->node_required_moderation($node); 1559 unless( $needs_moderation ) { 1559 my $in_moderate_whitelist 1560 = OpenGuides::Utils->in_moderate_whitelist($self->config, $new_metadata{host}); 1561 1562 if ( $in_moderate_whitelist or not $needs_moderation ) { 1560 1563 $self->_autoCreateCategoryLocale( 1561 1564 id => $node, … … 1568 1571 1569 1572 if ($written) { 1570 if ( $needs_moderation and $config->send_moderation_notifications ) { 1571 my $body = "The node '$node' in the OpenGuides installation\n" . 1572 "'" . $config->site_name . "' requires moderation. ". 1573 "Please visit\n" . 1574 $config->script_url . $config->script_name . 1575 "?action=show_needing_moderation\nat your convenience.\n"; 1576 eval { 1577 OpenGuides::Utils->send_email( 1578 config => $config, 1579 subject => "Node requires moderation", 1580 body => $body, 1581 admin => 1, 1582 return_output => $return_output 1573 if ( $needs_moderation ) { 1574 if ( $in_moderate_whitelist ) { 1575 $self->wiki->moderate_node( 1576 name => $node, 1577 version => $written 1583 1578 ); 1584 }; 1585 warn $@ if $@; 1579 } 1580 elsif ( $config->send_moderation_notifications ) { 1581 my $body = "The node '$node' in the OpenGuides installation\n" . 1582 "'" . $config->site_name . "' requires moderation. ". 1583 "Please visit\n" . 1584 $config->script_url . $config->script_name . 1585 "?action=show_needing_moderation\nat your convenience.\n"; 1586 eval { 1587 OpenGuides::Utils->send_email( 1588 config => $config, 1589 subject => "Node requires moderation", 1590 body => $body, 1591 admin => 1, 1592 return_output => $return_output 1593 ); 1594 }; 1595 warn $@ if $@; 1596 } 1586 1597 } 1587 1598 -
trunk/lib/OpenGuides/Config.pm
r1233 r1240 23 23 show_gmap_in_node_display google_analytics_key 24 24 centre_lat default_gmaps_zoom default_gmaps_search_zoom force_wgs84 25 licence_name licence_url licence_info_url moderation_requires_password 25 licence_name licence_url licence_info_url 26 moderation_requires_password moderate_whitelist 26 27 enable_node_image enable_common_categories enable_common_locales 27 28 spam_detector_module host_checker_module static_path static_url … … 81 82 enable_page_deletion => 0, 82 83 moderation_requires_password => 1, 84 moderate_whitelist => "", 83 85 admin_pass => "Change This!", 84 86 enable_node_image => 1, … … 203 205 send_moderation_notifications => "Should we send email notifications when a moderated node is edited?", 204 206 website_link_max_chars => "How many characters of the URL of node websites should be displayed?", 207 moderate_whitelist => "Enter a comma-separated list of IP addresses able to make changes to moderated nodes and have them show up immediately", 205 208 ); 206 209 … … 337 340 =item * send_moderation_notifications 338 341 342 =item * moderate_whitelist 343 339 344 =item * website_link_max_chars (default: C<20>) 340 345 -
trunk/lib/OpenGuides/Test.pm
r1163 r1240 67 67 force_wgs84 => 1, 68 68 contact_email => 'admins@example.org', 69 moderate_whitelist => "", 69 70 } 70 71 ); -
trunk/lib/OpenGuides/Utils.pm
r1231 r1240 11 11 use URI::Escape; 12 12 use MIME::Lite; 13 use Net::Netmask; 14 use List::Util qw( first ); 13 15 use Data::Validate::URI qw( is_web_uri ); 14 16 … … 498 500 } 499 501 502 =item B<in_moderate_whitelist> 503 504 if (OpenGuides::Utils->in_moderate_whitelist( '127.0.0.1' )) { 505 # skip moderation and apply new verson to published site 506 } 507 508 Admins can supply a comma separated list of IP addresses or CIDR-notation 509 subnets indicating the hosts which can bypass enforced moderation. Any 510 values which cannot be parsed by C<NetAddr::IP> will be ignored. 511 512 =cut 513 514 sub in_moderate_whitelist { 515 my ($self, $config, $ip) = @_; 516 return undef if not defined $ip; 517 518 # create NetAddr::IP object of the test IP 519 my $addr = Net::Netmask->new2($ip) or return undef; 520 521 # load the configured whitelist 522 my @whitelist 523 = split ',', $config->moderate_whitelist; 524 525 # test each entry in the whitelist 526 return eval{ 527 first { Net::Netmask->new2($_)->match($addr->base) } @whitelist 528 }; 529 } 530 500 531 =back 501 532
