{% macro successInfo(msg, removable=true, trusted=false) -%}
{% if removable is not sameas false %} Close {% endif %} {% if trusted is sameas false %}

{{ msg |e }}

{% else %}

{{ msg }}

{% endif %}
{%- endmacro %} {% macro errorInfo(msg, removable=false, trusted=false) -%}
{% if removable is not sameas false %} Close {% endif %} {% if trusted is sameas false %}

{{ _('Error:') }} {{ msg |e }}

{% else %}

{{ _('Error:') }} {{ msg }}

{% endif %}
{%- endmacro %} {% macro warningInfo(msg, removable=false, trusted=false) -%}
{% if removable is not sameas false %} Close {% endif %} {% if trusted is sameas false %}

{{ _('Warning') }}: {{ msg |e }}

{% else %}

{{ _('Warning') }}: {{ msg }}

{% endif %}
{%- endmacro %} {% macro generalInfo(msg, removable=true, trusted=false) -%}
{% if removable is not sameas false %} Close {% endif %} {% if trusted is sameas false %}

{{ msg |e }}

{% else %}

{{ msg |e }}

{% endif %}
{%- endmacro %} {% macro loginMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% set handlers = { 'loginRequired': errorInfo(_('Login required')), 'INVALID_CREDENTIALS': errorInfo(_('Username or password is incorrect.')), 'vmailadmin_INVALID_CREDENTIALS': errorInfo(_('Password of cn=vmailadmin is incorrect.')), 'INVALID_USERNAME': errorInfo(_('Username must be an valid email address.')), 'EMPTY_PASSWORD': errorInfo(_('Empty password is not allowed.')), 'SESSION_EXPIRED': errorInfo(_('Session expired, please re-login.')), } %} {% if msg == 'SERVER_DOWN' %} {{ errorInfo(_('Server is down, Please contact webmaster to solve it.' % webmaster ), trusted=true) }} {% elif msg is sameas false %} {{ errorInfo( ('Authentication failed.') ) }} {% else %} {% if msg in handlers %} {{ handlers[msg] }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {% endif %} {%- endmacro %} {% macro domainMsgHandler(msg=none) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% set handlers = { 'UPDATED': successInfo(_('Profile updated success.')), 'INVALID_ACTION': errorInfo(_('Invalid action.')), 'DELETED': successInfo(_('Selected domains were deleted.')), 'DISABLED': successInfo(_('Selected domains were disabled.')), 'ENABLED': successInfo(_('Selected domains were enabled.')), 'INVALID_DOMAIN_NAME': errorInfo(_('Invalid domain name.')), 'INVALID_MAIL': errorInfo(_('Invalid mail address.')), 'EMPTY_DOMAIN': errorInfo(_('Domain name is empty.')), 'EXCEEDED_LDAP_SERVER_SIZELIMIT': errorInfo(_('Server-side size limit exceeded. Please increase "sizelimit" in your LDAP server.')), 'ALREADY_EXISTS': errorInfo(_('Domain already exists. Please check both primary or alias domains.')), 'PERMISSION_DENIED': errorInfo(_('Permission denied.')), 'DOMAIN_NAME_MISMATCH': errorInfo(_('Submited domain name is incorrect.')), 'NO_SUCH_OBJECT': errorInfo(_('No such domain.')), 'NO_DOMAIN_SELECTED': errorInfo(_('Please select at least one domain to apply action.')), 'NO_DOMAIN_AVAILABLE': generalInfo(_('No domain under control.')), } %} {% if msg == 'CREATED' %}

{{ _('Domain created.') }} {{ _('Add one more?') }} {{ _('Or create other mail accounts:') }} {{ _('User') }}.

{% else %} {% if msg in handlers %} {{ handlers[msg] }} {% else %} {{ errorInfo(msg) }} {% endif %} {% endif %} {% endif %} {%- endmacro %} {% macro userMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% set handlers = { 'UPDATED': successInfo(_('Profile updated success.')), 'UPDATED_FAILED': errorInfo( _('Profile updated failed.')), 'INVALID_ACTION': errorInfo(_('Invalid action.')), 'NO_DOMAIN_AVAILABLE': generalInfo( _('No domain under control.') ), 'MISSING_DOMAIN_OR_USERNAME': errorInfo( _('Domain name or username is missed.') ), 'INVALID_MAIL': errorInfo(_('Invalid mail address.')), 'EXCEEDED_DOMAIN_QUOTA_SIZE': errorInfo(_('Domain quota size exceeded. Please contact your administrator or service provider to increase it.')), 'EXCEEDED_DOMAIN_ACCOUNT_LIMIT': errorInfo(_('Exceeded domain account limit. Please contact your administrator or service provider to increase it.')), 'DELETED': successInfo( _('Selected accounts were deleted.') ), 'DISABLED': successInfo( _('Selected accounts were disabled.') ), 'ENABLED': successInfo( _('Selected accounts were enabled.') ), 'INCORRECT_OLDPW': errorInfo( _('Current password is incorrect.') ), 'PW_MISMATCH': errorInfo( _('New passwords are not match.') ), 'PW_EMPTY': errorInfo( _('Password is empty.') ), 'PW_LESS_THAN_MIN_LENGTH': errorInfo( _('Password is too short.') ), 'PW_GREATER_THAN_MAX_LENGTH': errorInfo( _('Password is too long.') ), 'ALREADY_EXISTS': errorInfo(_('Mail address already exists, please choose another one.')), 'NO_DOMAIN': errorInfo(_('No mail domain available.')), 'NO_ACCOUNT_SELECTED': errorInfo(_('Please select at least one account.')), 'NOT_ALLOWED': errorInfo(_('Not allowed to create mail user under this domain.')), } %} {% if msg == 'CREATED' %}

{{ _('User created.') }} {{ _('Add one more?') }}

{% else %} {% if msg in handlers %} {{ handlers[msg] }} {% else %} {{ errorInfo(msg) }} {% endif %} {% endif %} {% endif %} {%- endmacro %} {% macro adminMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% set handlers = { 'UPDATED': successInfo(_('Profile updated success.')), 'INVALID_ACTION': errorInfo(_('Invalid action.')), 'PERMISSION_DENIED': errorInfo(_("Permission denied.")), 'DELETED': successInfo(_('Selected accounts were deleted.')), 'DISABLED': successInfo(_('Selected accounts were disabled.')), 'ENABLED': successInfo(_('Selected accounts were enabled.')), 'NO_ACCOUNT_SELECTED': errorInfo(_('No account selected.')), 'INCORRECT_OLDPW': errorInfo(_('Current password is incorrect.')), 'INVALID_CREDENTIALS': errorInfo(_('Current password is incorrect.')), 'PW_MISMATCH': errorInfo(_('New passwords are not match.')), 'PW_EMPTY': errorInfo(_('Password is empty.')), 'INVALID_MAIL': errorInfo(_('Invalid mail address.')), 'ALREADY_EXISTS': errorInfo(_('Account already exists, please choose another username.')), 'NO_SUCH_OBJECT': errorInfo(_('Admin not exist.')), } %} {% if msg == 'CREATED' %}

{{ _('Admin created.') }} {{ _('Add one more?') }}

{% elif msg == 'PW_LESS_THAN_MIN_LENGTH' %} {{ errorInfo( _('New password must contain at least %s characters.') |format(min_passwd_length) ) }} {% elif msg == 'PW_GREATER_THAN_MAX_LENGTH' %} {{ errorInfo( _('New password must NOT contain more than %s characters.') |format(max_passwd_length) ) }} {% else %} {% if msg in handlers %} {{ handlers[msg] }} {% else %} {{ errorInfo(msg) }} {% endif %} {% endif %} {% endif %} {%- endmacro %} {% macro maillistMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% set handlers = { 'ALREADY_EXISTS': errorInfo(_('Account already exists, please choose another username.')), 'INVALID_USERNAME': errorInfo(_('Invalid username.')), 'UPDATED': successInfo(_('Profile updated success.')), 'INVALID_ACTION': errorInfo(_('Invalid action.')), 'UPDATED_FAILED': errorInfo(_('Profile updated failed.')), 'MEMBER_ASSIGNED': successInfo(_('Member assigned success.')), 'MEMBER_REMOVED': successInfo(_('Member removed success.')), 'MODERATOR_ASSIGNED_SUCCESS': successInfo(_('Moderators assigned success.')), 'MODERATOR_REMOVED_SUCCESS': successInfo(_('Moderators removed success.')), 'DELETED': successInfo(_('Selected accounts were deleted.')), 'DISABLED': successInfo(_('Selected accounts were disabled.')), 'ENABLED': successInfo(_('Selected accounts were enabled.')), 'ALREADY_EXISTS': errorInfo(_('Account already exists, please choose another username.')), 'NO_DOMAIN_AVAILABLE': generalInfo(_('No domain under control.')), 'NO_MODERATOR_SELECTED': errorInfo(_('No moderator selected.')), 'NOT_ALLOWED': errorInfo(_('Not allowed to create mail list under this domain.')), } %} {% if msg == 'CREATED' %}

{{ _('Mail list created.') }} {{ _('Add one more?') }}

{% else %} {% if msg in handlers %} {{ handlers[msg] }} {% else %} {{ errorInfo(msg) }} {% endif %} {% endif %} {% endif %} {%- endmacro %} {% macro aliasMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% set handlers = { 'ALREADY_EXISTS': errorInfo(_('Account already exists, please choose another username.')), 'UPDATED': successInfo(_('Profile updated success.')), 'INVALID_ACTION': errorInfo(_('Invalid action.')), 'NO_DOMAIN_AVAILABLE': generalInfo(_('No domain under control.')), 'DELETED': successInfo(_('Selected accounts were deleted.')), 'DISABLED': successInfo(_('Selected accounts were disabled.')), 'ENABLED': successInfo(_('Selected accounts were enabled.')), 'MEMBER_ASSIGNED': successInfo(_('Member assigned success.')), 'MEMBER_REMOVED': successInfo(_('Member removed success.')), 'UPDATED_FAILED': errorInfo(_('Profile updated failed.')), 'EMPTY_LISTNAME': errorInfo(_('Empty address is not allowed.')), 'NOT_ALLOWED': errorInfo(_('Not allowed to create mail alias under this domain.')), } %} {% if msg == 'CREATED' %}

{{ _('Mail alias created.') }} {{ _('Add one more?') }}

{% else %} {% if msg in handlers %} {{ handlers[msg] }} {% else %} {{ errorInfo(msg) }} {% endif %} {% endif %} {% endif %} {%- endmacro %} {% macro logMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'DELETED' %} {{ successInfo( _('Selected log records were deleted.') ) }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro amavisdQuarantinedMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% set handlers = { 'RELEASED': successInfo(_('Mails were released.')), 'DELETED': successInfo(_('Mails were deleted.')), 'INVALID_ACCOUNT': errorInfo(_('Invalid domain name or mail address.')), 'INVALID_ACTION': errorInfo(_('Invalid action.')), 'INVALID_MAILID': errorInfo(_('Invalid request data.')), 'PERMISSION_DENIED': errorInfo(_('Permission denied.')), } %} {% if msg in handlers %} {{ handlers[msg] }} {% else %} {{ errorInfo(msg) }} {% endif %} {% endif %} {%- endmacro %} {# Amavisd sent/received mail log #} {% macro maillogMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg |string != '' %} {% set handlers = { 'DELETED': successInfo(_('Selected log records were deleted.')), 'INVALID_ACTION': errorInfo(_('Invalid action.')), 'INVALID_ACCOUNT': errorInfo(_('Invalid domain name or mail address.')), 'PERMISSION_DENIED': errorInfo(_('Permission denied.')), } %} {% if msg in handlers %} {{ handlers[msg] }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {# Search accounts #} {% macro searchMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'SUCCESS' %} {{ successInfo( _('Operation completed.') ) }} {% elif msg == 'EMPTY_STRING' %} {{ errorInfo( _('Search keyword could not be empty.') ) }} {% elif msg == 'INVALID_MAIL' %} {{ errorInfo( _('Invalid mail address.') ) }} {% elif msg == 'INVALID_ACTION' %} {{ errorInfo(_('Invalid action.')) }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %}