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

{{msg}}

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

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

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

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

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

{{ msg }}

{%- endmacro %} {% macro loginMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'INVALID_CREDENTIALS' %} {{ errorInfo( _('Username or password is incorrect.') ) }} {% elif msg == 'INVALID_USERNAME' %} {{ errorInfo( _('Username must be an valid email address.') ) }} {% elif msg == 'loginRequired' %} {{ errorInfo( _('Login required') ) }} {% elif msg == 'EMPTY_PASSWORD' %} {{ errorInfo( _('Empty password is not allowed.') ) }} {% elif msg == 'SESSION_EXPIRED' %} {{ errorInfo( _('Session expired, please re-login.') ) }} {% elif msg == 'SERVER_DOWN' %} {{ errorInfo( _('Server is down, Please contact webmaster to solve it.' % webmaster ) ) }} {% elif msg is sameas false %} {{ errorInfo( ('Authentication failed.') ) }} {# Catch-all. displayed as a 'warning' msg. #} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro domainMsgHandler(msg=none) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'CREATED_SUCCESS' %}

{{ _('Domain created.') }} {{ _('add one more') }}? {{ _('Or create other mail accounts:') }} {{ _('User') }}, {{ _('Mail List') }}.

{% elif msg == 'ALREADY_EXISTS' %} {{ errorInfo('Domain already exists. Please check both primary or alias domains.') }} {% elif msg == 'PROFILE_UPDATED_SUCCESS' %} {{ successInfo( _('Profile updated success.') ) }} {% elif msg == 'DELETED_SUCCESS' %} {{ successInfo( _('Selected domains were deleted.') ) }} {% elif msg == 'DISABLED_SUCCESS' %} {{ successInfo( _('Selected domains were disabled.') ) }} {% elif msg == 'ENABLED_SUCCESS' %} {{ successInfo( _('Selected domains were enabled.') ) }} {# Error handler #} {% elif msg == 'INVALID_DOMAIN_NAME' %} {{ errorInfo( _('Invalid domain name.') ) }} {% elif msg == 'INVALID_ACTION' %} {{ errorInfo( _('Invalid action.') ) }} {% elif msg == 'EMPTY_DOMAIN' %} {{ errorInfo( _('Domain name is empty.') ) }} {% elif msg == 'EXCEEDED_LDAP_SERVER_SIZELIMIT' %} {{ errorInfo( _('Server-side size limit exceeded. Please increase "sizelimit" in your LDAP server.') ) }} {% elif msg == 'PERMISSION_DENIED' %} {{ errorInfo( _('Permission denied.') ) }} {% elif msg == 'NO_SUCH_OBJECT' %} {{ errorInfo( _('No such domain.') ) }} {% elif msg == 'DOMAIN_NAME_MISMATCH' %} {{ errorInfo( _('Submited domain name is incorrect.') ) }} {% elif msg == 'NO_DOMAIN_SELECTED' %} {{ errorInfo( _('Please select at least one domain to apply action.') ) }} {% elif msg == 'NO_DOMAIN_AVAILABLE' %} {{ generalInfo( _('No domain under control.') ) }} {# Catch-all. displayed as a 'warning' msg. #} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro userMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'PROFILE_UPDATED_SUCCESS' %} {{ successInfo( _('Profile updated success.') ) }} {% elif msg == 'UPDATED_FAILED' %} {{ errorInfo( _('Profile updated failed.') ) }} {% elif msg == 'CREATED_SUCCESS' %} {{ successInfo( _('User created. Would you like to add one more?' |format(ctx.homepath, mail.split('@', 1)[1] )) ) }} {% elif msg == 'NO_DOMAIN_AVAILABLE' %} {{ generalInfo( _('No domain under control.') ) }} {% elif msg == 'MISSING_DOMAIN_OR_USERNAME' %} {{ errorInfo( _('Domain name or username is missed.') ) }} {% elif msg == 'INVALID_MAIL' %} {{ errorInfo( _('Invalid mail address.') ) }} {% elif msg == 'EXCEEDED_DOMAIN_QUOTA_SIZE' %} {{ errorInfo( _('Domain quota size exceeded. Please contact your administrator or service provider to increase it.') ) }} {# Delete, disable, enable accounts #} {% elif msg == 'DELETED_SUCCESS' %} {{ successInfo( _('Selected accounts were deleted.') ) }} {% elif msg == 'DISABLED_SUCCESS' %} {{ successInfo( _('Selected accounts were disabled.') ) }} {% elif msg == 'ENABLED_SUCCESS' %} {{ successInfo( _('Selected accounts were enabled.') ) }} {# Password related msg #} {% elif msg == 'INCORRECT_OLDPW' %} {{ errorInfo( _('Current password is incorrect.') ) }} {% elif msg == 'PW_MISMATCH' %} {{ errorInfo( _('New passwords are not match.') ) }} {% elif msg == 'PW_EMPTY' %} {{ errorInfo( _('Password is empty.') ) }} {% elif msg == 'PW_LESS_THAN_MIN_LENGTH' %} {{ errorInfo( _('Password is too short.') ) }} {% elif msg == 'PW_GREATER_THAN_MAX_LENGTH' %} {{ errorInfo( _('Password is too long.') ) }} {% elif msg == 'ALREADY_EXISTS' %} {{ errorInfo('Mail address already exists, please choose another one.') }} {% elif msg == 'NO_INIT_PASSWD' %} {{ errorInfo('No password while importing accounts.') }} {% elif msg == 'NO_DOMAIN' %} {{ errorInfo('No domain name available.') }} {% elif msg == 'NO_ACCOUNT_SELECTED' %} {{ errorInfo('Please select at least one account.') }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro adminMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'CREATED_SUCCESS' %} {{ successInfo( _('Admin created. Would you like to add one more?') |format(ctx.homepath) ) }} {% elif msg == 'PROFILE_UPDATED_SUCCESS' %} {{ successInfo( _('Profile updated success.') ) }} {% elif msg == 'PERMISSION_DENIED' %} {{ errorInfo("You are NOT permited to view/update other's profile.") }} {# Delete, disable, enable accounts #} {% elif msg == 'DELETED_SUCCESS' %} {{ successInfo( _('Selected accounts were deleted.') ) }} {% elif msg == 'DISABLED_SUCCESS' %} {{ successInfo( _('Selected accounts were disabled.') ) }} {% elif msg == 'ENABLED_SUCCESS' %} {{ successInfo( _('Selected accounts were enabled.') ) }} {% elif msg == 'NO_ACCOUNT_SELECTED' %} {{ errorInfo( _('No account selected.') ) }} {# Password related msg #} {% elif msg == 'INCORRECT_OLDPW' %} {{ errorInfo( _('Current password is incorrect.') ) }} {% elif msg == 'PW_MISMATCH' %} {{ errorInfo( _('New passwords are not match.') ) }} {% elif msg == 'PW_EMPTY' %} {{ errorInfo( _('Password is empty.') ) }} {% 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) ) }} {% elif msg == 'INVALID_MAIL' %} {{ errorInfo( _('Invalid mail address.') ) }} {% elif msg == 'ALREADY_EXISTS' %} {{ errorInfo('Account already exists, please choose another username.') }} {% elif msg == 'NO_SUCH_OBJECT' %} {{ errorInfo( _('Admin not exist.') ) }} {# Catch-all. displayed as a 'warning' msg. #} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro maillistMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'CREATED_SUCCESS' %} {{ successInfo( _('Mail list created. Would you like to add one more?' |format(ctx.homepath, mail.split('@', 1)[1] )) ) }} {% elif msg == 'ALREADY_EXISTS' %} {{ errorInfo('Account already exists, please choose another username.') }} {% elif msg == 'INVALID_USERNAME' %} {{ errorInfo('Invalid username.') }} {% elif msg == 'PROFILE_UPDATED_SUCCESS' %} {{ successInfo( _('Profile updated success.') ) }} {% elif msg == 'UPDATED_FAILED' %} {{ errorInfo( _('Profile updated failed.') ) }} {# Assign/remove members. #} {% elif msg == 'MEMBER_ASSIGNED_SUCCESS' %} {{ successInfo( _('Member assigned success.') ) }} {% elif msg == 'MEMBER_REMOVED_SUCCESS' %} {{ successInfo( _('Member removed success.') ) }} {# Assign/remove moderators. #} {% elif msg == 'MODERATOR_ASSIGNED_SUCCESS' %} {{ successInfo( _('Moderators assigned success.') ) }} {% elif msg == 'MODERATOR_REMOVED_SUCCESS' %} {{ successInfo( _('Moderators removed success.') ) }} {% elif msg == 'DELETED_SUCCESS' %} {{ successInfo( _('Selected accounts were deleted.') ) }} {% elif msg == 'DISABLED_SUCCESS' %} {{ successInfo( _('Selected accounts were disabled.') ) }} {% elif msg == 'ENABLED_SUCCESS' %} {{ successInfo( _('Selected accounts were enabled.') ) }} {% elif msg == 'ALREADY_EXISTS' %} {{ errorInfo( _('Account already exists, please choose another username.') ) }} {% elif msg == 'NO_DOMAIN_AVAILABLE' %} {{ generalInfo( _('No domain under control.') ) }} {% elif msg == 'NO_MODERATOR_SELECTED' %} {{ errorInfo( _('No moderator selected.') ) }} {# Catch-all. displayed as a 'warning' msg. #} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro aliasMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'CREATED_SUCCESS' %} {{ successInfo( _('Mail alias created. Would you like to add one more?' |format(ctx.homepath, mail.split('@', 1)[1] )) ) }} {% elif msg == 'ALREADY_EXISTS' %} {{ errorInfo( _('Account already exists, please choose another username.') ) }} {% elif msg == 'PROFILE_UPDATED_SUCCESS' %} {{ successInfo( _('Profile updated success.') ) }} {% elif msg == 'NO_DOMAIN_AVAILABLE' %} {{ generalInfo( _('No domain under control.') ) }} {% elif msg == 'DELETED_SUCCESS' %} {{ successInfo( _('Selected accounts were deleted.') ) }} {% elif msg == 'DISABLED_SUCCESS' %} {{ successInfo( _('Selected accounts were disabled.') ) }} {% elif msg == 'ENABLED_SUCCESS' %} {{ successInfo( _('Selected accounts were enabled.') ) }} {% elif msg == 'MEMBER_ASSIGNED_SUCCESS' %} {{ successInfo( _('Member assigned success.') ) }} {% elif msg == 'MEMBER_REMOVED_SUCCESS' %} {{ successInfo( _('Member removed success.') ) }} {% elif msg == 'UPDATED_FAILED' %} {{ errorInfo( _('Profile updated failed.') ) }} {% elif msg == 'EMPTY_LISTNAME' %} {{ errorInfo( _('Empty address is not allowed.') ) }} {# Catch-all. displayed as a 'warning' msg. #} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro logMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'DELETED' %} {{ successInfo( _('Records were deleted.') ) }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro policydMsgHandler(msg, listname='whitelist') -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'CREATED_SUCCESS' %} {{ successInfo( _('Records are added. View them now') |format(ctx.homepath + '/system/' + listname) ) }} {% endif %} {% endif %} {%- endmacro %} {% macro amavisdQuarantinedMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'RELEASED' %} {{ successInfo( _('Mails were released.') ) }} {% elif msg == 'DELETED' %} {{ successInfo( _('Mails were deleted.') ) }} {% elif msg == 'INVALID_ACTION' %} {{ errorInfo( _('Invalid action.') ) }} {% elif msg == 'INVALID_LOGTYPE' %} {{ errorInfo( _('Invalid log type.') ) }} {% elif msg == 'INVALID_MAILID' %} {{ errorInfo( _('Invalid request data.') ) }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro maillogMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'DELETED' %} {{ successInfo( _('Records were deleted.') ) }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %} {% macro searchMsgHandler(msg) -%} {% if msg is defined and msg is not sameas none and msg|string != '' %} {% if msg == 'SUCCESS' %} {{ successInfo( _('Operation completed.') ) }} {% else %} {{ errorInfo( msg ) }} {% endif %} {% endif %} {%- endmacro %}