Commits

Zhang Huangbin committed f0901d3

Sync with the latest iRedAdmin-Pro.

Comments (0)

Files changed (8)

 
 #####################################
 # Pre-defined values of SQL functions.
-sqlNOW = web.sqlliteral('NOW()')
 sqlUnixTimestamp = web.sqlliteral('UNIX_TIMESTAMP()')
 
 #####
 
 
 def getGMTTime():
+    # Convert local time to UTC
     return time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime())
 
 
     return md5crypt.unix_md5_crypt(p, getRandomPassword(length=8))
 
 
+def getPlainMD5Password(p):
+    p = str(p)
+    try:
+        from hashlib import md5
+        return md5(p).hexdigest()
+    except ImportError:
+        import md5
+        return md5.new(p).hexdigest()
+
+    return p
+
+
 def getSQLPassword(p, pwscheme=settings.SQL_DEFAULT_PASSWD_SCHEME):
     p = str(p)
     pw = p
 
     if pwscheme == 'MD5':
         pw = getMD5Password(p)
+    elif pwscheme == 'PLAIN-MD5':
+        pw = getPlainMD5Password(p)
     elif pwscheme == 'PLAIN':
         backend = cfg.general.get('backend', 'mysql')
         if backend == 'mysql':

libs/panel/__init__.py

 # Events in admin log.
-LOG_EVENTS = set(['all', 'login', 'active', 'create', 'delete', 'disable',])
+LOG_EVENTS = ['all', 'login', 'active', 'create', 'delete', 'disable', 'update']

settings.ini.dbmail_mysql.sample

 debug = False
 
 # Mail detail message of '500 internal server error' to webmaster: True, False.
-# If set to True, iredadmin will mail detail error to webmaster when
+# If set to True, DBMailAdmin will mail detail error to webmaster when
 # it catches 'internal server error' via LOCAL mail server to aid
 # in debugging production servers.
 mail_error_to_webmaster = False
 max_passwd_length = 0
 
 [dbmailadmin]
-# Database used to store iRedAdmin data. e.g. sessions, log.
+# Database used to store DBMailAdmin data. e.g. sessions, log.
 host = 127.0.0.1
 port = 3306
 db = dbmailadmin
 #
 [policyd]
 
+# Policyd support is not yet finished, please disable it.
 # Enable policyd integration: True, False.
 enabled = False
 
 
 # #### Quarantining ####
 # Release quarantined SPAM/Virus mails: True, False.
-# iRedAdmin-Pro will connect to @quarantine_server to release quarantined mails.
+# DBMailAdmin will connect to @quarantine_server to release quarantined mails.
 # How to enable quarantining in Amavisd-new:
 # http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/Quarantining.SPAM
 quarantine = False

templates/default/dbmail_mysql/domain/profile.html

         display_domain_transport,
         display_domain_quota,
         display_domain_default_userquota,
-        display_enabled_services,
         display_recipient_bcc,
         display_sender_bcc,
         with context

templates/default/dbmail_mysql/user/profile.html

         with context
         %}
 
-{% from "macros/mysql.html" import
-        display_enabled_services,
-        with context
-        %}
-
 {% from "macros/msgHandlers.html" import userMsgHandler with context %}
 
 {% block title %}{{ _('Edit account profile') }}{% endblock %}
                     {{ display_button_submit() }}
                 </form>
             </div>
-
-            {#
-            <div id="profile_advanced">
-                <form name="advanced" method="post" action="{{ctx.homepath}}/profile/user/advanced/{{mail}}">
-                    {{ input_csrf_token }}
-
-                    <div class="bt-space0">&nbsp;</div>
-                    {{ display_enabled_services(accountType='user', profile=profile) }}
-
-                    {{ display_button_submit() }}
-                </form>
-            </div>
-            #}
         </div>
     </div>
 </div>

templates/default/layout.html

             <div class="head_top">
                 <div class="topbuts">
                     <ul class="clear">
-                        <li><a href="{{ctx.homepath}}/profile/admin/general/{{session.get('username')}}" title="{{ _('Edit your profile') }}">{{ _('Preferences') }}</a></li>
+                        <li><a href="{{ctx.homepath}}/profile/admin/general/{{session.get('username')}}">{{ _('Preferences') }}</a></li>
                         <li><a href="{{ctx.homepath}}/logout" class="red">{{ _('Logout') }}</a></li>
                     </ul>
 
                             {% endif %}
                         </ul>
                     </li>
-                    {% if backend in ['ldap', 'mysql'] %}
+                    {% if backend in ['ldap', 'mysql', 'pgsql'] %}
                         <li {% block navlinks_active_search %}{% endblock %}><a href="{{ctx.homepath}}/search">{{ _('Search') }}</a></li>
                     {% endif %}
                 </ul>
         <div class="main-wrap">
             <div class="page clear">
                 {#
-                    <form action="{{ctx.homepath}}/search" method="post">
-                        <input class="action_search quickSearch" type="text" name="searchString" size="22" value="{{ _('Search name or email') }}&nbsp;&nbsp;" title="{{ _('Search account display name or email address') }}" onfocus="clearDefaultValue(this)" onBlur="restoreDefaultValue(this)"/>
+                    <form name="search" action="{{ctx.homepath}}/search" method="post">
+                        <input class="action_search quickSearch" type="text" name="searchString" size="22" value="{{ _('Search name or email') }}&nbsp;&nbsp;" title="{{ _('Search account display name or email address') }}" onfocus="clearDefaultValue(this)" onBlur="restoreDefaultValue(this)" />
                     </form>
                 #}
 
     <div class="footer">
         <div class="pagesize clear">
             <p class="bt-space0">
-                &copy 2011 <a target="_blank" href="http://www.iredmail.org/">iRedMail Project</a>
+                &copy 2012 <a target="_blank" href="http://www.iredmail.org/">iRedMail Project</a>
                 {% if session.get('domainGlobalAdmin') is sameas true %}
-                    | <a href="http://www.iredmail.org/forum/feed-rss-forum4.xml" target="_blank"><img src="{{ctx.homepath}}/static/{{skin}}/images/feed-icon.png" style="vertical-align: middle;" /></a>&nbsp;<a href="http://www.iredmail.org/forum/forum4-news-announcements.html" target="_blank">{{ _('News & Announments') }}</a>
+                    | <a href="http://www.iredmail.org/forum/forum4-news-announcements.html" target="_blank">{{ _('News & Announments') }}</a>
                     | <a target="_blank" href="http://www.iredmail.org/forum/">{{ _('Support') }}</a>
                 {% else %}
                     | <a href="mailto:{{session.get('webmaster')}}">{{ _('Contact webmaster') }}</a>

templates/default/macros/mysql.html

     </div>
 {%- endmacro %}
 
-{% macro display_enabled_services(accountType, profile) -%}
+{% macro display_enabled_services(accountType, profile, greylisted=False) -%}
     {% if accountType == 'user' %}
         {% set available_services = [
                 ('checkbox', 'enabledeliver', _('Receiving mails for this account on mail server')),
                 ('checkbox', 'enableimapsecured', _('Fetching mails via IMAP over TLS/SSL')),
                 ('checkbox', 'enablemanagesieve', _('Customize mail filter rule')),
                 ('checkbox', 'enablemanagesievesecured', _('Customize mail filter rule over TLS/SSL')),
-                ('hidden', 'enableinternal', ''),
                 ] %}
     {% endif %}
 
 <div class="form-field clear">
-    <h4 class="size-250 fl-space">{{ _('Enabled Services') }}</h4>
+    {% if session.get('enablePolicyd') is sameas true %}
+        <h4 class="size-250 fl-space">{{ _('Enabled Services') }}</h4>
+        <div class="form-checkbox-item clear">
+            <input type="checkbox" name="greylisting" value="greylisting" {% if greylisted is sameas true %}checked{%endif%} class="checkbox fl-space" rel="checkboxhorizont" />
+            <label>{{ _('Greylisting') }}</label>
+        </div>
+    {% else %}
+        <h4 class="size-250 fl-space">{{ _('Enabled Services') }}</h4>
+    {% endif %}
 
     {% for srv in available_services %}
-        {% if not loop.first and srv[0] != 'hidden' %}
+        {% if session.get('enablePolicyd') is sameas true %}
             <h4 class="size-250 fl-space">&nbsp;</h4>
+        {% else %}
+            {% if not loop.first %}
+                <h4 class="size-250 fl-space">&nbsp;</h4>
+            {% endif %}
         {% endif %}
 
         <div class="form-checkbox-item clear">
             <label>{{ srv[2] }}</label>
         </div>
     {% endfor %}
+
+    {% if accountType == 'user' %}
+        <h4 class="size-250 fl-space">&nbsp;</h4>
+        <div class="form-checkbox-item clear">
+            <input type="hidden" name="enabledService" value="enableinternal" rel="checkboxhorizont" />
+            <label>&nbsp;</label>
+        </div>
+    {% endif %}
 </div>
 {%- endmacro %}

templates/default/panel/log.html

 {# List all pages. #}
 <div class="clear"></div>
 <div class="top-space5 bt-space5 left-space5">
-    <form method="get" action="{{ctx.homepath}}/system/log">
+    <form name="pages" method="get" action="{{ctx.homepath}}/system/log">
     {{ _('Filter:') }}
     <select name="domain">
         <option value="all">{{ _('Domains') }}</option>
     </form>
 </div>
 
-{# List all whitelist under control. #}
-    <form id="list_table" method="post" action="{{ctx.homepath}}/system/log">
+{# List all logs #}
+    <form name="log" id="list_table" method="post" action="{{ctx.homepath}}/system/log">
     {{ display_csrf_token() }}
 
     <table class="style1" cellspacing="0">