merge_users.php
3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Auth;
use Exception, StdClass;
use WP_User;
// Make sure some defaults are set because we use these values as is in the input boxes
if (! isset($_POST['search_user_from'])) {
$_POST['search_user_from'] = '';
}
if (! isset($_POST['search_user_to'])) {
$_POST['search_user_to'] = '';
}
?>
<style>
#post-body {
-moz-border-radius-bottomleft: 6px;
-moz-border-radius-bottomright: 6px;
-moz-border-radius-topright: 6px;
background: none repeat scroll 0 0 #FFFFFF;
border-width: 1px 1px 1px;
padding: 10px;
}
#field-list {
display: none;
}
</style>
<div class="wrap">
<div id="icon-users" class="icon32"><br /></div>
<h2>Merging CBV Users...</h2>
<div class="validation-errors" style="display:none; margin-top:10px;">
<div class="error-wrap">
<h6>OOPS...</h6>
<ul></ul>
</div>
</div>
<div id="post-body" style="padding:0px 10px 15px 10px;">
<form method="post" id="admin-search-merge-form">
<div class="merge-users">
<label for="search_user_from">Merge FROM User:</label>
<input class="clear" type="text" name="search_user_from" value="<?php echo $_POST['search_user_from'] ?>" />
<input type="button" name="btn_user_from" value="Search" />
<div id="user-list-from"></div>
</div>
<div class="merge-users">
<label for="search_user_to">Merge TO User:</label>
<input class="clear" type="text" name="search_user_to" value="<?php echo $_POST['search_user_to'] ?>" />
<input type="button" name="btn_user_to" value="Search" />
<div id="user-list-to"></div>
</div>
<div id="field-list">
<h6>Success!</h6>
<table></table>
</div>
<div style="clear:both;"></div>
<div style="margin-top:10px;padding-top:5px; border-top:1px solid #e8e8e8;">
<input type="hidden" value="from" name="which_user_search" />
<input type="hidden" value="no" name="do_search" />
<input type="hidden" value="no" name="do_merge" />
<input type="button" value="Merge Users" name="btn_merge" />
</div>
</form>
</div>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
<script type="text/javascript">
var $ = jQuery;
var $which_user_search = $('[name=which_user_search]');
var $do_search = $('[name=do_search]');
var $do_merge = $('[name=do_merge]');
var $form = $('#admin-search-merge-form');
var $error_container = $('.validation-errors');
var $field_list = $('#field-list');
$('[name=btn_user_from]').click(function() {
$which_user_search.val("from");
$do_search.val("yes");
$('[name=merge_user_from]').attr("checked", false);
$form.submit();
});
$('[name=btn_user_to]').click(function() {
$which_user_search.val("to");
$do_search.val("yes");
$('[name=merge_user_to]').attr("checked", false);
$form.submit();
});
$('[name=btn_merge]').click(function() {
$do_search.val("no");
$do_merge.val("yes");
$form.submit();
});
$(function() {
var options = {
url: ajaxurl,
dataType: 'json',
type: 'post',
data: ({ajax:"yes", action: 'admin_search_merge_users'}),
success: function(data) {
if (data.success == "false") {
$('h6', $error_container).html("OOPS...");
$('ul', $error_container).html(data.msg);
$field_list.hide();
$error_container.show();
} else {
$error_container.hide();
if (data.fields === undefined) {
$('#user-list-' + data.direction).html(data.html);
$field_list.hide();
} else {
$('#user-list-from').html("");
$('#user-list-to').html("");
$('table', $field_list).html(data.fields);
$field_list.show();
}
}
}
};
$form.ajaxForm(options);
});
</script>