user.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. // Base64 functions
  2. var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(r){var t,e,o,a,h,n,c,d="",C=0;for(r=Base64._utf8_encode(r);C<r.length;)a=(t=r.charCodeAt(C++))>>2,h=(3&t)<<4|(e=r.charCodeAt(C++))>>4,n=(15&e)<<2|(o=r.charCodeAt(C++))>>6,c=63&o,isNaN(e)?n=c=64:isNaN(o)&&(c=64),d=d+this._keyStr.charAt(a)+this._keyStr.charAt(h)+this._keyStr.charAt(n)+this._keyStr.charAt(c);return d},decode:function(r){var t,e,o,a,h,n,c="",d=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");d<r.length;)t=this._keyStr.indexOf(r.charAt(d++))<<2|(a=this._keyStr.indexOf(r.charAt(d++)))>>4,e=(15&a)<<4|(h=this._keyStr.indexOf(r.charAt(d++)))>>2,o=(3&h)<<6|(n=this._keyStr.indexOf(r.charAt(d++))),c+=String.fromCharCode(t),64!=h&&(c+=String.fromCharCode(e)),64!=n&&(c+=String.fromCharCode(o));return c=Base64._utf8_decode(c)},_utf8_encode:function(r){r=r.replace(/\r\n/g,"\n");for(var t="",e=0;e<r.length;e++){var o=r.charCodeAt(e);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t},_utf8_decode:function(r){for(var t="",e=0,o=c1=c2=0;e<r.length;)(o=r.charCodeAt(e))<128?(t+=String.fromCharCode(o),e++):o>191&&o<224?(c2=r.charCodeAt(e+1),t+=String.fromCharCode((31&o)<<6|63&c2),e+=2):(c2=r.charCodeAt(e+1),c3=r.charCodeAt(e+2),t+=String.fromCharCode((15&o)<<12|(63&c2)<<6|63&c3),e+=3);return t}};
  3. $(document).ready(function() {
  4. // Spam score slider
  5. var spam_slider = $('#spam_score')[0];
  6. if (typeof spam_slider !== 'undefined') {
  7. noUiSlider.create(spam_slider, {
  8. start: user_spam_score,
  9. connect: [true, true, true],
  10. range: {
  11. 'min': [0], //stepsize is 50.000
  12. '50%': [10],
  13. '70%': [20, 5],
  14. '80%': [50, 10],
  15. '90%': [100, 100],
  16. '95%': [1000, 1000],
  17. 'max': [5000]
  18. },
  19. });
  20. var connect = spam_slider.querySelectorAll('.noUi-connect');
  21. var classes = ['c-1-color', 'c-2-color', 'c-3-color'];
  22. for (var i = 0; i < connect.length; i++) {
  23. connect[i].classList.add(classes[i]);
  24. }
  25. spam_slider.noUiSlider.on('update', function (values, handle) {
  26. $('.spam-ham-score').text('< ' + Math.round(values[0] * 10) / 10);
  27. $('.spam-spam-score').text(Math.round(values[0] * 10) / 10 + ' - ' + Math.round(values[1] * 10) / 10);
  28. $('.spam-reject-score').text('> ' + Math.round(values[1] * 10) / 10);
  29. $('#spam_score_value').val((Math.round(values[0] * 10) / 10) + ',' + (Math.round(values[1] * 10) / 10));
  30. });
  31. }
  32. // syncjobLogModal
  33. $('#syncjobLogModal').on('show.bs.modal', function(e) {
  34. var syncjob_id = $(e.relatedTarget).data('syncjob-id');
  35. $.ajax({
  36. url: '/inc/ajax/syncjob_logs.php',
  37. data: { id: syncjob_id },
  38. dataType: 'text',
  39. success: function(data){
  40. $(e.currentTarget).find('#logText').text(data);
  41. },
  42. error: function(xhr, status, error) {
  43. $(e.currentTarget).find('#logText').text(xhr.responseText);
  44. }
  45. });
  46. });
  47. $(".arrow-toggle").on('click', function(e) { e.preventDefault(); $(this).find('.arrow').toggleClass("animation"); });
  48. $("#pushover_delete").click(function() { return confirm(lang.delete_ays); });
  49. });
  50. jQuery(function($){
  51. // http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
  52. var entityMap = {
  53. '&': '&amp;',
  54. '<': '&lt;',
  55. '>': '&gt;',
  56. '"': '&quot;',
  57. "'": '&#39;',
  58. '/': '&#x2F;',
  59. '`': '&#x60;',
  60. '=': '&#x3D;'
  61. };
  62. function escapeHtml(string) {
  63. return String(string).replace(/[&<>"'`=\/]/g, function (s) {
  64. return entityMap[s];
  65. });
  66. }
  67. // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
  68. function validateEmail(email) {
  69. var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  70. return re.test(email);
  71. }
  72. function unix_time_format(tm) {
  73. var date = new Date(tm ? tm * 1000 : 0);
  74. return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
  75. }
  76. acl_data = JSON.parse(acl);
  77. $('.clear-last-logins').on('click', function () {if (confirm(lang.delete_ays)) {last_logins('reset');}})
  78. $(".login-history").on('click', function(e) {e.preventDefault(); last_logins('get', $(this).data('days'));$(this).addClass('active').siblings().removeClass('active');});
  79. function last_logins(action, days = 1) {
  80. if (action == 'get') {
  81. $('.last-login').html('<i class="bi bi-hourglass"></i>' + lang.waiting);
  82. $.ajax({
  83. dataType: 'json',
  84. url: '/api/v1/get/last-login/' + encodeURIComponent(mailcow_cc_username) + '/' + days,
  85. jsonp: false,
  86. error: function () {
  87. console.log('error reading last logins');
  88. },
  89. success: function (data) {
  90. $('.last-login').html();
  91. if (data.ui.time) {
  92. $('.last-login').html('<i class="bi bi-person-fill"></i> ' + lang.last_ui_login + ': ' + unix_time_format(data.ui.time));
  93. } else {
  94. $('.last-login').text(lang.no_last_login);
  95. }
  96. if (data.sasl) {
  97. $('.last-login').append('<ul class="list-group">');
  98. $.each(data.sasl, function (i, item) {
  99. var datetime = new Date(item.datetime.replace(/-/g, "/"));
  100. var local_datetime = datetime.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
  101. var service = '<div class="label label-default">' + item.service.toUpperCase() + '</div>';
  102. var app_password = item.app_password ? ' <a href="/edit/app-passwd/' + item.app_password + '"><i class="bi bi-pen"></i> ' + escapeHtml(item.app_password_name || "App") + '</a>' : '';
  103. var real_rip = item.real_rip.startsWith("Web") ? item.real_rip : '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + "</a>";
  104. var ip_location = item.location ? ' <span class="flag-icon flag-icon-' + item.location.toLowerCase() + '"></span>' : '';
  105. var ip_data = real_rip + ip_location + app_password;
  106. $(".last-login").append('<li class="list-group-item">' + local_datetime + " " + service + " " + lang.from + " " + ip_data + "</li>");
  107. })
  108. $('.last-login').append('</ul>');
  109. }
  110. }
  111. })
  112. } else if (action == 'reset') {
  113. $.ajax({
  114. dataType: 'json',
  115. url: '/api/v1/get/reset-last-login/' + encodeURIComponent(mailcow_cc_username),
  116. jsonp: false,
  117. error: function () {
  118. console.log('cannot reset last logins');
  119. },
  120. success: function (data) {
  121. last_logins('get');
  122. }
  123. })
  124. }
  125. }
  126. function draw_tla_table() {
  127. ft_tla_table = FooTable.init('#tla_table', {
  128. "columns": [
  129. {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
  130. {"name":"address","title":lang.alias},
  131. {"name":"validity","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});},"title":lang.alias_valid_until,"style":{"width":"170px"}},
  132. {"sorted": true,"sortValue": function(value){res = new Date(value);return res.getTime();},"direction":"DESC","name":"created","formatter":function date_format(datetime) { var date = new Date(datetime.replace(/-/g, "/")); return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});},"title":lang.created_on,"style":{"width":"170px"}},
  133. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"220px","width":"220px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  134. ],
  135. "empty": lang.empty,
  136. "rows": $.ajax({
  137. dataType: 'json',
  138. url: '/api/v1/get/time_limited_aliases',
  139. jsonp: false,
  140. error: function () {
  141. console.log('Cannot draw tla table');
  142. },
  143. success: function (data) {
  144. $.each(data, function (i, item) {
  145. if (acl_data.spam_alias === 1) {
  146. item.action = '<div class="btn-group footable-actions">' +
  147. '<a href="#" data-action="delete_selected" data-id="single-tla" data-api-url="delete/time_limited_alias" data-item="' + encodeURIComponent(item.address) + '" class="btn btn-xs btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' +
  148. '</div>';
  149. item.chkbox = '<input type="checkbox" data-id="tla" name="multi_select" value="' + encodeURIComponent(item.address) + '" />';
  150. item.address = escapeHtml(item.address);
  151. }
  152. else {
  153. item.chkbox = '<input type="checkbox" disabled />';
  154. item.action = '<span>-</span>';
  155. }
  156. });
  157. }
  158. }),
  159. "paging": {
  160. "enabled": true,
  161. "limit": 5,
  162. "size": pagination_size
  163. },
  164. "state": {"enabled": true},
  165. "sorting": {
  166. "enabled": true
  167. },
  168. "toggleSelector": "table tbody span.footable-toggle"
  169. });
  170. }
  171. function draw_sync_job_table() {
  172. ft_syncjob_table = FooTable.init('#sync_job_table', {
  173. "columns": [
  174. {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
  175. {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  176. {"name":"server_w_port","title":"Server","breakpoints":"xs sm md","style":{"word-break":"break-all"}},
  177. {"name":"enc1","title":lang.encryption,"breakpoints":"all"},
  178. {"name":"user1","title":lang.username},
  179. {"name":"exclude","title":lang.excludes,"breakpoints":"all"},
  180. {"name":"mins_interval","title":lang.interval + " (min)","breakpoints":"all"},
  181. {"name":"last_run","title":lang.last_run,"breakpoints":"xs sm md"},
  182. {"name":"exit_status","filterable": false,"title":lang.syncjob_last_run_result},
  183. {"name":"log","title":"Log"},
  184. {"name":"active","filterable": false,"style":{"maxWidth":"70px","width":"70px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
  185. {"name":"is_running","filterable": false,"style":{"maxWidth":"120px","width":"100px"},"title":lang.status},
  186. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"260px","width":"260px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  187. ],
  188. "empty": lang.empty,
  189. "rows": $.ajax({
  190. dataType: 'json',
  191. url: '/api/v1/get/syncjobs/' + encodeURIComponent(mailcow_cc_username) + '/no_log',
  192. jsonp: false,
  193. error: function () {
  194. console.log('Cannot draw sync job table');
  195. },
  196. success: function (data) {
  197. $.each(data, function (i, item) {
  198. item.user1 = escapeHtml(item.user1);
  199. item.log = '<a href="#syncjobLogModal" data-toggle="modal" data-syncjob-id="' + item.id + '">' + lang.open_logs + '</a>'
  200. if (!item.exclude > 0) {
  201. item.exclude = '-';
  202. } else {
  203. item.exclude = '<code>' + escapeHtml(item.exclude) + '</code>';
  204. }
  205. item.server_w_port = escapeHtml(item.user1 + '@' + item.host1 + ':' + item.port1);
  206. if (acl_data.syncjobs === 1) {
  207. item.action = '<div class="btn-group footable-actions">' +
  208. '<a href="/edit/syncjob/' + item.id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' +
  209. '<a href="#" data-action="delete_selected" data-id="single-syncjob" data-api-url="delete/syncjob" data-item="' + item.id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' +
  210. '</div>';
  211. item.chkbox = '<input type="checkbox" data-id="syncjob" name="multi_select" value="' + item.id + '" />';
  212. }
  213. else {
  214. item.action = '<span>-</span>';
  215. item.chkbox = '<input type="checkbox" disabled />';
  216. }
  217. if (item.is_running == 1) {
  218. item.is_running = '<span id="active-script" class="label label-success">' + lang.running + '</span>';
  219. } else {
  220. item.is_running = '<span id="inactive-script" class="label label-warning">' + lang.waiting + '</span>';
  221. }
  222. if (!item.last_run > 0) {
  223. item.last_run = lang.waiting;
  224. }
  225. if (item.success == null) {
  226. item.success = '-';
  227. item.exit_status = '';
  228. } else {
  229. item.success = '<i class="text-' + (item.success == 1 ? 'success' : 'danger') + ' bi bi-' + (item.success == 1 ? 'check-lg' : 'x-lg') + '"></i>';
  230. }
  231. if (lang['syncjob_'+item.exit_status]) {
  232. item.exit_status = lang['syncjob_'+item.exit_status];
  233. } else if (item.success != '-') {
  234. item.exit_status = lang.syncjob_check_log;
  235. }
  236. item.exit_status = item.success + ' ' + item.exit_status;
  237. });
  238. }
  239. }),
  240. "paging": {
  241. "enabled": true,
  242. "limit": 5,
  243. "size": pagination_size
  244. },
  245. "state": {"enabled": true},
  246. "sorting": {
  247. "enabled": true
  248. },
  249. "toggleSelector": "table tbody span.footable-toggle"
  250. });
  251. }
  252. function draw_app_passwd_table() {
  253. ft_apppasswd_table = FooTable.init('#app_passwd_table', {
  254. "columns": [
  255. {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
  256. {"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
  257. {"name":"name","title":lang.app_name},
  258. {"name":"protocols","title":lang.allowed_protocols},
  259. {"name":"active","filterable": false,"style":{"maxWidth":"70px","width":"70px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
  260. {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"220px","width":"220px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
  261. ],
  262. "empty": lang.empty,
  263. "rows": $.ajax({
  264. dataType: 'json',
  265. url: '/api/v1/get/app-passwd/all',
  266. jsonp: false,
  267. error: function () {
  268. console.log('Cannot draw app passwd table');
  269. },
  270. success: function (data) {
  271. $.each(data, function (i, item) {
  272. item.name = escapeHtml(item.name)
  273. item.protocols = []
  274. if (item.imap_access == 1) { item.protocols.push("<code>IMAP</code>"); }
  275. if (item.smtp_access == 1) { item.protocols.push("<code>SMTP</code>"); }
  276. if (item.eas_access == 1) { item.protocols.push("<code>EAS/ActiveSync</code>"); }
  277. if (item.dav_access == 1) { item.protocols.push("<code>DAV</code>"); }
  278. if (item.pop3_access == 1) { item.protocols.push("<code>POP3</code>"); }
  279. if (item.sieve_access == 1) { item.protocols.push("<code>Sieve</code>"); }
  280. item.protocols = item.protocols.join(" ")
  281. if (acl_data.app_passwds === 1) {
  282. item.action = '<div class="btn-group footable-actions">' +
  283. '<a href="/edit/app-passwd/' + item.id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' +
  284. '<a href="#" data-action="delete_selected" data-id="single-apppasswd" data-api-url="delete/app-passwd" data-item="' + item.id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' +
  285. '</div>';
  286. item.chkbox = '<input type="checkbox" data-id="apppasswd" name="multi_select" value="' + item.id + '" />';
  287. }
  288. else {
  289. item.action = '<span>-</span>';
  290. item.chkbox = '<input type="checkbox" disabled />';
  291. }
  292. });
  293. }
  294. }),
  295. "paging": {
  296. "enabled": true,
  297. "limit": 5,
  298. "size": pagination_size
  299. },
  300. "state": {"enabled": true},
  301. "sorting": {
  302. "enabled": true
  303. },
  304. "toggleSelector": "table tbody span.footable-toggle"
  305. });
  306. }
  307. function draw_wl_policy_mailbox_table() {
  308. ft_wl_policy_mailbox_table = FooTable.init('#wl_policy_mailbox_table', {
  309. "columns": [
  310. {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
  311. {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
  312. {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
  313. {"name":"object","title":"Scope"}
  314. ],
  315. "empty": lang.empty,
  316. "rows": $.ajax({
  317. dataType: 'json',
  318. url: '/api/v1/get/policy_wl_mailbox',
  319. jsonp: false,
  320. error: function () {
  321. console.log('Cannot draw mailbox policy wl table');
  322. },
  323. success: function (data) {
  324. $.each(data, function (i, item) {
  325. if (validateEmail(item.object)) {
  326. item.chkbox = '<input type="checkbox" data-id="policy_wl_mailbox" name="multi_select" value="' + item.prefid + '" />';
  327. }
  328. else {
  329. item.chkbox = '<input type="checkbox" disabled title="' + lang.spamfilter_table_domain_policy + '" />';
  330. }
  331. if (acl_data.spam_policy === 0) {
  332. item.chkbox = '<input type="checkbox" disabled />';
  333. }
  334. });
  335. }
  336. }),
  337. "state": {"enabled": true},
  338. "paging": {
  339. "enabled": true,
  340. "limit": 5,
  341. "size": pagination_size
  342. },
  343. "sorting": {
  344. "enabled": true
  345. }
  346. });
  347. }
  348. function draw_bl_policy_mailbox_table() {
  349. ft_bl_policy_mailbox_table = FooTable.init('#bl_policy_mailbox_table', {
  350. "columns": [
  351. {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
  352. {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
  353. {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
  354. {"name":"object","title":"Scope"}
  355. ],
  356. "empty": lang.empty,
  357. "rows": $.ajax({
  358. dataType: 'json',
  359. url: '/api/v1/get/policy_bl_mailbox',
  360. jsonp: false,
  361. error: function () {
  362. console.log('Cannot draw mailbox policy bl table');
  363. },
  364. success: function (data) {
  365. $.each(data, function (i, item) {
  366. if (validateEmail(item.object)) {
  367. item.chkbox = '<input type="checkbox" data-id="policy_bl_mailbox" name="multi_select" value="' + item.prefid + '" />';
  368. }
  369. else {
  370. item.chkbox = '<input type="checkbox" disabled tooltip="' + lang.spamfilter_table_domain_policy + '" />';
  371. }
  372. if (acl_data.spam_policy === 0) {
  373. item.chkbox = '<input type="checkbox" disabled />';
  374. }
  375. });
  376. }
  377. }),
  378. "paging": {
  379. "enabled": true,
  380. "limit": 5,
  381. "size": pagination_size
  382. },
  383. "state": {"enabled": true},
  384. "sorting": {
  385. "enabled": true
  386. }
  387. });
  388. }
  389. $('body').on('click', 'span.footable-toggle', function () {
  390. event.stopPropagation();
  391. })
  392. draw_sync_job_table();
  393. draw_app_passwd_table();
  394. draw_tla_table();
  395. draw_wl_policy_mailbox_table();
  396. draw_bl_policy_mailbox_table();
  397. last_logins('get');
  398. // FIDO2 friendly name modal
  399. $('#fido2ChangeFn').on('show.bs.modal', function (e) {
  400. rename_link = $(e.relatedTarget)
  401. if (rename_link != null) {
  402. $('#fido2_cid').val(rename_link.data('cid'));
  403. $('#fido2_subject_desc').text(Base64.decode(rename_link.data('subject')));
  404. }
  405. })
  406. // Sieve data modal
  407. $('#userFilterModal').on('show.bs.modal', function(e) {
  408. $('#user_sieve_filter').text(lang.loading);
  409. $.ajax({
  410. dataType: 'json',
  411. url: '/api/v1/get/active-user-sieve/' + encodeURIComponent(mailcow_cc_username),
  412. jsonp: false,
  413. error: function () {
  414. console.log('Cannot get active sieve script');
  415. },
  416. complete: function (data) {
  417. if (data.responseText == '{}') {
  418. $('#user_sieve_filter').text(lang.no_active_filter);
  419. } else {
  420. $('#user_sieve_filter').text(JSON.parse(data.responseText));
  421. }
  422. }
  423. })
  424. });
  425. $('#userFilterModal').on('hidden.bs.modal', function () {
  426. $('#user_sieve_filter').text(lang.loading);
  427. });
  428. });