Add files via upload

This commit is contained in:
Harold Finch
2023-04-10 07:23:44 +02:00
committed by GitHub
parent 047f85e92d
commit ae35dc5986
56 changed files with 11982 additions and 0 deletions

View File

@@ -0,0 +1,167 @@
{% extends "layout.html" %}
{% from "macros/form_inputs.html" import
input_csrf_token
with context
%}
{% from "macros/general.html" import
display_subnav,
set_account_status_img,
set_forwarding_address_img,
with context
%}
{% from "macros/msg_handlers.html" import user_msg_handler with context %}
{% block title %}{{ _('Last Logins') }}{% endblock %}
{% block navlinks_domains %}class="active"{% endblock %}
{% block breadcrumb %}
{% if all_are_admins %}
{% set crumbs = [
(ctx.homepath + '/domains', _('All domains')),
(ctx.homepath + '/profile/domain/general/' + cur_domain, cur_domain),
(ctx.homepath + '/users/' + cur_domain, _('Users')),
(ctx.homepath + '/mls/' + cur_domain, _('Mailing Lists')),
(ctx.homepath + '/aliases/' + cur_domain, _('Aliases')),
(ctx.homepath + '/admins/' + cur_domain, _('Admins')),
]
%}
{% else %}
{% set crumbs = [
(ctx.homepath + '/domains', _('All domains')),
(ctx.homepath + '/profile/domain/general/' + cur_domain, cur_domain),
(ctx.homepath + '/users/' + cur_domain, _('Users')),
(ctx.homepath + '/mls/' + cur_domain, _('Mailing Lists')),
(ctx.homepath + '/aliases/' + cur_domain, _('Aliases')),
] %}
{% if session.get('is_global_admin') %}
{% set crumbs = crumbs + [(ctx.homepath + '/admins/' + cur_domain, _('Admins'))] %}
{% endif %}
{% endif %}
{% if backend != "pgsql" %}
{% set crumbs = crumbs + [('active', ctx.homepath + '/users/' + cur_domain + '/last_logins', _('Last Logins'))] %}
{% endif %}
{{ display_subnav(crumbs) }}
{% endblock %}
{% block main %}
{# Show system message #}
{{ user_msg_handler(msg) }}
<div class="content-box">
<div class="box-body">
<div class="box-header clear">
<h2>{{ _("Last Logins") }}</h2>
</div>
<div class="box-wrapper clear">
<div id="all_last_logins">
<table class="style1">
<thead>
<tr>
<th data-sort="string-ins">{{ _("Display Name") }}</th>
<th data-sort="string-ins">{{ _("Mail Address") }}</th>
<th data-sort="int" data-sort-default="desc" data-sort-onload="yes">IMAP</th>
<th data-sort="int" data-sort-default="desc">POP3</th>
<th data-sort="int" data-sort-default="desc">{{ _("Last Email Delivery") }}</th>
<th></th>
</tr>
</thead>
<tbody>
{% if last_logins %}
{% for email in last_logins %}
{% set active = last_logins[email]["active"] %}
{% set forwardings = last_logins[email]["forwardings"] %}
{% set name = last_logins[email]["name"] %}
{% set imap = last_logins[email]["imap"] %}
{% set pop3 = last_logins[email]["pop3"] %}
{% set lda = last_logins[email]["lda"] %}
<tr id="row_{{ loop.index }}">
<td>{% if name %}{{ name | e }}{% endif %}</td>
<td id="td_status_{{ loop.index }}">
<a href="{{ ctx.homepath }}/profile/user/general/{{ email }}"
title="{{ _('Edit account profile') }}"
>{{ email }}</a>
<a href="{{ ctx.homepath }}/profile/user/general/{{ email }}" title="{{ _('Edit account profile') }}"><i class="fa fa-cog fa-lg fr-space"></i></a>
{{ set_account_status_img(active) }}
{% if forwardings %}
{{ set_forwarding_address_img(email, forwardings) }}
{% endif %}
</td>
<td data-sort-value="{{ imap }}">
{% if imap > 0 %}
{{ imap | epoch_seconds_to_gmt | utc_to_timezone(timezone=session['timezone']) }}
{% endif %}
</td>
<td data-sort-value="{{ pop3 }}">
{% if pop3 > 0 %}
{{ pop3 | epoch_seconds_to_gmt | utc_to_timezone(timezone=session['timezone']) }}
{% endif %}
</td>
<td data-sort-value="{{ lda }}">
{% if lda > 0 %}
{{ lda | epoch_seconds_to_gmt | utc_to_timezone(timezone=session['timezone']) }}
{% endif %}
</td>
<td>
{% if active %}
<span
id="btn_disable_{{ loop.index }}"
class="button"
onclick='disable_user("{{ loop.index }}", "{{ email }}")'
>{{ _("Disable") }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="5">{{ _("No any login or mail delivery yet.") }}</td>
</tr>
{% endif %}
</tbody>
</table>
</div>{# .all_last_logins #}
</div>{# .box-wrapper #}
</div>{# .box-body #}
</div>{# .content-box #}
{% endblock main %}
{% block extra_js %}
<script type="text/javascript">
function disable_user(id, email) {
$.ajax({
type: "PUT",
url: '{{ ctx.homepath }}/apiproxy/user/' + email,
data: "accountStatus=disabled",
success: function (ret) {
if (ret._success) {
$('#td_status_' + id + ' i').
attr("title", '{{ _("Disabled") }}').
removeClass().
toggleClass("fas fa-times-circle fa-lg color-red fr-space");
$('#btn_disable_' + id).
text('{{ _("Disabled") }}').
addClass("grey").
attr('disabled','disabled');
} else {
alert(ret._msg);
}
}
});
};
</script>
{% endblock extra_js %}

View File

@@ -0,0 +1,186 @@
{% extends "layout.html" %}
{% from "macros/form_inputs.html" import input_csrf_token with context %}
{% from "macros/general.html" import
display_subnav,
display_input_cn,
display_preferred_language,
display_reset_password,
display_random_password,
display_quota
with context
%}
{% from "macros/msg_handlers.html" import user_msg_handler with context %}
{% block title %}{{ _('Add mail user') }}{% endblock title %}
{% block navlinks_create %}class="active"{% endblock %}
{% block breadcrumb %}
{% set crumbs = [
(ctx.homepath + '/domains', _('All domains')),
(ctx.homepath + '/profile/domain/general/' + cur_domain, cur_domain),
(ctx.homepath + '/users/' + cur_domain, _('Users')),
(ctx.homepath + '/mls/' + cur_domain, _('Mailing Lists')),
(ctx.homepath + '/aliases/' + cur_domain, _('Aliases')),
(ctx.homepath + '/admins/' + cur_domain, _('Admins')),
]
%}
{% if backend != "pgsql" %}
{% set crumbs = crumbs + [(ctx.homepath + '/users/' + cur_domain + '/last_logins', _('Last Logins'))] %}
{% endif %}
{{ display_subnav(crumbs) }}
{% endblock %}
{% block main %}
{# Show system message #}
{% if msg %}
{% if msg.startswith('PW_') %}
{% set _pw_errors = msg.split(',') %}
{% for _err in _pw_errors %}
{{ user_msg_handler(_err) }}
{% endfor %}
{% else %}
{{ user_msg_handler(msg) }}
{% endif %}
{% endif %}
{# -- Allow to create new account --#}
{% set createNewAccount = true %}
{% set numberOfSpareAccounts = profile.mailboxes - num_existing_users %}
{% set spareQuotaBytes = (profile.maxquota - usedQuotaSize) * 1024 * 1024 %}
{% if profile.mailboxes == -1 %}
{% set createNewAccount = false %}
{% set whyDisabledCreation = _('Not allowed to create mail alias under this domain.') %}
{% elif profile.mailboxes > 0 and numberOfSpareAccounts <= 0 %}
{% set createNewAccount = false %}
{% set whyDisabledCreation = _('Already exceed max number of account limit (%d).') |format(profile.mailboxes |int) %}
{% endif %}
{% if profile.maxquota > 0 and spareQuotaBytes <= 0 %}
{% set createNewAccount = false %}
{% set whyDisabledCreation = _('No free domain quota left.') %}
{% endif %}
{# Display input field for adding new user. #}
{% if not createNewAccount %}
<div class="notification note-error">
<p>
<strong>{{ _('Error:') }}</strong> {{ _('You can NOT create more users under domain %s.') |format('<a href="' + ctx.homepath + '/profile/domain/general/' + cur_domain + '"><strong>' + cur_domain + '</strong></a>') }} {{ whyDisabledCreation }}
{# Show link to change limit #}
{% if session.get('is_global_admin') %}
{% if profile.mailboxes > 0 and numberOfSpareAccounts <= 0 %}
<a href='{{ctx.homepath}}/profile/domain/advanced/{{cur_domain}}#domainQuota'>{{ _('Increase it now?') }}</a>
{% endif %}
{% endif %}
</p>
</div>
{% else %}
{% if profile.mailboxes > 0 and numberOfSpareAccounts > 0 %}
<div class="notification note-info">
<p>{{ _('You can create <strong>%d</strong> more mail user(s) under domain %s.') |format(numberOfSpareAccounts, '<a href="' + ctx.homepath + '/profile/domain/general/' + cur_domain + '"><strong>' + cur_domain + '</strong></a>') }}</p>
</div>
<div class="bt-space0"></div>
{% endif %}
{% endif %}
<div class="content-box">
<div class="box-body">
<div class="box-header clear">
<ul class="tabs clear">
<li class="active"><a href="#user_add"><i class="fa fa-plus"></i> {{ _('User') }}</a>
<li><a href="{{ctx.homepath}}/create/ml/{{cur_domain}}"><i class="fa fa-plus"></i> {{ _('Mailing List') }}</a>
<li><a href="{{ctx.homepath}}/create/alias/{{cur_domain}}"><i class="fa fa-plus"></i> {{ _('Alias') }}</a>
</ul>
<h2>{{ _('Add mail user') }}</h2>
</div>
<div id="user_add" class="box-wrap clear">
<form name="form_add_user" method="post" action="{{ctx.homepath}}/create/user/{{cur_domain}}">
{{ input_csrf_token() }}
<div class="columns clear">
<div class="col3-4">
<div class="form-field clear">
<h4 class="size-250 fl-space">{{ _('Add mail user under domain') }} <span class="required">*</span></h4>
<span class="clean-padding">
<select
name="domainName"
onchange="change_url(this, baseurl='{{ctx.homepath}}/create/user/');"
{% if not createNewAccount %}disabled{% endif %}
>
{% for d in all_domains %}
<option value="{{ d |e }}" {% if d == cur_domain %}selected{%endif%}>{{ d |e }}</option>
{% endfor %}
</select>
</span>
</div>
<div class="form-field clear">
<h4 class="size-250 fl-space">{{ _('Mail Address') }} <span class="required">*</span></h4>
<span class="clean-padding">
<input type="text" size="35"
name="username"
autocomplete="off"
value=""
class="text fl-space {% if not createNewAccount %}disabled{% endif %}"
{% if not createNewAccount %}disabled="disabled"{% endif %} />@{{ cur_domain }}
</span>
</div>
<div class="bt-space5">&nbsp;</div>
{{ display_reset_password(
min_passwd_length=min_passwd_length,
max_passwd_length=max_passwd_length,
store_password_in_plain_text=store_password_in_plain_text,
enable_input=createNewAccount,
) }}
<div class="bt-space5">&nbsp;</div>
{{ display_input_cn(
value=cn,
account_type='user',
enable_input=createNewAccount,
) }}
{{ display_preferred_language(
value=domain_settings.get('default_language', 'en_US'),
languagemaps=languagemaps,
enable_input=createNewAccount,
) }}
{{ display_quota(value=domain_settings.get('default_user_quota', 0),
spare_quota_bytes=spareQuotaBytes,
show_spare_quota=true,
show_value_in_input=true,
show_used_quota=false,
enable_input=createNewAccount) }}
</div>{# .col2-3 #}
<div class="col1-4 lastcol">
{{ display_random_password(password_length=min_passwd_length,
password_policies=password_policies) }}
</div>
</div>{# .columns #}
<div class="rule2"></div>
<div class="form-field clear">
<h4 class="size-250 fl-space">&nbsp;</h4>
<span>
<input type="submit" name="submit_add_user" value="{{ _('Add') }}" {% if not createNewAccount %}class="button color-grey" disabled="disabled"{% else %}class="button green"{% endif %} />
</span>
</div>
</form>
</div>{# -- End box-wrap -- #}
</div>{# -- End content-box -- #}
</div>{# -- End box-body -- #}
{% endblock main %}

View File

@@ -0,0 +1,332 @@
{% extends "layout.html" %}
{% from "macros/form_inputs.html" import
input_csrf_token
with context
%}
{% from "macros/general.html" import
display_subnav,
set_account_status_img,
set_account_activity_img,
set_forwarding_address_img,
set_alias_address_img,
set_assigned_groups_img,
set_user_admin_type_img,
highlight_username_in_mail,
display_progress_bar,
display_filter_by_first_char,
show_pages,
display_remove_mailbox_days
with context
%}
{% from "macros/msg_handlers.html" import user_msg_handler with context %}
{% block title %}{{ _('Mail Users') }}{% endblock %}
{% block navlinks_domains %}class="active"{% endblock %}
{% block breadcrumb %}
{% if all_are_admins %}
{% set crumbs = [
(ctx.homepath + '/domains', _('All domains')),
(ctx.homepath + '/profile/domain/general/' + cur_domain, cur_domain),
(ctx.homepath + '/users/' + cur_domain, _('Users')),
(ctx.homepath + '/mls/' + cur_domain, _('Mailing Lists')),
(ctx.homepath + '/aliases/' + cur_domain, _('Aliases')),
('active', ctx.homepath + '/admins/' + cur_domain, _('Admins')),
]
%}
{% else %}
{% set crumbs = [
(ctx.homepath + '/domains', _('All domains')),
(ctx.homepath + '/profile/domain/general/' + cur_domain, cur_domain),
('active', ctx.homepath + '/users/' + cur_domain, _('Users')),
(ctx.homepath + '/mls/' + cur_domain, _('Mailing Lists')),
(ctx.homepath + '/aliases/' + cur_domain, _('Aliases')),
] %}
{% if session.get('is_global_admin') %}
{% set crumbs = crumbs + [(ctx.homepath + '/admins/' + cur_domain, _('Admins'))] %}
{% endif %}
{% endif %}
{% if backend != "pgsql" %}
{% set crumbs = crumbs + [(ctx.homepath + '/users/' + cur_domain + '/last_logins', _('Last Logins'))] %}
{% endif %}
{{ display_subnav(crumbs) }}
{% endblock %}
{% block main %}
{# Show system message #}
{{ user_msg_handler(msg) }}
{% if users is defined %}
{% if users or (not users and first_char) %}
{% if all_are_admins %}
{{ display_filter_by_first_char(baseurl=ctx.homepath + '/admins/' + cur_domain,
first_char=first_char,
account_type='admin',
disabled_only=disabled_only) }}
{% else %}
{{ display_filter_by_first_char(baseurl=ctx.homepath + '/users/' + cur_domain,
available_chars=all_first_chars,
first_char=first_char,
account_type='user',
disabled_only=disabled_only) }}
{% endif %}
{% endif %}
{# List all users. #}
<div class="content-box">
<div class="box-body">
<div class="box-header clear">
<ul class="tabs clear">
<li><a href="{{ctx.homepath}}/create/user/{{cur_domain}}"><i class="fa fa-plus"></i> {{ _('User') }}</a>
<li><a href="{{ctx.homepath}}/create/ml/{{cur_domain}}"><i class="fa fa-plus"></i> {{ _('Mailing List') }}</a>
<li><a href="{{ctx.homepath}}/create/alias/{{cur_domain}}"><i class="fa fa-plus"></i> {{ _('Alias') }}</a>
</ul>
<h2>
{% if all_are_admins %}
{{ _('Admins under domain: %s') |format(cur_domain) }}
{% else %}
{{ _('Users under domain: %s') |format(cur_domain) }}
{% endif %}
{% if total is defined and users|length > 0 %}
({{ (cur_page-1) * page_size_limit + 1 }}-{{ (cur_page-1) * page_size_limit + users|length}}/{{ total }})
{% endif %}
<a href="{{ctx.homepath}}/profile/domain/general/{{cur_domain}}"><i class="fa fa-cog fa-lg" title="{{ _('Edit domain profile') }}"></i></a>
{{ set_account_activity_img('sent', 'domain', cur_domain, float=false) }}
</h2>
</div>
<div class="box-wrapper clear">
<div id="user_list">
<form name="form_users" id="account_list" method="post" action="{{ctx.homepath}}/users/{{cur_domain}}/page/{{ cur_page }}">
{# Control whether we should redirect to /admins/[domain] or /usrs/[domain] #}
{% if all_are_admins %}
<input type="hidden" name="redirect_to_admin_list" value="yes">
{% endif %}
{{ input_csrf_token() }}
<table class="style1">
<thead>
<tr>
<th class="checkbox"><input type="checkbox" class="checkbox select-all" /></th>
<th data-sort="string-ins"><a href="{{ctx.homepath}}/users/{{cur_domain}}?order_name=name&order_by={% if order_name == 'name' and not order_by_desc %}desc{% else %}asc{% endif %}">{{ _('Display Name') }}</a></th>
<th data-sort="string-ins">{{ _('Mail Address') }}</th>
<th data-sort="string-ins">{{ _('User/Employee ID') }}</th>
{#
<th data-sort="string-ins">{{ _('Job Title') }}</th>
#}
{% if all_are_admins %}
<th data-sort="int">{{ _('Quota') }}</th>
{% else %}
<th data-sort="int"><a href="{{ctx.homepath}}/users/{{cur_domain}}?order_name=quota&order_by={% if order_name == 'quota' and order_by_desc %}asc{% else %}desc{% endif %}">{{ _('Quota') }}</a></th>
{% endif %}
{% if last_logins %}
<th data-sort="int">
{{ _('Last Login') }}
{% if backend != "pgsql" %}
(<a href="{{ ctx.homepath }}/users/{{ cur_domain }}/last_logins">{{ _("All users") }}</a>)
{% endif %}
</th>
{% endif %}
</tr>
</thead>
<tbody>
{% if users %}
{% for r in users %}
{% set mail = r.username |e %}
<tr>
<td class="checkbox">
<input type="checkbox"
name="mail"
class="checkbox"
value="{{ mail }}"
alt="{% if r.active %}active{% else %}disabled{% endif %}"
{% if session.get('is_global_admin') %}
{% if mail == session.get('username') %}disabled="disabled"{% endif %}
{% else %}
{# Normal admin is NOT allowed to enable/disable/delete itself and global admin accounts. #}
{% if mail == session.get('username') or r.isglobaladmin == 1 %}disabled="disabled"{% endif %}
{% endif %}
/>
</td>
<td class="vcenter">
<a href="{{ctx.homepath}}/profile/user/general/{{mail}}">
<i class="fa fa-cog fa-lg fr-space" title="{{ _('Edit account profile') }}{% if r.passwordlastchange %}<br/>{{ _('Password last change:') }} {{ r.passwordlastchange | utc_to_timezone(timezone=session.get('timezone')) }}{% endif %}"></i>
</a>
{{ set_account_activity_img('sent', 'user', mail) }}
{{ set_account_status_img(r.active) }}
{% if r.isglobaladmin %}
{{ set_user_admin_type_img('globaladmin') }}
{% elif r.isadmin %}
{{ set_user_admin_type_img('domainadmin') }}
{% endif %}
{{ set_assigned_groups_img(addresses=user_assigned_groups.get(mail, [])) }}
{{ set_forwarding_address_img(user=mail, addresses=user_forwardings.get(mail, [])) }}
{{ set_alias_address_img(addresses=user_alias_addresses.get(mail, [])) }}
<a href="{{ctx.homepath}}/profile/user/general/{{mail}}" title="{{ _('Edit account profile') }}">{% if r.name %}{{ r.name |cut_string |e }}{% else %}{{ mail.split('@', 1)[0] }}{% endif %}</a>
</td>
<td class="vcenter">{{ highlight_username_in_mail(mail) }}</td>
<td class="vcenter">{% if r.employeeid %}{{ r.employeeid |e }}{% endif %}</td>
{# mail quota #}
{% set usedQuotaBytes = used_quotas.get(mail, {}).get('bytes', 0) %}
{% set usedQuotaMessages = used_quotas.get(mail, {}).get('messages', 0) %}
{% if r.quota == 0 %}
{% if session.get('show_used_quota') %}
<td class="vcenter" data-sort-value="0">{{ usedQuotaBytes |file_size_format }} / {{ _('Unlimited') }}</td>
{% else %}
<td class="vcenter" data-sort-value="0">{{ _('Unlimited') }}</td>
{% endif %}
{% else %}
{% set percent = usedQuotaBytes |convert_to_percentage(r.quota |int * 1024 * 1024) %}
<td class="vcenter" data-sort-value="{{ r.quota }}">
<div>
<span title="{{ _('Edit quota setting') }}"><a href="{{ctx.homepath}}/profile/user/general/{{mail}}">{{ percent }}%</a></span>
<span class="color-grey">(<span title="{{ _('Stored') }}">{{ usedQuotaMessages }} {{_('Emails') }} / {{ usedQuotaBytes |file_size_format }}</span>) / <span title="{{ _('Allocated') }}">{{ r.quota |file_size_format(base_mb=True) }}</span></span>
</div>
{{ display_progress_bar(percent, show_zero=true, width='60%', style='thin') }}
</td>
{% endif %}
{% if last_logins %}
{% if mail in last_logins %}
{% set _times = last_logins.get(mail, {}) %}
{% set _imap = _times.get('imap') or 0 %}
{% set _pop3 = _times.get('pop3') or 0 %}
{% set _lda = _times.get('lda') or 0 %}
{# imap or pop3 login time #}
{% set _login_time = 0 %}
{% set _login_service = None %}
{% if (_imap > 0) and (_pop3 > 0) %}
{% if _imap > _pop3 %}
{% set _login_time = _imap %}
{% set _login_service = 'imap' %}
{% else %}
{% set _login_time = _pop3 %}
{% set _login_service = 'pop3' %}
{% endif %}
{% elif _imap > 0 %}
{% set _login_time = _imap %}
{% set _login_service = 'imap' %}
{% elif _pop3 > 0 %}
{% set _login_time = _pop3 %}
{% set _login_service = 'pop3' %}
{% endif %}
<td data-sort-value="{{ _login_time }}">
{% if _login_time %}
<span title="{% if _imap %}{{ _('IMAP Login:') }} {{ _imap | epoch_seconds_to_gmt | utc_to_timezone(timezone=session.get('timezone')) }}<br/>{% endif %}{% if _pop3 %}{{ _('POP3 Login:') }} {{ _pop3 | epoch_seconds_to_gmt | utc_to_timezone(timezone=session.get('timezone')) }}<br/>{% endif %}{% if _lda %}{{ _('New Mail Delivered:') }} {{ _lda | epoch_seconds_to_gmt | utc_to_timezone(timezone=session.get('timezone')) }}{% endif %}">
{{ _login_time | epoch_seconds_to_gmt | utc_to_timezone(timezone=session.get('timezone')) }}
{% if _login_service %}
{{ _login_service | upper }}
{% endif %}
</span>
{% endif %}
</td>
{% else %}
<td data-sort-value="0"></td>
{% endif %}
{% endif %}
</tr>
{% endfor %}
{% else %}
<tr>
<td class="checkbox"></td>
{% if all_are_admins %}
<td colspan="4">{{ _('No mail admin assigned.') }}</td>
{% else %}
<td colspan="4">{{ _('No mail user available.') }}
{% if not (first_char or disabled_only) %}
<a href="{{ctx.homepath}}/create/user/{{ cur_domain }}">{{ _('Add one') }}</a>?
{% endif %}
</td>
{% endif %}
</tr>
{% endif %}
</tbody>
</table>
<input type="hidden" name="cur_page" value="{{cur_page}}" />
{% if users %}
<div class="tab-footer clear f1">
<div class="fl">
<select name="action" class="fl-space" id="account_list_actions" >
<option>{{ _('Choose Action') }}</option>
<option disabled>----</option>
<option value="enable">{{ _('Enable') }}</option>
<option value="disable">{{ _('Disable') }}</option>
<option value="delete">{{ _('Delete') }}</option>
<option disabled>----</option>
<option value="markasadmin">{{ _('Mark as domain admin') }}</option>
<option value="unmarkasadmin">{{ _('Unmark as domain admin') }}</option>
{% if session.get('is_global_admin') %}
<option disabled>----</option>
<option value="markasglobaladmin">{{ _('Mark as global admin') }}</option>
<option value="unmarkasglobaladmin">{{ _('Unmark as global admin') }}</option>
{% endif %}
</select>
<select name="keep_mailbox_days" class="fl-space" id="account_delete_date">
{% for _day in days_to_keep_removed_mailbox %}
<option value="{{ _day }}">{{ display_remove_mailbox_days(_day) }}</option>
{% endfor %}
</select>
<input type="submit" name="submit_users" value="{{ _('Apply') }}" class="button fl-space" />
</div>
{% if all_are_admins %}
{% set baseurl = ctx.homepath + '/admins/' + cur_domain %}
{% else %}
{% set baseurl = ctx.homepath + '/users/' + cur_domain %}
{% endif %}
{% if disabled_only %}
{% set baseurl = baseurl + '/disabled' %}
{% endif %}
{% if all_are_admins %}
{{ show_pages(baseurl=baseurl,
total=total,
cur_page=cur_page) }}
{% else %}
{{ show_pages(baseurl=baseurl,
total=total,
cur_page=cur_page,
url_suffix=ctx.query) }}
{% endif %}
</div>
{% endif %}
</form>
</div>{# #user_list #}
</div>{# .box-wrapper #}
</div>{# -- End id=user_list -- #}
</div>
{% endif %}
{% endblock main %}

View File

@@ -0,0 +1,606 @@
{% extends "layout.html" %}
{% from "macros/form_inputs.html" import
input_submit,
input_csrf_token
with context
%}
{% from "macros/general.html" import
display_subnav,
set_account_activity_img,
display_input_cn,
display_preferred_language,
display_timezones,
display_quota,
display_change_email_address,
display_input_employeeid,
display_account_status,
display_mark_user_as_admin,
display_reset_password,
display_random_password,
display_user_forwarding,
display_recipient_bcc,
display_sender_bcc,
display_relay,
display_sender_relayhost,
display_per_account_wblist_all,
display_allow_nets
with context
%}
{% from "macros/sql.html" import
display_enabled_user_services,
display_all_domains
with context
%}
{% from "macros/iredapd.html" import
display_throttle_setting,
display_greylisting_setting,
display_greylisting_whitelists
with context
%}
{% from "macros/amavisd.html" import display_spam_policy with context %}
{% from "macros/msg_handlers.html" import warning_info, user_msg_handler with context %}
{% block title %}{{ _('Edit account profile') }}{% endblock %}
{% block navlinks_domains %}class="active"{% endblock %}
{% block breadcrumb %}
{% set tmp_crumbs = [
(ctx.homepath + '/domains', _('All domains')),
(ctx.homepath + '/profile/domain/general/' + cur_domain, cur_domain),
(ctx.homepath + '/users/' + cur_domain, _('Users')),
('active', ctx.homepath + '/profile/user/general/' + mail, _('Profile of user:') + '&nbsp;' + mail),
(ctx.homepath + '/mls/' + cur_domain, _('Mailing Lists')),
(ctx.homepath + '/aliases/' + cur_domain, _('Aliases')),
] %}
{% if session.get('is_global_admin') %}
{% set crumbs = tmp_crumbs + [(ctx.homepath + '/admins/' + cur_domain, _('Admins'))] %}
{% else %}
{% set crumbs = tmp_crumbs %}
{% endif %}
{% if backend != "pgsql" %}
{% set crumbs = crumbs + [(ctx.homepath + '/users/' + cur_domain + '/last_logins', _('Last Logins'))] %}
{% endif %}
{{ display_subnav(crumbs) }}
{% endblock %}
{% block main %}
{# Show system message #}
{% if msg %}
{% if msg.startswith('PW_') %}
{% set _pw_errors = msg.split(',') %}
{% for _err in _pw_errors %}
{{ user_msg_handler(_err) }}
{% endfor %}
{% else %}
{{ user_msg_handler(msg) }}
{% endif %}
{% endif %}
{% if discarded_aliases %}
{% set _msg = _('Some addresses have been discarded because they have been used: %s.') |format(discarded_aliases | join(', ')) %}
{{ warning_info(msg=_msg, removable=true) }}
{% endif %}
{% if session.get('is_global_admin') %}
{% set navlinks = [
('general', _('General'), [true]),
('forwarding', _('Forwarding'), [true]),
('bcc', _('BCC'), [true]),
('relay', _('Relay'), [true]),
('aliases', _('Aliases'), [true]),
('throttle', _('Throttling'), [session.get('iredapd_enabled')]),
('greylisting', _('Greylisting'), [session.get('iredapd_enabled')]),
('wblist', _('White/Blacklists'), [session.get('amavisd_enable_policy_lookup')]),
('spampolicy', _('Spam Policy'), [session.get('amavisd_enable_policy_lookup')]),
('password', _('Password'), [true]),
('advanced', _('Advanced'), [true]),
]
%}
{% else %}
{% set navlinks = [
('general', _('General'), [true]),
('forwarding', _('Forwarding'), ['forwarding' not in disabled_user_profiles]),
('bcc', _('BCC'), ['bcc' not in disabled_user_profiles]),
('relay', _('Relay'), ['relay' not in disabled_user_profiles]),
('aliases', _('Aliases'), ['aliases' not in disabled_user_profiles]),
('throttle', _('Throttling'), ['throttle' not in disabled_user_profiles, session.get('iredapd_enabled')]),
('greylisting', _('Greylisting'), ['greylisting' not in disabled_user_profiles, session.get('iredapd_enabled')]),
('wblist', _('White/Blacklists'), [session.get('amavisd_enable_policy_lookup'), 'wblist' not in disabled_user_profiles]),
('spampolicy', _('Spam Policy'), [session.get('amavisd_enable_policy_lookup'), 'spampolicy' not in disabled_user_profiles]),
('password', _('Password'), [true]),
('advanced', _('Advanced'), [true]),
]
%}
{% endif %}
<div class="content-box">
<div class="box-body">
<div class="box-header clear">
<ul class="tabs clear">
{% for nav in navlinks %}
{% if not false in nav[2] and not none in nav[2] %}
<li><a href="#profile_{{nav[0]}}">{{ nav[1] }}</a></li>
{% endif %}
{% endfor %}
</ul>
<h2>{{ set_account_activity_img('sent', 'user', mail, float=false) }}</h2>
</div>
{# modal window used to change email address #}
{{ display_change_email_address(current_domain=cur_domain,
post_url=ctx.homepath + '/profile/user/rename/' + mail ) }}
<div class="box-wrap clear">
<div id="profile_general">
<form name="general" method="post" action="{{ctx.homepath}}/profile/user/general/{{mail}}">
{{ input_csrf_token() }}
{# imap or pop3 login time #}
{% set _login_time = 0 %}
{% set _login_service = None %}
{% set _times = last_logins.get(mail, {}) %}
{# values may be None, so we use `or 0` to set it to `0` #}
{% set _imap = _times.get('imap', 0) or 0 %}
{% set _pop3 = _times.get('pop3', 0) or 0 %}
{% set _lda = _times.get('lda', 0) or 0 %}
{% if (_imap > 0) and (_pop3 > 0) %}
{% if _imap > _pop3 %}
{% set _login_time = _imap %}
{% set _login_service = 'imap' %}
{% else %}
{% set _login_time = _pop3 %}
{% set _login_service = 'pop3' %}
{% endif %}
{% elif _imap > 0 %}
{% set _login_time = _imap %}
{% set _login_service = 'imap' %}
{% elif _pop3 > 0 %}
{% set _login_time = _pop3 %}
{% set _login_service = 'pop3' %}
{% endif %}
<div class="columns clear">
<div class="col2-3">
{{ display_account_status(profile.active,
last_login_epoch_seconds=_login_time,
last_login_service=_login_service) }}
<div class="bt-space10"></div>
{{ display_input_cn(value=profile.name, email=mail, empty_if_equal_to_username=true) }}
{% set stored_mailbox_size = used_quota.get(mail, {}).get('bytes', 0) %}
{% set stored_mailbox_messages = used_quota.get(mail, {}).get('messages', 0) %}
{{ display_quota(value=profile.quota,
show_value_in_input=true,
used_quota=stored_mailbox_size,
stored_messages=stored_mailbox_messages,
show_used_quota=true) }}
{{ display_preferred_language(value=profile.get('language'), languagemaps=languagemaps) }}
{{ display_timezones(value=user_settings.get('timezone'), timezones=timezones) }}
<div class="bt-space10"></div>
{{ display_input_employeeid(profile.employeeid) }}
</div>{#-- .col2-3 --#}
<div class="col1-3 lastcol">
{% if _login_time or _lda %}
<div class="mark_blue bt-space10">
<ul class="standard clean-padding bt-space10">
{% if _imap %}
<li class="bt-space5">{{ _('IMAP Login:') }} {{ _imap | epoch_seconds_to_gmt | utc_to_timezone(timezone=session.get('timezone')) }}</li>
{% endif %}
{% if _pop3 %}
<li class="bt-space5">{{ _('POP3 Login:') }} {{ _pop3 | epoch_seconds_to_gmt | utc_to_timezone(timezone=session.get('timezone')) }}</li>
{% endif %}
{% if _lda %}
<li class="bt-space5">{{ _('New Mail Delivered:') }} {{ _lda | epoch_seconds_to_gmt | utc_to_timezone(timezone=session.get('timezone')) }}</li>
{% endif %}
</ul>
</div>
{% endif %}
<div class="mark_blue bt-space10">
<ul class="standard clean-padding bt-space10">
<li><a href="#change_email_address" class="modal-link"><span class="text">{{ _('Change email address') }}</span></a></li>
<li class="bt-space5">{{ _('You can enable self-service (per-domain setting) to allow users to manage their own preferences and more.') }}</li>
</ul>
</div>
</div>{# .col1-3 #}
</div>{#-- .columns --#}
<div class="rule"></div>
<div class="columns clear">
<div class="col2-3">
<div class="form-field clear">
<h4 class="size-250 fl-space">{{ _('Member of Mailing Lists') }}</h4>
<div class="checklist clear">
<fieldset>
{% for ml_profile in all_maillist_profiles %}
{% set ml_mail = ml_profile.address |e %}
{% set ml_name = ml_profile.name |e %}
<div class="checklist-item">
<span class="fl-space">
<input type="checkbox" name="subscribed_list" value="{{ ml_mail }}" {% if ml_mail in all_subscribed_lists %}checked="checked"{% endif %} />
</span>
<label>
{%- if ml_name -%}
<a href="{{ctx.homepath}}/profile/ml/general/{{ ml_mail }}">{{ ml_name }}</a>&nbsp;({{ ml_mail }})
{%- else -%}
<a href="{{ctx.homepath}}/profile/ml/general/{{ ml_mail }}">{{ ml_mail }}</a>
{%- endif -%}
</label>
</div>
<div class="clear"></div>
{% endfor %}
</fieldset>
</div>{#-- .checklist --#}
</div>{#-- form-field --#}
</div>{#-- End col2-3 -- #}
<div class="col1-3 lastcol">
<div class="mark_blue bt-space10">
<ul class="standard clean-padding bt-space10">
<li class="bt-space5"><a href="{{ctx.homepath}}/create/ml/{{ cur_domain }}">{{ _('Add mailing list') }}</a></li>
</ul>
</div>
</div>{# .col1-3 #}
</div>{#-- .columns --#}
<div class="rule"></div>
<div class="columns clear">
<div class="col2-3">
<div class="form-field clear">
<h4 class="size-250 fl-space">{{ _('Member of Mail Aliases') }}</h4>
<div class="checklist clear">
<fieldset>
{% for _profile in all_aliases %}
{% set _name = _profile.name |e %}
{% set _mail = _profile.address |e %}
<div class="checklist-item">
<span class="fl-space">
<input type="checkbox" name="memberOfGroup" value="{{ _mail }}" {% if _mail in assigned_aliases %}checked="checked"{% endif %} />
</span>
<label><a href="{{ctx.homepath}}/profile/alias/general/{{ _mail }}">{{ _name }}</a>&nbsp;({{ _mail }})</label>
</div>
<div class="clear"></div>
{% endfor %}
{# Display assigned aliases which is not in same domain as current user #}
{% for _mail in assigned_aliases %}
{% if not _mail.endswith('@' + cur_domain) %}
<div class="checklist-item">
<span class="fl-space">
<input type="checkbox" name="memberOfGroup" value="{{ _mail }}" checked="checked" />
</span>
<label><a href="{{ctx.homepath}}/profile/alias/general/{{ _mail }}">{{ _mail }}</a></label>
</div>
<div class="clear"></div>
{% endif %}
{% endfor %}
</fieldset>
</div>{#-- .checklist --#}
</div>{#-- form-field --#}
</div>{#-- End col2-3 -- #}
<div class="col1-3 lastcol">
<div class="mark_blue bt-space10">
<ul class="standard clean-padding bt-space10">
<li class="bt-space5"><a href="{{ctx.homepath}}/create/alias/{{ cur_domain }}">{{ _('Add mail alias') }}</a></li>
</ul>
</div>
</div>{# .col1-3 #}
</div>{#-- .columns --#}
{% if session.get('is_global_admin') or session.get('allowed_to_grant_admin') %}
<div class="rule"></div>
<div class="columns clear">
<div class="col2-3">
{{ display_mark_user_as_admin(is_domain_admin=profile.get('isadmin', 0),
is_global_admin=profile.get('isglobaladmin', 0),
allowed_to_grant_admin=user_settings.get('grant_admin', 'no'),
user_settings=user_settings) }}
</div>
{% if session.get('is_global_admin') %}
<div class="col1-3 lastcol normal_admin_options">
<div class="mark_blue bt-space10">
<ul class="standard clean-padding bt-space10">
<li>{{ _('All domains managed by this admin share the mailbox quota and limit of mail accounts.') }}</li>
<li>{{ _('Domain ownership verification is recommended if you can not fully trust this admin, because if domains like gmail.com, hotmail.com were added locally, all emails sent to gmail.com/hotmail.com will be delivered locally on your server instead of the real Gmail/Hotmail servers.') }}</li>
</ul>
</div>
</div>{# .col1-3 #}
{% endif %}
</div>
{{ display_all_domains(managedDomains=managed_domains, allDomains=all_domains) }}
{% endif %}
{{ input_submit() }}
</form>
</div>{# #profile_general #}
{# profile_type == 'forwarding' #}
{% if session.get('is_global_admin') or 'forwarding' not in disabled_user_profiles %}
<div id="profile_forwarding">
<form name="forwarding" method="post" action="{{ctx.homepath}}/profile/user/forwarding/{{mail}}">
{{ input_csrf_token() }}
{{ display_user_forwarding(mail=mail,
enabled=none,
forwarding_addresses=profile.forwardings) }}
{{ input_submit() }}
</form>
</div>{# #profile_forwarding #}
{% endif %}
{# profile_type: bcc #}
{% if session.get('is_global_admin') or 'bcc' not in disabled_user_profiles %}
<div id="profile_bcc">
<form name="bcc" method="post" action="{{ctx.homepath}}/profile/user/bcc/{{mail}}">
{{ input_csrf_token() }}
{# BCC #}
<div class="columns clear">
<div class="col2-3 ">
<div class="form-field clear">
<h4 class="size-250 fl-space">{{ _('Monitor incoming emails via BCC') }}</h4>
<div class="clear">
<input type="checkbox"
name="recipientbcc"
class="checkbox"
rel="checkboxhorizont"
{% if profile.rbcc_active in [1, '1'] %}checked="checked"{%endif%}
/>
</div>
</div>
<div class="form-field clear">
<h4 class="size-250 fl-space">{{ _('Monitor outgoing emails via BCC') }}</h4>
<div class="clear">
<input type="checkbox"
name="senderbcc"
{% if profile.sbcc_active in [1, '1'] %}checked="checked"{%endif%}
class="checkbox"
rel="checkboxhorizont"
/>
</div>
</div>
{{ display_recipient_bcc(address=profile.recipient_bcc_address) }}
{{ display_sender_bcc(address=profile.sender_bcc_address) }}
</div>
<div class="col1-3 lastcol">
<div class="mark_blue bt-space10">
<ul class="standard clean-padding bt-space10">
<li class="bt-space5">{{ _('Multiple addresses are NOT supported.') }}</li>
<li class="bt-space5">{{ _('Per-user bcc settings has higher priority than per-domain bcc settings.') }}</li>
<li class="bt-space5">{{ _('Invalid email addresses will be silently discarded.') }}</li>
</ul>
</div>
</div>{#-- .col1-3 --#}
</div>
{{ input_submit() }}
</form>
</div>
{% endif %}
{# Relay #}
{% if session.get('is_global_admin') or 'relay' not in disabled_user_profiles %}
<div id="profile_relay">
<form name="relay" method="post" action="{{ctx.homepath}}/profile/user/relay/{{mail}}">
{{ input_csrf_token() }}
{{ display_relay(profile.transport |default('') |e,
account_type='user',
url=ctx.homepath + '/profile/domain/relay/' + cur_domain) }}
<div class="rule"></div>
{{ display_sender_relayhost(relayhost=relayhost) }}
{{ input_submit() }}
</form>
</div>
{% endif %}
{# Aliases #}
{% if session.get('is_global_admin') or 'aliases' not in disabled_user_profiles %}
<div id="profile_aliases">
<form name="aliases" method="post" action="{{ctx.homepath}}/profile/user/aliases/{{mail}}">
{{ input_csrf_token() }}
<div class="columns clear">
<div class="col2-3">
<div class="form-field clear">
<h4 class="size-250 fl-space">{{ _('Email addresses of alias accounts') }}</h4>
<small>{{ _('One mail address per line. Invalid address will be discarded.') }}</small>
</div>
<div class="form-field clear">
<h4 class="size-250 fl-space"></h4>
<textarea name="user_alias_addresses"
rows="6"
style="width: 50%"
class="textarea"
>{%- for addr in user_alias_addresses %}{{ addr |e }}
{% endfor -%}
</textarea>
</div>
</div>{#-- .col2-3 --#}
<div class="col1-3 lastcol">
<div class="mark_blue bt-space10">
<ul class="standard clean-padding bt-space10">
<li class="bt-space5">{{ _('Emails sent to alias addresses will be delivered to %s.') |format('<strong>' + mail + '</strong>') }}</li>
{% if user_alias_cross_all_domains is sameas false %}
<li class="bt-space5">{{ _('Email address of alias account must end with domain name(s): %s.') |format('<strong>' + cur_domain + '</strong>') }}</li>
{% endif %}
</ul>
</div>
</div>
</div>{#-- .columns --#}
{{ input_submit() }}
</form>
</div>
{% endif %}
{# Throttling #}
{% if session.get('iredapd_enabled') and (session.get('is_global_admin') or ('throttle' not in disabled_user_profiles)) %}
<div id="profile_throttle">
<form name="throttle" method="post" action="{{ctx.homepath}}/profile/user/throttle/{{mail}}">
{{ input_csrf_token() }}
{# Throttling in iRedAPD#}
<div class="columns clear">
{{ display_throttle_setting(account=mail,
setting=outbound_throttle_setting,
inout_type='outbound') }}
{{ display_throttle_setting(account=mail,
setting=inbound_throttle_setting,
inout_type='inbound',
with_left_border=true) }}
<div class="col1-3 lastcol">
<div class="mark_blue bt-space10">
<ul class="standard clean-padding bt-space10">
<li class="bt-space5">{{ _('You can set per-domain throttling in domain profile page.') }}</li>
</ul>
</div>
</div>{#-- .col1-3 --#}
</div>{# .columns #}
{{ input_submit() }}
</form>
</div>{# #profile_throttle #}
{% endif %}
{# profile_type: greylisting, with iRedAPD #}
{% if 'greylisting' not in disabled_user_profiles %}
{% if session.get('iredapd_enabled') %}
<div id="profile_greylisting">
<form name="greylisting" method="post" action="{{ctx.homepath}}/profile/user/greylisting/{{mail}}">
{{ input_csrf_token() }}
{{ display_greylisting_setting(account=mail, gl_setting=gl_setting) }}
{{ display_greylisting_whitelists(account=mail, gl_whitelists=gl_whitelists) }}
{{ input_submit() }}
</form>
</div>
{% endif %}
{% endif %}
{# wblist #}
{% if session.get('amavisd_enable_policy_lookup') and (session.get('is_global_admin') or ('wblist' not in disabled_user_profiles)) %}
<div id="profile_wblist">
<form name="wblist" method="post" action="{{ctx.homepath}}/profile/user/wblist/{{mail}}">
{{ input_csrf_token() }}
{{ display_per_account_wblist_all(inbound_whitelists=whitelists,
inbound_blacklists=blacklists,
outbound_whitelists=outbound_whitelists,
outbound_blacklists=outbound_blacklists) }}
{{ input_submit() }}
</form>
</div>
{% endif %}
{# Spam Policy#}
{% if session.get('amavisd_enable_policy_lookup') and (session.get('is_global_admin') or ('spampolicy' not in disabled_user_profiles)) %}
<div id="profile_spampolicy">
<form name="spampolicy" method="post" action="{{ctx.homepath}}/profile/user/spampolicy/{{mail}}">
{{ input_csrf_token() }}
<div class="columns clear">
{{ display_spam_policy(account_type='user',
spampolicy=spampolicy,
custom_ban_rules=custom_ban_rules,
global_spam_score=global_spam_score) }}
{{ input_submit() }}
</div>
</form>
</div>
{% endif %}
{# Password #}
<div id="profile_password">
<form name="password" method="post" action="{{ctx.homepath}}/profile/user/password/{{mail}}">
{{ input_csrf_token() }}
<div class="columns clear">
<div class="col3-4">
{{ display_reset_password(show_confirmpw=true,
min_passwd_length=min_passwd_length,
max_passwd_length=max_passwd_length,
store_password_in_plain_text=store_password_in_plain_text) }}
</div>
<div class="col1-4 lastcol">
{{ display_random_password(password_length=min_passwd_length,
password_policies=password_policies,
password_last_change_date=profile.passwordlastchange) }}
</div>
</div>
{{ input_submit() }}
</form>
</div>
<div id="profile_advanced">
<form name="advanced" method="post" action="{{ctx.homepath}}/profile/user/advanced/{{mail}}">
{{ input_csrf_token() }}
{{ display_enabled_user_services(profile=profile, greylisted=greylisted) }}
<div class="rule"></div>
{{ display_allow_nets(allow_nets=allow_nets) }}
<div class="rule"></div>
{% if session.get('is_global_admin') %}
{# Maildir path #}
<div class="form-field clear">
<h4 class="size-250 fl-space">{{ _('Path to mailbox') }}</h4>
<input type="text" name="storageBaseDirectory" value="{{ profile.storagebasedirectory |default('') |e }}" size="{{ storageBaseDirectory |length}}" class="fl-space text" />
<span class="vcenter">/</span>
<input type="text" name="storageNode" value="{{ profile.storagenode |default('') |e }}" />
<span class="vcenter">/</span>
<input type="text" name="mailMessageStore" value="{{ profile.maildir |default('') }}" size="{{ profile.maildir |length }}" class="text" />
</div>
{% endif %}
{{ input_submit() }}
</form>
</div>
</div>
</div>
</div>
{% endblock main %}
{% block extra_js %}
<script type="text/javascript">
$(document).ready(function() {
$(".tabs li").idTabs("profile_{{ profile_type }}");
$('#domain_search').quickfilter('#all_domains tr');
});
</script>
{% endblock extra_js %}