Commit 2cd4eb4d authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Change calling convention: Use function name instead of list/domain parameter, and so on.

This will fix several bugs due to confusion with function and parameter.
parent 599aa224
......@@ -17,7 +17,7 @@
[% IF pitem.scenario && is_listmaster ~%]
&nbsp;<a class="input"
href="[% 'dump_scenario' | url_rel([list,pitem.name]) %]"
href="[% 'dump_scenario' | url_rel([list,pitem.scenario]) %]"
title="[%|loc%]scenario source[%END%]">[%|loc%]scenario source[%END~%]
</a>
[%~ END %]
......
......@@ -13,7 +13,7 @@
[% ELSE %]
<div id="ActionHeader">
<h2 class='block'>[% pname %] [% scenario_name %] </h2>
<h2 class='block'>[% scenario_function %].[% scenario_name %] </h2>
<span class="text_center">([%|loc%]path:[%END%] [% scenario_path %])</span>
</div>
<font size="-2">
......@@ -22,7 +22,7 @@
<fieldset>
<textarea cols="80" rows="10" name="new_scenario_content">[% dumped_scenario %]</textarea><br />
<input type="hidden" name="list" value="[% list %]" />
<input type="hidden" name="pname" value="[% pname %]" />
<input type="hidden" name="scenario_function" value="[% scenario_function %]" />
<!-- template is ready for saving scenario with scope limited to the current list or to the current robot but wwsympa
[% IF is_listmaster %]
......
......@@ -44,7 +44,7 @@
<li><a href="[% 'review' | url_rel([l.key]) %]"><i class="fa fa-users"></i> [%|loc%]Review members[%END%]</a></li>
[% END %]
[% IF is_user_allowed_to('archive.web_access', l.key) %]
[% IF is_user_allowed_to('archive_web_access', l.key) %]
<li><a href="[% 'arc' | url_rel([l.key]) %]"><i class="fa fa-archive"></i> [%|loc%]Archives[%END%]</a></li>
[% END %]
</ul>
......
......@@ -63,7 +63,7 @@
<li><a href="[% 'review' | url_rel([l.key]) %]">[%|loc%]Review members[%END%]</a></li>
[% END %]
[% IF is_user_allowed_to('archive.web_access', l.key) %]
[% IF is_user_allowed_to('archive_web_access', l.key) %]
<li><a href="[% 'arc' | url_rel([l.key]) %]">[%|loc%]Archives[%END%]</a></li>
[% END %]
</ul>
......
This diff is collapsed.
......@@ -1885,8 +1885,22 @@ sub _infer_server_specific_parameter_values {
}
}
foreach my $action (split(/,/, $param->{'config_hash'}{'use_blacklist'}))
foreach
my $action (split /\s*,\s*/, $param->{'config_hash'}{'use_blacklist'})
{
next unless $action =~ /\A[.\w]+\z/;
# Compat. <= 6.2.38
$action = {
'shared_doc.d_read' => 'd_read',
'shared_doc.d_edit' => 'd_edit',
'archive.access' => 'archive_mail_access', # obsoleted
'web_archive.access' => 'archive_web_access', # obsoleted
'archive.web_access' => 'archive_web_access',
'archive.mail_access' => 'archive_mail_access',
'tracking.tracking' => 'tracking',
}->{$action}
|| $action;
$param->{'config_hash'}{'blacklist'}{$action} = 1;
}
......@@ -1965,7 +1979,20 @@ sub _infer_robot_parameter_values {
. $param->{'config_hash'}{'domain'};
# split action list for blacklist usage
foreach my $action (split(/,/, $Conf{'use_blacklist'})) {
foreach my $action (split /\s*,\s*/, $Conf{'use_blacklist'}) {
next unless $action =~ /\A[.\w]+\z/;
# Compat. <= 6.2.38
$action = {
'shared_doc.d_read' => 'd_read',
'shared_doc.d_edit' => 'd_edit',
'archive.access' => 'archive_mail_access', # obsoleted
'web_archive.access' => 'archive_web_access', # obsoleted
'archive.web_access' => 'archive_web_access',
'archive.mail_access' => 'archive_mail_access',
'tracking.tracking' => 'tracking',
}->{$action}
|| $action;
$param->{'config_hash'}{'blacklist'}{$action} = 1;
}
......
......@@ -4287,10 +4287,10 @@ sub is_included {
## Loads all scenari for an action
sub load_scenario_list {
my ($self, $action, $robot) = @_;
$log->syslog('debug3', '(%s, %s)', $action, $robot);
$log->syslog('debug3', '(%s, %s)', @_);
my $self = shift;
my $function = shift;
my $directory = "$self->{'dir'}";
my %list_of_scenario;
my %skip_scenario;
my @list_of_scenario_dir =
......@@ -4298,33 +4298,29 @@ sub load_scenario_list {
unshift @list_of_scenario_dir, $self->{'dir'} . '/scenari'; #FIXME
foreach my $dir (@list_of_scenario_dir) {
next unless (-d $dir);
next unless -d $dir;
my $scenario_regexp = Sympa::Regexps::scenario();
while (<$dir/$action.*:ignore>) {
if (/$action\.($scenario_regexp):ignore$/) {
while (<$dir/$function.*:ignore>) {
if (/$function\.($scenario_regexp):ignore$/) {
my $name = $1;
$skip_scenario{$name} = 1;
}
}
while (<$dir/$action.*>) {
next unless (/$action\.($scenario_regexp)$/);
while (<$dir/$function.*>) {
next unless /$function\.($scenario_regexp)$/;
my $name = $1;
# Ignore default setting on <= 6.2.40, using symbolic link.
next if $name eq 'default' and -l "$dir/$action.$name";
next if (defined $list_of_scenario{$name});
next if (defined $skip_scenario{$name});
next if $list_of_scenario{$name};
next if $skip_scenario{$name};
my $scenario = Sympa::Scenario->new(
'robot' => $robot,
'directory' => $directory,
'function' => $action,
'name' => $name
);
my $scenario =
Sympa::Scenario->new($self, $function, name => $name);
$list_of_scenario{$name} = $scenario;
}
}
......@@ -8028,8 +8024,7 @@ sub _load_list_param {
my $value = shift;
my $p = shift;
my $robot = $self->{'domain'};
my $directory = $self->{'dir'};
my $robot = $self->{'domain'};
# Empty value.
unless (defined $value and $value =~ /\S/) {
......@@ -8058,21 +8053,9 @@ sub _load_list_param {
## Scenario
if ($p->{'scenario'}) {
$value =~ y/,/_/;
my $scenario = Sympa::Scenario->new(
'function' => $p->{'scenario'},
'robot' => $robot,
'name' => $value,
'directory' => $directory
);
## We store the path of the scenario in the sstructure
## Later Sympa::Scenario::request_action() will look for the scenario in
## %Sympa::Scenario::all_scenarios through Scenario::new()
$value = {
'file_path' => $scenario->{'file_path'},
'name' => $scenario->{'name'}
};
$value =~ y/,/_/; # Compat. eg "add owner,notify"
#FIXME: Check existence of scenario file.
$value = {'name' => $value};
} elsif ($p->{'task'}) {
$value = {'name' => $value};
}
......
......@@ -38,7 +38,7 @@ use base qw(Sympa::Request::Handler);
my $language = Sympa::Language->instance;
my $log = Sympa::Log->instance;
use constant _action_scenario => 'archive.mail_access';
use constant _action_scenario => 'archive_mail_access';
use constant _action_regexp => qr'reject|do_it'i;
use constant _context_class => 'Sympa::List';
......
......@@ -38,7 +38,7 @@ use base qw(Sympa::Request::Handler);
my $language = Sympa::Language->instance;
my $log = Sympa::Log->instance;
use constant _action_scenario => 'archive.mail_access';
use constant _action_scenario => 'archive_mail_access';
use constant _action_regexp => qr'reject|do_it'i;
use constant _context_class => 'Sympa::List';
......
......@@ -62,12 +62,8 @@ sub _twist {
## Set title in the current language
foreach my $p ('subscribe', 'unsubscribe', 'send', 'review') {
my $scenario = Sympa::Scenario->new(
'robot' => $robot,
'directory' => $list->{'dir'},
'file_path' => $list->{'admin'}{$p}{'file_path'}
);
$data->{$p} = $scenario->get_current_title();
my $scenario = Sympa::Scenario->new($list, $p);
$data->{$p} = $scenario->get_current_title;
}
## Digest
......
......@@ -38,7 +38,7 @@ use base qw(Sympa::Request::Handler);
my $language = Sympa::Language->instance;
my $log = Sympa::Log->instance;
use constant _action_scenario => 'archive.mail_access';
use constant _action_scenario => 'archive_mail_access';
use constant _action_regexp => qr'reject|do_it'i;
use constant _context_class => 'Sympa::List';
......
This diff is collapsed.
......@@ -46,7 +46,6 @@ use Sympa::LockedFile;
use Sympa::Log;
use Sympa::Message;
use Sympa::Request;
use Sympa::Scenario;
use Sympa::Spool;
use Sympa::Spool::Archive;
use Sympa::Spool::Auth;
......@@ -1290,19 +1289,9 @@ sub upgrade {
unless ref $list->{'admin'}{'archive'} eq 'HASH';
if ($list->{'admin'}{'archive'}{'access'}) {
my $scenario = Sympa::Scenario->new(
'function' => 'archive_mail_access',
'robot' => $list->{domain},
'name' => $list->{'admin'}{'archive'}{'access'},
'directory' => $list->{dir}
);
$list->{'admin'}{'archive'}{'mail_access'} = {
'file_path' => $scenario->{'file_path'},
'name' => $scenario->{'name'}
};
$list->{'admin'}{'archive'}{'mail_access'} =
{'name' => $list->{'admin'}{'archive'}{'access'}};
}
delete $list->{'admin'}{'archive'}{'access'};
if (ref $list->{'admin'}{'web_archive'} eq 'HASH'
......
......@@ -634,8 +634,7 @@ sub get_privileges {
# if not privileged owner
if ($mode_read) {
my $result =
Sympa::Scenario::request_action($list, 'shared_doc.d_read',
my $result = Sympa::Scenario::request_action($list, 'd_read',
$auth_method, $scenario_context);
my $action;
if (ref($result) eq 'HASH') {
......@@ -647,8 +646,7 @@ sub get_privileges {
}
if ($mode_edit) {
my $result =
Sympa::Scenario::request_action($list, 'shared_doc.d_edit',
my $result = Sympa::Scenario::request_action($list, 'd_edit',
$auth_method, $scenario_context);
my $action;
if (ref($result) eq 'HASH') {
......@@ -679,14 +677,10 @@ sub get_privileges {
while ($current and @{$current->{paths}}) {
if ($current->{scenario}) {
if ($mode_read) {
my $result = Sympa::Scenario::request_action(
$list,
'shared_doc.d_read',
$auth_method,
{ %$scenario_context,
scenario => $current->{scenario}{read}
}
);
my $result =
Sympa::Scenario::request_action($list, 'd_read',
$auth_method, $scenario_context,
name => $current->{scenario}{read});
my $action;
if (ref($result) eq 'HASH') {
$action = $result->{'action'};
......@@ -698,14 +692,10 @@ sub get_privileges {
}
if ($mode_edit) {
my $result = Sympa::Scenario::request_action(
$list,
'shared_doc.d_edit',
$auth_method,
{ %$scenario_context,
scenario => $current->{scenario}{edit}
}
);
my $result =
Sympa::Scenario::request_action($list, 'd_edit',
$auth_method, $scenario_context,
name => $current->{scenario}{edit});
my $action_edit;
if (ref($result) eq 'HASH') {
$action_edit = $result->{'action'};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment