Commit e89671aa authored by IKEDA Soji's avatar IKEDA Soji
Browse files

[feature] Now review page deals with owner and editors in addition to members.

Reorganizing user interface (1).
parent 5e190f69
......@@ -141,10 +141,30 @@
<li class="[% class %]"><a href="[% 'edit_list_request' | url_rel([list,'other']) %]" >[%|loc%]Miscellaneous[%END%]</a></li>
</ul>
</li>
[% IF is_owner %]
[% IF action == 'review' %][% SET class = 'active' %][% ELSE %][% SET class = '' %][% END %]
<li class="[% class %]"><a href="[% 'review' | url_rel([list]) %]">[%|loc%]Manage Subscribers[%END%]</a></li>
[% END %]
[% IF is_owner ~%]
<li class="has-dropdown [% IF action == 'review' %]active[%END%]">
<a href="#">
[%|loc%]Users[%END%]
</a>
<ul class="dropdown">
<li [% IF page.match('^\d+$') %]class="active"[%END%]>
<a href="[% 'review' | url_rel([list]) %]" >
[%|loc%]Subscribers[%END%]
</a>
</li>
<li [% IF page == 'owner' %]class="active"[%END%]>
<a href="[% 'review' | url_rel([list,'owner']) %]" >
[%|loc%]Owners[%END%]
</a>
</li>
<li [% IF page == 'editor' %]class="active"[%END%]>
<a href="[% 'review' | url_rel([list,'editor']) %]" >
[%|loc%]Editors[%END%]
</a>
</li>
</ul>
</li>
[%~ END %]
[% IF conf.use_blacklist != 'none' %]
[% IF action == 'blacklist' %][% SET class = 'active' %][% ELSE %][% SET class = '' %][% END %]
<li class="[% class %]"><a href="[% 'blacklist' | url_rel([list]) %]" >[%|loc%]Blacklist[%END%]</a></li>
......
<!-- review.tt2 -->
[% IF page.match('^\d*$') ~%]
[% PROCESS ReviewMembers ~%]
[%~ ELSIF page == 'owner' ~%]
[% PROCESS ReviewUsers
users = owners %]
[%~ ELSIF page == 'editor' ~%]
[% PROCESS ReviewUsers
users = editors %]
[%~ END %]
[%~ BLOCK ReviewMembers # (members) ~%]
[% IF is_owner %]
<h2>[%|loc%]Manage list members[%END%] <a href="[% 'nomenu/help/admin' | url_rel %]#manage_members" title="[%|loc%]Open in a new window[%END%]" onclick="window.open('','wws_help','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=400,height=200')" target="wws_help"><i class="fa fa-question-circle" title="[%|loc%]Help[%END%]"></i></a></h2>
......@@ -202,4 +215,192 @@
[% END %]
[% END %]
[%~ END #ReviewMembers %]
[%~ BLOCK ReviewUsers # (users) ~%]
<h2>
[% IF page == 'owner' ~%]
[%|loc%]Owners[%END%]
[%~ ELSIF page == 'editor' ~%]
[%|loc%]Moderators[%END%]
[%~ END %]
</h2>
<form action="[% path_cgi %]" method="POST">
<fieldset role="table">
<input type="hidden" name="list" value="[% list %]" />
<input type="hidden" name="action" value="review" />
<input type="hidden" name="page" value="[% page %]" />
<div class="row" role="row">
<div class="small-10 medium-11 columns">
<div class="small-6 medium-4 columns" role="columnheader">
<label>[%|loc%]Email[%END%]</label>
</div>
<div class="small-6 medium-4 columns" role="columnheader">
<label>[%|loc%]Name[%END%]</label>
</div>
<div class="medium-2 columns show-for-medium-up" role="columnheader">
<label>[%|loc%]Reception[%END%]</label>
</div>
<div class="medium-2 columns show-for-medium-up" role="columnheader">
<label>[%|loc%]Visibility[%END%]</label>
</div>
[% IF is_privileged_owner ~%]
<div class="columns" role="columnheader">
<label>[%|loc%]private information[%END%]</label>
</div>
[%~ END %]
<div class="columns" role="separator">
<hr>
</div>
</div>
[% IF is_privileged_owner ~%]
<div class="small-2 medium-1 columns" role="columnheader">
<label title="[%|loc%]Delete[%END%]">
<i class="fa fa-user-times"></i>
</label>
</div>
[%~ END %]
</div>
[% IF users.size() ~%]
[% SET idx = 0 ~%]
[% FOREACH u = users ~%]
<div class="row" role="row">
<div class="small-10 medium-11 columns" id="item.user.[% idx %]">
<div class="small-6 medium-4 columns" role="cell">
<span class="show-for-medium-up">
[%~ IF page == 'owner' && u.profile == 'privileged' ~%]
<i class="fa fa-fw fa-star"
title="[%|loc%]Privileged owner[%END%]"></i>
[%~ ELSIF page == 'owner' ~%]
<i class="fa fa-fw" title="[%|loc%]Owner[%END%]"></i>
[%~ ELSIF page == 'editor' ~%]
<i class="fa fa-fw" title="[%|loc%]Moderator[%END%]"></i>
[%~ END %]
</span>
[% u.email %]
</div>
<div class="small-6 medium-4 columns" role="cell">
[% u.gecos || '&nbsp;' %]
</div>
<div class="medium-2 columns show-for-medium-up" role="cell">
[% u.reception | optdesc %]
</div>
<div class="medium-2 columns show-for-medium-up" role="cell">
[% u.visibility | optdesc %]
</div>
[% IF is_privileged_owner ~%]
<div class="columns" role="cell">
[% u.info %]
</div>
[%~ END %]
<div class="columns" role="separator">
<hr>
</div>
</div>
[% IF is_privileged_owner ~%]
<div class="small-2 medium-1 columns" role="cell">
[% IF u.subscribed ~%]
<input type="checkbox" name="del_emails"
id="del.user.[% idx %]"
class="fadeIfChecked" data-selector="#item\.user\.[% idx %]"
title="[%|loc%]Delete[%END%]"
value="[% u.email %]" />
[%~ ELSIF u.included ~%]
&nbspo;
[%~ END %]
</div>
[%~ END %]
</div>
[%~ SET idx = idx + 1 %]
[%~ END %]
[%~ ELSE ~%]
<p
class="small-12 medium-8 medium-centered columns alert-box info text-center">
[% IF page == 'owner' ~%]
[%|loc%]List has no owners[%END%]
[%~ ELSIF page == 'editor' ~%]
[%|loc%]List has no moderators[%END%]
[%~ END %]
</p>
[%~ END %]
<h3>
[% IF page == 'owner' ~%]
[%|loc%]Add owners[%END%]
[%~ ELSIF page == 'editor' ~%]
[%|loc%]Add momderators[%END%]
[%~ END %]
</h3>
[% IF is_privileged_owner ~%]
<div class="row" id="item.user.0.new" role="row">
<div class="small-10 medium-11 columns">
[% IF page == 'owner' ~%]
<div class="columns show-for-medium-up" role="cell">
<input type="checkbox"
name="single_param.user.0.profile" id="param.user.0.profile"
value="privileged" />
<label for="param.user.0.profile">[% 'privileged' | optdesc %]</label>
</div>
[%~ END %]
<div class="small-6 medium-4 columns" role="cell">
<label for="param.user.0.email">[%|loc%]Email[%END%]
<input type="text"
name="single_param.user.0.email" id="param.user.0.email" />
</div>
<div class="small-6 medium-4 columns" role="cell">
<label for="param.user.0.gecos">[%|loc%]Name[%END%]
<input name="single_param.user.0gecos" id="param.user.0.gecos" />
</div>
<div class="medium-2 columns show-for-medium-up" role="cell">
<input type="checkbox"
name="single_param.user.0.reception" id="param.user.0.reception"
value="nomail" />
<label for="param.user.0.reception">[% 'nomail' | optdesc %]</label>
</div>
<div class="medium-2 columns show-for-medium-up" role="cell">
<input type="checkbox"
name="single_param.user.0.visibility" id="param.user.0.visibility"
value="conceal" />
<label for="param.user.0.visibility">[% 'conceal' | optdesc %]</label>
</div>
<div class="columns" role="cell">
<label for="param.user.0.info">[%|loc%]private information[%END%]</label>
<input type="text"
name="single_param.user.0.info" id="param.user.0.info" />
</div>
</div>
</div>
[%~ END %]
<input class="MainMenuLInks" type="submit" name="action_review"
value="[%|loc%]Update[%END%]" />
</fieldset>
</form>
[%~ END#ReviewUsers ~%]
<!-- end review.tt2 -->
......@@ -828,7 +828,7 @@ our %in_regexp = (
'blacklist' => '.*',
 
## Integer
'page' => '\d+',
'page' => '\d+|owner|editor',
'size' => '\d+',
 
## Free data
......@@ -905,6 +905,7 @@ our %in_regexp = (
'new_email' => Sympa::Regexps::email(),
'sender' => Sympa::Regexps::email(),
'fromaddr' => Sympa::Regexps::email(),
'del_emails' => '.*',
'to' => '(([\w\-\_\.\/\+\=\']+|\".*\")\s[\w\-]+(\.[\w\-]+)+(,?))*',
'automatic_list_part_*' => '[\w\-\.\+]*',
 
......@@ -4737,6 +4738,75 @@ sub do_subscriber_count {
## Subscribers' list
sub do_review {
wwslog('info', '(%s)', $in{'page'});
$param->{'page'} = $in{'page'} || 1;
if ($param->{'page'} eq 'owner') {
return _review_user('owner');
} elsif ($in{'page'} eq 'editor') {
return _review_user('editor');
} else {
return _review_member();
}
}
# List of owners / editors
sub _review_user {
wwslog('info', '(%s)', @_);
my $role = shift;
# Access control
return undef
unless Sympa::is_listmaster($list, $param->{'user'}{'email'})
or $list->is_admin('owner', $param->{'user'}{'email'});
# Delete/add users.
my @del_users = grep {$_} map { Sympa::Tools::Text::canonic_email($_) }
split /\0/, $in{'del_emails'};
my $new_users = [
grep { $_ and $_->{email} }
@{(_deserialize_changes() || {})->{user} || []}
];
foreach my $email (@del_users) {
next if grep {$email eq $_->{email}} @$new_users;
$list->delete_list_admin($role, $email);
}
foreach my $user (@{(ref $new_users eq 'ARRAY') ? $new_users : []}) {
my $email = $user->{email};
if (grep {$email eq $_} @del_users) {
; #FIXME: Update user?
} else {
unless ($list->add_list_admin($role, $user)) {
#FIXME: Report error
} else {
# Notify the new list owner/editor
Sympa::send_notify_to_user(
$list,
'added_as_listadmin',
$email,
{ admin_type => $role,
delegator => $param->{'user'}{'email'}
}
);
Sympa::Report::notice_report_web('user_notified',
{'notified_user' => $email},
$param->{'action'});
}
}
}
# Users list
my $users =
[grep { $_->{role} eq $role } @{$list->get_current_admins || []}];
foreach my $user (@$users) {
$user->{sources} = $list->get_datasource_name($user->{id})
if $user->{id};
}
$param->{($role eq 'owner') ? 'owners' : 'editors'} = $users;
return 1;
}
sub _review_member {
my $record;
my @users;
my $size;
......
......@@ -745,7 +745,7 @@ sub dump_users {
} else {
my %map_field = _map_list_admin_cols();
foreach my $user (@{$self->_get_admins || []}) {
foreach my $user (@{$self->get_current_admins || []}) {
next unless $user->{role} eq $role;
foreach my $k (sort keys %map_field) {
printf $lock_fh "%s %s\n", $k, $user->{$k}
......@@ -2908,7 +2908,8 @@ sub get_admins {
my $admin_user = $self->_cache_get('admin_user');
unless ($admin_user and @{$admin_user || []}) {
$admin_user = $self->_get_admins; # Get recent admins from database
# Get recent admins from database.
$admin_user = $self->get_current_admins;
if ($admin_user) {
$self->_cache_put('admin_user', $admin_user);
} else {
......@@ -2970,8 +2971,9 @@ sub get_admins {
return wantarray ? @users : [@users];
}
# Get recent admins from database.
sub _get_admins {
# Get all admins passing cache.
# Note: Use with care. This increases database load.
sub get_current_admins {
my $self = shift;
my $sdm = Sympa::DatabaseManager->instance;
......@@ -4032,6 +4034,9 @@ sub add_list_admin {
$new_admin_user->{'subscribed'} ||= 0;
$new_admin_user->{'included'} ||= 0;
$new_admin_user->{'reception'} ||= 'mail';
$new_admin_user->{'visibility'} ||= 'noconceal';
my $sdm = Sympa::DatabaseManager->instance;
# Update Admin Table
......
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