-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathtemplate-new-user.php
More file actions
329 lines (289 loc) · 21.5 KB
/
Copy pathtemplate-new-user.php
File metadata and controls
329 lines (289 loc) · 21.5 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?php
/*
* Name: User Management
*/
// Ensure Add New Users' admin setting has been enabled on multi-sites
if ( current_user_can( 'manage_dt' ) && !current_user_can( 'create_users' ) && is_multisite() && empty( get_site_option( 'add_new_users' ) ) ){
get_header();
?>
<div class="large-6 medium-6 small-6"
style="max-width: 50% !important; margin-left: auto !important; margin-right: auto !important; margin-top: 50px; margin-bottom: 50px;">
<div class="bordered-box">
<h3><?php esc_html_e( 'Permission denied', 'disciple_tools' ); ?></h3>
<p>
<?php esc_html_e( 'Administrator must enable "Add New Users" option in multisite settings:', 'disciple_tools' ); ?>
<a href="<?php echo esc_html( site_url( '/wp-admin/network/settings.php' ) ); ?>"
target="_blank">Network Admin Settings</a>
</p>
</div>
</div>
<?php
get_footer();
exit();
}
$current_user_can_manage_users = current_user_can( 'create_users' ) || current_user_can( 'manage_dt' );
if ( !$current_user_can_manage_users && !DT_User_Management::non_admins_can_make_users() ) {
wp_safe_redirect( '/registered' );
exit();
}
$dt_url_path = dt_get_url_path();
/* Build variables for page */
$dt_user_fields = dt_get_site_custom_lists( 'user_fields' );
$gender_fields = DT_Posts::get_post_settings( 'contacts' )['fields']['gender'];
?>
<?php get_header(); ?>
<div id="user-add-user" style="padding:15px">
<div id="inner-content" class="grid-x grid-margin-x grid-margin-y">
<?php if ( $current_user_can_manage_users ): ?>
<div class="large-2 medium-3 small-12 cell hide-for-small-only" id="side-nav-container">
<section id="metrics-side-section" class="medium-12 cell">
<div class="bordered-box">
<ul id="metrics-sidemenu" class="vertical menu accordion-menu" data-accordion-menu data-multi-expand="true" >
<?php
// WordPress.XSS.EscapeOutput.OutputNotEscaped
// @phpcs:ignore
echo apply_filters( 'dt_metrics_menu', '' );
?>
</ul>
</div>
</section>
</div>
<?php endif; ?>
<!-- List Section -->
<div class="<?php echo ( $current_user_can_manage_users ) ? 'large-10 medium-9 small-12' : '' ?> cell ">
<section id="metrics-container" class="medium-12 cell">
<div class="bordered-box">
<div id="chart">
<div class="grid-x">
<div id="page-title" class="cell">
<h3><?php esc_html_e( 'Add New User', 'disciple_tools' ); ?><span class="loading-spinner" style="margin-inline-start: 5px"></span></h3>
</div>
<div class="cell medium-12">
<form data-abide id="new-user-form">
<div data-abide-error class="alert callout" style="display: none;">
<p><i class="fi-alert"></i><?php esc_html_e( 'There are some errors in your form.', 'disciple_tools' ); ?></p>
</div>
<div class="grid-x row gutter-small">
<div class="cell medium-6">
<dt-label for="subassigned[query]"><?php esc_html_e( 'Contact to make a user (optional)', 'disciple_tools' ); ?></dt-label>
<div class="subassigned details" style="margin-bottom: 16px;">
<var id="subassigned-result-container" class="result-container subassigned-result-container"></var>
<div id="subassigned_t" name="form-subassigned" class="scrollable-typeahead">
<div class="typeahead__container">
<div class="typeahead__field">
<span class="typeahead__query">
<input id="subassigned[query]" class="js-typeahead-subassigned input-height"
name="subassigned[query]" placeholder="<?php esc_html_e( 'Search multipliers and contacts', 'disciple_tools' ); ?>"
autocomplete="off">
</span>
</div>
</div>
</div>
</div>
<div id="contact-result"></div>
<div style="margin-bottom: 16px;">
<?php DT_Components::render_text( 'emankcin', [
'emankcin' => [
'name' => __( 'Display Name', 'disciple_tools' ),
'type' => 'text',
'default' => '',
]
], [], [ 'placeholder' => __( 'Nickname (Display Name)', 'disciple_tools' ) ] ) ?>
</div>
<div style="margin-bottom: 16px;">
<?php DT_Components::render_text( 'liame', [
'liame' => [
'name' => __( 'Email', 'disciple_tools' ),
'type' => 'text',
'default' => '',
'required' => true,
]
], [], [ 'placeholder' => __( 'Email', 'disciple_tools' ) ] ) ?>
</div>
<div class="hidden-fields" style="display:none">
<div style="margin-bottom: 16px;">
<?php DT_Components::render_text( 'emanresu', [
'emanresu' => [
'name' => __( 'Username', 'disciple_tools' ),
'type' => 'text',
'default' => '',
]
], [], [ 'placeholder' => __( 'Username', 'disciple_tools' ) ] ) ?>
</div>
<div style="margin-bottom: 16px;">
<?php DT_Components::render_text( 'ddrowssap', [
'ddrowssap' => [
'name' => __( 'Password', 'disciple_tools' ),
'type' => 'text',
'default' => '',
]
], [], [ 'placeholder' => __( 'Password', 'disciple_tools' ) ] ) ?>
</div>
</div>
<?php if ( $current_user_can_manage_users ) : ?>
<div id="show-shield-banner" style="text-align: center; background-color:rgb(236, 245, 252);margin: 3px -15px 15px -15px;">
<a class="button clear" id="show-hidden-fields" style="margin:0;padding:3px 0; width:100%">
<?php esc_html_e( 'See More Options', 'disciple_tools' ); ?>
</a>
<a class="button clear" id="hide-hidden-fields" style="margin:0;padding:3px 0; width:100%; display: none;">
<?php esc_html_e( 'See Fewer Options', 'disciple_tools' ); ?>
</a>
</div>
<?php endif; ?>
<dt-label for="new-user-language-dropdown"><?php esc_html_e( 'Language', 'disciple_tools' ); ?></dt-label>
<div id="new-user-language-dropdown" style="margin-bottom: 16px;"></div>
<?php if ( $current_user_can_manage_users ): ?>
<dt-label><?php esc_html_e( 'Role', 'disciple_tools' ); ?></dt-label>
<?php
$user_roles = [ 'multiplier' ];
$roles = dt_list_roles( false );
?>
<ul id="user_roles_list" class="no-bullet">
<?php foreach ( $roles as $role_key => $role_value ) : ?>
<li>
<label style="color:<?php echo esc_html( $role_value['disabled'] ? 'grey' : 'inherit' ); ?>">
<input type="checkbox" name="dt_multi_role_user_roles[]"
value="<?php echo esc_attr( $role_key ); ?>"
<?php checked( in_array( $role_key, $user_roles ) ); ?>
<?php disabled( $role_value['disabled'] ); ?> />
<strong>
<?php
if ( isset( $role_value['label'] ) && !empty( $role_value['label'] ) ){
echo esc_html( $role_value['label'] );
} else {
echo esc_html( $role_key );
}
?>
</strong>
<?php
if ( isset( $role_value['description'] ) ){
echo ' - ' . esc_html( $role_value['description'] );
}
?>
</label>
</li>
<?php endforeach; ?>
</ul>
<p> <a href="https://disciple.tools/docs/roles-introduction/" target="_blank"><?php esc_html_e( 'Click here to see roles documentation', 'disciple_tools' ); ?></a> </p>
<?php endif; ?>
<button type="submit" class="submit button loader" id="create-user"><?php esc_html_e( 'Create User', 'disciple_tools' ); ?></button>
</div>
<div id="optional-fields" class="cell medium-6 show-for-medium">
<div style="margin-bottom: 16px;">
<?php DT_Components::render_text( 'first_name', [
'first_name' => [
'name' => __( 'First Name (optional)', 'disciple_tools' ),
'type' => 'text',
'default' => '',
]
], [], [ 'placeholder' => __( 'First Name', 'disciple_tools' ) ] ) ?>
</div>
<div style="margin-bottom: 16px;">
<?php DT_Components::render_text( 'last_name', [
'last_name' => [
'name' => __( 'Last Name (optional)', 'disciple_tools' ),
'type' => 'text',
'default' => '',
]
], [], [ 'placeholder' => __( 'Last Name', 'disciple_tools' ) ] ) ?>
</div>
<div style="margin-bottom: 16px;">
<?php DT_Components::render_key_select( 'gender', [
'gender' => [
'name' => __( 'Gender (optional)', 'disciple_tools' ),
'type' => 'key_select',
'default' => $gender_fields['default'],
'select_cannot_be_empty' => true,
]
], [ 'gender' => [ 'key' => 'male' ] ], [] ) ?>
</div>
<?php // site defined fields
foreach ( $dt_user_fields as $dt_field ) {
if ( empty( $dt_field['enabled'] ) ){
continue;
}
?>
<div style="margin-bottom: 16px;">
<?php DT_Components::render_text( $dt_field['key'], [
$dt_field['key'] => [
'name' => $dt_field['label'],
'type' => 'text',
'default' => '',
]
], [], [ 'placeholder' => $dt_field['label'], 'data-optional' => true ] ) ?>
</div>
<?php
} // end foreach
?>
<dt-textarea
class="input" id="description"
label="<?php esc_html_e( 'Biography', 'disciple_tools' )?>"
name="description"
placeholder="<?php esc_html_e( 'Biography', 'disciple_tools' )?>"
rows="5"
data-optional
></textarea>
</div>
</div>
<div id="show-optional-fields-banner" class="show-for-small-only" style="text-align: center; background-color:rgb(236, 245, 252);margin: 3px -15px 15px -15px;">
<a class="button clear" id="show-optional-fields" style="margin:0;padding:3px 0; width:100%">
<?php esc_html_e( 'See More Options', 'disciple_tools' ); ?>
</a>
<a class="button clear" id="hide-optional-fields" style="margin:0;padding:3px 0; width:100%; display: none;">
<?php esc_html_e( 'See Fewer Options', 'disciple_tools' ); ?>
</a>
</div>
</form>
</div>
<div class="cell" id="result-link"></div>
<div class="cell" style="height:20rem;"></div>
</div>
</div>
</div>
</section>
</div>
</div> <!-- end #inner-content -->
<div class="reveal" id="confirm-user-upgrade" data-reveal data-reset-on-close>
<h3><?php esc_html_e( 'Upgrading a contact', 'disciple_tools' ); ?></h3>
<p>
<img class="dt-icon dt-red-icon" src="<?php echo esc_html( get_template_directory_uri() . '/dt-assets/images/broken.svg' ) ?>"/>
<?php esc_html_e( 'The new user will have access to all the fields and comments on this contact record. We suggest archiving the comments if they contain sensitive data.', 'disciple_tools' ); ?>
</p>
<div class="grid-x">
<div class="button-group">
<button class="button button-cancel clear" data-close aria-label="Close reveal" type="button">
<?php echo esc_html__( 'Back', 'disciple_tools' )?>
</button>
<button class="button clear" id="continue-archive-comments" data-close><?php esc_html_e( 'Continue and archive comments', 'disciple_tools' ); ?></button>
<button class="button" id="continue-user-creation" data-close><?php esc_html_e( 'Continue, keeping comments', 'disciple_tools' ); ?></button>
</div>
<button class="close-button" data-close aria-label="<?php esc_html_e( 'Close', 'disciple_tools' ); ?>" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
<div class="reveal" id="merge-contact-details" data-reveal data-reset-on-close>
<h3><?php esc_html_e( 'Merge Contact Details', 'disciple_tools' ); ?></h3>
<p>
<?php esc_html_e( 'A new contact record has been created.', 'disciple_tools' ); ?> <a id="new-contact-record" href="" target="_blank"><img style="height:20px; width:20px; vertical-align: text-bottom" src="<?php echo esc_html( get_template_directory_uri() . '/dt-assets/images/open-link.svg' ) ?>"/></a>
</p>
<p>
<?php esc_html_e( 'The old one is now closed.', 'disciple_tools' ); ?> <a id="existing-contact-record" herf="" target="_blank"><img style="height:20px; width:20px; vertical-align: text-bottom" src="<?php echo esc_html( get_template_directory_uri() . '/dt-assets/images/open-link.svg' ) ?>"/></a>
</p>
<p>
<?php esc_html_e( 'Do you wish to merge fields from the old record to the new one?', 'disciple_tools' ); ?>
</p>
<div class="grid-x">
<div class="button-group">
<button class="button button-cancel" data-close aria-label="Close reveal" type="button">
<?php echo esc_html__( 'Close', 'disciple_tools' )?>
</button>
<a class="button" href="" id="merge-new-contact-link" data-close><?php esc_html_e( 'Merge', 'disciple_tools' ); ?></a>
</div>
<button class="close-button" data-close aria-label="<?php esc_html_e( 'Close', 'disciple_tools' ); ?>" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
</div> <!-- end #content -->
<?php get_footer(); ?>