1
# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
from Mailman import mm_cfg
18
from Mailman.i18n import _
19
from Mailman.Gui.GUIBase import GUIBase
23
class Usenet(GUIBase):
24
def GetConfigCategory(self):
25
return 'gateway', _('Mail<->News gateways')
27
def GetConfigInfo(self, mlist, category, subcat=None):
28
if category <> 'gateway':
31
WIDTH = mm_cfg.TEXTFIELDWIDTH
35
_('Mail-to-News and News-to-Mail gateway services.'),
37
_('News server settings'),
39
('nntp_host', mm_cfg.String, WIDTH, 0,
40
_('The hostname of the machine your news server is running on.'),
41
_('''This value may be either the name of your news server, or
42
optionally of the format name:port, where port is a port number.
44
The news server is not part of Mailman proper. You have to
45
already have access to an NNTP server, and that NNTP server must
46
recognize the machine this mailing list runs on as a machine
47
capable of reading and posting news.''')),
49
('linked_newsgroup', mm_cfg.String, WIDTH, 0,
50
_('The name of the Usenet group to gateway to and/or from.')),
52
('gateway_to_news', mm_cfg.Toggle, (_('No'), _('Yes')), 0,
53
_('''Should new posts to the mailing list be sent to the
56
('gateway_to_mail', mm_cfg.Toggle, (_('No'), _('Yes')), 0,
57
_('''Should new posts to the newsgroup be sent to the mailing
60
_('Forwarding options'),
62
('news_moderation', mm_cfg.Radio,
63
(_('None'), _('Open list, moderated group'), _('Moderated')),
66
_("""The moderation policy of the newsgroup."""),
68
_("""This setting determines the moderation policy of the
69
newsgroup and its interaction with the moderation policy of the
70
mailing list. This only applies to the newsgroup that you are
71
gatewaying <em>to</em>, so if you are only gatewaying from
72
Usenet, or the newsgroup you are gatewaying to is not moderated,
73
set this option to <em>None</em>.
75
<p>If the newsgroup is moderated, you can set this mailing list
76
up to be the moderation address for the newsgroup. By selecting
77
<em>Moderated</em>, an additional posting hold will be placed in
78
the approval process. All messages posted to the mailing list
79
will have to be approved before being sent on to the newsgroup,
80
or to the mailing list membership.
82
<p><em>Note that if the message has an <tt>Approved</tt> header
83
with the list's administrative password in it, this hold test
84
will be bypassed, allowing privileged posters to send messages
85
directly to the list and the newsgroup.</em>
87
<p>Finally, if the newsgroup is moderated, but you want to have
88
an open posting policy anyway, you should select <em>Open list,
89
moderated group</em>. The effect of this is to use the normal
90
Mailman moderation facilities, but to add an <tt>Approved</tt>
91
header to all messages that are gatewayed to Usenet.""")),
93
('news_prefix_subject_too', mm_cfg.Toggle, (_('No'), _('Yes')), 0,
94
_('Prefix <tt>Subject:</tt> headers on postings gated to news?'),
95
_("""Mailman prefixes <tt>Subject:</tt> headers with
96
<a href="?VARHELP=general/subject_prefix">text you can
97
customize</a> and normally, this prefix shows up in messages
98
gatewayed to Usenet. You can set this option to <em>No</em> to
99
disable the prefix on gated messages. Of course, if you turn off
100
normal <tt>Subject:</tt> prefixes, they won't be prefixed for
101
gated messages either.""")),
105
('_mass_catchup', mm_cfg.Toggle, (_('No'), _('Yes')), 0,
106
_('Should Mailman perform a <em>catchup</em> on the newsgroup?'),
107
_('''When you tell Mailman to perform a catchup on the newsgroup,
108
this means that you want to start gating messages to the mailing
109
list with the next new message found. All earlier messages on
110
the newsgroup will be ignored. This is as if you were reading
111
the newsgroup yourself, and you marked all current messages as
112
<em>read</em>. By catching up, your mailing list members will
113
not see any of the earlier messages.''')),
117
def _setValue(self, mlist, property, val, doc):
118
# Watch for the special, immediate action attributes
119
if property == '_mass_catchup' and val:
120
mlist.usenet_watermark = None
121
doc.AddItem(_('Mass catchup completed'))
123
GUIBase._setValue(self, mlist, property, val, doc)
125
def _postValidate(self, mlist, doc):
126
# Make sure that if we're gating, that the newsgroups and host
127
# information are not blank.
128
if mlist.gateway_to_news or mlist.gateway_to_mail:
129
# BAW: It's too expensive and annoying to ensure that both the
130
# host is valid and that the newsgroup is a valid n.g. on the
131
# server. This should be good enough.
132
if not mlist.nntp_host or not mlist.linked_newsgroup:
133
doc.addError(_("""You cannot enable gatewaying unless both the
134
<a href="?VARHELP=gateway/nntp_host">news server field</a> and
135
the <a href="?VARHELP=gateway/linked_newsgroup">linked
136
newsgroup</a> fields are filled in."""))
137
# And reset these values
138
mlist.gateway_to_news = 0
139
mlist.gateway_to_mail = 0