Commit 34e50784 authored by sikeda's avatar sikeda
Browse files

[bug][#10968] [Submitted by S. Hornburg] Visibility settings in topics.conf...

[bug][#10968] [Submitted by S. Hornburg] Visibility settings in topics.conf were ignored.  Fixed by cheking topics_visibility scenario along with subtopics.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12968 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 23f4a130
......@@ -18123,18 +18123,52 @@ sub do_stats {
return 1;
}
 
sub _purge_subtopics {
my ($robot, $topic_name, $topic) = @_;
if ($topic->{sub}) {
my @names = (keys %{$topic->{sub}});
for my $name (@names) {
my $result = Sympa::Scenario::request_action(
$robot,
'topics_visibility',
$param->{'auth_method'},
{ 'topicname' => join ('/', $topic_name, $name),
'sender' => $param->{'user'}{'email'},
'remote_host' => $param->{'remote_host'},
'remote_addr' => $param->{'remote_addr'}
}
);
my $action;
$action = $result->{'action'} if (ref($result) eq 'HASH');
if ($action =~ /do_it/) {
_purge_subtopics($robot, $topic->{sub}->{$name});
}
else {
delete $topic->{sub}->{$name};
}
}
}
}
## setting the topics list for templates
sub export_topics {
 
my $robot = shift;
wwslog('debug2', '(%s)', $robot);
my %topics = Sympa::Robot::load_topics($robot);
my %topics_orig = Sympa::Robot::load_topics($robot);
 
unless (%topics) {
unless (%topics_orig) {
wwslog('err', 'No topics defined');
return undef;
}
 
my $dup = Sympa::Tools::Data::dup_var(\%topics_orig);
my %topics = %$dup;
## Remove existing topics
$param->{'topics'} = undef;
 
......@@ -18157,6 +18191,9 @@ sub export_topics {
$action = $result->{'action'} if (ref($result) eq 'HASH');
next unless ($action =~ /do_it/);
 
# Purge concealed subtopics
_purge_subtopics($robot, $t, $topics{$t});
my $current = $topics{$t};
$current->{'id'} = $t;
 
......
......@@ -257,8 +257,9 @@ sub load_topics {
} else {
my $subtopic = join('/', @tree[1 .. $#tree]);
my $title = _get_topic_titles($topic);
my $visibility = $topic->{'visibility'} || 'default';
$list_of_topics{$robot}{$tree[0]}{'sub'}{$subtopic} =
_add_topic($subtopic, $title);
_add_topic($subtopic, $title, $visibility);
}
}
......@@ -339,15 +340,15 @@ sub _get_topic_titles {
## Inner sub used by load_topics()
sub _add_topic {
my ($name, $title) = @_;
my ($name, $title, $visibility) = @_;
my $topic = {};
my @tree = split '/', $name;
if ($#tree == 0) {
return {'title' => $title};
return {'title' => $title, 'visibility' => $visibility};
} else {
$topic->{'sub'}{$name} =
_add_topic(join('/', @tree[1 .. $#tree]), $title);
_add_topic(join('/', @tree[1 .. $#tree]), $title, $visibility);
return $topic;
}
}
......
......@@ -444,12 +444,24 @@ sub request_action {
} elsif ($context->{'topicname'}) {
## Topics
my $visibility;
## Split in case of subtopics
my @tree = split '/', $context->{'topicname'};
my $topic = $Sympa::Robot::list_of_topics{$robot_id}{$tree[0]};
shift(@tree);
for my $node (@tree) {
next unless exists $topic->{sub};
$topic = $topic->{sub}->{$node};
}
$visibility = $topic->{'visibility'};
$scenario = Sympa::Scenario->new(
'robot' => $robot_id,
'function' => 'topics_visibility',
'name' => $Sympa::Robot::list_of_topics{$robot_id}
{$context->{'topicname'}}{'visibility'},
'name' => $visibility,
'options' => $context->{'options'}
);
......
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