
Vcc           @   sV   d  Z  d d l m Z d d l m Z d d l m Z d Z d e f d     YZ d S(	   s5   GUI component managing the content filtering options.i(   t   mm_cfg(   t   _(   t   GUIBases   
t   ContentFilterc           B   s/   e  Z d    Z d d  Z d   Z d   Z RS(   c         C   s   d t  d  f S(   Nt   contentfilters   Content&nbsp;filtering(   R   (   t   self(    (    s8   /export/web/mailman/mailman/Mailman/Gui/ContentFilter.pyt   GetConfigCategory   s    c         C   s  | d k r d  St j } t d  t d  t d  g } t j rY | j t d   n  t d  d t j t d  t d	  f d
 t d  f d t j d | f d
 t d  t d  f d t j d | f d
 t d  t d  f d t j d | f d
 t d  f d t j d | f d
 t d  f d t j t d  t d	  f d
 t d  f d t j t d  t d	  f d
 t d  f d t j t |  d
 t d  t d  f g	 S(   NR   t   Discardt   Rejects   Forward to List Ownert   Preserves>  Policies concerning the content of list traffic.

            <p>Content filtering works like this: when a message is
            received by the list and you have enabled content filtering, the
            individual attachments are first compared to the
            <a href="?VARHELP=contentfilter/filter_mime_types">filter
            types</a>.  If the attachment type matches an entry in the filter
            types, it is discarded.

            <p>Then, if there are <a
            href="?VARHELP=contentfilter/pass_mime_types">pass types</a>
            defined, any attachment type that does <em>not</em> match a
            pass type is also discarded.  If there are no pass types defined,
            this check is skipped.

            <p>After this initial filtering, any <tt>multipart</tt>
            attachments that are empty are removed.  If the outer message is
            left empty after this filtering, then the whole message is
            discarded.

            <p> Then, each <tt>multipart/alternative</tt> section will
            be replaced by just the first alternative that is non-empty after
            filtering if
            <a href="?VARHELP=contentfilter/collapse_alternatives"
            >collapse_alternatives</a> is enabled.

            <p>Finally, any <tt>text/html</tt> parts that are left in the
            message may be converted to <tt>text/plain</tt> if
            <a href="?VARHELP=contentfilter/convert_html_to_plaintext"
            >convert_html_to_plaintext</a> is enabled and the site is
            configured to allow these conversions.t   filter_contentt   Not   Yesi    s_   Should Mailman filter the content of list traffic according
             to the settings below?t   filter_mime_typesi
   sJ   Remove message attachments that have a matching content
             type.s  Use this option to remove each message attachment that
             matches one of these content types.  Each line should contain a
             string naming a MIME <tt>type/subtype</tt>,
             e.g. <tt>image/gif</tt>.  Leave off the subtype to remove all
             parts with a matching major content type, e.g. <tt>image</tt>.

             <p>Blank lines are ignored.

             <p>See also <a href="?VARHELP=contentfilter/pass_mime_types"
             >pass_mime_types</a> for a content type whitelist.t   pass_mime_typess   Remove message attachments that don't have a matching
             content type.  Leave this field blank to skip this filter
             test.s  Use this option to remove each message attachment that does
             not have a matching content type.  Requirements and formats are
             exactly like <a href="?VARHELP=contentfilter/filter_mime_types"
             >filter_mime_types</a>.

             <p><b>Note:</b> if you add entries to this list but don't add
             <tt>multipart</tt> to this list, any messages with attachments
             will be rejected by the pass filter.t   filter_filename_extensionssP   Remove message attachments that have a matching filename
             extension.t   pass_filename_extensionss   Remove message attachments that don't have a matching
             filename extension.  Leave this field blank to skip this filter
             test.t   collapse_alternativessU   Should Mailman collapse multipart/alternative to its
             first part content?t   convert_html_to_plaintexts   Should Mailman convert <tt>text/html</tt> parts to plain
             text?  This conversion happens after MIME attachments have been
             stripped.t   filter_actionsO   Action to take when a message matches the content filtering
             rules.sK  One of these actions is taken when the message matches one of
             the content filtering rules, meaning, the top-level
             content type matches one of the <a
             href="?VARHELP=contentfilter/filter_mime_types"
             >filter_mime_types</a>, or the top-level content type does
             <strong>not</strong> match one of the
             <a href="?VARHELP=contentfilter/pass_mime_types"
             >pass_mime_types</a>, or if after filtering the subparts of the
             message, the message ends up empty.

             <p>Note this action is not taken if after filtering the message
             still contains content.  In that case the message is always
             forwarded on to the list membership.

             <p>When messages are discarded, a log entry is written
             containing the Message-ID of the discarded message.  When
             messages are rejected or forwarded to the list owner, a reason
             for the rejection is included in the bounce message to the
             original author.  When messages are preserved, they are saved in
             a special queue directory on disk for the site administrator to
             view (and possibly rescue) but otherwise discarded.  This last
             option is only available if enabled by the site
             administrator.(	   t   NoneR    t   TEXTFIELDWIDTHR   t%   OWNERS_CAN_PRESERVE_FILTERED_MESSAGESt   appendt   Radiot   Textt   tuple(   R   t   mlistt   categoryt   subcatt   WIDTHt   actions(    (    s8   /export/web/mailman/mailman/Mailman/Gui/ContentFilter.pyt   GetConfigInfo    sL    	!	!						!	!	c         C   s  | d	 k rJg  } xg  | j    D] } | j   ^ q" D] } d } | j d  }	 |	 d k ro | ro d } no |	 d k r g  | j d  D] } | j   j   ^ q \ }
 } |
 s | r d } q n |	 d k r d } n  | s | j t d   q8 | j | j   j    q8 W| d k r/| | _ q| d k r| | _	 qn | d
 k rg  } x@ g  | j    D] } | j   ^ qlD] } | j | j    qW| d k r| | _
 q| d k r| | _ qn t j |  | | | |  d  S(   NR   R   i   t   /i    s#   Bad MIME type ignored: %(spectype)sR   R   (   R   R   (   R   R   (   t
   splitlinest   stript   countt   splitt   lowert   addErrorR   R   R   R   R   R   R   t	   _setValue(   R   R   t   propertyt   valt   doct   typest   st   spectypet   okt   slashest   maintypet   subtypet   fextst   ext(    (    s8   /export/web/mailman/mailman/Mailman/Gui/ContentFilter.pyR(      s>    ,	1		,c         C   st   | d k r t  j | j  S| d k r8 t  j | j  S| d k rT t  j | j  S| d k rp t  j | j  Sd  S(   NR   R   R   R   (   t   NLt   joinR   R   R   R   R   (   R   R   t   kindR)   t   params(    (    s8   /export/web/mailman/mailman/Mailman/Gui/ContentFilter.pyt   getValue   s    N(   t   __name__t
   __module__R   R   R    R(   R9   (    (    (    s8   /export/web/mailman/mailman/Mailman/Gui/ContentFilter.pyR      s   	{	#N(	   t   __doc__t   MailmanR    t   Mailman.i18nR   t   Mailman.Gui.GUIBaseR   R5   R   (    (    (    s8   /export/web/mailman/mailman/Mailman/Gui/ContentFilter.pyt   <module>   s
   