summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Restriction/Command.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-03-14 06:51:33 +0000
committerfukachan <fukachan>2004-03-14 06:51:33 +0000
commitd24affcf0072143c2f67c64903e9c0628a746855 (patch)
treee3e4b8900f7f72984f5c194791240418ed9718fc /fml/lib/FML/Restriction/Command.pm
parente9b78e850b29b4cc78215d76411c3021468b81fd (diff)
downloadfml8-d24affcf0072143c2f67c64903e9c0628a746855.tar.gz
fml8-d24affcf0072143c2f67c64903e9c0628a746855.tar.bz2
fml8-d24affcf0072143c2f67c64903e9c0628a746855.zip
implement permit_user_command() and permit_anonymous_command() methods.
inherit methods from FML::Restriction::Post class if needed.
Diffstat (limited to 'fml/lib/FML/Restriction/Command.pm')
-rw-r--r--fml/lib/FML/Restriction/Command.pm76
1 files changed, 75 insertions, 1 deletions
diff --git a/fml/lib/FML/Restriction/Command.pm b/fml/lib/FML/Restriction/Command.pm
index 62623ebb..2dc09d6f 100644
--- a/fml/lib/FML/Restriction/Command.pm
+++ b/fml/lib/FML/Restriction/Command.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Command.pm,v 1.10 2004/03/04 04:30:15 fukachan Exp $
+# $FML: Command.pm,v 1.11 2004/03/04 12:21:34 fukachan Exp $
#
package FML::Restriction::Command;
@@ -12,6 +12,10 @@ use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
+use FML::Restriction::Post;
+push(@ISA, qw(FML::Restriction::Post));
+
+
=head1 NAME
FML::Restriction::Command - safe regexp allowed as a command
@@ -40,6 +44,76 @@ sub new
}
+# Descriptions: permit if $sender is an ML member.
+# Arguments: OBJ($self) STR($rule) STR($sender) HASH_REF($v_args)
+# Side Effects: none
+# Return Value: ARRAY(STR, STR)
+sub permit_user_command
+{
+ my ($self, $rule, $sender, $v_args) = @_;
+ my $curproc = $self->{ _curproc };
+ my $config = $curproc->config();
+ my $context = $v_args || {};
+ my $comname = $context->{ comname } || '';
+
+ # 1) sender check
+ my ($match, $reason) = $self->SUPER::permit_member_maps($rule, $sender);
+
+ # 2) command match anonymous one ?
+ if ($match) {
+ if ($reason eq 'reject') {
+ my $_rule = "permit_member_maps";
+ $curproc->restriction_state_set_deny_reason($_rule);
+ return(0, undef);
+ }
+ else {
+ if ($config->has_attribute('user_command_mail_allowed_commands',
+ $comname)) {
+ $curproc->log("debug: match: rule=$rule comname=$comname");
+ return("matched", "permit");
+ }
+ else {
+ $curproc->restriction_state_set_deny_reason($rule);
+ return(0, undef);
+ }
+ }
+ }
+ else {
+ my $_rule = "permit_member_maps";
+ $curproc->restriction_state_set_deny_reason($_rule);
+ return(0, undef);
+ }
+}
+
+
+# Descriptions: permit this command even if $sender is a stranger.
+# Arguments: OBJ($self) STR($rule) STR($sender) HASH_REF($v_args)
+# Side Effects: none
+# Return Value: ARRAY(STR, STR)
+sub permit_anonymous_command
+{
+ my ($self, $rule, $sender, $v_args) = @_;
+ my $curproc = $self->{ _curproc };
+ my $config = $curproc->config();
+ my $context = $v_args || {};
+ my $comname = $context->{ comname } || '';
+
+ # 1) sender: no check.
+ # 2) command match anonymous one ?
+ if ($config->has_attribute('anonymous_command_mail_allowed_commands',
+ $comname)) {
+ $curproc->log("debug: match: rule=$rule comname=$comname");
+ return("matched", "permit");
+ }
+
+ return(0, undef);
+}
+
+
+=head1 UTILITIES
+
+=cut
+
# Descriptions: $s looks secure as a command ?
# Arguments: OBJ($self) STR($s)
# Side Effects: none