PageRenderTime 71ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/default/macros/general.html

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