Source

iredadmin-ose / templates / default / macros / general.html

Full commit
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
{# ------------ Load JS files ------------- #}
{% macro load_jquery(plugins=[], nonSortedCols=[], defaultPlugins=['tooltip', 'idtabs', 'fancybox'], quarantined=false) -%}
    {#
        Available jQuery plugins:
        [idtabs, jeditable, visualize, fancybox, idtabs, ui, jcarousel, validate,]

        excanvas.js,
        cufon.js,
    #}
    <script type="text/javascript" src="{{ctx.homepath}}/static/js/jquery-1.4.2.min.js"></script>

    {% for p in defaultPlugins %}
        <script type="text/javascript" src="{{ctx.homepath}}/static/js/jquery.{{p}}.js"></script>
    {% endfor %}

    {% for p in plugins %}
        <script type="text/javascript" src="{{ctx.homepath}}/static/js/jquery.{{p}}.js"></script>
    {% endfor %}

    {#
    <script type="text/javascript" src="{{ctx.homepath}}/static/js/cufon.js"></script>
    <script type="text/javascript" src="{{ctx.homepath}}/static/js/Zurich_Condensed_Lt_Bd.js"></script>
    #}

    <script type="text/javascript">
    {# Access URL to get RAW mail of quarantined mail. #}
    {% if quarantined is sameas true %}
        function displayRawQuarantinedMail() {
            //$('.box-slide-head').click(function (event) {
            $('.box-slide-head > td > span').click(function (event) {
                tgt = $(event.target);
                if (tgt.hasClass('clickable')) {
                    return;
                }

                //mailid = $(this).attr('id');
                mailid = $(this).parents('tr').attr('id');
                mailid_orig = $(this).parents('tr').attr('mailid');
                body = $('#box-tr-'+mailid);
                if (!body.hasClass('box-slide-tr')) {
                    $.get('{{ctx.homepath}}/activities/quarantined/raw/'+mailid_orig, function(data) {
                        if (data != ''){
                            $('#'+mailid).after(data);
                        }
                    });
                }
                if (body.is(':visible')) {
                    body.hide();
                } else {
                    body.show();
                }
                return false;
            });
        }
    {% endif %}

    {# Addition JS/jQuery functions #}
    $(document).ready(function() {
        {# -- Menus -- #}
        $('.menu li').hover(function () {
            $(this).find('ul:first').css({'visibility': 'visible', 'display': 'none'}).slideDown();
        }, function () {
            $(this).find('ul:first').css({visibility: "hidden"});
        });

        {#-- Content Boxes --#}
        $('.content-box .select-all').click(function () {
            if ($(this).is(':checked'))
                $(this).parent().parent().parent().parent().find(':checkbox').attr('checked', true);
            else
                $(this).parent().parent().parent().parent().find(':checkbox').attr('checked', false);
        });

        /* Tabs */
        $('.content-box .tabs').idTabs();

        {# Notifications #}
        $('.notification .close').click(function () {
            $(this).parent().fadeOut(300);
            return false;
        });

        {# tooltip #}
        $("a[title], img[title], span[title], input[title]").tooltip({
            position: "top center",
            offset: [-5, 0],
            predelay: 300,
            delay: 100,
            effect: "fade",
            opacity: 1
        });

        {% if 'tablesorter' in plugins %}
            $(".tablesorter").tablesorter(
                {% if nonSortedCols |length > 0 %}
                    { headers: {
                        {% for col in nonSortedCols %}
                            {{ col }}: {sorter: false }{% if not loop.last %},{% endif %}
                        {% endfor %}
                    }}
                {% endif %}
            );
        {% endif %}

        $('.onFocusEmpty').focus(function () {
            $(this).val('');
        });

        {# -- Fancybox -- #}
        $('.modal-link').fancybox({
            'modal'                 : false,
            'hideOnOverlayClick'    : true,
            'hideOnContentClick'    : false,
            'enableEscapeButton'    : true,
            'showCloseButton'       : true
        });
        $("a[href$='gif']").fancybox();
        $("a[href$='jpg']").fancybox();
        $("a[href$='png']").fancybox();

        {% if quarantined is sameas true %}
            displayRawQuarantinedMail();
        {% endif %}

        {# -- Cufon -- #}
        {#
        Cufon.replace('.logo .title', { fontFamily: 'Zurich Cn BT', color: '-linear-gradient(#FFFFFF, #FFFFFF, #c0c0c0, rgb(200, 200, 200))', textShadow: '#FFFFFF 0px 1px'});
        Cufon.replace('.user-detail .name', { fontFamily: 'Zurich Cn BT' });
        Cufon.replace('.visualize-title', { fontFamily: 'Zurich Cn BT' });
        Cufon.replace('table caption', { fontFamily: 'Zurich Cn BT' });

        Cufon.replace('h1', { fontFamily: 'Zurich LtCn BT' });
        Cufon.replace('h2', { fontFamily: 'Zurich Cn BT' });
        Cufon.replace('h3', { fontFamily: 'Zurich LtCn BT' });
        Cufon.replace('h4', { fontFamily: 'Zurich Cn BT' });
        Cufon.replace('h5', { fontFamily: 'Zurich Cn BT' });
        Cufon.replace('h6', { fontFamily: 'Zurich LtCn BT' });
        Cufon.replace('h1 .label', { fontFamily: 'Zurich Cn BT' });
        #}
    });
    </script>

{%- endmacro %}
{# ------------ END Load JS files ------------- #}

{% macro load_jquery_quicksearch() -%}
    $("input.quickSearch").quicksearch("table.dataList tbody tr");
{%- endmacro %}

{# ------------ END Load jQuery $(document).read() functions ------------- #}


{%- macro display_subnav(crumbs) -%}
    {# Crumb format: (link, label), ('active', link, label) #}
    {% if crumbs | length > 0 %}
        <div class="breadcrumb">
            <div class="pagesize">
                <ul id="breadcrumb">
                    {% for crb in crumbs %}
                        <li>
                            {%- if crb |length == 2 -%}
                                <a href="{{ crb[0] }}">{{ crb[1] }}</a>
                            {%- elif crb |length ==3 -%}
                                <a href="{{ crb[1] }}" class="inactive"><strong>{{ crb[2] }}</strong></a>
                            {%- endif -%}
                            {% if not loop.last %}/{% endif %}
                        </li>
                    {% endfor %}
                </ul>
            </div>
        </div>
    {% endif %}
{%- endmacro -%}

{% macro set_account_status_img(status, float="right", tooltip=true, vcenter=true) -%}
    {% if float == 'right' %}
        {% set imgfloat = 'fr-space' %}
    {% elif float == 'left' %}
        {% set imgfloat = 'fl-space' %}
    {% elif float == 'center' %}
        {% set imgfloat = 'fl-space' %}
    {% else %}
        {% set imgfloat = '' %}
    {% endif %}

    {% if status == 'active' or status |string == '1' %}
        <img src="{{ctx.homepath}}/static/{{skin}}/images/enabled.png" class="{{ imgfloat }}" {% if tooltip is sameas true %}title="{{ _('Account is active.') }}"{% endif %} {% if vcenter is sameas true %}style="vertical-align: middle;"{% endif %}/>
    {% else %}
        {% set tooltip = _('Account is disabled.') %}
        <img src="{{ctx.homepath}}/static/{{skin}}/images/ball_grey_16.png" class="{{ imgfloat }}" {% if tooltip is sameas true %}title="{{ _('Account is disabled.') }}"{% endif %} {% if vcenter is sameas true %}style="vertical-align: middle;"{% endif %}/>
    {% endif %}
{%- endmacro %}

{% macro set_admin_type_img(value) -%}
    {% if value == 'yes' %}
        <img src="{{ctx.homepath}}/static/{{skin}}/images/enabled.png" class="block" title="{{ _('Is a global admin.') }}" alt="" />
    {% else %}
        <img src="{{ctx.homepath}}/static/{{skin}}/images/ball_grey_16.png" class="block" title="{{ _('Not a global admin.') }}" alt="" />
    {% endif %}
{%- endmacro %}

{% macro display_button_submit(label=none, color='green') -%}
    <div class="rule2"></div>
    <div class="form-field clear">
        <h4 class="size-250 fl-space">&nbsp;</h4>
        <span>
            <input type="submit" value="{% if label is not sameas none %}{{ label |e }}{% else %}{{ _('Save changes') }}{% endif %}" class="button {{ color |e }}" />
        </span>
    </div>
{%- endmacro %}

{% macro display_progress_bar(percent, tooltip=none, show_zero=false, style='normal', width='100%') -%}
    {% set percent = percent |int %}
    {% if percent < 0 %}
        {% set percent = 0 %}
    {% elif percent > 100 %}
        {% set percent = 100 %}
    {% endif %}

    {% if tooltip is sameas none %}
        {% set tooltip = percent |string + '%' %}
    {% endif %}

    {% if style == 'thin' %}
        {% set height = '3px' %}
    {% else %}
        {% set height = '1.6em' %}
    {% endif %}

    {% if percent < 80 %}
        {% set bgcolor = '#ACE97C' %}
    {% elif 80 <= percent < 90 %}
        {% set bgcolor = 'yellow' %}
    {% elif 90 <= percent < 99 %}
        {% set bgcolor = '#F76541' %}
    {% else %}
        {% set bgcolor = '#F62217' %}
    {% endif %}

    {% if percent > 0 or show_zero is sameas true %}
        <div class="progress-container" title="{{ tooltip |e }}" style="width: {{width |e }}; height: {{height}};">
            <div class="progress-bar" style="height: {{height}}; width: {{percent}}%; background-color: {{bgcolor}};"></div>
        </div>
    {% endif %}
{%- endmacro %}


{% macro display_csrf_token(token=none) -%}
    {% if token is sameas none %}
        {% set token = csrf_token() %}
    {% else %}
        {% set token = token |e %}
    {% endif %}

    <input type="hidden" name="csrf_token" value="{{ token }}"/>
{%- endmacro %}


{% macro display_input_employeeid(value='') -%}
    {% if value is sameas none %}
        {% set value = '' %}
    {% endif %}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('User ID') }}</h4>
        <span class="clean-padding bt-space20"><input type="text" name="employeeNumber" value="{% if value != 'None' %}{{ value |e }}{% endif %}" size="35" class="text" /></span>
    </div>
{%- endmacro %}

{% macro display_input_jobtitle(value='') -%}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('Job Title/Responsibility') }}</h4>
        <span class="clean-padding bt-space20"><input type="text" name="title" value="{% if value != 'None' %}{{ value |e }}{% endif %}" size="35" class="text" /></span>
    </div>
{%- endmacro %}

{% macro display_input_mobile(value) -%}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('Mobile') }}</h4>
        <span class="clean-padding bt-space20"><input type="text" name="mobile" value="{{ value |e }}" size="35" class="text" /></span>
    </div>
{%- endmacro %}

{% macro display_input_phone(value=[]) -%}
    {% if value |length == 0 %}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('Telephone Number') }}</h4>
        <span class="clean-padding bt-space20">
            <input type="text" name="telephoneNumber" value="" size="35" class="text" />
        </span>
    </div>
    {% else %}
        {% for phone in value %}
        <div class="form-field clear">
            {% if loop.first %}
                <h4 class="size-250 fl-space">{{ _('Telephone Number') }}</h4>
            {% else %}
                <h4 class="size-250 fl-space">&nbsp;</h4>
            {% endif %}
            <span class="clean-padding bt-space20">
                <input type="text" name="telephoneNumber" value="{{ phone |e }}" size="35" class="text" />
            </span>
        </div>
        {% endfor %}
    {% endif %}

    {#-- Always display one more field to input new value --#}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">&nbsp;</h4>
        <span class="clean-padding bt-space20">
            <input type="text" name="telephoneNumber" value="" size="35" class="text" />
        </span>
    </div>
{%- endmacro %}

{% macro display_preferred_language(value='', languagemaps=['en_US',]) -%}
<div class="form-field clear">
    <h4 class="size-250 fl-space">{{ _('Preferred language') }}</h4>
    <select name="preferredLanguage">
        {% for lang in languagemaps %}
            <option value="{{ lang |e }}" {% if value == lang %}selected{%endif%}>{{ languagemaps[lang] |e }}</option>
        {% endfor %}
    </select>
</div>
{%- endmacro %}

{% macro display_in_global_address_book(enabledService=[]) %}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _("Displayed in Global LDAP Address Book") }}</h4>
        <div class="form-checkbox-item clear">
            <input name="displayedInGlobalAddressBook" {% if 'displayedInGlobalAddressBook' in enabledService %}checked{% endif %} type="checkbox" rel="checkboxhorizont" class="checkbox" />
        </div>
    </div>
{%- endmacro %}


{% macro display_input_global_admin(value='no') %}
<div class="form-field clear">
    <h4 class="size-250 fl-space">{{ _('Mark as global admin') }}</h4>
    <div class="form-checkbox-item clear">
        {#
            ldap: yes, no
            mysql: true, false
        #}
        <span class="clean-padding bt-space20"><input class="checkbox" name="domainGlobalAdmin" value="yes" type="checkbox" {% if value in ['yes', true,] %}checked{%endif%} /></span>
    </div>
</div>
{%- endmacro %}


{% macro display_mark_user_as_admin(is_domain_admin=false, is_global_admin=false) %}
{# possible value: 0, 1 (SQL), or true, yes, false, no (LDAP) #}
{% if session.get('domainGlobalAdmin') is sameas true %}
<div class="form-field clear">
    <h4 class="size-250 fl-space">{{ _('Mark this user as') }}</h4>
    <div class="form-checkbox-item clear">
        <span class="clean-padding bt-space20"><input class="checkbox" name="domainGlobalAdmin" value="global" type="checkbox" {% if is_global_admin in [1, true, 'yes'] %}checked{%endif%} /> {{ _('Global admin') }}</span>
    </div>
</div>
{% endif %}
{%- endmacro %}


{# Used to display domainMaxXXXNumber #}
{% macro display_number_of_account_limited(value, hide_unlimited=true, hide_slash=false) -%}
    {% if value == '0' or value == 0 or value == 'None' %}
        {% if hide_unlimited is not sameas true %}
            <span class="grey">{% if hide_slash is not sameas true %}/{% endif %}<em>{{ _('Unlimited') }}</em></span>
        {% endif %}
    {%else%}
        <span class="grey">{% if hide_slash is not sameas true %}/ {% endif %}<em>{{ value |e }}</em></span>
    {%endif%}
{%- endmacro %}


{# Display accountStatus #}
{% macro display_account_status(accountStatus, accountType='user') %}
    {% if accountStatus is sameas none %}
        {% set accountStatus = none %}
    {% endif %}

    <div class="form-field clear">
        {% if accountType == 'domain' %}
            <h4 class="size-250 fl-space">{{ _('Enable this domain') }}</h4>
        {% else %}
            <h4 class="size-250 fl-space">{{ _('Enable this account') }}</h4>
        {% endif %}

        <div class="form-checkbox-item clear fl-space2">
            <input name="accountStatus" value="active" type="checkbox" rel="checkboxhorizont" class="checkbox fl-space" {% if accountStatus in ['active', 1, '1',] %}checked{%endif%} />
        </div>
    </div>
{%- endmacro %}

{% macro display_reset_password(show_oldpw=false, show_confirmpw=true, min_passwd_length='0', max_passwd_length='0', store_in_plain=false) -%}

    {% if min_passwd_length != '0' and max_passwd_length != '0'%}
        {% set tooltip = _('At least %s characters, but no more than %s.') |format(min_passwd_length, max_passwd_length) %}
    {% elif min_passwd_length != '0' and max_passwd_length == '0' %}
        {% set tooltip = _('At least %s characters.') |format(min_passwd_length) %}
    {% elif max_passwd_length == '0' and max_passwd_length != '0' %}
        {% set tooltip = _('No more than %s characters.') |format(max_passwd_length) %}
    {% else %}
        {% set tooltip = '' %}
    {% endif %}

    {% if show_oldpw is sameas true %}
        <div class="form-field clear">
            <h4 class="size-250 fl-space">{{ _('Old password') }} <span class="required">*</span></h4>
            <span class="clean-padding bt-space20"><input type="password" name="oldpw" value="" size="35" class="text" /></span>
        </div>
    {% endif %}

    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('New password') }} <span class="required">*</span></h4>
        <span class="clean-padding bt-space20"><input type="password" name="newpw" value="" size="35" title="{{ tooltip }}" class="text" /></span>
    </div>

    {% if show_confirmpw is sameas true %}
        <div class="form-field clear">
            <h4 class="size-250 fl-space">{{ _('Confirm new password') }} <span class="required">*</span></h4>
            <span class="clean-padding bt-space20"><input type="password" name="confirmpw" value="" size="35" title="{{ tooltip }}" class="text" /></span>
        </div>
    {% endif %}

    {% if store_in_plain is sameas true %}
        {% if session.get('storePasswordInPlain') is sameas true %}
            <div class="form-field clear">
                <h4 class="size-250 fl-space">{{ _('Store password in plain text') }}</span></h4>
                <span class="clean-padding bt-space20"><input type="checkbox" name="storePasswordInPlainText" class="checkbox" /></span>
            </div>
        {% endif %}
    {% endif %}
{%- endmacro %}

{% macro display_quota(value='', label='', comment='', used_quota=none, spare_quota_bytes=0, show_spare_quota=false, show_value_in_input=true, hide_zero=true, show_used_quota=false) -%}
    {# Convert to string #}
    {% set used_quota = used_quota |string %}

    {% if spare_quota_bytes > 0 %}
        {% if value > spare_quota_bytes/1024/1024 %}
            {% set value = spare_quota_bytes/1024/1024 %}
        {% endif %}
    {% endif %}
    {% set value = value |string %}

    {% if hide_zero is sameas true %}
        {% if value == '0' %}
            {% set value = '' %}
        {% endif %}
    {% endif %}

    <div class="form-field clear">
        {% if label == '' %}
            <h4 class="size-250 fl-space">{{ _('Mailbox Quota') }}</h4>
        {% else %}
            <h4 class="size-250 fl-space">{{ label |e }}</h4>
        {% endif %}

        <span class="clean-padding fl-space2">
            <input type="text" name="mailQuota" value="{% if show_value_in_input is sameas true %}{{ value |e }}{% endif %}" size="10" class="text fl-space" /> <label class="fl-space">MB {{ comment |e }}</label>

            {% if spare_quota_bytes |int >= 0 %}
                {% if show_spare_quota is sameas true %}
                    <label class="fl-space">{{ _('Available quota:') }} {{ spare_quota_bytes | filesizeformat |e }}</label>
                {% endif %}
            {% elif spare_quota_bytes |int == -1 %}
                {% set comment = _('Set to 0 for unlimited.') %}
            {% endif %}
        </span>

        <span><input type="hidden" name="oldMailQuota" value="{{ value |e }}" /></span>
    </div>
{%- endmacro %}

{% macro display_domain_transport(transport='') -%}
    <div class="columns clear">
        <div class="col2-3 ">
            <div class="form-field clear">
                <h4 class="size-250 fl-space">{{ _('Relay/Transport Setting') }}</h4>
                <div class="clear">
                    <input type="text" name="mtaTransport" value="{% if transport not in ['', none] %}{{ transport |e }}{% endif %}" size="35" class="text" />
                </div>
            </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">{{ _('Per-user relay setting will override per-domain relay setting you set in this page.') }}</li>
                    <li class="bt-space5"><a href="http://www.postfix.org/transport.5.html" target="_blank">{{ _('Sample') }}</a></li>
                </ul>
            </div>
        </div>{#-- .col1-3 --#}
    </div>
{%- endmacro %}


{% macro display_recipient_bcc(address='') -%}
    {% if address is sameas none %}
        {% set address = '' %}
    {% endif %}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('BCC incoming emails to single address') }}</h4>
        <span class="clean-padding">
            <input type="text" name="recipientBccAddress" value="{{ address |e }}" size="35" class="text" />
        </span>
    </div>
{%- endmacro %}

{% macro display_sender_bcc(address='') -%}
    {% if address is sameas none %}
        {% set address = '' %}
    {% endif %}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('BCC outgoing emails to single address') }}</h4>
        <span class="clean-padding">
            <input type="text" name="senderBccAddress" value="{{ address |e }}" size="35" class="text" />
        </span>
    </div>
{%- endmacro %}

{% macro display_input_mail(mail='', name='mail', required=false) -%}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('Mail Address') }} {% if required is sameas true %}<span class="required">*</span>{% endif %}</h4>
        <span class="clean-padding bt-space20"><input type="text" name="{{ name |e }}" value="{{ mail |e }}" size="35" class="text" /></span>
    </div>
{%- endmacro %}

{% macro display_input_domain(domain='', name='domainName', required=false) -%}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('Domain Name') }} {% if required is sameas true %}<span class="required">*</span>{% endif %}</h4>
        <span class="clean-padding bt-space20">
            <input type="text" name="{{ name |e }}" value="{{ domain |e }}" size="35" class="text" />
        </span>
    </div>
{%- endmacro %}


{% macro display_input_cn(cn='', name='cn', accountType='user', tooltip='', size="size-250", show_first_last_name=false, first_name='', last_name='') -%}

    {% if cn is sameas none %}
        {% set cn = '' %}
    {% endif %}

    <div class="form-field clear">
        {% if accountType == 'domain' %}
            <h4 class="{{ size }} fl-space">{{ _('Company/Organization Name') }}</h4>
        {% else %}
            <h4 class="{{ size }} fl-space">{{ _('Display Name') }}</h4>
        {% endif %}

        <span class="clean-padding bt-space20">
            <input type="text" name="{{ name |e }}" value="{{ cn |e }}" size="35" class="text" {% if tooltip != '' %}title="{{ tooltip |e }}"{% endif %} />
        </span>
    </div>

    {% if show_first_last_name is sameas true %}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">&nbsp;</h4>
        <span class="clean-padding bt-space20">
            <input type="text" name="first_name" value="{{ first_name |e }}" size="15" class="text" title="{{ _('First name') }}" />
            <input type="text" name="last_name" value="{{ last_name |e }}" size="15" class="text" title="{{ _('Last name') }}"/>
        </span>
    </div>
    {% endif %}
{%- endmacro %}


{% macro display_add_admin(min_passwd_length='0', max_passwd_length='0', lang='en_US', languagemaps=['en_US',]) -%}
    <div id="admin_add" class="box-wrap clear">
        <form name="create" method="post" action="{{ctx.homepath}}/create/admin">
            {{ display_csrf_token() }}
            {{ display_input_mail(required=true) }}

            <div class="bt-space5">&nbsp;</div>

            {{ display_reset_password(
                        show_confirmpw=true,
                        min_passwd_length=min_passwd_length,
                        max_passwd_length=max_passwd_length,
                        ) }}

            <div class="bt-space5">&nbsp;</div>

            {{ display_input_cn() }}
            <input class="hidden" name="domainGlobalAdmin" value="yes" />
            {{ display_preferred_language(lang, languagemaps) }}

            {{ display_button_submit(label=_('Add')) }}
        </form>
    </div>
{%- endmacro %}

{% macro display_domain_quota(quota='', quotaUnit='GB')%}
    <div class="form-field clear">
        <a name="domainQuota">&nbsp;</a>
        <h4 class="size-250 fl-space">{{ _('Domain quota size') }}</h4>
        <span class="clean-padding fl-space">
            <input type="text" name="domainQuota" size="8" value="{{ quota |e }}" class="text fl-space" />
            <select name="domainQuotaUnit">
                {% for unit in ['TB', 'GB', 'MB',] %}
                    <option value="{{unit}}" {% if quotaUnit == unit %}selected{% endif %}>{{unit}}</option>
                {% endfor %}
            </select>
        </span>
    </div>
{% endmacro %}

{% macro display_domain_default_userquota(quota='1024') %}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ _('Default quota of new user') }}</h4>
        <span class="clean-padding">
            <input type="text" name="defaultQuota" size="8" value="{{ quota |e }}" class="text fl-space" /><label>MB</label>
        </span>
    </div>
{% endmacro %}

{% macro display_add_domain(label=false) -%}
    <div id="domain_add" class="box-wrap clear">
        {% if label is sameas true %}
            <h3>{{ _('Add domain') }}</h3>
        {% endif %}
        <form name="create" method="post" action="{{ctx.homepath}}/create/domain">

            {{ display_csrf_token() }}
            {{ display_input_domain(required=true) }}
            {{ display_input_cn(accountType='domain') }}

            <h4 class="size-250 fl-space">&nbsp;</h4>
            <span class="clean-padding bt-space20"><input type="submit" class="button green" value="{{ _('Add') }}" /></span>
        </form>
    </div>
{%- endmacro %}

{% macro display_maillist_restrictions(policy, maillist_email) -%}
    {% set policy = policy.lower() %}
    {% if policy == 'open' %}
        {{ _('Unrestricted') }}
    {% elif policy == 'domain' %}
        {{ _("<a href='%s'>Domain users</a>") |format(ctx.homepath + '/users/' + maillist_email.split('@')[-1] ) }}
    {% elif policy == 'subdomain' %}
        {{ _("<a href='%s'>Domain and sub-domain users</a>") |format(ctx.homepath + '/users/' + maillist_email.split('@')[-1] ) }}
    {% elif policy == 'membersonly' %}
        {{ _("<a href='%s'>Members</a>") |format(ctx.homepath + '/profile/maillist/members/' + maillist_email) }}
    {% elif policy == 'allowedonly' %}
        {{ _("<a href='%s'>Moderators</a>") |format(ctx.homepath + '/profile/maillist/moderators/' + maillist_email) }}
    {% elif policy == 'membersandmoderatorsonly' %}
        {{ _("<a href='%s'>Members</a> and <a href='%s'>moderators</a>") |format(ctx.homepath + '/profile/maillist/members/' + maillist_email, ctx.homepath + '/profile/maillist/moderators/' + maillist_email) }}
    {% else %}
        {{ _('Unrestricted') }}
    {% endif %}
{% endmacro %}


{% macro highlight_username_in_mail(mail) -%}
    <span><strong>{{ mail.split('@')[0] |e }}</strong></span><span class="grey"><em>@{{ mail.split('@')[-1] |e }}</em></span>
{% endmacro %}

{%- macro display_random_password(length) -%}
    <div class="mark_blue bt-space10">
        <h4>{{ _('Need a random password?') }}</h4>
        <p class="clean-padding clean-padding bt-space10">{{ length | generate_random_strings }}</p>
    </div>
{%- endmacro -%}

{% macro show_pages(baseurl, total, cur_page, near_pages=4, sep='/page/') -%}
    {% if total % pageSizeLimit > 0 %}
        {% set total_pages = total // pageSizeLimit + 1 %}
    {% else %}
        {% set total_pages = total // pageSizeLimit %}
    {% endif %}

    {% set baseurl = baseurl |e %}
    {% set sep = sep |e %}

    <div class="pager fr">
        {# Show links of 'First Page', 'Previous Page' #}
        {%- if total_pages > 0 -%}
            <span class="nav">
                {% if total_pages > 3 %}
                    <a href="{{baseurl}}{{sep}}1" class="first" title="{{ _('First Page') }}"><span>{{ _('First Page') }}</span></a>
                {% endif %}

                {% if cur_page != 1 and cur_page != 0 %}
                    <a href="{{baseurl}}{{sep}}{{cur_page - 1}}" class="previous" title="{{ _('Previous Page') }}" ><span>{{ _('Previous Page') }}</span></a>
                {% endif %}
            </span>
        {%- endif -%}

        <span class="pages">
        {% if total_pages <= near_pages %}
            {# Show all cur_page numbers if total pages is less than or equal to 4 pages.#}
            {% for page_no in range(1, total_pages+1) %}
                <a href="{{baseurl}}{{sep}}{{page_no}}" {% if page_no == cur_page %}class="active"{% endif %}><span>{{page_no}}</span></a>
            {% endfor %}
        {% else %}
            {# Show current cur_page number and near numbers.#}
            {% if cur_page <= near_pages %}
                {# Show near pages. #}
                {% if total_pages - cur_page <= near_pages %}
                    {% set end_page = cur_page + (total_pages - cur_page) %}
                {% else %}
                    {% set end_page = cur_page + near_pages %}
                {% endif %}

                {% for page_no in range(1, end_page) %}
                    {% if page_no != cur_page %}
                        <a href="{{baseurl}}{{sep}}{{page_no}}"><span>{{page_no}}</span></a>
                    {% else %}
                        <a href="#" class="active"><span>{{ cur_page }}</span></a>
                    {% endif %}
                {% endfor %}

                {# Show last page. #}
                {% if cur_page + near_pages < total_pages %}
                    {% if cur_page + near_pages <= total_pages - 1 %}<a href="#"><span>...</span></a>{% endif %}
                {% endif %}
                <a href="{{baseurl}}{{sep}}{{total_pages}}"><span>{{total_pages}}</span></a>
            {% else %}
                {# Show first page number. #}
                {%- if cur_page - near_pages == 2 -%}
                    <a href="{{baseurl}}{{sep}}1"><span>1</span></a>
                {%- elif cur_page - near_pages > 2 -%}
                    <a href="{{baseurl}}{{sep}}1"><span>1</span></a>
                    <a href="#"><span>...</span></a>
                {%- endif -%}

                {# Show nearby pages which number larger than cur_page. #}
                {% if total_pages - cur_page < near_pages %}
                    {% set end_page = cur_page + (total_pages - cur_page) %}
                {% else %}
                    {% set end_page = cur_page + near_pages %}
                {% endif %}

                {% for page_no in range((cur_page-near_pages), end_page + 1) %}
                    {% if page_no != cur_page %}
                        <a href="{{baseurl}}{{sep}}{{page_no}}" ><span>{{page_no}}</span></a>
                    {% else %}
                        <a href="#" class="active"><span>{{ cur_page }}</span></a>
                    {% endif %}
                {% endfor %}

                {% if total_pages - cur_page > near_pages and total_pages - cur_page != near_pages + 1 %}
                    <a href="#"><span>...</span></a>
                {% endif %}

                {% if end_page < total_pages %}
                    <a href="{{baseurl}}{{sep}}{{total_pages}}" ><span>{{total_pages}}</span></a>
                {% endif %}
            {% endif %}
        {% endif %}
        </span>

        {# -- Show 'Next' and 'Last' -- #}
        {% if total_pages > 0 %}
        <span class="nav">
            {% if cur_page < total_pages and cur_page != 0 %}
                <a href="{{ baseurl }}{{ sep }}{{ cur_page + 1 }}" class="next" title="{{ _('Next Page') }}"><span>{{ _('Next Page') }}</span></a>
            {% endif %}

            {% if total_pages != 1 %}
                <a href="{{ baseurl }}{{ sep }}{{ total_pages }}" class="last" title="{{ _('Last Page') }}"><span>{{ _('Last Page') }}</span></a>
            {% endif %}
        </span>
        {% endif %}
    </div>
{%- endmacro %}


{# Convert event code to event name #}
{% macro show_event_name(event) -%}
    {% if event == 'all' %}
        {{ _('Events') }}
    {% elif event == 'login' %}
        {{ _('Admin login') }}
    {% elif event == 'create' %}
        {{ _('Add account') }}
    {% elif event == 'delete' %}
        {{ _('Delete account') }}
    {% elif event == 'disable' %}
        {{ _('Disable account') }}
    {% elif event == 'active' %}
        {{ _('Active account') }}
    {% elif event == 'update' %}
        {{ _('Edit account profile') }}
    {% else %}
        {{ event |e }}
    {% endif %}
{%- endmacro %}


{# iRedAPD: per-user wblist #}
{% macro display_per_user_wblist(values=[], htmlInputName, label) -%}
    <div class="form-field clear">
        <h4 class="size-250 fl-space">{{ label |e }}</h4>
        <small>{{ _('One record per line.') }}</small>

        {% if values |length == 0 %}
            <textarea name="{{ htmlInputName |e }}" rows="6" class="textarea"></textarea>
        {% else %}
            <textarea name="{{ htmlInputName |e }}" rows="6" class="textarea">{% for v in values %}{{ v |e }}
{% endfor %}</textarea>
        {% endif %}
    </div>
{%- endmacro %}