Commits

Zhang Huangbin  committed 7ffa6f4

Code cleanup.

  • Participants
  • Parent commits 84f4d94

Comments (0)

Files changed (41)

+= 0.3 =
+    * Use python source file as config file. You can convert old ini config
+      file with script tools/convert_ini_to_py.py.
+
 = 0.2.2 =
     * New SQL table: deleted_mailboxes. Required by iRedAdmin-Pro, used to
       store basic info of deleted user mailbox, majorly maildir path.

File controllers/ldap/basic.py

 from socket import getfqdn
 from urllib import urlencode
 import settings
-from libs import __url_latest_ose__, __version_ose__, __no__, __id__
+from libs import __url_latest_ose__, __version_ose__
 from libs import iredutils, languages
 from libs.ldaplib import auth, decorators, admin as adminlib, ldaputils
 
         password = i.get('password', '').strip()
         save_pass = web.safestr(i.get('save_pass', 'no').strip())
 
-        if not iredutils.isEmail(username):
+        if not iredutils.is_email(username):
             raise web.seeother('/login?msg=INVALID_USERNAME')
 
         if not password:
             raise web.seeother('/login?msg=%s' % web.safestr(e))
 
         # Convert username to admin dn.
-        dn_login = ldaputils.convKeywordToDN(username, accountType='admin')
+        dn_login = ldaputils.convert_keyword_to_dn(username, accountType='admin')
         if dn_login[0] is False:
             raise web.seeother('/login?msg=%s' % dn_login[1])
 
         # Check whether it's a mail user
         qr_user_auth = False
         if qr_admin_auth is not True:
-            dn_user = ldaputils.convKeywordToDN(username, accountType='user')
+            dn_user = ldaputils.convert_keyword_to_dn(username, accountType='user')
             qr_user_auth = auth.Auth(uri, dn_user, password)
 
         if qr_admin_auth is True or qr_user_auth is True:
                 if len(r) == 0:
                     urlInfo = {
                         'v': __version_ose__,
-                        'o': __no__,
-                        'f': __id__,
                         'lang': settings.default_language,
                         'host': getfqdn(),
                         'backend': settings.backend,

File controllers/ldap/domain.py

         self.domain = web.safestr(domain.split('/', 1)[0])
         self.profile_type = web.safestr(profile_type)
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             raise web.seeother('/domains?msg=EMPTY_DOMAIN')
 
         domainLib = domainlib.Domain()

File controllers/ldap/user.py

         domain = web.safestr(domain).split('/', 1)[0]
         cur_page = int(cur_page)
 
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         if cur_page == 0:
         self.cur_domain = self.mail.split('@', 1)[-1]
         self.profile_type = web.safestr(profile_type)
 
-        if self.mail.startswith('@') and iredutils.isDomain(self.cur_domain):
+        if self.mail.startswith('@') and iredutils.is_domain(self.cur_domain):
             # Catchall account.
             raise web.seeother('/profile/domain/catchall/%s' % self.cur_domain)
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             raise web.seeother('/domains?msg=INVALID_USER')
 
         domainAccountSetting = {}

File controllers/mysql/admin.py

         self.mail = web.safestr(mail)
         self.profile_type = web.safestr(profile_type)
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             raise web.seeother('/admins?msg=INVALID_MAIL')
 
         if session.get('domainGlobalAdmin') is not True and session.get('username') != self.mail:

File controllers/mysql/basic.py

 from urllib import urlencode
 import web
 import settings
-from libs import __url_latest_ose__, __version_ose__, __no__, __id__
+from libs import __url_latest_ose__, __version_ose__
 from libs import iredutils, languages
 from libs.mysql import core, decorators
 
                 if len(r) == 0:
                     urlInfo = {
                         'v': __version_ose__,
-                        'o': __no__,
-                        'f': __id__,
                         'lang': settings.default_language,
                         'host': getfqdn(),
                         'backend': settings.backend,

File controllers/mysql/domain.py

         self.domain = web.safestr(domain.split('/', 1)[0])
         self.profile_type = web.safestr(profile_type)
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             raise web.seeother('/domains?msg=EMPTY_DOMAIN')
 
         domainLib = domainlib.Domain()

File controllers/mysql/user.py

         self.domain = web.safestr(domain).split('/', 1)[0]
         cur_page = int(cur_page)
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         if cur_page == 0:
 
         self.domain = str(domain)
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         self.mails = [str(v)
                       for v in i.get('mail', [])
-                      if iredutils.isEmail(v)
+                      if iredutils.is_email(v)
                       and str(v).endswith('@' + self.domain)
                      ]
 
         self.cur_domain = self.mail.split('@', 1)[-1]
         self.profile_type = str(profile_type)
 
-        if self.mail.startswith('@') and iredutils.isDomain(self.cur_domain):
+        if self.mail.startswith('@') and iredutils.is_domain(self.cur_domain):
             # Catchall account.
             raise web.seeother('/profile/domain/catchall/%s' % self.cur_domain)
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             raise web.seeother('/domains?msg=INVALID_USER')
 
-        if not iredutils.isDomain(self.cur_domain):
+        if not iredutils.is_domain(self.cur_domain):
             raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         userLib = userlib.User()
             self.cur_domain = None
         else:
             self.cur_domain = str(domain)
-            if not iredutils.isDomain(self.cur_domain):
+            if not iredutils.is_domain(self.cur_domain):
                 raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         i = web.input()

File controllers/pgsql/admin.py

         self.mail = web.safestr(mail)
         self.profile_type = web.safestr(profile_type)
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             raise web.seeother('/admins?msg=INVALID_MAIL')
 
         if session.get('domainGlobalAdmin') is not True and session.get('username') != self.mail:

File controllers/pgsql/basic.py

 from urllib import urlencode
 import web
 import settings
-from libs import __url_latest_ose__, __version_ose__, __no__, __id__
+from libs import __url_latest_ose__, __version_ose__
 from libs import iredutils, languages
 from libs.pgsql import core, decorators
 
                 if len(r) == 0:
                     urlInfo = {
                         'v': __version_ose__,
-                        'o': __no__,
-                        'f': __id__,
                         'lang': settings.default_language,
                         'host': getfqdn(),
                         'backend': settings.backend,

File controllers/pgsql/domain.py

         self.domain = web.safestr(domain.split('/', 1)[0])
         self.profile_type = web.safestr(profile_type)
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             raise web.seeother('/domains?msg=EMPTY_DOMAIN')
 
         domainLib = domainlib.Domain()

File controllers/pgsql/user.py

         self.domain = web.safestr(domain).split('/', 1)[0]
         cur_page = int(cur_page)
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         if cur_page == 0:
 
         self.domain = str(domain)
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         self.mails = [str(v)
                       for v in i.get('mail', [])
-                      if iredutils.isEmail(v)
+                      if iredutils.is_email(v)
                       and str(v).endswith('@' + self.domain)
                      ]
 
         self.cur_domain = self.mail.split('@', 1)[-1]
         self.profile_type = str(profile_type)
 
-        if self.mail.startswith('@') and iredutils.isDomain(self.cur_domain):
+        if self.mail.startswith('@') and iredutils.is_domain(self.cur_domain):
             # Catchall account.
             raise web.seeother('/profile/domain/catchall/%s' % self.cur_domain)
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             raise web.seeother('/domains?msg=INVALID_USER')
 
-        if not iredutils.isDomain(self.cur_domain):
+        if not iredutils.is_domain(self.cur_domain):
             raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         userLib = userlib.User()
             self.cur_domain = None
         else:
             self.cur_domain = str(domain)
-            if not iredutils.isDomain(self.cur_domain):
+            if not iredutils.is_domain(self.cur_domain):
                 raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
 
         i = web.input()

File libs/__init__.py

 __author__ = 'Zhang Huangbin'
 __author_mail__ = 'zhb@iredmail.org'
-__version_ose__ = '0.2.2'
+__version_ose__ = '0.3'
 __url_latest_ose__ = 'http://iredmail.org/version/check.py/ose.xml'
-__no__ = ''
-__id__ = ''

File libs/default_settings.py

+# Author: Zhang Huangbin <zhb@iredmail.org>
+
+#
+# WARNING
+#
+# Please place all your settings in settings.py to override settings below, so
+# that you can simply copy settings.py after upgrading iRedAdmin.
+#
+
+# Debug iRedAdmin: True, False.
+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            
+# it catches 'internal server error' via LOCAL mail server to aid               
+# in debugging production servers.                                              
+MAIL_ERROR_TO_WEBMASTER = False
+
+# Set http proxy server address if iRedAdmin cannot access internet
+# (iredmail.org) directly.
+# Sample:
+#   HTTP_PROXY = 'http://192.168.1.1:3128'
+HTTP_PROXY = ''
+
+# Local timezone. It must be one of below:
+#   GMT-12:00
+#   GMT-11:00
+#   GMT-10:00
+#   GMT-09:30
+#   GMT-09:00
+#   GMT-08:00
+#   GMT-07:00
+#   GMT-06:00
+#   GMT-05:00
+#   GMT-04:30
+#   GMT-04:00
+#   GMT-03:30
+#   GMT-03:00
+#   GMT-02:00
+#   GMT-01:00
+#   GMT
+#   GMT+01:00
+#   GMT+02:00
+#   GMT+03:00
+#   GMT+03:30
+#   GMT+04:00
+#   GMT+04:30
+#   GMT+05:00
+#   GMT+05:30
+#   GMT+05:45
+#   GMT+06:00
+#   GMT+06:30
+#   GMT+07:00
+#   GMT+08:00
+#   GMT+08:45
+#   GMT+09:00
+#   GMT+09:30
+#   GMT+10:00
+#   GMT+10:30
+#   GMT+11:00
+#   GMT+11:30
+#   GMT+12:00
+#   GMT+12:45
+#   GMT+13:00
+#   GMT+14:00
+LOCAL_TIMEZONE = 'GMT'
+
+# Allow to store password in plain text.
+# It will show a HTML checkbox to allow admin to store newly created user
+# password or reset password in plain text. If not checked, password
+# will be stored as encrypted.
+# See LDAP_DEFAULT_PASSWD_SCHEME and SQL_DEFAULT_PASSWD_SCHEME below.
+STORE_PASSWORD_IN_PLAIN_TEXT_TEXT = False
+
+# Print PERMISSION_DENIED related programming info to stdout or web server
+# log file. e.g. Apache log file.
+LOG_PERMISSION_DENIED = False
+
+# Redirect to "Domains and Accounts" page instead of Dashboard.
+REDIRECT_TO_DOMAIN_LIST_AFTER_LOGIN = False
+
+###################################
+# Maildir related.
+#
+
+#It's RECOMMEND for better performance. Samples:
+# - hashed: domain.ltd/u/s/e/username-2009.09.04.12.05.33/
+# - non-hashed: domain.ltd/username-2009.09.04.12.05.33/
+MAILDIR_HASHED = True
+
+# Prepend domain name in path. Samples:
+# - with domain name: domain.ltd/username/
+# - without: username/
+MAILDIR_PREPEND_DOMAIN = True
+
+# Append timestamp in path. Samples:
+# - with timestamp: domain.ltd/username-2010.12.20.13.13.33/
+# - without timestamp: domain.ltd/username/
+MAILDIR_APPEND_TIMESTAMP = True
+
+
+#######################################
+# OpenLDAP backend related settings.
+#
+
+# LDAP connection trace level. Must be an integer.
+LDAP_CONN_TRACE_LEVEL = 0
+
+# Default password scheme: SSHA, SHA, PLAIN.
+# Must be a string. SSHA is recommended.
+# To store passwords in plain text, please change below setting to 'PLAIN',
+# no addition changes are required in iredmail, dovecot will detect password
+# scheme automatically.
+LDAP_DEFAULT_PASSWD_SCHEME = 'SSHA'
+
+#######################################
+# MySQL/PostgreSQL backends related settings. Note: Not applicable for DBMail.
+#
+
+# Default password scheme: MD5, SSHA, SSHA512, PLAIN-MD5, PLAIN.
+#
+# Passwords of new accounts (admin, user) will be crypted by specified scheme.
+#
+# - MD5: MD5 based salted password hash.
+#       Example: '$1$ozdpg0V0$0fb643pVsPtHVPX8mCZYW/'.
+#
+# - SSHA: {SSHA} is RFC 2307 password scheme which use the SHA1 secure hash
+#       algorithm. The {SSHA} is the seeded varient. {SSHA} is recommended
+#       over other RFC 2307 schemes.
+#       Example: {SSHA}bfxqKqOOKODJw/bGqMo54f9Q/iOvQoftOQrqWA==
+#
+# - SSHA512: {SSHA512} is salted SHA512 which uses the SHA2 secure hash
+#       algorithm, SSHA512 is better than SSHA.
+#       Example: {SSHA512}FxgXDhBVYmTqoboW+ibyyzPv/wGG7y4VJtuHWrx+wfqrs/lIH2Qxn2eA0jygXtBhMvRi7GNFmL++6aAZ0kXpcy1fxag=
+#       Note: SSHA512 support requires Dovecot-2.0 (and later) and Python-2.5
+#             (and later).
+#
+# - PLAIN-MD5: MD5 based password without salt.
+#       Example: 900150983cd24fb0d6963f7d28e17f72.
+#
+# - PLAIN: Plain text.
+#
+# Reference:
+#   - For dovecot-1.1.x, 1.2.x: http://wiki.dovecot.org/Authentication/PasswordSchemes
+#   - For dovecot-2.x: http://wiki2.dovecot.org/Authentication/PasswordSchemes
+SQL_DEFAULT_PASSWD_SCHEME = 'MD5'
+
+# Prefix '{PLAIN}' in plain passwords: True, False.
+#
+# Required by dovecot if you want to store passwords as plain text.
+# Password scheme can be overridden for each password by prefixing it with
+# {SCHEME}, for example: {PLAIN}my_password.
+# It's recommended to prefix it if you have some passwords stored in MD5 or
+# other scheme, so that dovecot can detect scheme for each passwords.
+SQL_PASSWD_PREFIX_SCHEME = True
+
+# Access policies of mail deliver restrictions. Must be in lower cases.
+SQL_ALIAS_ACCESS_POLICIES = [
+    'public',       # Unrestricted Everyone can send mail to this address.
+    'domain',       # Domain users only.
+    'subdomain',    # Domain and sub-domain users only.
+    'membersonly',  # Members only
+    'allowedonly',  # Moderators only
+    'membersandmoderatorsonly',  # Members and moderators only
+]
+
+###################################
+# Amavisd related settings.
+#
+
+# Remove old SQL records of sent/received mails in Amavisd database.
+# NOTE: require cron job with script tools/cleanup_amavisd_db.py.
+AMAVISD_REMOVE_MAILLOG_IN_DAYS = 7
+
+# Remove old SQL records of quarantined mails.
+# Since quarantined mails may take much disk space, it's better to release
+# or remove them as soon as possible.
+# NOTE: require cron job with script tools/cleanup_amavisd_db.py.
+AMAVISD_REMOVE_QUARANTINED_IN_DAYS = 7
+
+# SQL command used to create necessary Amavisd policy for newly created
+# mail user.
+#
+# To execute specified SQL commands without enabling Amavisd integration
+# in settings.ini, please set AMAVISD_EXECUTE_SQL_WITHOUT_ENABLED to True,
+# and make sure you have correct Amavisd database related settings in
+# settings.ini.
+#
+# Available placeholders:
+#   - $mail:     replaced by email address of newly created user
+#   - $username: replaced by username part of email address
+#   - $domain:   replaced by domain part of email address
+#
+# For example:
+#
+#   AMAVISD_SQL_FOR_NEWLY_CREATED_USER = [
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, $mail)',
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, $username)',
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, concat("@", $domain))',
+#   ]
+#
+# Will be replaced by:
+#
+#   AMAVISD_SQL_FOR_NEWLY_CREATED_USER = [
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, "user@domain.ltd")',
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, "user")',
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, concat("@", "domain.ltd"))',
+#   ]
+#
+AMAVISD_EXECUTE_SQL_WITHOUT_ENABLED = False
+AMAVISD_SQL_FOR_NEWLY_CREATED_USER = []
+
+###################################
+# DBMail related settings.
+#
+
+# Default domain transport will be stored in `dbmail_domains.transport`.
+DBMAIL_DEFAULT_DOMAIN_TRANSPORT = 'dbmail-lmtp:127.0.0.1:24'
+
+# Create and subscribe to default IMAP folders after creating new mail user.
+DBMAIL_CREATE_DEFAULT_IMAP_FOLDERS = True
+DBMAIL_DEFAULT_IMAP_FOLDERS = ['INBOX', 'Sent', 'Drafts', 'Trash', 'Junk', ]
+
+# Execute addition SQL commands after successfully created new users.
+#
+# Available placeholders:
+#   - $user_idnr: value of dbmail_users.user_idnr
+#   - $mail:     replaced by email address of newly created user
+#   - $username: replaced by username part of email address
+#   - $domain:   replaced by domain part of email address
+#
+# For example:
+#
+#   DBMAIL_SQL_FOR_NEWLY_CREATED_USER = [
+#       """INSERT INTO dbmail_sievescripts (owner_idnr, name, script, active)
+#               VALUES (
+#                       $user_idnr,
+#                       'Move SPAM to Junk folder',
+#                       'require ["fileinto"]; if header :is "X-Spam-Flag" "YES" {fileinto "Junk"; stop;}',
+#                       1)
+#       """,
+#   ]
+#
+DBMAIL_SQL_FOR_NEWLY_CREATED_USER = []
+
+###################################
+# Policyd related settings.
+#
+
+# Priority of Policyd policies, includes throttling, greylist opt-in, etc.
+POLICY_PRIORITY_OF_DOMAIN = 10
+POLICY_PRIORITY_OF_USER = 20
+
+# If you turn off greylisting in Policyd config file (policyd.conf), please
+# turn below setting to False.
+POLICY_GREYLISTED_BY_DEFAULT = True
+
+###################################
+# Minor settings. You do not need to change them.
+#
+# List how many items in one page. e.g. domain list, user list.
+PAGE_SIZE_LIMIT = 50
+
+# Import local settings.
+try:
+    from libs.settings_local import *
+except Exception:
+    pass

File libs/iredbase.py

 
 urls = backendUrls
 
-# Import Policyd/Cluebringer related urls.
-if enable_policyd:
-    from controllers.policyd.urls import urls as policydUrls
-    urls += policydUrls
-
-if enable_cluebringer:
-    from controllers.cluebringer.urls import urls as policydUrls
-    urls += policydUrls
-
-# Import amavisd related urls.
-if settings.amavisd_enable_quarantine or settings.amavisd_enable_logging:
-    from controllers.amavisd.urls import urls as amavisdUrls
-    urls += amavisdUrls
-
 from controllers.panel.urls import urls as panelUrls
 urls += panelUrls
 
         'default_mta_transport': settings.default_mta_transport,
 
         # Store password in plain text.
-        'store_password_in_plain_text': settings.STORE_PASSWORD_IN_PLAIN_TEXT,
+        'store_password_in_plain_text': settings.STORE_PASSWORD_IN_PLAIN_TEXT_TEXT,
 
         # Policyd/Cluebringer integration.
         'enable_policyd': enable_policyd,
         'filesizeformat': iredutils.filesizeformat,
         'set_datetime_format': iredutils.set_datetime_format,
         'generate_random_strings': iredutils.generate_random_strings,
-        'convert_to_percentage': iredutils.convert_to_percentage,
         'cut_string': iredutils.cut_string,
         'convert_utc_to_timezone': convert_utc_to_timezone,
     })

File libs/iredutils.py

 INVALID_DOMAIN_CHARS = '~!#$%^&*()+\\/\ '
 
 
-def isEmail(s):
+def is_email(s):
     s = str(s)
     if len(set(s) & set(INVALID_EMAIL_CHARS)) > 0 \
        or '.' not in s \
         return False
 
 
-def isDomain(s):
+def is_domain(s):
     s = str(s)
     if len(set(s) & set(INVALID_DOMAIN_CHARS)) > 0 or '.' not in s:
         return False
     """Generate path of mailbox."""
 
     mail = web.safestr(mail)
-    if not isEmail(mail):
+    if not is_email(mail):
         return (False, 'INVALID_EMAIL_ADDRESS')
 
     # Get user/domain part from mail address.

File libs/ldaplib/admin.py

     # Get admin profile.
     def profile(self, mail, attributes=attrs.ADMIN_ATTRS_ALL):
         self.mail = web.safestr(mail)
-        self.dn = ldaputils.convKeywordToDN(self.mail, accountType='admin')
+        self.dn = ldaputils.convert_keyword_to_dn(self.mail, accountType='admin')
         if self.dn[0] is False:
             return self.dn
 
         self.cn = data.get('cn')
         self.mail = web.safestr(data.get('mail')).strip().lower()
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         self.domainGlobalAdmin = web.safestr(data.get('domainGlobalAdmin', 'no'))
                 domainGlobalAdmin=self.domainGlobalAdmin,
                 )
 
-        self.dn = ldaputils.convKeywordToDN(self.mail, accountType='admin')
+        self.dn = ldaputils.convert_keyword_to_dn(self.mail, accountType='admin')
         if self.dn[0] is False:
             return self.dn
 
             # Don't allow to view/update other admins' profile.
             return (False, 'PERMISSION_DENIED')
 
-        self.dn = ldaputils.convKeywordToDN(self.mail, accountType='admin')
+        self.dn = ldaputils.convert_keyword_to_dn(self.mail, accountType='admin')
         if self.dn[0] is False:
             return self.dn
 
 
         for mail in mails:
             self.mail = web.safestr(mail)
-            dn = ldaputils.convKeywordToDN(self.mail, accountType='admin')
+            dn = ldaputils.convert_keyword_to_dn(self.mail, accountType='admin')
             if dn[0] is False:
                 return dn
 
             try:
                 deltree.DelTree(self.conn, dn, ldap.SCOPE_SUBTREE)
                 web.logger(msg="Delete admin: %s." % (self.mail,), event='delete',)
+            except ldap.NO_SUCH_OBJECT:
+                # This is a mail user admin
+                dn = ldaputils.convert_keyword_to_dn(self.mail, accountType='user')
+                try:
+                    connutils = connUtils.Utils()
+                    # Delete enabledService=domainadmin
+                    connutils.addOrDelAttrValue(
+                            dn=dn,
+                            attr='enabledService',
+                            value='domainadmin',
+                            action='delete',
+                            )
+
+                    # Delete domainGlobalAdmin=yes
+                    connutils.addOrDelAttrValue(
+                            dn=dn,
+                            attr='domainGlobalAdmin',
+                            value='yes',
+                            action='delete',
+                            )
+                    web.logger(msg="Delete admin: %s." % (self.mail), event='delete')
+                except Exception, e:
+                    result[self.mail] = str(e)
             except ldap.LDAPError, e:
                 result[self.mail] = str(e)
 
         connutils = connUtils.Utils()
         for mail in mails:
             self.mail = web.safestr(mail).strip().lower()
-            if not iredutils.isEmail(self.mail):
+            if not iredutils.is_email(self.mail):
                 continue
 
             self.domain = self.mail.split('@')[-1]
-            self.dn = ldaputils.convKeywordToDN(self.mail, accountType='admin')
+            self.dn = ldaputils.convert_keyword_to_dn(self.mail, accountType='admin')
             if self.dn[0] is False:
                 return self.dn
 
         else:
             admin = str(admin)
 
-        if not iredutils.isEmail(admin):
+        if not iredutils.is_email(admin):
             return 0
 
         domains = []
         if len(domains) > 0:
-            domains = [str(d).lower() for d in domains if iredutils.isDomain(d)]
+            domains = [str(d).lower() for d in domains if iredutils.is_domain(d)]
         else:
             connutils = connUtils.Utils()
             qr = connutils.getManagedDomains(mail=admin, attrs=['domainName'], listedOnly=True)

File libs/ldaplib/connUtils.py

     def getNumberOfCurrentAccountsUnderDomain(self, domain, accountType='user', filter=None):
         # accountType in ['user', 'list', 'alias',]
         self.domain = web.safestr(domain)
-        self.domaindn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.domaindn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
 
         if filter is not None:
             self.searchdn = self.domaindn
             return (False, ldaputils.getExceptionDesc(e))
 
     # Check whether domain name already exist (domainName, domainAliasName).
-    def isDomainExists(self, domain):
+    def is_domain_exists(self, domain):
         # Return True if account is invalid or exist.
         self.domain = web.safestr(domain).strip().lower()
 
         # Check domain name.
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             # Return True if invalid.
             return True
 
         self.domain = str(domain)
         self.mail = str(mail)
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             return True
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return True
 
         # Check whether mail address ends with domain name or alias domain name.
     @decorators.require_domain_access
     def deleteObjWithDN(self, domain, dn, account, accountType,):
         self.domain = web.safestr(domain)
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         self.dn = escape_filter_chars(dn)
             if domain is not None:
                 # Update number of current domain quota size in LDAP.
                 try:
-                    dnDomain = ldaputils.convKeywordToDN(domain, accountType='domain')
+                    dnDomain = ldaputils.convert_keyword_to_dn(domain, accountType='domain')
                     self.updateAttrSingleValue(
                         dn=dnDomain,
                         attr=attrs.ATTR_DOMAIN_CURRENT_QUOTA_SIZE,
     @decorators.require_domain_access
     def getDomainCurrentQuotaSizeFromLDAP(self, domain):
         self.domain = web.safestr(domain).strip().lower()
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
-        self.domainDN = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.domainDN = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
 
         # Initial @domainCurrentQuotaSize
         self.domainCurrentQuotaSize = 0
         (True, ['example.com', 'aliasdomain01.com', 'aliasdomain02.com', ...])
         '''
         domain = web.safestr(domain).strip().lower()
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
-        dn = ldaputils.convKeywordToDN(domain, accountType='domain')
+        dn = ldaputils.convert_keyword_to_dn(domain, accountType='domain')
 
         try:
             result = self.conn.search_s(
 
         if accountType == 'user':
             if attrs.RDN_USER == 'mail':
-                if not iredutils.isEmail(self.keyword):
+                if not iredutils.is_email(self.keyword):
                     return False
-                return ldaputils.convKeywordToDN(self.keyword, accountType='user')
+                return ldaputils.convert_keyword_to_dn(self.keyword, accountType='user')
             else:
                 self.domain = self.keyword.split('@', 1)[-1]
-                self.dnOfDomain = ldaputils.convKeywordToDN(self.domain, accountType='domain',)
+                self.dnOfDomain = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain',)
                 try:
                     result = self.conn.search_s(
                         attrs.DN_BETWEEN_USER_AND_DOMAIN + self.dnOfDomain,
     # Get domains under control.
     def getManagedDomains(self, mail, attrs=attrs.ADMIN_ATTRS_ALL, listedOnly=False):
         self.mail = web.safestr(mail)
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INCORRECT_USERNAME')
 
         # Pre-defined filter.

File libs/ldaplib/decorators.py

         except Exception:
             pass
 
-    def isDomainAdmin(self, domain, admin=session.get('username'),):
-        dn = ldaputils.convKeywordToDN(domain, accountType='domain')
+    def is_domainAdmin(self, domain, admin=session.get('username'),):
+        dn = ldaputils.convert_keyword_to_dn(domain, accountType='domain')
         try:
             result = self.conn.search_s(
                 dn,
         if session.get('domainGlobalAdmin') is True:
             return func(*args, **kw)
         else:
-            if 'mail' in kw.keys() and iredutils.isEmail(kw.get('mail')):
+            if 'mail' in kw.keys() and iredutils.is_email(kw.get('mail')):
                 domain = web.safestr(kw['mail']).split('@')[-1]
-            elif 'domain' in kw.keys() and iredutils.isDomain(kw.get('domain')):
+            elif 'domain' in kw.keys() and iredutils.is_domain(kw.get('domain')):
                 domain = web.safestr(kw['domain'])
             else:
                 return (False, 'PERMISSION_DENIED')
 
             # Check whether is domain admin.
             validator = Validator()
-            if validator.isDomainAdmin(domain=domain, admin=session.get('username'),):
+            if validator.is_domainAdmin(domain=domain, admin=session.get('username'),):
                 return func(*args, **kw)
             else:
                 return (False, 'PERMISSION_DENIED')

File libs/ldaplib/domain.py

         self.domain = web.safestr(data.get('domainName', '')).strip().lower()
 
         # Check domain name.
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         # Check whether domain name already exist (domainName, domainAliasName).
         connutils = connUtils.Utils()
-        if connutils.isDomainExists(self.domain):
+        if connutils.is_domain_exists(self.domain):
             return (False, 'ALREADY_EXISTS')
 
-        self.dn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.dn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
         if self.dn[0] is False:
             return self.dn
 
     # List all domain admins.
     def getDomainAdmins(self, domain):
         domain = web.safestr(domain)
-        dn = ldaputils.convKeywordToDN(domain, accountType='domain')
+        dn = ldaputils.convert_keyword_to_dn(domain, accountType='domain')
         if dn[0] is False:
             return dn
 
     def getDomainDefaultUserQuota(self, domain, domainAccountSetting=None,):
         # Return 0 as unlimited.
         self.domain = web.safestr(domain)
-        self.dn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.dn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
         if self.dn[0] is False:
             return self.dn
 
 
         domains = [str(v).lower()
                    for v in domains
-                   if iredutils.isDomain(v)
+                   if iredutils.is_domain(v)
                   ]
 
         if not domains:
 
         msg = {}
         for domain in domains:
-            dn = ldaputils.convKeywordToDN(web.safestr(domain), accountType='domain')
+            dn = ldaputils.convert_keyword_to_dn(web.safestr(domain), accountType='domain')
             if dn[0] is False:
                 return dn
 
         connutils = connUtils.Utils()
         for domain in domains:
             self.domain = web.safestr(domain)
-            self.dn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+            self.dn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
             if self.dn[0] is False:
                 return self.dn
 
     @decorators.require_domain_access
     def profile(self, domain):
         self.domain = web.safestr(domain)
-        self.dn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.dn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
         if self.dn[0] is False:
             return self.dn
 
     def update(self, profile_type, domain, data):
         self.profile_type = web.safestr(profile_type)
         self.domain = web.safestr(domain)
-        self.domaindn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.domaindn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
         if self.domaindn[0] is False:
             return self.domaindn
 
                 mod_attrs += [(ldap.MOD_REPLACE, 'accountStatus', accountStatus)]
 
         try:
-            dn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+            dn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
             if dn[0] is False:
                 return dn
 

File libs/ldaplib/iredldif.py

 
 def ldif_mailExternalUser(mail,):
     mail = web.safestr(mail).lower()
-    if not iredutils.isEmail(mail):
+    if not iredutils.is_email(mail):
         return None
 
     listname, domain = mail.split('@')
     # Append @shadowAddress.
     shadowAddresses = []
     for d in aliasDomains:
-        if iredutils.isDomain(d):
+        if iredutils.is_domain(d):
             shadowAddresses += [username + '@' + d]
 
     if len(shadowAddresses) > 0:

File libs/ldaplib/ldaputils.py

 session = web.config.get('_session')
 
 
-def convKeywordToDN(keyword, accountType='user'):
+def convert_keyword_to_dn(keyword, accountType='user'):
     '''Convert keyword and account type to DN.'''
     keyword = web.safestr(keyword).strip().replace(' ', '')
     keyword = escape_dn_chars(keyword)
 
     # Validate account type.
     if accountType not in attrs.ACCOUNT_TYPES_ALL:
-        return (False, 'INVALID_ACCOUNT_TYPE')
+        return 'INVALID_ACCOUNT_TYPE'
 
     # Validate keyword.
     # Keyword is email address.
     if accountType in attrs.ACCOUNT_TYPES_EMAIL and \
-       not iredutils.isEmail(keyword):
-        return (False, 'INVALID_MAIL')
+       not iredutils.is_email(keyword):
+        return 'INVALID_MAIL'
 
     # Keyword is domain name.
     if accountType in attrs.ACCOUNT_TYPES_DOMAIN and \
-       not iredutils.isDomain(keyword):
-        return (False, 'INVALID_DOMAIN_NAME')
+       not iredutils.is_domain(keyword):
+        return 'INVALID_DOMAIN_NAME'
 
     # Convert keyword to DN.
     if accountType == 'user':

File libs/ldaplib/user.py

     @decorators.require_domain_access
     def listAccounts(self, domain):
         self.domain = domain
-        self.domainDN = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.domainDN = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
         if self.domainDN[0] is False:
             return self.domainDN
 
                 raise web.seeother('/domains?msg=PERMISSION_DENIED')
 
         if attrs.RDN_USER == 'mail':
-            self.searchdn = ldaputils.convKeywordToDN(self.mail, accountType=accountType)
+            self.searchdn = ldaputils.convert_keyword_to_dn(self.mail, accountType=accountType)
             self.scope = ldap.SCOPE_BASE
 
             if self.searchdn[0] is False:
                 return self.searchdn
         else:
-            domain_dn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+            domain_dn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
             if domain_dn[0] is False:
                 return domain_dn
 
         self.mail = self.username + '@' + self.domain
         self.groups = data.get('groups', [])
 
-        if not iredutils.isDomain(self.domain) or not iredutils.isEmail(self.mail):
+        if not iredutils.is_domain(self.domain) or not iredutils.is_email(self.mail):
             return (False, 'MISSING_DOMAIN_OR_USERNAME')
 
         # Check account existing.
                                           max_passwd_length=domainAccountSetting.get('maxPasswordLength', '0'),
                                          )
         if result[0] is True:
-            if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN:
+            if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN_TEXT:
                 self.passwd = ldaputils.generateLDAPPasswd(result[1], pwscheme='PLAIN')
             else:
                 self.passwd = ldaputils.generateLDAPPasswd(result[1])
         # Get default groups.
         self.groups = [web.safestr(v)
                        for v in domainAccountSetting.get('defaultList', '').split(',')
-                       if iredutils.isEmail(v)
+                       if iredutils.is_email(v)
                       ]
 
         self.defaultStorageBaseDirectory = domainAccountSetting.get('defaultStorageBaseDirectory', None)
             storageBaseDirectory=self.defaultStorageBaseDirectory,
         )
 
-        domain_dn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        domain_dn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
         if domain_dn[0] is False:
             return domain_dn
 
         if attrs.RDN_USER == 'mail':
-            self.dn = ldaputils.convKeywordToDN(self.mail, accountType='user')
+            self.dn = ldaputils.convert_keyword_to_dn(self.mail, accountType='user')
             if self.dn[0] is False:
                 return self.dn
 
     def getFilterOfDeleteUserFromGroups(self, mail):
         # Get valid emails as list.
         if isinstance(mail, list):
-            self.mails = [web.safestr(v).lower() for v in mail if iredutils.isEmail(str(v))]
+            self.mails = [web.safestr(v).lower() for v in mail if iredutils.is_email(str(v))]
         else:
             # Single email.
             self.mails = [web.safestr(mail).lower()]
     # Delete single user from mail list, alias, user forwarding addresses.
     def deleteSingleUserFromGroups(self, mail):
         self.mail = web.safestr(mail)
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         # Get domain name of this account.
         self.domain = self.mail.split('@')[-1]
 
         # Get dn of mail user and domain.
-        self.dnUser = ldaputils.convKeywordToDN(self.mail, accountType='user')
-        self.dnDomain = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.dnUser = ldaputils.convert_keyword_to_dn(self.mail, accountType='user')
+        self.dnDomain = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
 
         if self.dnUser[0] is False:
             return self.dnUser
     # Delete single user.
     def deleteSingleUser(self, mail, deleteFromGroups=True,):
         self.mail = web.safestr(mail)
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         # Get domain name of this account.
         self.domain = self.mail.split('@')[-1]
 
         # Get dn of mail user and domain.
-        self.dnUser = ldaputils.convKeywordToDN(self.mail, accountType='user')
+        self.dnUser = ldaputils.convert_keyword_to_dn(self.mail, accountType='user')
         if self.dnUser[0] is False:
             return self.dnUser
 
             return (False, 'NO_ACCOUNT_SELECTED')
 
         self.domain = web.safestr(domain)
-        self.mails = [str(v) for v in mails if iredutils.isEmail(v) and str(v).endswith('@' + self.domain)]
+        self.mails = [str(v) for v in mails if iredutils.is_email(v) and str(v).endswith('@' + self.domain)]
         if not len(self.mails) > 0:
             return (False, 'INVALID_MAIL')
 
-        self.domaindn = ldaputils.convKeywordToDN(self.domain, accountType='domain')
+        self.domaindn = ldaputils.convert_keyword_to_dn(self.domain, accountType='domain')
         if self.domaindn[0] is False:
             return self.domaindn
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         result = {}
                 # Delete user object and whole sub-tree.
                 # Get dn of mail user and domain.
                 """
-                self.userdn = ldaputils.convKeywordToDN(self.mail, accountType='user')
+                self.userdn = ldaputils.convert_keyword_to_dn(self.mail, accountType='user')
                 deltree.DelTree(self.conn, self.userdn, ldap.SCOPE_SUBTREE)
 
                 # Log delete action.
 
         self.mails = [str(v)
                       for v in mails
-                      if iredutils.isEmail(v)
+                      if iredutils.is_email(v)
                       and str(v).endswith('@' + str(domain))
                      ]
 
         connutils = connUtils.Utils()
         for mail in self.mails:
             self.mail = web.safestr(mail)
-            if not iredutils.isEmail(self.mail):
+            if not iredutils.is_email(self.mail):
                 continue
 
             self.domain = self.mail.split('@')[-1]
-            self.dn = ldaputils.convKeywordToDN(self.mail, accountType='user')
+            self.dn = ldaputils.convert_keyword_to_dn(self.mail, accountType='user')
             if self.dn[0] is False:
                 result[self.mail] = self.dn[1]
                 continue
                 max_passwd_length=maxPasswordLength,
             )
             if result[0] is True:
-                if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN:
+                if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN_TEXT:
                     self.passwd = ldaputils.generateLDAPPasswd(result[1], pwscheme='PLAIN')
                 else:
                     self.passwd = ldaputils.generateLDAPPasswd(result[1])

File libs/mysql/admin.py

         else:
             self.admin = str(admin)
 
-        if not iredutils.isEmail(self.admin):
+        if not iredutils.is_email(self.admin):
             return 0
 
         self.domains = []
         if accountType in ['user', 'alias', ]:
             if len(domains) > 0:
-                self.domains = [str(d).lower() for d in domains if iredutils.isDomain(d)]
+                self.domains = [str(d).lower() for d in domains if iredutils.is_domain(d)]
             else:
                 connutils = connUtils.Utils()
                 qr = connutils.getManagedDomains(admin=self.admin, domainNameOnly=True)
         if not isinstance(mails, list):
             return (False, 'INVALID_MAIL')
 
-        self.mails = [str(v).lower() for v in mails if iredutils.isEmail(v)]
+        self.mails = [str(v).lower() for v in mails if iredutils.is_email(v)]
         sql_vars = {'username': self.mails, }
 
         # Delete domain and related records.
         self.mail = web.safestr(mail)
         self.domainGlobalAdmin = False
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         try:
         self.cn = data.get('cn', '')
         self.mail = web.safestr(data.get('mail')).strip().lower()
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         # Check admin exist.

File libs/mysql/connUtils.py

 
 class Utils(core.MySQLWrap):
 
-    def isDomainExists(self, domain):
+    def is_domain_exists(self, domain):
         # Return True if account is invalid or exist.
         domain = str(domain)
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return True
 
         sql_vars = {'domain': domain, }
     def isAdminExists(self, mail):
         # Return True if account is invalid or exist.
         mail = str(mail)
-        if not iredutils.isEmail(mail):
+        if not iredutils.is_email(mail):
             return True
 
         try:
             return True
 
     # Check whether account exist or not.
-    def isEmailExists(self, mail):
+    def is_email_exists(self, mail):
         # Return True if account is invalid or exist.
         mail = web.safestr(mail)
 
-        if not iredutils.isEmail(mail):
+        if not iredutils.is_email(mail):
             return True
 
         sql_vars = {'email': mail, }
     def getManagedDomains(self, admin, domainNameOnly=False, listedOnly=False,):
         admin = web.safestr(admin)
 
-        if not iredutils.isEmail(admin):
+        if not iredutils.is_email(admin):
             return (False, 'INCORRECT_USERNAME')
 
         sql_left_join = ''
             if domainNameOnly is True:
                 domains = []
                 for i in result:
-                    if iredutils.isDomain(i.domain):
+                    if iredutils.is_domain(i.domain):
                         domains += [str(i.domain).lower()]
 
                 return (True, domains)

File libs/mysql/core.py

         except Exception:
             return False
 
-    def isDomainAdmin(self, domain, admin=session.get('username'),):
-        if not iredutils.isDomain(domain) or not iredutils.isEmail(admin):
+    def is_domainAdmin(self, domain, admin=session.get('username'),):
+        if not iredutils.is_domain(domain) or not iredutils.is_email(admin):
             return False
 
         if admin == session.get('username') \
             action = 'Disable'
 
         if accountType == 'domain':
-            accounts = [str(v) for v in accounts if iredutils.isDomain(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_domain(v)]
             try:
                 self.conn.update(
                     'domain',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'user':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.update(
                     'mailbox',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'admin':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.update(
                     'admin',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'alias':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.update(
                     'alias',
         accountType = str(accountType)
 
         if accountType == 'domain':
-            accounts = [str(v) for v in accounts if iredutils.isDomain(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_domain(v)]
             try:
                 self.conn.delete(
                     'domain',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'user':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             sql_vars = {'accounts': accounts, }
             try:
                 for tbl in ['mailbox', 'used_quota',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'admin':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.delete(
                     'admin',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'alias':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.delete(
                     'alias',
 
 class Auth(MySQLWrap):
     def auth(self, username, password, accountType='admin', verifyPassword=False,):
-        if not iredutils.isEmail(username):
+        if not iredutils.is_email(username):
             return (False, 'INVALID_USERNAME')
 
         if len(password) == 0:
 
     def require_domain_access(self, func):
         def proxyfunc(self, *args, **kw):
-            if 'mail' in kw.keys() and iredutils.isEmail(kw.get('mail')):
+            if 'mail' in kw.keys() and iredutils.is_email(kw.get('mail')):
                 self.domain = web.safestr(kw['mail']).split('@')[-1]
-            elif 'domain' in kw.keys() and iredutils.isDomain(kw.get('domain')):
+            elif 'domain' in kw.keys() and iredutils.is_domain(kw.get('domain')):
                 self.domain = web.safestr(kw['domain'])
             else:
                 return False
 
             self.admin = session.get('username')
-            if not iredutils.isEmail(self.admin):
+            if not iredutils.is_email(self.admin):
                 return False
 
             # Check domain global admin.

File libs/mysql/decorators.py

         if session.get('domainGlobalAdmin') is True:
             return func(*args, **kw)
         else:
-            if 'domain' in kw.keys() and iredutils.isDomain(kw.get('domain')):
+            if 'domain' in kw.keys() and iredutils.is_domain(kw.get('domain')):
                 domain = web.safestr(kw['domain'])
-            elif 'mail' in kw.keys() and iredutils.isEmail(kw.get('mail')):
+            elif 'mail' in kw.keys() and iredutils.is_email(kw.get('mail')):
                 domain = web.safestr(kw['mail']).split('@')[-1]
-            elif 'admin' in kw.keys() and iredutils.isEmail(kw.get('admin')):
+            elif 'admin' in kw.keys() and iredutils.is_email(kw.get('admin')):
                 domain = web.safestr(kw['admin']).split('@')[-1]
             else:
                 return (False, 'PERMISSION_DENIED')
 
             # Check whether is domain admin.
             validator = core.MySQLWrap()
-            if validator.isDomainAdmin(domain=domain, admin=session.get('username'),):
+            if validator.is_domainAdmin(domain=domain, admin=session.get('username'),):
                 return func(*args, **kw)
             else:
                 return (False, 'PERMISSION_DENIED')

File libs/mysql/domain.py

     def getDomainAdmins(self, domain, mailOnly=False):
         domain = str(domain)
 
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         try:
 
     @decorators.require_domain_access
     def getCountsOfExistAccountsUnderDomain(self, domain, accountType='user'):
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         sql_vars = {'domain': domain, }
 
         domains = [str(v).lower()
                    for v in domains
-                   if iredutils.isDomain(v)
+                   if iredutils.is_domain(v)
                   ]
 
         if not domains:
     def simpleProfile(self, domain, columns=[]):
         domain = web.safestr(domain)
 
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         try:
     def profile(self, domain):
         domain = web.safestr(domain)
 
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         try:
         cn = data.get('cn', '')
 
         # Check domain name.
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         # Check whether domain name already exist (domainName, domainAliasName).
         connutils = connUtils.Utils()
-        if connutils.isDomainExists(domain):
+        if connutils.is_domain_exists(domain):
             return (False, 'ALREADY_EXISTS')
 
         # Add domain in database.

File libs/mysql/user.py

     @decorators.require_login
     def listAccounts(self, domain, cur_page=1):
         '''List all users.'''
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         domain = str(domain)
         connutils = connUtils.Utils()
-        if not connutils.isDomainExists(domain):
+        if not connutils.is_domain_exists(domain):
             return (False, 'PERMISSION_DENIED')
 
         # Pre-defined.
     @decorators.require_domain_access
     def delete(self, domain, mails=[]):
         domain = str(domain)
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         if not isinstance(mails, list):
             return (False, 'INVALID_MAIL')
 
-        mails = [str(v).lower() for v in mails if iredutils.isEmail(v) and str(v).endswith('@' + domain)]
+        mails = [str(v).lower() for v in mails if iredutils.is_email(v) and str(v).endswith('@' + domain)]
         if not mails:
             return (False, 'INVALID_MAIL')
 
         mail_local_part = web.safestr(data.get('username')).strip().lower()
         self.mail = mail_local_part + '@' + self.domain
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         if self.domain != domain:
             return (False, 'PERMISSION_DENIED')
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         # Check account existing.
         connutils = connUtils.Utils()
-        if connutils.isEmailExists(mail=self.mail):
+        if connutils.is_email_exists(mail=self.mail):
             return (False, 'ALREADY_EXISTS')
 
         # Get domain profile.
         )
         if resultOfPW[0] is True:
             pwscheme = None
-            if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN:
+            if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN_TEXT:
                 pwscheme = 'PLAIN'
             passwd = iredutils.generate_password_for_sql_mail_account(resultOfPW[1], pwscheme=pwscheme)
         else:
             qr = iredutils.verify_new_password(newpw, confirmpw)
             if qr[0] is True:
                 pwscheme = None
-                if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN:
+                if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN_TEXT:
                     pwscheme = 'PLAIN'
                 passwd = iredutils.generate_password_for_sql_mail_account(qr[1], pwscheme=pwscheme)
             else:

File libs/panel/log.py

 
 import web
 from controllers import decorators
-from libs import iredutils, settings
+import settings
+from libs import iredutils
 from libs.panel import LOG_EVENTS
 
 db = web.admindb
         if self.event in LOG_EVENTS and self.event != 'all':
             queryDict['event'] = self.event
 
-        if iredutils.isDomain(self.domain):
+        if iredutils.is_domain(self.domain):
             queryDict['domain'] = self.domain
 
         if session.get('domainGlobalAdmin') is not True:
             queryDict['admin'] = session.get('username')
         else:
-            if iredutils.isEmail(self.admin):
+            if iredutils.is_email(self.admin):
                 queryDict['admin'] = self.admin
 
         # Get number of total records.

File libs/pgsql/admin.py

         else:
             self.admin = str(admin)
 
-        if not iredutils.isEmail(self.admin):
+        if not iredutils.is_email(self.admin):
             return 0
 
         self.domains = []
         if accountType in ['user', 'alias', ]:
             if len(domains) > 0:
-                self.domains = [str(d).lower() for d in domains if iredutils.isDomain(d)]
+                self.domains = [str(d).lower() for d in domains if iredutils.is_domain(d)]
             else:
                 connutils = connUtils.Utils()
                 qr = connutils.getManagedDomains(admin=self.admin, domainNameOnly=True)
         if not isinstance(mails, list):
             return (False, 'INVALID_MAIL')
 
-        self.mails = [str(v).lower() for v in mails if iredutils.isEmail(v)]
+        self.mails = [str(v).lower() for v in mails if iredutils.is_email(v)]
         sql_vars = {'username': self.mails, }
 
         # Delete domain and related records.
         self.mail = web.safestr(mail)
         self.domainGlobalAdmin = False
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         try:
         self.cn = data.get('cn', '')
         self.mail = web.safestr(data.get('mail')).strip().lower()
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         # Check admin exist.

File libs/pgsql/connUtils.py

 
 class Utils(core.PGSQLWrap):
 
-    def isDomainExists(self, domain):
+    def is_domain_exists(self, domain):
         # Return True if account is invalid or exist.
         domain = str(domain)
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return True
 
         sql_vars = {'domain': domain, }
     def isAdminExists(self, mail):
         # Return True if account is invalid or exist.
         mail = str(mail)
-        if not iredutils.isEmail(mail):
+        if not iredutils.is_email(mail):
             return True
 
         try:
             return True
 
     # Check whether account exist or not.
-    def isEmailExists(self, mail):
+    def is_email_exists(self, mail):
         # Return True if account is invalid or exist.
         mail = web.safestr(mail)
 
-        if not iredutils.isEmail(mail):
+        if not iredutils.is_email(mail):
             return True
 
         sql_vars = {'email': mail, }
     def getManagedDomains(self, admin, domainNameOnly=False, listedOnly=False,):
         admin = web.safestr(admin)
 
-        if not iredutils.isEmail(admin):
+        if not iredutils.is_email(admin):
             return (False, 'INCORRECT_USERNAME')
 
         sql_left_join = ''
             if domainNameOnly is True:
                 domains = []
                 for i in result:
-                    if iredutils.isDomain(i.domain):
+                    if iredutils.is_domain(i.domain):
                         domains += [str(i.domain).lower()]
 
                 return (True, domains)

File libs/pgsql/core.py

         except Exception:
             return False
 
-    def isDomainAdmin(self, domain, admin=session.get('username'),):
-        if not iredutils.isDomain(domain) or not iredutils.isEmail(admin):
+    def is_domainAdmin(self, domain, admin=session.get('username'),):
+        if not iredutils.is_domain(domain) or not iredutils.is_email(admin):
             return False
 
         if admin == session.get('username') \
             action = 'Disable'
 
         if accountType == 'domain':
-            accounts = [str(v) for v in accounts if iredutils.isDomain(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_domain(v)]
             try:
                 self.conn.update(
                     'domain',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'user':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.update(
                     'mailbox',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'admin':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.update(
                     'admin',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'alias':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.update(
                     'alias',
         accountType = str(accountType)
 
         if accountType == 'domain':
-            accounts = [str(v) for v in accounts if iredutils.isDomain(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_domain(v)]
             try:
                 self.conn.delete(
                     'domain',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'user':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             sql_vars = {'accounts': accounts, }
             try:
                 for tbl in ['mailbox', 'used_quota',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'admin':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.delete(
                     'admin',
             except Exception, e:
                 return (False, str(e))
         elif accountType == 'alias':
-            accounts = [str(v) for v in accounts if iredutils.isEmail(v)]
+            accounts = [str(v) for v in accounts if iredutils.is_email(v)]
             try:
                 self.conn.delete(
                     'alias',
 
 class Auth(PGSQLWrap):
     def auth(self, username, password, accountType='admin', verifyPassword=False,):
-        if not iredutils.isEmail(username):
+        if not iredutils.is_email(username):
             return (False, 'INVALID_USERNAME')
 
         if len(password) == 0:
 
     def require_domain_access(self, func):
         def proxyfunc(self, *args, **kw):
-            if 'mail' in kw.keys() and iredutils.isEmail(kw.get('mail')):
+            if 'mail' in kw.keys() and iredutils.is_email(kw.get('mail')):
                 self.domain = web.safestr(kw['mail']).split('@')[-1]
-            elif 'domain' in kw.keys() and iredutils.isDomain(kw.get('domain')):
+            elif 'domain' in kw.keys() and iredutils.is_domain(kw.get('domain')):
                 self.domain = web.safestr(kw['domain'])
             else:
                 return False
 
             self.admin = session.get('username')
-            if not iredutils.isEmail(self.admin):
+            if not iredutils.is_email(self.admin):
                 return False
 
             # Check domain global admin.

File libs/pgsql/decorators.py

         if session.get('domainGlobalAdmin') is True:
             return func(*args, **kw)
         else:
-            if 'domain' in kw.keys() and iredutils.isDomain(kw.get('domain')):
+            if 'domain' in kw.keys() and iredutils.is_domain(kw.get('domain')):
                 domain = web.safestr(kw['domain'])
-            elif 'mail' in kw.keys() and iredutils.isEmail(kw.get('mail')):
+            elif 'mail' in kw.keys() and iredutils.is_email(kw.get('mail')):
                 domain = web.safestr(kw['mail']).split('@')[-1]
-            elif 'admin' in kw.keys() and iredutils.isEmail(kw.get('admin')):
+            elif 'admin' in kw.keys() and iredutils.is_email(kw.get('admin')):
                 domain = web.safestr(kw['admin']).split('@')[-1]
             else:
                 return (False, 'PERMISSION_DENIED')
 
             # Check whether is domain admin.
             validator = core.PGSQLWrap()
-            if validator.isDomainAdmin(domain=domain, admin=session.get('username'),):
+            if validator.is_domainAdmin(domain=domain, admin=session.get('username'),):
                 return func(*args, **kw)
             else:
                 return (False, 'PERMISSION_DENIED')

File libs/pgsql/domain.py

     def getDomainAdmins(self, domain, mailOnly=False):
         domain = str(domain)
 
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         try:
 
     @decorators.require_domain_access
     def getCountsOfExistAccountsUnderDomain(self, domain, accountType='user'):
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         sql_vars = {'domain': domain, }
 
         domains = [str(v).lower()
                    for v in domains
-                   if iredutils.isDomain(v)
+                   if iredutils.is_domain(v)
                   ]
 
         if not domains:
     def simpleProfile(self, domain, columns=[]):
         domain = web.safestr(domain)
 
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         try:
     def profile(self, domain):
         domain = web.safestr(domain)
 
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         try:
         cn = data.get('cn', '')
 
         # Check domain name.
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         # Check whether domain name already exist (domainName, domainAliasName).
         connutils = connUtils.Utils()
-        if connutils.isDomainExists(domain):
+        if connutils.is_domain_exists(domain):
             return (False, 'ALREADY_EXISTS')
 
         # Add domain in database.

File libs/pgsql/user.py

     @decorators.require_login
     def listAccounts(self, domain, cur_page=1):
         '''List all users.'''
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         domain = str(domain)
         connutils = connUtils.Utils()
-        if not connutils.isDomainExists(domain):
+        if not connutils.is_domain_exists(domain):
             return (False, 'PERMISSION_DENIED')
 
         # Pre-defined.
     @decorators.require_domain_access
     def delete(self, domain, mails=[]):
         domain = str(domain)
-        if not iredutils.isDomain(domain):
+        if not iredutils.is_domain(domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         if not isinstance(mails, list):
             return (False, 'INVALID_MAIL')
 
-        mails = [str(v).lower() for v in mails if iredutils.isEmail(v) and str(v).endswith('@' + domain)]
+        mails = [str(v).lower() for v in mails if iredutils.is_email(v) and str(v).endswith('@' + domain)]
         if not mails:
             return (False, 'INVALID_MAIL')
 
         mail_local_part = web.safestr(data.get('username')).strip().lower()
         self.mail = mail_local_part + '@' + self.domain
 
-        if not iredutils.isDomain(self.domain):
+        if not iredutils.is_domain(self.domain):
             return (False, 'INVALID_DOMAIN_NAME')
 
         if self.domain != domain:
             return (False, 'PERMISSION_DENIED')
 
-        if not iredutils.isEmail(self.mail):
+        if not iredutils.is_email(self.mail):
             return (False, 'INVALID_MAIL')
 
         # Check account existing.
         connutils = connUtils.Utils()
-        if connutils.isEmailExists(mail=self.mail):
+        if connutils.is_email_exists(mail=self.mail):
             return (False, 'ALREADY_EXISTS')
 
         # Get domain profile.
         )
         if resultOfPW[0] is True:
             pwscheme = None
-            if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN:
+            if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN_TEXT:
                 pwscheme = 'PLAIN'
             passwd = iredutils.generate_password_for_sql_mail_account(resultOfPW[1], pwscheme=pwscheme)
         else:
             qr = iredutils.verify_new_password(newpw, confirmpw)
             if qr[0] is True:
                 pwscheme = None
-                if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN:
+                if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN_TEXT:
                     pwscheme = 'PLAIN'
                 passwd = iredutils.generate_password_for_sql_mail_account(qr[1], pwscheme=pwscheme)
             else:

File libs/settings.py

-# Author: Zhang Huangbin <zhb@iredmail.org>
-
-#################################### WARNING ####################################
-# It's strongly recommended to place all your settings in libs/settings_local.py
-# to override settings below, so that you don't need to sync settings after
-# upgrading iRedAdmin-Pro.
-#################################### WARNING ####################################
-
-# Set http proxy server address if iRedAdmin cannot access internet
-# (iredmail.org) directly.
-# Sample:
-#   HTTP_PROXY = 'http://192.168.1.1:3128'
-HTTP_PROXY = ''
-