PageRenderTime 65ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/default/macros/general.html

https://bitbucket.org/zhb/iredadmin-ose
HTML | 742 lines | 638 code | 104 blank | 0 comment | 0 complexity | 64f1a9c27a0a34191bacf08cd36600ca MD5 | raw file
Possible License(s): GPL-2.0
  1. {# ------------ Load JS files ------------- #}
  2. {% macro load_jquery(plugins=[], nonSortedCols=[], defaultPlugins=['tooltip', 'idtabs', 'fancybox'], quarantined=false) -%}
  3. {# Available jQuery plugins:
  4. [idtabs, jeditable, visualize, fancybox, idtabs, ui, jcarousel, validate]
  5. #}
  6. <script type="text/javascript" src="{{ctx.homepath}}/static/js/jquery-1.12.4.min.js"></script>
  7. {% for p in defaultPlugins %}
  8. <script type="text/javascript" src="{{ctx.homepath}}/static/js/jquery.{{p}}.js"></script>
  9. {% endfor %}
  10. {% for p in plugins %}
  11. <script type="text/javascript" src="{{ctx.homepath}}/static/js/jquery.{{p}}.js"></script>
  12. {% endfor %}
  13. {# Addition JS/jQuery functions #}
  14. <script type="text/javascript">
  15. $(document).ready(function() {
  16. {# -- Menus -- #}
  17. $('.menu li').hover(function () {
  18. $(this).find('ul:first').css({'visibility': 'visible', 'display': 'none'}).slideDown();
  19. }, function () {
  20. $(this).find('ul:first').css({visibility: "hidden"});
  21. });
  22. {#-- Content Boxes --#}
  23. $('.content-box .select-all').click(function () {
  24. if ($(this).is(':checked'))
  25. $(this).parent().parent().parent().parent().find(':checkbox').attr('checked', true);
  26. else
  27. $(this).parent().parent().parent().parent().find(':checkbox').attr('checked', false);
  28. });
  29. /* Tabs */
  30. $('.content-box .tabs').idTabs();
  31. {# Notifications #}
  32. $('.notification .close').click(function () {
  33. $(this).parent().fadeOut(300);
  34. return false;
  35. });
  36. {# tooltip #}
  37. $("a[title], img[title], span[title], input[title]").tooltip({
  38. position: "top center",
  39. offset: [-5, 0],
  40. predelay: 300,
  41. delay: 100,
  42. effect: "fade",
  43. opacity: 1
  44. });
  45. {% if 'tablesorter' in plugins %}
  46. $(".tablesorter").tablesorter(
  47. {% if nonSortedCols |length > 0 %}
  48. { headers: {
  49. {% for col in nonSortedCols %}
  50. {{ col }}: {sorter: false }{% if not loop.last %},{% endif %}
  51. {% endfor %}
  52. }}
  53. {% endif %}
  54. );
  55. {% endif %}
  56. $('.onFocusEmpty').focus(function () {
  57. $(this).val('');
  58. });
  59. {# -- Fancybox -- #}
  60. $('.modal-link').fancybox({
  61. 'modal' : false,
  62. 'hideOnOverlayClick' : true,
  63. 'hideOnContentClick' : false,
  64. 'enableEscapeButton' : true,
  65. 'showCloseButton' : true
  66. });
  67. $("a[href$='gif']").fancybox();
  68. $("a[href$='jpg']").fancybox();
  69. $("a[href$='png']").fancybox();
  70. // Show a select box to let admin choose to delete mailboxes in how many days
  71. $('#account_delete_date').hide()
  72. $('#account_list_actions').change(function(){
  73. if ($(this).val() == 'delete') {
  74. $('#account_delete_date').show();
  75. } else {
  76. $("#account_delete_date").hide();
  77. }
  78. });
  79. });
  80. </script>
  81. {%- endmacro %}
  82. {# ------------ END Load JS files ------------- #}
  83. {% macro load_jquery_quicksearch() -%}
  84. $("input.quickSearch").quicksearch("table.dataList tbody tr");
  85. {%- endmacro %}
  86. {# ------------ END Load jQuery $(document).read() functions ------------- #}
  87. {%- macro display_subnav(crumbs) -%}
  88. {# Crumb format: (link, label), ('active', link, label) #}
  89. {% if crumbs | length > 0 %}
  90. <div class="breadcrumb">
  91. <div class="pagesize">
  92. <ul id="breadcrumb">
  93. {% for crb in crumbs %}
  94. <li>
  95. {%- if crb |length == 2 -%}
  96. <a href="{{ crb[0] }}">{{ crb[1] }}</a>
  97. {%- elif crb |length ==3 -%}
  98. <a href="{{ crb[1] }}" class="inactive"><strong>{{ crb[2] }}</strong></a>
  99. {%- endif -%}
  100. {% if not loop.last %}/{% endif %}
  101. </li>
  102. {% endfor %}
  103. </ul>
  104. </div>
  105. </div>
  106. {% endif %}
  107. {%- endmacro -%}
  108. {% macro set_account_status_img(status, float="right", tooltip=true, vcenter=true) -%}
  109. {% if float == 'right' %}
  110. {% set imgfloat = 'fr-space' %}
  111. {% elif float == 'left' %}
  112. {% set imgfloat = 'fl-space' %}
  113. {% elif float == 'center' %}
  114. {% set imgfloat = 'fl-space' %}
  115. {% else %}
  116. {% set imgfloat = '' %}
  117. {% endif %}
  118. {% if status == 'active' or status |string == '1' %}
  119. <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 %}/>
  120. {% else %}
  121. {% set tooltip = _('Account is disabled.') %}
  122. <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 %}/>
  123. {% endif %}
  124. {%- endmacro %}
  125. {% macro set_admin_type_img(value) -%}
  126. {% if value == 'yes' %}
  127. <img src="{{ctx.homepath}}/static/{{skin}}/images/enabled.png" class="block" title="{{ _('Is a global admin.') }}" alt="" />
  128. {% else %}
  129. <img src="{{ctx.homepath}}/static/{{skin}}/images/ball_grey_16.png" class="block" title="{{ _('Not a global admin.') }}" alt="" />
  130. {% endif %}
  131. {%- endmacro %}
  132. {% macro display_button_submit(label=none, color='green') -%}
  133. <div class="rule2"></div>
  134. <div class="form-field clear">
  135. <h4 class="size-250 fl-space">&nbsp;</h4>
  136. <span>
  137. <input type="submit" value="{% if label is not sameas none %}{{ label |e }}{% else %}{{ _('Save changes') }}{% endif %}" class="button {{ color |e }}" />
  138. </span>
  139. </div>
  140. {%- endmacro %}
  141. {% macro display_progress_bar(percent, tooltip=none, show_zero=false, style='normal', width='100%') -%}
  142. {% set percent = percent |int %}
  143. {% if percent < 0 %}
  144. {% set percent = 0 %}
  145. {% elif percent > 100 %}
  146. {% set percent = 100 %}
  147. {% endif %}
  148. {% if tooltip is sameas none %}
  149. {% set tooltip = percent |string + '%' %}
  150. {% endif %}
  151. {% if style == 'thin' %}
  152. {% set height = '3px' %}
  153. {% else %}
  154. {% set height = '1.6em' %}
  155. {% endif %}
  156. {% if percent < 80 %}
  157. {% set bgcolor = '#ACE97C' %}
  158. {% elif 80 <= percent < 90 %}
  159. {% set bgcolor = 'yellow' %}
  160. {% elif 90 <= percent < 99 %}
  161. {% set bgcolor = '#F76541' %}
  162. {% else %}
  163. {% set bgcolor = '#F62217' %}
  164. {% endif %}
  165. {% if percent > 0 or show_zero is sameas true %}
  166. <div class="progress-container" title="{{ tooltip |e }}" style="width: {{width |e }}; height: {{height}};">
  167. <div class="progress-bar" style="height: {{height}}; width: {{percent}}%; background-color: {{bgcolor}};"></div>
  168. </div>
  169. {% endif %}
  170. {%- endmacro %}
  171. {% macro display_csrf_token(token=none) -%}
  172. {% if token is sameas none %}
  173. {% set token = csrf_token() %}
  174. {% else %}
  175. {% set token = token |e %}
  176. {% endif %}
  177. <input type="hidden" name="csrf_token" value="{{ token }}"/>
  178. {%- endmacro %}
  179. {% macro display_input_employeeid(value='') -%}
  180. {% if value is sameas none %}
  181. {% set value = '' %}
  182. {% endif %}
  183. <div class="form-field clear">
  184. <h4 class="size-250 fl-space">{{ _('User ID') }}</h4>
  185. <span class="clean-padding bt-space20"><input type="text" name="employeeNumber" value="{% if value != 'None' %}{{ value |e }}{% endif %}" size="35" class="text" /></span>
  186. </div>
  187. {%- endmacro %}
  188. {% macro display_input_jobtitle(value='') -%}
  189. <div class="form-field clear">
  190. <h4 class="size-250 fl-space">{{ _('Job Title/Responsibility') }}</h4>
  191. <span class="clean-padding bt-space20"><input type="text" name="title" value="{% if value != 'None' %}{{ value |e }}{% endif %}" size="35" class="text" /></span>
  192. </div>
  193. {%- endmacro %}
  194. {% macro display_input_mobile(value) -%}
  195. <div class="form-field clear">
  196. <h4 class="size-250 fl-space">{{ _('Mobile') }}</h4>
  197. <span class="clean-padding bt-space20"><input type="text" name="mobile" value="{{ value |e }}" size="35" class="text" /></span>
  198. </div>
  199. {%- endmacro %}
  200. {% macro display_input_phone(value=[]) -%}
  201. {% if value |length == 0 %}
  202. <div class="form-field clear">
  203. <h4 class="size-250 fl-space">{{ _('Telephone Number') }}</h4>
  204. <span class="clean-padding bt-space20">
  205. <input type="text" name="telephoneNumber" value="" size="35" class="text" />
  206. </span>
  207. </div>
  208. {% else %}
  209. {% for phone in value %}
  210. <div class="form-field clear">
  211. {% if loop.first %}
  212. <h4 class="size-250 fl-space">{{ _('Telephone Number') }}</h4>
  213. {% else %}
  214. <h4 class="size-250 fl-space">&nbsp;</h4>
  215. {% endif %}
  216. <span class="clean-padding bt-space20">
  217. <input type="text" name="telephoneNumber" value="{{ phone |e }}" size="35" class="text" />
  218. </span>
  219. </div>
  220. {% endfor %}
  221. {% endif %}
  222. {#-- Always display one more field to input new value --#}
  223. <div class="form-field clear">
  224. <h4 class="size-250 fl-space">&nbsp;</h4>
  225. <span class="clean-padding bt-space20">
  226. <input type="text" name="telephoneNumber" value="" size="35" class="text" />
  227. </span>
  228. </div>
  229. {%- endmacro %}
  230. {% macro display_preferred_language(value='', languagemaps=['en_US',]) -%}
  231. <div class="form-field clear">
  232. <h4 class="size-250 fl-space">{{ _('Preferred language') }}</h4>
  233. <select name="preferredLanguage">
  234. {% for lang in [''] + languagemaps |sort %}
  235. <option value="{{ lang |e }}" {% if value == lang %}selected{%endif%}>{{ languagemaps[lang] |e }}</option>
  236. {% endfor %}
  237. </select>
  238. </div>
  239. {%- endmacro %}
  240. {% macro display_in_global_address_book(enabledService=[]) %}
  241. <div class="form-field clear">
  242. <h4 class="size-250 fl-space">{{ _("Displayed in Global LDAP Address Book") }}</h4>
  243. <div class="form-checkbox-item clear">
  244. <input name="displayedInGlobalAddressBook" {% if 'displayedInGlobalAddressBook' in enabledService %}checked{% endif %} type="checkbox" rel="checkboxhorizont" class="checkbox" />
  245. </div>
  246. </div>
  247. {%- endmacro %}
  248. {% macro display_input_global_admin(value='no') %}
  249. <div class="form-field clear">
  250. <h4 class="size-250 fl-space">{{ _('Mark as global admin') }}</h4>
  251. <div class="form-checkbox-item clear">
  252. {#
  253. ldap: yes, no
  254. mysql: true, false
  255. #}
  256. <span class="clean-padding bt-space20"><input class="checkbox" name="domainGlobalAdmin" value="yes" type="checkbox" {% if value in ['yes', true,] %}checked{%endif%} /></span>
  257. </div>
  258. </div>
  259. {%- endmacro %}
  260. {% macro display_mark_user_as_admin(is_domain_admin=false, is_global_admin=false) %}
  261. {# possible value: 0, 1 (SQL), or true, yes, false, no (LDAP) #}
  262. {% if session.get('domainGlobalAdmin') is sameas true %}
  263. <div class="form-field clear">
  264. <h4 class="size-250 fl-space">{{ _('Mark this user as') }}</h4>
  265. <div class="form-checkbox-item clear">
  266. <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>
  267. </div>
  268. </div>
  269. {% endif %}
  270. {%- endmacro %}
  271. {# Used to display domainMaxXXXNumber #}
  272. {% macro display_number_of_account_limited(value, hide_unlimited=true, hide_slash=false) -%}
  273. {% if value == '0' or value == 0 or value == 'None' %}
  274. {% if hide_unlimited is not sameas true %}
  275. <span class="grey">{% if hide_slash is not sameas true %}/{% endif %}<em>{{ _('Unlimited') }}</em></span>
  276. {% endif %}
  277. {%else%}
  278. <span class="grey">{% if hide_slash is not sameas true %}/ {% endif %}<em>{{ value |e }}</em></span>
  279. {%endif%}
  280. {%- endmacro %}
  281. {# Display accountStatus #}
  282. {% macro display_account_status(accountStatus, accountType='user') %}
  283. {% if accountStatus is sameas none %}
  284. {% set accountStatus = none %}
  285. {% endif %}
  286. <div class="form-field clear">
  287. {% if accountType == 'domain' %}
  288. <h4 class="size-250 fl-space">{{ _('Enable this domain') }}</h4>
  289. {% else %}
  290. <h4 class="size-250 fl-space">{{ _('Enable this account') }}</h4>
  291. {% endif %}
  292. <div class="form-checkbox-item clear fl-space2">
  293. <input name="accountStatus" value="active" type="checkbox" rel="checkboxhorizont" class="checkbox fl-space" {% if accountStatus in ['active', 1, '1',] %}checked{%endif%} />
  294. </div>
  295. </div>
  296. {%- endmacro %}
  297. {% macro display_reset_password(show_oldpw=false, show_confirmpw=true, min_passwd_length='0', max_passwd_length='0', store_in_plain=false) -%}
  298. {% if min_passwd_length != '0' and max_passwd_length != '0'%}
  299. {% set tooltip = _('At least %s characters, but no more than %s.') |format(min_passwd_length, max_passwd_length) %}
  300. {% elif min_passwd_length != '0' and max_passwd_length == '0' %}
  301. {% set tooltip = _('At least %s characters.') |format(min_passwd_length) %}
  302. {% elif max_passwd_length == '0' and max_passwd_length != '0' %}
  303. {% set tooltip = _('No more than %s characters.') |format(max_passwd_length) %}
  304. {% else %}
  305. {% set tooltip = '' %}
  306. {% endif %}
  307. {% if show_oldpw is sameas true %}
  308. <div class="form-field clear">
  309. <h4 class="size-250 fl-space">{{ _('Old password') }} <span class="required">*</span></h4>
  310. <span class="clean-padding bt-space20"><input type="password" name="oldpw" value="" size="35" class="text" /></span>
  311. </div>
  312. {% endif %}
  313. <div class="form-field clear">
  314. <h4 class="size-250 fl-space">{{ _('New password') }} <span class="required">*</span></h4>
  315. <span class="clean-padding bt-space20"><input type="password" name="newpw" value="" size="35" title="{{ tooltip }}" class="text" /></span>
  316. </div>
  317. {% if show_confirmpw is sameas true %}
  318. <div class="form-field clear">
  319. <h4 class="size-250 fl-space">{{ _('Confirm new password') }} <span class="required">*</span></h4>
  320. <span class="clean-padding bt-space20"><input type="password" name="confirmpw" value="" size="35" title="{{ tooltip }}" class="text" /></span>
  321. </div>
  322. {% endif %}
  323. {% if store_in_plain is sameas true %}
  324. {% if session.get('storePasswordInPlain') is sameas true %}
  325. <div class="form-field clear">
  326. <h4 class="size-250 fl-space">{{ _('Store password in plain text') }}</span></h4>
  327. <span class="clean-padding bt-space20"><input type="checkbox" name="storePasswordInPlainText" class="checkbox" /></span>
  328. </div>
  329. {% endif %}
  330. {% endif %}
  331. {%- endmacro %}
  332. {% 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) -%}
  333. {# Convert to string #}
  334. {% set used_quota = used_quota |string %}
  335. {% if spare_quota_bytes > 0 %}
  336. {% if value > spare_quota_bytes/1024/1024 %}
  337. {% set value = spare_quota_bytes/1024/1024 %}
  338. {% endif %}
  339. {% endif %}
  340. {% set value = value |string %}
  341. {% if hide_zero is sameas true %}
  342. {% if value == '0' %}
  343. {% set value = '' %}
  344. {% endif %}
  345. {% endif %}
  346. <div class="form-field clear">
  347. {% if label == '' %}
  348. <h4 class="size-250 fl-space">{{ _('Mailbox Quota') }}</h4>
  349. {% else %}
  350. <h4 class="size-250 fl-space">{{ label |e }}</h4>
  351. {% endif %}
  352. <span class="clean-padding fl-space2">
  353. <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>
  354. {% if spare_quota_bytes |int >= 0 %}
  355. {% if show_spare_quota is sameas true %}
  356. <label class="fl-space">{{ _('Available quota:') }} {{ spare_quota_bytes | filesizeformat |e }}</label>
  357. {% endif %}
  358. {% elif spare_quota_bytes |int == -1 %}
  359. {% set comment = _('Set to 0 for unlimited.') %}
  360. {% endif %}
  361. </span>
  362. <span><input type="hidden" name="oldMailQuota" value="{{ value |e }}" /></span>
  363. </div>
  364. {%- endmacro %}
  365. {% macro display_domain_transport(transport='') -%}
  366. <div class="columns clear">
  367. <div class="col2-3 ">
  368. <div class="form-field clear">
  369. <h4 class="size-250 fl-space">{{ _('Relay/Transport Setting') }}</h4>
  370. <div class="clear">
  371. <input type="text" name="mtaTransport" value="{% if transport not in ['', none] %}{{ transport |e }}{% endif %}" size="35" class="text" />
  372. </div>
  373. </div>
  374. </div>{#-- .col2-3 --#}
  375. <div class="col1-3 lastcol">
  376. <div class="mark_blue bt-space10">
  377. <ul class="standard clean-padding bt-space10">
  378. <li class="bt-space5">{{ _('Per-user relay setting will override per-domain relay setting you set in this page.') }}</li>
  379. <li class="bt-space5"><a href="http://www.postfix.org/transport.5.html" target="_blank">{{ _('Sample') }}</a></li>
  380. </ul>
  381. </div>
  382. </div>{#-- .col1-3 --#}
  383. </div>
  384. {%- endmacro %}
  385. {% macro display_recipient_bcc(address='') -%}
  386. {% if address is sameas none %}
  387. {% set address = '' %}
  388. {% endif %}
  389. <div class="form-field clear">
  390. <h4 class="size-250 fl-space">{{ _('BCC incoming emails to single address') }}</h4>
  391. <span class="clean-padding">
  392. <input type="text" name="recipientBccAddress" value="{{ address |e }}" size="35" class="text" />
  393. </span>
  394. </div>
  395. {%- endmacro %}
  396. {% macro display_sender_bcc(address='') -%}
  397. {% if address is sameas none %}
  398. {% set address = '' %}
  399. {% endif %}
  400. <div class="form-field clear">
  401. <h4 class="size-250 fl-space">{{ _('BCC outgoing emails to single address') }}</h4>
  402. <span class="clean-padding">
  403. <input type="text" name="senderBccAddress" value="{{ address |e }}" size="35" class="text" />
  404. </span>
  405. </div>
  406. {%- endmacro %}
  407. {% macro display_input_mail(mail='', name='mail', required=false) -%}
  408. <div class="form-field clear">
  409. <h4 class="size-250 fl-space">{{ _('Mail Address') }} {% if required is sameas true %}<span class="required">*</span>{% endif %}</h4>
  410. <span class="clean-padding bt-space20"><input type="text" name="{{ name |e }}" value="{{ mail |e }}" size="35" class="text" /></span>
  411. </div>
  412. {%- endmacro %}
  413. {% macro display_input_domain(domain='', name='domainName', required=false) -%}
  414. <div class="form-field clear">
  415. <h4 class="size-250 fl-space">{{ _('Domain Name') }} {% if required is sameas true %}<span class="required">*</span>{% endif %}</h4>
  416. <span class="clean-padding bt-space20">
  417. <input type="text" name="{{ name |e }}" value="{{ domain |e }}" size="35" class="text" />
  418. </span>
  419. </div>
  420. {%- endmacro %}
  421. {% macro display_input_cn(cn='', name='cn', accountType='user', tooltip='', size="size-250", show_first_last_name=false, first_name='', last_name='') -%}
  422. {% if cn is sameas none %}
  423. {% set cn = '' %}
  424. {% endif %}
  425. <div class="form-field clear">
  426. {% if accountType == 'domain' %}
  427. <h4 class="{{ size }} fl-space">{{ _('Company/Organization Name') }}</h4>
  428. {% else %}
  429. <h4 class="{{ size }} fl-space">{{ _('Display Name') }}</h4>
  430. {% endif %}
  431. <span class="clean-padding bt-space20">
  432. <input type="text" name="{{ name |e }}" value="{{ cn |e }}" size="35" class="text" {% if tooltip != '' %}title="{{ tooltip |e }}"{% endif %} />
  433. </span>
  434. </div>
  435. {% if show_first_last_name is sameas true %}
  436. <div class="form-field clear">
  437. <h4 class="size-250 fl-space">&nbsp;</h4>
  438. <span class="clean-padding bt-space20">
  439. <input type="text" name="first_name" value="{{ first_name |e }}" size="15" class="text" title="{{ _('First name') }}" />
  440. <input type="text" name="last_name" value="{{ last_name |e }}" size="15" class="text" title="{{ _('Last name') }}"/>
  441. </span>
  442. </div>
  443. {% endif %}
  444. {%- endmacro %}
  445. {% macro display_add_admin(min_passwd_length='0', max_passwd_length='0', lang='en_US', languagemaps=['en_US',]) -%}
  446. <div id="admin_add" class="box-wrap clear">
  447. <form name="create" method="post" action="{{ctx.homepath}}/create/admin">
  448. {{ display_csrf_token() }}
  449. {{ display_input_mail(required=true) }}
  450. <div class="bt-space5">&nbsp;</div>
  451. {{ display_reset_password(
  452. show_confirmpw=true,
  453. min_passwd_length=min_passwd_length,
  454. max_passwd_length=max_passwd_length,
  455. ) }}
  456. <div class="bt-space5">&nbsp;</div>
  457. {{ display_input_cn() }}
  458. <input class="hidden" name="domainGlobalAdmin" value="yes" />
  459. {{ display_preferred_language(lang, languagemaps) }}
  460. {{ display_button_submit(label=_('Add')) }}
  461. </form>
  462. </div>
  463. {%- endmacro %}
  464. {% macro display_domain_quota(quota='', quotaUnit='GB')%}
  465. <div class="form-field clear">
  466. <a name="domainQuota">&nbsp;</a>
  467. <h4 class="size-250 fl-space">{{ _('Domain quota size') }}</h4>
  468. <span class="clean-padding fl-space">
  469. <input type="text" name="domainQuota" size="8" value="{{ quota |e }}" class="text fl-space" />
  470. <select name="domainQuotaUnit">
  471. {% for unit in ['TB', 'GB', 'MB',] %}
  472. <option value="{{unit}}" {% if quotaUnit == unit %}selected{% endif %}>{{unit}}</option>
  473. {% endfor %}
  474. </select>
  475. </span>
  476. </div>
  477. {% endmacro %}
  478. {% macro display_domain_default_userquota(quota='1024') %}
  479. <div class="form-field clear">
  480. <h4 class="size-250 fl-space">{{ _('Default quota of new user') }}</h4>
  481. <span class="clean-padding">
  482. <input type="text" name="defaultQuota" size="8" value="{{ quota |e }}" class="text fl-space" /><label>MB</label>
  483. </span>
  484. </div>
  485. {% endmacro %}
  486. {% macro display_add_domain(label=false) -%}
  487. <div id="domain_add" class="box-wrap clear">
  488. {% if label is sameas true %}
  489. <h3>{{ _('Add domain') }}</h3>
  490. {% endif %}
  491. <form name="create" method="post" action="{{ctx.homepath}}/create/domain">
  492. {{ display_csrf_token() }}
  493. {{ display_input_domain(required=true) }}
  494. {{ display_input_cn(accountType='domain') }}
  495. <h4 class="size-250 fl-space">&nbsp;</h4>
  496. <span class="clean-padding bt-space20"><input type="submit" class="button green" value="{{ _('Add') }}" /></span>
  497. </form>
  498. </div>
  499. {%- endmacro %}
  500. {% macro display_maillist_restrictions(policy, maillist_email) -%}
  501. {% set policy = policy.lower() %}
  502. {% if policy == 'open' %}
  503. {{ _('Unrestricted') }}
  504. {% elif policy == 'domain' %}
  505. {{ _("<a href='%s'>Domain users</a>") |format(ctx.homepath + '/users/' + maillist_email.split('@')[-1] ) }}
  506. {% elif policy == 'subdomain' %}
  507. {{ _("<a href='%s'>Domain and sub-domain users</a>") |format(ctx.homepath + '/users/' + maillist_email.split('@')[-1] ) }}
  508. {% elif policy == 'membersonly' %}
  509. {{ _("<a href='%s'>Members</a>") |format(ctx.homepath + '/profile/maillist/members/' + maillist_email) }}
  510. {% elif policy == 'allowedonly' %}
  511. {{ _("<a href='%s'>Moderators</a>") |format(ctx.homepath + '/profile/maillist/moderators/' + maillist_email) }}
  512. {% elif policy == 'membersandmoderatorsonly' %}
  513. {{ _("<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) }}
  514. {% else %}
  515. {{ _('Unrestricted') }}
  516. {% endif %}
  517. {% endmacro %}
  518. {% macro highlight_username_in_mail(mail) -%}
  519. <span><strong>{{ mail.split('@')[0] |e }}</strong></span><span class="grey"><em>@{{ mail.split('@')[-1] |e }}</em></span>
  520. {% endmacro %}
  521. {%- macro display_random_password(length) -%}
  522. <div class="mark_blue bt-space10">
  523. <h4>{{ _('Need a random password?') }}</h4>
  524. <p class="clean-padding clean-padding bt-space10">{{ length | generate_random_strings }}</p>
  525. </div>
  526. {%- endmacro -%}
  527. {% macro show_pages(baseurl, total, cur_page, near_pages=4, sep='/page/') -%}
  528. {% if total % pageSizeLimit > 0 %}
  529. {% set total_pages = total // pageSizeLimit + 1 %}
  530. {% else %}
  531. {% set total_pages = total // pageSizeLimit %}
  532. {% endif %}
  533. {% set baseurl = baseurl |e %}
  534. {% set sep = sep |e %}
  535. <div class="pager fr">
  536. {# Show links of 'First Page', 'Previous Page' #}
  537. {%- if total_pages > 0 -%}
  538. <span class="nav">
  539. {% if total_pages > 3 %}
  540. <a href="{{baseurl}}{{sep}}1" class="first" title="{{ _('First Page') }}"><span>{{ _('First Page') }}</span></a>
  541. {% endif %}
  542. {% if cur_page != 1 and cur_page != 0 %}
  543. <a href="{{baseurl}}{{sep}}{{cur_page - 1}}" class="previous" title="{{ _('Previous Page') }}" ><span>{{ _('Previous Page') }}</span></a>
  544. {% endif %}
  545. </span>
  546. {%- endif -%}
  547. <span class="pages">
  548. {% if total_pages <= near_pages %}
  549. {# Show all cur_page numbers if total pages is less than or equal to 4 pages.#}
  550. {% for page_no in range(1, total_pages+1) %}
  551. <a href="{{baseurl}}{{sep}}{{page_no}}" {% if page_no == cur_page %}class="active"{% endif %}><span>{{page_no}}</span></a>
  552. {% endfor %}
  553. {% else %}
  554. {# Show current cur_page number and near numbers.#}
  555. {% if cur_page <= near_pages %}
  556. {# Show near pages. #}
  557. {% if total_pages - cur_page <= near_pages %}
  558. {% set end_page = cur_page + (total_pages - cur_page) %}
  559. {% else %}
  560. {% set end_page = cur_page + near_pages %}
  561. {% endif %}
  562. {% for page_no in range(1, end_page) %}
  563. {% if page_no != cur_page %}
  564. <a href="{{baseurl}}{{sep}}{{page_no}}"><span>{{page_no}}</span></a>
  565. {% else %}
  566. <a href="#" class="active"><span>{{ cur_page }}</span></a>
  567. {% endif %}
  568. {% endfor %}
  569. {# Show last page. #}
  570. {% if cur_page + near_pages < total_pages %}
  571. {% if cur_page + near_pages <= total_pages - 1 %}<a href="#"><span>...</span></a>{% endif %}
  572. {% endif %}
  573. <a href="{{baseurl}}{{sep}}{{total_pages}}"><span>{{total_pages}}</span></a>
  574. {% else %}
  575. {# Show first page number. #}
  576. {%- if cur_page - near_pages == 2 -%}
  577. <a href="{{baseurl}}{{sep}}1"><span>1</span></a>
  578. {%- elif cur_page - near_pages > 2 -%}
  579. <a href="{{baseurl}}{{sep}}1"><span>1</span></a>
  580. <a href="#"><span>...</span></a>
  581. {%- endif -%}
  582. {# Show nearby pages which number larger than cur_page. #}
  583. {% if total_pages - cur_page < near_pages %}
  584. {% set end_page = cur_page + (total_pages - cur_page) %}
  585. {% else %}
  586. {% set end_page = cur_page + near_pages %}
  587. {% endif %}
  588. {% for page_no in range((cur_page-near_pages), end_page + 1) %}
  589. {% if page_no != cur_page %}
  590. <a href="{{baseurl}}{{sep}}{{page_no}}" ><span>{{page_no}}</span></a>
  591. {% else %}
  592. <a href="#" class="active"><span>{{ cur_page }}</span></a>
  593. {% endif %}
  594. {% endfor %}
  595. {% if total_pages - cur_page > near_pages and total_pages - cur_page != near_pages + 1 %}
  596. <a href="#"><span>...</span></a>
  597. {% endif %}
  598. {% if end_page < total_pages %}
  599. <a href="{{baseurl}}{{sep}}{{total_pages}}" ><span>{{total_pages}}</span></a>
  600. {% endif %}
  601. {% endif %}
  602. {% endif %}
  603. </span>
  604. {# -- Show 'Next' and 'Last' -- #}
  605. {% if total_pages > 0 %}
  606. <span class="nav">
  607. {% if cur_page < total_pages and cur_page != 0 %}
  608. <a href="{{ baseurl }}{{ sep }}{{ cur_page + 1 }}" class="next" title="{{ _('Next Page') }}"><span>{{ _('Next Page') }}</span></a>
  609. {% endif %}
  610. {% if total_pages != 1 %}
  611. <a href="{{ baseurl }}{{ sep }}{{ total_pages }}" class="last" title="{{ _('Last Page') }}"><span>{{ _('Last Page') }}</span></a>
  612. {% endif %}
  613. </span>
  614. {% endif %}
  615. </div>
  616. {%- endmacro %}
  617. {# Convert event code to event name #}
  618. {% macro show_event_name(event) -%}
  619. {% set event_names = {'all': _('Events'),
  620. 'login': _('Admin login'),
  621. 'user_login': _('User login (self-service)'),
  622. 'create': _('Add account'),
  623. 'delete': _('Delete account'),
  624. 'disable': _('Disable account'),
  625. 'active': _('Activate account'),
  626. 'update': _('Edit account profile'),
  627. 'grant': _('Grant admin'),
  628. 'revoke': _('Revoke admin privilege'),
  629. 'backup': _('Backup'),
  630. 'update_wblist': _('Update whitelists and blacklists'),
  631. 'iredapd': 'iRedAPD',
  632. 'cron_delete_mailboxes': _('Delete mailboxes')} %}
  633. {% if event in event_names %}
  634. {{ event_names[event] }}
  635. {% else %}
  636. {{ event |e }}
  637. {% endif %}
  638. {%- endmacro %}