PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | assets/js/mainwp-users.js +84 -48 5.1 → 6.2.1 View file →
@@ -3,9 +3,25 @@
3 3 */
4 4 let userCountSent = 0;
5 5 let userCountReceived = 0;
6 6
7 +let updateUsersBulkActionsState = function () {
8 + let checkedCount = jQuery('#mainwp-users-table input[name="user[]"]:checked').length;
9 + let dropdown = jQuery('#mainwp-manage-users #mainwp-bulk-actions');
10 + let applyButton = jQuery('#mainwp-do-users-bulk-actions');
7 11
12 + if (checkedCount > 0) {
13 + dropdown.removeClass('disabled');
14 + dropdown.parent('.ui.dropdown').removeClass('disabled');
15 + applyButton.removeClass('disabled');
16 + } else {
17 + dropdown.addClass('disabled');
18 + dropdown.parent('.ui.dropdown').addClass('disabled');
19 + dropdown.dropdown('set selected', 'none');
20 + applyButton.addClass('disabled');
21 + }
22 +};
23 +
8 24 let import_user_stop_by_user = false;
9 25 let import_user_current_line_number = 0;
10 26 let import_user_total_import = 0;
11 27 let import_user_count_created_users = 0;
@@ -12,8 +28,14 @@
12 28 let import_user_count_create_fails = 0;
13 29
14 30 jQuery(function () {
15 31
32 + updateUsersBulkActionsState();
33 +
34 + jQuery(document).on('change', '#mainwp-users-table .check-column INPUT:checkbox', function () {
35 + updateUsersBulkActionsState();
36 + });
37 +
16 38 // Fetch users
17 39 jQuery(document).on('click', '#mainwp_show_users', function () {
18 40 mainwp_fetch_users();
19 41 });
@@ -69,9 +91,9 @@
69 91 );
70 92 };
71 93
72 94 if (action == 'delete') {
73 - let msg = __('You are about to delete %1 user(s). Are you sure you want to proceed?', userCountSent);
95 + let msg = MainWP.I18n.t('You are about to delete %1 user(s). Are you sure you want to proceed?', userCountSent);
74 96 mainwp_confirm(msg, _callback);
75 97 return;
76 98 }
77 99
@@ -84,9 +106,9 @@
84 106 let tmp = jQuery("input[name='user[]']:checked");
85 107 userCountSent = tmp.length;
86 108
87 109 if (userCountSent == 0) {
88 - errors.push(__('Please search and select users.'));
110 + errors.push(MainWP.I18n.t('Please search and select users.'));
89 111 }
90 112
91 113 if (errors.length > 0) {
92 114 jQuery('#mainwp_update_password_error').html(errors.join('<br />'));
@@ -105,8 +127,18 @@
105 127 mainwpuser_postAction(elem, 'update_user');
106 128 }
107 129 );
108 130 });
131 +
132 + jQuery(document).on('click', '#bulk_updateadminpassword', function () {
133 + mainwp_confirm(
134 + 'You are about to update administrator passwords on selected sites. This will overwrite the current password for the admin account used for connection.',
135 + function () {
136 + jQuery('#mainwp-update-admin-password-form').submit()
137 + }
138 + );
139 + return false;
140 + });
109 141 });
110 142
111 143 let mainwp_edit_users_box_init = function () {
112 144
@@ -139,11 +171,8 @@
139 171 if (what == 'update_user') {
140 172 data['user_data'] = jQuery('form#update_user_profile').serialize();
141 173 }
142 174
143 -
144 -
145 -
146 175 rowElement.find('.row-actions').hide();
147 176 if (what === 'delete') {
148 177 rowElement.html('<td colspan="8"><i class="ui active inline loader tiny"></i> Please wait</td>');
149 178 }
@@ -223,21 +252,21 @@
223 252 let selected_sites = [];
224 253 let selected_groups = [];
225 254 let selected_clients = [];
226 255
227 - if (jQuery('#select_by').val() == 'site') {
256 + if (jQuery('input[name="select_by"]').val() == 'site') {
228 257 jQuery("input[name='selected_sites[]']:checked").each(function () {
229 258 selected_sites.push(jQuery(this).val());
230 259 });
231 260 if (selected_sites.length == 0) {
232 - errors.push(__('Please select at least one website or group or clients.'));
261 + errors.push(MainWP.I18n.t('Please select at least one website or group or clients.'));
233 262 }
234 - } else if (jQuery('#select_by').val() == 'client') {
263 + } else if (jQuery('input[name="select_by"]').val() == 'client') {
235 264 jQuery("input[name='selected_clients[]']:checked").each(function () {
236 265 selected_clients.push(jQuery(this).val());
237 266 });
238 267 if (selected_clients.length == 0) {
239 - errors.push(__('Please select at least one website or group or clients.'));
268 + errors.push(MainWP.I18n.t('Please select at least one website or group or clients.'));
240 269 }
241 270 } else {
242 271 jQuery("input[name='selected_groups[]']:checked").each(function () {
243 272 selected_groups.push(jQuery(this).val());
@@ -242,9 +271,9 @@
242 271 jQuery("input[name='selected_groups[]']:checked").each(function () {
243 272 selected_groups.push(jQuery(this).val());
244 273 });
245 274 if (selected_groups.length == 0) {
246 - errors.push(__('Please select at least one website or group or clients.'));
275 + errors.push(MainWP.I18n.t('Please select at least one website or group or clients.'));
247 276 }
248 277 }
249 278
250 279 let role = "";
@@ -264,9 +293,9 @@
264 293 let name = jQuery('#mainwp_search_users').val();
265 294
266 295 let data = mainwp_secure_data({
267 296 action: 'mainwp_users_search',
268 - role: role,
297 + urole: role,
269 298 search: name,
270 299 'groups[]': selected_groups,
271 300 'sites[]': selected_sites,
272 301 'clients[]': selected_clients
@@ -293,14 +322,15 @@
293 322 "columnDefs": [{
294 323 "targets": 'no-sort',
295 324 "orderable": false
296 325 }],
297 - "preDrawCallback": function () {
326 + "drawCallback": function () {
298 327 setTimeout(() => {
299 - jQuery('#mainwp_users_wrap_table table .ui.dropdown').dropdown();
300 - jQuery('#mainwp_users_wrap_table table .ui.checkbox').checkbox();
301 - mainwp_datatable_fix_menu_overflow();
328 + jQuery('#mainwp-users-table .ui.dropdown').dropdown();
329 + jQuery('#mainwp-users-table .ui.checkbox').checkbox();
330 + mainwp_datatable_fix_menu_overflow('#mainwp-users-table');
302 331 mainwp_table_check_columns_init(); // ajax: to fix checkbox all.
332 + updateUsersBulkActionsState();
303 333 }, 1000);
304 334 },
305 335 select: {
306 336 items: 'row',
@@ -311,8 +341,9 @@
311 341 if ('row' == type) {
312 342 dt.rows(indexes)
313 343 .nodes()
314 344 .to$().find('td.check-column .ui.checkbox').checkbox('set checked');
345 + updateUsersBulkActionsState();
315 346 }
316 347 }).on('deselect', function (e, dt, type, indexes) {
317 348 if ('row' == type) {
318 349 dt.rows(indexes)
@@ -317,15 +348,15 @@
317 348 if ('row' == type) {
318 349 dt.rows(indexes)
319 350 .nodes()
320 351 .to$().find('td.check-column .ui.checkbox').checkbox('set unchecked');
352 + updateUsersBulkActionsState();
321 353 }
322 354 }).on('columns-reordered', function () {
323 - console.log('columns-reordered');
324 355 setTimeout(() => {
325 - jQuery('#mainwp_users_wrap_table table .ui.dropdown').dropdown();
326 - jQuery('#mainwp_users_wrap_table table .ui.checkbox').checkbox();
327 - mainwp_datatable_fix_menu_overflow();
356 + jQuery('#mainwp-users-table .ui.dropdown').dropdown();
357 + jQuery('#mainwp-users-table .ui.checkbox').checkbox();
358 + mainwp_datatable_fix_menu_overflow('#mainwp-users-table');
328 359 mainwp_table_check_columns_init(); // ajax: to fix checkbox all.
329 360 }, 1000);
330 361 });
331 362 });
@@ -339,25 +370,25 @@
339 370 jQuery(function () {
340 371 import_user_total_import = jQuery('#import_user_total_import').val();
341 372
342 373 jQuery('#import_user_btn_import').on('click', function () {
343 - if (!import_user_stop_by_user) {
344 - import_user_stop_by_user = true;
345 - jQuery('#import_user_import_logging .log').append(_('Paused import by user.') + "\n");
346 - jQuery('#import_user_btn_import').val(__('Continue'));
347 - jQuery('#MainWPBulkUploadUserLoading').hide();
374 + if (import_user_stop_by_user) {
375 + import_user_stop_by_user = false;
376 + jQuery('#import_user_import_logging .log').append(MainWP.I18n.t('Continue import.') + "\n");
377 + jQuery('#import_user_btn_import').val(MainWP.I18n.t('Pause'));
378 + jQuery('#MainWPBulkUploadUserLoading').show();
348 379 if (import_user_count_create_fails > 0) {
349 380 jQuery('#import_user_btn_save_csv').attr("style", 'display:inline-block;'); //Enable
350 381 }
382 + mainwp_import_users_next();
351 383 } else {
352 - import_user_stop_by_user = false;
353 - jQuery('#import_user_import_logging .log').append(__('Continue import.') + "\n");
354 - jQuery('#import_user_btn_import').val(__('Pause'));
355 - jQuery('#MainWPBulkUploadUserLoading').show();
384 + import_user_stop_by_user = true;
385 + jQuery('#import_user_import_logging .log').append(_('Paused import by user.') + "\n");
386 + jQuery('#import_user_btn_import').val(MainWP.I18n.t('Continue'));
387 + jQuery('#MainWPBulkUploadUserLoading').hide();
356 388 if (import_user_count_create_fails > 0) {
357 389 jQuery('#import_user_btn_save_csv').attr("style", 'display:inline-block;'); //Enable
358 390 }
359 - mainwp_import_users_next();
360 391 }
361 392 });
362 393
363 394
@@ -376,11 +407,11 @@
376 407 }
377 408 });
378 409
379 410
380 -window.mainwp_bulkupload_users = function () {
411 +globalThis.mainwp_bulkupload_users = function () {
381 412 if (jQuery('#import_user_file_bulkupload').val() == '') {
382 - feedback('mainwp-message-zone', __('Please enter CSV file for upload.'), 'yellow');
413 + feedback('mainwp-message-zone', MainWP.I18n.t('Please enter CSV file for upload.'), 'yellow');
383 414 jQuery('#import_user_file_bulkupload').parent().parent().addClass('form-invalid');
384 415 } else {
385 416 jQuery('#createuser').submit();
386 417 }
@@ -390,8 +421,12 @@
390 421
391 422 if (import_user_stop_by_user)
392 423 return;
393 424
425 + if (!jQuery('[id^="user_import_csv_line_"]').length) {
426 + return;
427 + }
428 +
394 429 import_user_current_line_number++;
395 430
396 431 if (import_user_current_line_number > import_user_total_import) {
397 432 mainwp_import_users_finished();
@@ -406,11 +441,11 @@
406 441 let errors = [];
407 442
408 443 try {
409 444 decoded_data = JSON.parse(import_data);
410 - } catch (e) {
445 + } catch {
411 446 decoded_data = false;
412 - errors.push(__('Invalid import data.'));
447 + errors.push(MainWP.I18n.t('Invalid import data.'));
413 448 }
414 449
415 450 if (decoded_data) {
416 451 jQuery('#import_user_import_logging .log').append('[' + import_user_current_line_number + '] ' + original_line + '\n');
@@ -463,40 +498,41 @@
463 498 val_data.select_groups = decoded_data.select_groups == undefined ? '' : decoded_data.select_groups;
464 499 val_data.select_by = '';
465 500
466 501 if (val_data.user_login == '') {
467 - errors.push(__('Please enter a username.'));
502 + errors.push(MainWP.I18n.t('Please enter a username.'));
468 503 }
469 504
470 505 if (val_data.email == '') {
471 - errors.push(__('Please enter an email.'));
506 + errors.push(MainWP.I18n.t('Please enter an email.'));
472 507 }
473 508
474 509 if (val_data.pass1 == '') {
475 - errors.push(__('Please enter a password.'));
510 + errors.push(MainWP.I18n.t('Please enter a password.'));
476 511 }
477 512
478 513 let allowed_roles = ['subscriber', 'administrator', 'editor', 'author', 'contributor'];
479 514 if (jQuery.inArray(val_data.role, allowed_roles) == -1) {
480 - errors.push(__('Please select a data role.'));
515 + errors.push(MainWP.I18n.t('Please select a data role.'));
481 516 }
482 517
483 - if (val_data.select_sites != '') {
518 + if (val_data.select_sites == '') {
519 +
520 + let selected_groups = val_data.select_groups.split(';');
521 + if (selected_groups.length == 0) {
522 + errors.push(MainWP.I18n.t('Please select websites or groups to add a user.'));
523 + } else {
524 + val_data.select_groups = selected_groups;
525 + val_data.select_by = 'group';
526 + }
527 + } else {
484 528 let selected_sites = val_data.select_sites.split(';');
485 529 if (selected_sites.length == 0) {
486 - errors.push(__('Please select websites or groups to add a user.'));
530 + errors.push(MainWP.I18n.t('Please select websites or groups to add a user.'));
487 531 } else {
488 532 val_data.select_sites = selected_sites;
489 533 val_data.select_by = 'site';
490 534 }
491 - } else {
492 - let selected_groups = val_data.select_groups.split(';');
493 - if (selected_groups.length == 0) {
494 - errors.push(__('Please select websites or groups to add a user.'));
495 - } else {
496 - val_data.select_groups = selected_groups;
497 - val_data.select_by = 'group';
498 - }
499 535 }
500 536 return {
501 537 errors: errors,
502 538 data: val_data
@@ -529,9 +565,9 @@
529 565
530 566 let mainwp_import_users_finished = function () {
531 567 jQuery('#import_user_btn_import').val('Finished').attr('disabled', 'true');
532 568 jQuery('#MainWPBulkUploadUserLoading').hide();
533 - jQuery('#import_user_import_logging .log').append('\n' + __('Number of users to import: %1 Created users: %2 Failed: %3', import_user_total_import, import_user_count_created_users, import_user_count_create_fails) + '\n');
569 + jQuery('#import_user_import_logging .log').append('\n' + MainWP.I18n.t('Number of users to import: %1 Created users: %2 Failed: %3', import_user_total_import, import_user_count_created_users, import_user_count_create_fails) + '\n');
534 570 if (import_user_count_create_fails > 0) {
535 571 jQuery('#import_user_btn_save_csv').attr("style", 'display:inline-block;'); //Enable
536 572 }
537 573 jQuery('#import_user_import_logging').scrollTop(jQuery('#import_user_import_logging .log').height());