Commit 5fb56b45 authored by sikeda's avatar sikeda
Browse files

[-change] WWSympa: /sympa/suspend_request page was replaced with /sympa/my, more appropriate name.

Known bugs:
- Bulk suspending/resuming subscription won't work.
- Inclusion from external sources is not considered.
- Lack of feature to change subscription options in each list: Suspending/resuming, reception mode, visibility in review page, display name (a.k.a. gecos).


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11838 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 0266f3de
......@@ -267,6 +267,7 @@ nobase_default_DATA = \
web_tt2/menu_search.tt2 \
web_tt2/modindex.tt2 \
web_tt2/modform.tt2 \
web_tt2/my.tt2 \
web_tt2/nav.tt2 \
web_tt2/news.tt2 \
web_tt2/notice.tt2 \
......
......@@ -36,7 +36,7 @@
<div class="prefs">
<ul id="MainMenuLinks">
<li><a href="[% path_cgi %]/pref">[%|loc%]My preferences[%END%]</a></li>
<li><a href="[% path_cgi %]/suspend_request" onclick="show('loading'); hide('content-inner');">[%|loc%]My lists[%END%]</a></li>
<li><a href="[% path_cgi %]/my" onclick="show('loading'); hide('content-inner');">[%|loc%]My lists[%END%]</a></li>
</ul>
</div>
......
......@@ -40,7 +40,7 @@
<div><input type="text" name="email" id="email_login" size="28" value="[% unauthenticated_email %]" /></div>
<label for="passwd" >[%|loc%]password:[%END%]</label>
<div><input type="password" name="passwd" id="passwd" size="8" /></div>
<input class="MainMenuLinks" type="submit" name="action_login" value="[%|loc%]Login[%END%]" />
<input class="MainMenuLinks" type="submit" name="action_login" value="[%|loc%]Login[%END%]" onclick="show('loading'); hide('content-inner');" />
</fieldset>
</form>
[% END %]
......
<!-- $Id: suspend_request.tt2 5973 2009-07-20 10:29:53Z meleard $ -->
<div class="block">
[% IF user.email %]
<h2>[%|loc%]Manage your subscriptions[%END%] <a class="input" href="[%path_cgi %]/help/suspend">[%|loc%]Help[%END%]</a></h2>
<p>[%|loc%]You are subscribed to the following lists[%END%]</p>
<form class="noborder" action="[% path_cgi %]" method="post" name="suspend_request">
[% IF which.size %]
<div class="item_list">
[% FOREACH l = which %]
[% suspended = 0 %]
[% suspendable = 0 %]
[% additional_class = '' %]
[% IF l.value.is_subscriber %]
[% suspendable = 1 %]
[% END %]
[% IF l.value.listsuspend %]
[% suspended = 1 %]
[% additional_class = ' suspended' %]
[% END %]
<div class="item[% additional_class %]">
<div class="item_content">
<a class="item_title" href="[% path_cgi %]/info/[% l.key %]">
[% hidden_head %][% l.key %][% hidden_end %]
[% IF l.value.is_owner %]
<span class="highlighted">[%|loc%](Owner)[%END%]</span>
[% ELSIF l.value.is_editor %]
<span class="highlighted">[%|loc%](Editor)[%END%]</span>
[% END %]
</a>
[% IF suspendable %]
[% IF suspended %]
[%|loc(l.value.liststartdate)%]Suspended from %1 to[% END %]
[% IF l.value.listenddate %]
[% l.value.listenddate %]
[% ELSE %]
[%|loc%]indefinite end date[%END%]
[% END %]<br/>
<input id="listname.[% l.key %]" type="checkbox" checked="checked" name="listname" value="[% l.key %]" />
<label for="listname">[%|loc(l.key)%]Check to restore reception from list %1[% END %]</label>
[% ELSE %]
<input id="listname.[% l.key %]" type="checkbox" checked="checked" name="listname" value="[% l.key %]" />
<label for="listname">[%|loc(l.key)%]Check to suspend or unsubscribe from list %1[% END %]</label>
[% END %]
[% ELSE %]
<p class="note">[%|loc%]You are not allowed to suspend your subscription / unsusbscribe from this list.[% END %]
[% END %]
<p class="list_subject">[% l.value.subject %]</p>
<ul>
[% IF l.value.admin %]
<li><a href="[% path_cgi %]/review/[% l.key %]">[%|loc%]Review members[%END%]</a></li>
[% END %]
[% IF is_user_allowed_to('archive.web_access', l.key) %]
<li><a href="[% path_cgi %]/arc/[% l.key %]">[%|loc%]Archives[%END%]</a></li>
[% END %]
</ul>
</div>
</div>
[% END %]
</div>
[% ELSE %]
<p>[%|loc%]No subscription.[%END%]</p>
[% END %]
<p>[%|loc%]You can bulk suspend or revoke your memberships by selecting relevant lists and using the buttons below. The suspend option prevents delivery of emails, this can be useful if you are out of the office for some time.[%END%]</p>
<input class="MainMenuLinks" type="button" value="[%|loc%]Toggle selection[%END%]" onclick="toggle_selection(document.suspend_request.listname)" />
<br />
<input type="hidden" name="action" value="suspend_request_action"/>
<input class="MainMenuLinks" type="submit" name="sub_action_suspendsave" value="[%|loc%]Suspend my subscriptions[%END%]"/>
[%|loc%]From:[%END%] <noscript>(dd-mm-yyyy)</noscript><input type="text" id="date_deb" name="date_deb" maxlength="10" size="10" value="[% d_day %]" onfocus="visuCal(this,param_ddeb);" onblur="masqueCal(this);" />
[%|loc%]To:[%END%] <noscript>(dd-mm-yyyy)</noscript><input type="text" id="date_fin" name="date_fin" maxlength="10" size="10" onfocus="visuCal(this,param_dfin)" onblur="masqueCal(this)" />
<input type="checkbox" name="indefinite" />[%|loc%]Suspend my membership indefinitely[%END%]
<br />
[% IF suspended %]
<input class="MainMenuLinks" type="submit" name="sub_action_suspendstop" value="[%|loc%]Resume my subscriptions[%END%]"/>
<br />
[% END %]
<input class="MainMenuLinks" type="submit" name="sub_action_signoff" value="[%|loc%]Unsubscribe[%END%]"/>
</form>
[% ELSE %]
[%|loc%]You need to be logged in to access this page.[%END%]
[% END %]
</div>
<!-- end suspend_request.tt2 -->
......@@ -177,6 +177,7 @@ our %comm = (
#XXX'multiple_signoff' => 'do_multiple_signoff',
'sigrequest' => 'do_sigrequest',
'ignoresub' => 'do_ignoresub',
'my' => 'do_my',
'which' => 'do_which',
'lists' => 'do_lists',
'latest_lists' => 'do_latest_lists',
......@@ -4819,6 +4820,15 @@ sub do_requestpasswd {
return $param->{'previous_action'};
}
 
sub do_my {
wwslog('info', '', $in{'action'});
# Sets the date of the field "start date" to "today"
$param->{'d_day'} = POSIX::strftime('%d-%m-%Y', localtime time);
_set_my_lists_info();
return 1;
}
## Which list the user is subscribed to
## TODO (pour listmaster, toutes les listes)
sub do_which {
......@@ -4905,7 +4915,7 @@ sub do_lists {
|| $in{'subtopic'}
);
} elsif ($topics{$in{'topic'}}{'current_title'}) {
$param->{'subtitle'} = $topics{$in{'topic'}}{'current_title'}
$param->{'subtitle'} = $topics{$in{'topic'}}{'current_title'};
} elsif ($in{'topic'} eq 'others' or $in{'topic'} eq 'topicsless') {
$param->{'subtitle'} = $language->gettext('Others');
} else {
......@@ -21393,82 +21403,29 @@ sub do_change_email {
# | 'info' | undef #
# #
####################################################
# We display in the table the lists of the subscriber and the state in
# which they are.
# reception : - nomail/digest/mail ||
# - . suspended From XX-XX-XXXX To XX-XX-XXXX
sub do_suspend_request {
# Action = suspend_request
wwslog('info', '', $in{'action'});
my $email = $param->{'user'}{'email'};
my $data;
 
## Sets the date of the field "start date" to "today"
my @d_day = localtime(time);
$param->{'d_day'} =
($d_day[3]) . "-" . ($d_day[4] + 1) . "-" . ($d_day[5] + 1900);
my $display_resume = 0;
## We display in the table the lists of the subscriber and the state in
## which they are.
## reception : - nomail/digest/mail ||
## - . suspended From XX-XX-XXXX To XX-XX-XXXX
my @lists = Sympa::List::get_which($email, $robot, 'member');
foreach my $list (@lists) {
my $member_info = $list->get_list_member($param->{'user'}{'email'});
if ($member_info->{'enddate'} and $member_info->{'enddate'} < time) {
## If end date is < time, update the BDD by deleting the
## suspending's data
$list->restore_suspended_subscription($param->{'user'}{'email'});
}
my $final_start_date =
$language->gettext_strftime("%d %b %Y",
localtime($member_info->{'startdate'}));
my $final_end_date;
$param->{'d_day'} = POSIX::strftime('%d-%m-%Y', localtime time);
_set_my_lists_info();
 
if ($member_info->{'suspend'} == 1) {
$display_resume = 1;
}
if ($member_info->{'enddate'}) {
$final_end_date =
$language->gettext_strftime("%d %b %Y",
localtime($member_info->{'enddate'}));
} else {
$final_end_date = undef;
}
$member_info->{'reception'} ||= 'mail';
$member_info->{'visibility'} ||= 'noconceal';
foreach my $mode ($list->available_reception_mode) {
$param->{'reception'}{$list->{'name'}}{$mode}{'description'} =
$list->get_option_title($mode, 'reception');
if ($member_info->{'reception'} eq $mode) {
$param->{'reception'}{$list->{'name'}}{$mode}{'selected'} =
' selected';
} else {
$param->{'reception'}{$list->{'name'}}{$mode}{'selected'} =
'';
}
}
my $subscription = {
'listname' => $list->{'name'},
'listdomain' => $list->{'domain'},
'listreception' => $member_info->{'reception'},
'listsuspend' => $member_info->{'suspend'},
'liststartdate' => $final_start_date,
'listenddate' => $final_end_date,
'display' => $display_resume,
'visibility' => $member_info->{'visibility'},
'reception' => $param->{'reception'}{$list->{'name'}},
};
push @{$param->{'suspend_list'}}, $subscription;
}
_set_which_info();
# Compatibility with Sympa <= 6.1b.1.
$param->{'which_info'} = $param->{'which'};
$param->{'suspend_list'} =
[grep { $_->{'listsuspend'} } values %{$param->{'which'}}];
 
return 1;
}
 
sub _set_which_info {
sub _set_my_lists_info {
my $which = {};
# Set which_info unless in one list page
if ($param->{'user'}{'email'} and ref $list ne 'Sympa::List') {
my %get_which;
......@@ -21483,7 +21440,7 @@ sub _set_which_info {
);
}
 
# Add lists information to 'which_info'
# Add lists information to 'which'
foreach my $list (@{$get_which{member}}) {
# Evaluate AuthZ scenario first
my $result = Sympa::Scenario::request_action(
......@@ -21500,29 +21457,83 @@ sub _set_which_info {
and $result->{'action'} eq 'do_it';
 
my $l = $list->{'name'};
$param->{'which_info'}{$l}{'subject'} =
$list->{'admin'}{'subject'};
$param->{'which_info'}{$l}{'host'} = $list->{'admin'}{'host'};
$param->{'which_info'}{$l}{'info'} = 1;
$which->{$l}{'subject'} = $list->{'admin'}{'subject'};
$which->{$l}{'host'} = $list->{'admin'}{'host'};
$which->{$l}{'is_subscriber'} = 1; # New on 6.2b.2.
# Compat. < 6.2b.2.
$which->{$l}{'info'} = 1;
my $member_info =
$list->get_list_member($param->{'user'}{'email'});
my ($final_start_date, $final_end_date);
if ($member_info->{'suspend'}) {
if (defined $member_info->{'enddate'}
and $member_info->{'enddate'} < time) {
# If end date is < time, update the BDD by deleting the
# suspending's data
# FIXME: Is this required?
$list->restore_suspended_subscription(
$param->{'user'}{'email'});
}
$final_start_date =
$language->gettext_strftime("%d %b %Y",
localtime $member_info->{'startdate'})
if defined $member_info->{'startdate'};
$final_end_date =
$language->gettext_strftime("%d %b %Y",
localtime $member_info->{'enddate'})
if defined $member_info->{'enddate'};
}
$member_info->{'reception'} ||= 'mail';
$member_info->{'visibility'} ||= 'noconceal';
foreach my $mode ($list->available_reception_mode) {
$param->{'reception'}{$list->{'name'}}{$mode}{'description'} =
$list->get_option_title($mode, 'reception');
if ($member_info->{'reception'} eq $mode) {
$param->{'reception'}{$list->{'name'}}{$mode}
{'selected'} = ' selected';
} else {
$param->{'reception'}{$list->{'name'}}{$mode}
{'selected'} = '';
}
}
$which->{$l}{'listname'} = $list->{'name'};
$which->{$l}{'listdomain'} = $list->{'domain'};
$which->{$l}{'listreception'} = $member_info->{'reception'};
$which->{$l}{'listsuspend'} = $member_info->{'suspend'};
$which->{$l}{'liststartdate'} = $final_start_date;
$which->{$l}{'listenddate'} = $final_end_date;
$which->{$l}{'visibility'} = $member_info->{'visibility'};
$which->{$l}{'reception'} =
$param->{'reception'}{$list->{'name'}};
# Compat. < 6.2b.1.
$which->{$l}{'display'} = $which->{$l}{'listsuspend'};
}
foreach my $list (@{$get_which{owner}}) {
my $l = $list->{'name'};
$param->{'which_info'}{$l}{'subject'} =
$list->{'admin'}{'subject'};
$param->{'which_info'}{$l}{'host'} = $list->{'admin'}{'host'};
$param->{'which_info'}{$l}{'info'} = 1;
$param->{'which_info'}{$l}{'admin'} = 1;
$which->{$l}{'subject'} = $list->{'admin'}{'subject'};
$which->{$l}{'host'} = $list->{'admin'}{'host'};
$which->{$l}{'is_owner'} = 1; # New on 6.2b.2.
# Compat. < 6.2b.1.
$which->{$l}{'info'} = 1;
$which->{$l}{'admin'} = 1;
}
foreach my $list (@{$get_which{editor}}) {
my $l = $list->{'name'};
 
$param->{'which_info'}{$l}{'subject'} =
$list->{'admin'}{'subject'};
$param->{'which_info'}{$l}{'host'} = $list->{'admin'}{'host'};
$param->{'which_info'}{$l}{'info'} = 1;
$param->{'which_info'}{$l}{'admin'} = 1;
$which->{$l}{'subject'} = $list->{'admin'}{'subject'};
$which->{$l}{'host'} = $list->{'admin'}{'host'};
$which->{$l}{'is_editor'} = 1; # New on 6.2b.2.
# Compat. < 6.2b.1.
$which->{$l}{'info'} = 1;
$which->{$l}{'admin'} = 1;
}
}
$param->{'which'} = $which;
}
 
####################################################
......
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