class-zvc-admin-users.php
3.87 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
<?php
/**
* Users Controller
*
* @since 2.0.0
* @author Deepen
*/
class Zoom_Video_Conferencing_Admin_Users {
public static $message = '';
public $settings;
/**
* List meetings page
*
* @since 1.0.0
* @changes in CodeBase
* @author Deepen Bajracharya
*/
public static function list_users() {
wp_enqueue_script( 'video-conferencing-with-zoom-api-datable-js' );
wp_enqueue_script( 'video-conferencing-with-zoom-api-js' );
//Check if any transient by name is available
if ( isset( $_GET['flush'] ) == true ) {
video_conferencing_zoom_api_delete_user_cache();
self::set_message( 'updated', __( "Flushed User Cache!", "video-conferencing-with-zoom-api" ) );
}
if ( isset( $_GET['status'] ) && $_GET['status'] === "pending" ) {
//Get Template
require_once ZVC_PLUGIN_VIEWS_PATH . '/live/tpl-list-pending-users.php';
} else {
//Get Template
require_once ZVC_PLUGIN_VIEWS_PATH . '/live/tpl-list-users.php';
}
}
/**
* Add Zoom users view
*
* @since 1.0.0
* @changes in CodeBase
* @author Deepen Bajracharya
*/
public static function add_zoom_users() {
wp_enqueue_script( 'video-conferencing-with-zoom-api-js' );
if ( isset( $_POST['add_zoom_user'] ) ) {
check_admin_referer( '_zoom_add_user_nonce_action', '_zoom_add_user_nonce' );
$postData = array(
'action' => filter_input( INPUT_POST, 'action' ),
'email' => sanitize_email( filter_input( INPUT_POST, 'email' ) ),
'first_name' => sanitize_text_field( filter_input( INPUT_POST, 'first_name' ) ),
'last_name' => sanitize_text_field( filter_input( INPUT_POST, 'last_name' ) ),
'type' => filter_input( INPUT_POST, 'type' ),
'user_id' => filter_input( INPUT_POST, 'user_id' )
);
$created_user = zoom_conference()->createAUser( $postData );
$result = json_decode( $created_user );
if ( ! empty( $result->code ) ) {
self::set_message( 'error', $result->message );
} else {
self::set_message( 'updated', __( "Created a User. Please check email for confirmation. Added user will only appear in the list after approval.", "video-conferencing-with-zoom-api" ) );
update_user_meta( $postData['user_id'], 'user_zoom_hostid', $result->id );
//After user has been created delete this transient in order to fetch latest Data.
video_conferencing_zoom_api_delete_user_cache();
}
}
require_once ZVC_PLUGIN_VIEWS_PATH . '/live/tpl-add-user.php';
}
/**
* Assign Host ID
*/
static function assign_host_id() {
wp_enqueue_script( 'video-conferencing-with-zoom-api-datable-js' );
wp_enqueue_script( 'video-conferencing-with-zoom-api-js' );
if ( isset( $_POST['saving_host_id'] ) ) {
check_admin_referer( '_zoom_assign_hostid_nonce_action', '_zoom_assign_hostid_nonce' );
$host_ids = filter_input( INPUT_POST, 'zoom_host_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
$email_ids = filter_input( INPUT_POST, 'zoom_host_email', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
if ( ! empty( $host_ids ) ) {
foreach ( $host_ids as $k => $host_id ) {
if ( $host_id == "0" ) {
update_user_meta( $k, 'user_zoom_hostid', '' );
} else {
update_user_meta( $k, 'user_zoom_hostid', $host_id );
}
}
}
if ( ! empty( $email_ids ) ) {
foreach ( $email_ids as $k => $email_id ) {
if ( $email_id == "Not a Host" ) {
update_user_meta( $k, 'vczapi_user_zoom_email_address', '' );
} else {
update_user_meta( $k, 'vczapi_user_zoom_email_address', $email_id );
}
}
}
self::set_message( 'updated', __( "Saved !", "video-conferencing-with-zoom-api" ) );
}
require_once ZVC_PLUGIN_VIEWS_PATH . '/live/tpl-assign-host-id.php';
}
static function get_message() {
return self::$message;
}
static function set_message( $class, $message ) {
self::$message = '<div class=' . $class . '><p>' . $message . '</p></div>';
}
}
new Zoom_Video_Conferencing_Admin_Users();