PageRenderTime 68ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/default/macros/general.html

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