;
)?Bc           @   sM   d  Z  d k l Z d k l Z d k l Z d Z d e f d     YZ d S(   s6   GUI component managing the content filtering options.
(   s   mm_cfg(   s   _(   s   GUIBases   
s   ContentFilterc           B   s/   t  Z d   Z e d  Z d   Z d   Z RS(   Nc         C   s   d t  d  f Sd  S(   Ns   contentfilters   Content&nbsp;filtering(   s   _(   s   self(    (    s)   /var/mailman/Mailman/Gui/ContentFilter.pys   GetConfigCategory   s    c         C   sI  | d j o t Sn t i } t d  t d  t d  g } t i o | i t d   n t d  d t i	 t d  t d	  f d
 t d  f d t i
 d | f d
 t d  t d  f d t i
 d | f d
 t d  t d  f d t i	 t d  t d	  f d
 t d  f d t i	 t |  d
 t d  t d  f g Sd  S(   Ns   contentfilters   Discards   Rejects   Forward to List Owners   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.  Then, each <tt>multipart/alternative</tt> section will
            be replaced by just the first alternative that is non-empty after
            filtering.

            <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.s   filter_contents   Nos   Yesi    s_   Should Mailman filter the content of list traffic according
             to the settings below?s   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.s   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.s   convert_html_to_plaintexts   Should Mailman convert <tt>text/html</tt> parts to plain
             text?  This conversion happens after MIME attachments have been
             stripped.s   filter_actionsO   Action to take when a message matches the content filtering
             rules.sJ  One of these actions is take 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.(   s   categorys   Nones   mm_cfgs   TEXTFIELDWIDTHs   WIDTHs   _s   actionss%   OWNERS_CAN_PRESERVE_FILTERED_MESSAGESs   appends   Radios   Texts   tuple(   s   selfs   mlists   categorys   subcats   actionss   WIDTH(    (    s)   /var/mailman/Mailman/Gui/ContentFilter.pys   GetConfigInfo    s    	!
c         C   s  | d d f j olg  } x+g  i } | i   D] }
 | |
 i    q0 ~ D] } d } | i
 d  } | d j o | o
 d } n | d j o` g  i } | i d  D] }
 | |
 i   i    q ~ \ } }	 | p |	 o
 d } qn | d j o
 d } n | o | i t d   qM | i | i   i    qM W| d j o | | _ q| d j o | | _ qn t i |  | | | |  d  S(   Ns   filter_mime_typess   pass_mime_typesi   s   /i    s#   Bad MIME type ignored: %(spectype)s(   s   propertys   typess   appends   _[1]s   vals
   splitliness   ss   strips   spectypes   oks   counts   slashess   splits   lowers   maintypes   subtypes   docs   addErrors   _s   mlists   filter_mime_typess   pass_mime_typess   GUIBases	   _setValues   self(   s   selfs   mlists   propertys   vals   docs   slashess   _[1]s   oks   maintypes   subtypes   ss   spectypes   types(    (    s)   /var/mailman/Mailman/Gui/ContentFilter.pys	   _setValue   s,    4 
B
c         C   sJ   | d j o t i | i  Sn | d j o t i | i  Sn t Sd  S(   Ns   filter_mime_typess   pass_mime_types(   s   propertys   NLs   joins   mlists   filter_mime_typess   pass_mime_typess   None(   s   selfs   mlists   kinds   propertys   params(    (    s)   /var/mailman/Mailman/Gui/ContentFilter.pys   getValue   s
    (   s   __name__s
   __module__s   GetConfigCategorys   Nones   GetConfigInfos	   _setValues   getValue(    (    (    s)   /var/mailman/Mailman/Gui/ContentFilter.pys   ContentFilter   s   	j	N(	   s   __doc__s   Mailmans   mm_cfgs   Mailman.i18ns   _s   Mailman.Gui.GUIBases   GUIBases   NLs   ContentFilter(   s   ContentFilters   mm_cfgs   NLs   GUIBases   _(    (    s)   /var/mailman/Mailman/Gui/ContentFilter.pys   ?   s
   