From 37ad8a95308dbcc0d18cd2c7d8c060faa250d53d Mon Sep 17 00:00:00 2001 From: dipin-bajra Date: Tue, 20 Jun 2023 18:04:24 +0545 Subject: [PATCH 1/9] aaded new class-zvc-admin-connect-user-account for the submenu and added function to add the data to be saved to its corresponding usermeta table --- includes/Bootstrap.php | 1 + .../class-zvc-admin-connect-user-account.php | 57 +++++++++++++++++++ includes/admin/class-zvc-admin-settings.php | 13 +++++ includes/api/S2SOAuth.php | 6 +- includes/api/class-zvc-zoom-api-v2.php | 1 - 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 includes/admin/class-zvc-admin-connect-user-account.php diff --git a/includes/Bootstrap.php b/includes/Bootstrap.php index 1d32bbe0..9f8bb193 100644 --- a/includes/Bootstrap.php +++ b/includes/Bootstrap.php @@ -222,6 +222,7 @@ protected function load_dependencies() { require_once ZVC_PLUGIN_INCLUDES_PATH . '/admin/class-zvc-admin-addons.php'; require_once ZVC_PLUGIN_INCLUDES_PATH . '/admin/class-zvc-admin-sync.php'; require_once ZVC_PLUGIN_INCLUDES_PATH . '/admin/class-zvc-admin-setup-wizard.php'; + require_once ZVC_PLUGIN_INCLUDES_PATH . '/admin/class-zvc-admin-connect-user-account.php'; //Timezone Timezone::get_instance(); diff --git a/includes/admin/class-zvc-admin-connect-user-account.php b/includes/admin/class-zvc-admin-connect-user-account.php new file mode 100644 index 00000000..252e71ae --- /dev/null +++ b/includes/admin/class-zvc-admin-connect-user-account.php @@ -0,0 +1,57 @@ + +
+

Users Server to Server Oauth Credentials

+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ save_api_credentials(); + $zoom_connect_user_account->render(); + } + ); } add_submenu_page( 'edit.php?post_type=zoom-meetings', __( 'Settings', 'video-conferencing-with-zoom-api' ), __( 'Settings', 'video-conferencing-with-zoom-api' ), 'manage_options', 'zoom-video-conferencing-settings', array( diff --git a/includes/api/S2SOAuth.php b/includes/api/S2SOAuth.php index 6ee2ae45..529ec4eb 100644 --- a/includes/api/S2SOAuth.php +++ b/includes/api/S2SOAuth.php @@ -70,11 +70,13 @@ private function generateAccessToken( $account_id, $client_id, $client_secret ) * * @return mixed */ - public function generateAndSaveAccessToken( $account_id, $client_id, $client_secret ) { + public function generateAndSaveAccessToken( $account_id, $client_id, $client_secret, $save_to_user = false ) { $result = $this->generateAccessToken( $account_id, $client_id, $client_secret ); if ( ! is_wp_error( $result ) ) { //@todo - implement a per person option to allow other users to add their own API Credentials and generate own access token - update_option( 'vczapi_global_oauth_data', $result ); + if(!$save_to_user){ + update_option( 'vczapi_global_oauth_data', $result ); + } } return $result; diff --git a/includes/api/class-zvc-zoom-api-v2.php b/includes/api/class-zvc-zoom-api-v2.php index fed7673e..7e5f8ed1 100644 --- a/includes/api/class-zvc-zoom-api-v2.php +++ b/includes/api/class-zvc-zoom-api-v2.php @@ -241,7 +241,6 @@ private function getBearerToken() { } else { return $this->generateJWTKey(); } - } /** From f218e6b36efad1b4a4da75893dd64446affedc4f Mon Sep 17 00:00:00 2001 From: dipin-bajra Date: Thu, 22 Jun 2023 17:29:31 +0545 Subject: [PATCH 2/9] added a global stting to enable the zoom users to connet to their individual zoom account --- .../class-zvc-admin-connect-user-account.php | 11 ++++++- includes/admin/class-zvc-admin-settings.php | 33 +++++++++++-------- includes/api/S2SOAuth.php | 11 ++++++- includes/views/tabs/api-settings.php | 7 ++++ 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/includes/admin/class-zvc-admin-connect-user-account.php b/includes/admin/class-zvc-admin-connect-user-account.php index 252e71ae..440d3ba0 100644 --- a/includes/admin/class-zvc-admin-connect-user-account.php +++ b/includes/admin/class-zvc-admin-connect-user-account.php @@ -10,7 +10,6 @@ public static function get_instance(): ?Zoom_Connect_User_Account { public function __construct() { } - public function render() { $account_id = get_user_meta( get_current_user_id(), 'zoom_user_account_id', true ); $client_id = get_user_meta( get_current_user_id(), 'zoom_user_client_id', true ); @@ -36,6 +35,16 @@ public function render() { generateAndSaveAccessToken( $account_id, $client_id, $client_secret, true ); + if ( is_wp_error( $access_token ) ) { + // Handle the error appropriately + $error_message = $access_token->get_error_message(); + // Display the error message to the user + echo '

Error: ' . esc_html( $error_message ) . '

'; + } else { + // Access token generated successfully + echo '

Access token generated and saved successfully!

'; + } } public function save_api_credentials() { diff --git a/includes/admin/class-zvc-admin-settings.php b/includes/admin/class-zvc-admin-settings.php index 7ab4caef..52af8585 100644 --- a/includes/admin/class-zvc-admin-settings.php +++ b/includes/admin/class-zvc-admin-settings.php @@ -223,19 +223,23 @@ public function zoom_video_conference_menus() { 'Zoom_Video_Conferencing_Admin_Sync', 'render', ) ); - - add_submenu_page( - 'edit.php?post_type=zoom-meetings', - __( 'Connect User Account', 'video-conferencing-with-zoom-api' ), - __( 'Connect User Account', 'video-conferencing-with-zoom-api' ), - 'read', - 'zoom-video-conferencing-connect', - function () { - $zoom_connect_user_account = Zoom_Connect_User_Account::get_instance(); - $zoom_connect_user_account->save_api_credentials(); - $zoom_connect_user_account->render(); - } - ); + $setting = get_option( '_vczapi_zoom_settings' ); + $enable_individual_zoom = $setting['enable_individual_zoom']; + //this condition only works on page refresh since data saved in same admin call + if ( $enable_individual_zoom == 'on' ) { + add_submenu_page( + 'edit.php?post_type=zoom-meetings', + __( 'Connect User Account', 'video-conferencing-with-zoom-api' ), + __( 'Connect User Account', 'video-conferencing-with-zoom-api' ), + 'read', + 'zoom-video-conferencing-connect', + function () { + $zoom_connect_user_account = Zoom_Connect_User_Account::get_instance(); + $zoom_connect_user_account->save_api_credentials(); + $zoom_connect_user_account->render(); + } + ); + } } add_submenu_page( 'edit.php?post_type=zoom-meetings', __( 'Settings', 'video-conferencing-with-zoom-api' ), __( 'Settings', 'video-conferencing-with-zoom-api' ), 'manage_options', 'zoom-video-conferencing-settings', array( @@ -328,7 +332,8 @@ class="nav-tab sanitize_text_field( filter_input( INPUT_POST, 'meeting-lang' ) ), 'disable_auto_pwd_generation' => sanitize_text_field( filter_input( INPUT_POST, 'disable_auto_pwd_generation' ) ), 'debugger_logs' => sanitize_text_field( filter_input( INPUT_POST, 'zoom_api_debugger_logs' ) ), - 'enable_direct_join_via_browser' => sanitize_text_field( filter_input( INPUT_POST, 'vczapi_enable_direct_join' ) ) + 'enable_direct_join_via_browser' => sanitize_text_field( filter_input( INPUT_POST, 'vczapi_enable_direct_join' ) ), + 'enable_individual_zoom' => sanitize_text_field( filter_input( INPUT_POST, 'vczapi_enable_individual_zoom' ) ), ]; /** diff --git a/includes/api/S2SOAuth.php b/includes/api/S2SOAuth.php index 529ec4eb..8d19cafb 100644 --- a/includes/api/S2SOAuth.php +++ b/includes/api/S2SOAuth.php @@ -74,8 +74,17 @@ public function generateAndSaveAccessToken( $account_id, $client_id, $client_sec $result = $this->generateAccessToken( $account_id, $client_id, $client_secret ); if ( ! is_wp_error( $result ) ) { //@todo - implement a per person option to allow other users to add their own API Credentials and generate own access token - if(!$save_to_user){ + if ( ! $save_to_user ) { update_option( 'vczapi_global_oauth_data', $result ); + } else { + //@todo check if allowed to use + //check current user capability minimum edit_posts + //check if global option is checked to allow user to add their own zoom account + $setting = get_option( '_vczapi_zoom_settings' ); + $enable_individual_zoom = $setting['enable_individual_zoom']; + if ( current_user_can( 'edit_posts' ) && $enable_individual_zoom == "on" ) { + update_user_meta( get_current_user_id(), 'zoom_user_access_token', $result ); + } } } diff --git a/includes/views/tabs/api-settings.php b/includes/views/tabs/api-settings.php index 9b92f1d4..b3c37ebc 100644 --- a/includes/views/tabs/api-settings.php +++ b/includes/views/tabs/api-settings.php @@ -24,6 +24,13 @@
+ + + + - - + + - - + printf(__('Did not find any hosts here ? Please %scheck here%s to verify your API keys are working correctly.', 'video-conferencing-with-zoom-api'), '', ''); + } ?> +

+ + + @@ -418,29 +418,28 @@ class="regular-text"> - - - - + + +

+ > From 3ea27b890f708963db397ab109b5a1d731228129 Mon Sep 17 00:00:00 2001 From: dipin-bajra Date: Mon, 17 Jul 2023 18:05:28 +0545 Subject: [PATCH 9/9] resolve conflict and code refactor --- .../tpl-meeting-fields-view-only.php | 481 +++++++++--------- 1 file changed, 230 insertions(+), 251 deletions(-) diff --git a/includes/views/post-type/tpl-meeting-fields-view-only.php b/includes/views/post-type/tpl-meeting-fields-view-only.php index 3c881e21..e52c2802 100644 --- a/includes/views/post-type/tpl-meeting-fields-view-only.php +++ b/includes/views/post-type/tpl-meeting-fields-view-only.php @@ -5,23 +5,23 @@ */ // If this file is called directly, abort. -if (!defined('ABSPATH')) { - exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; } ?>
+ > + +
From bb1b4fafe9380c2c783e0594b6c03e94c7bd2a29 Mon Sep 17 00:00:00 2001 From: dipin-bajra Date: Mon, 26 Jun 2023 13:29:14 +0545 Subject: [PATCH 3/9] added access token for individual zoom user --- .../admin/class-zvc-admin-connect-user-account.php | 4 ++-- includes/api/class-zvc-zoom-api-v2.php | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/includes/admin/class-zvc-admin-connect-user-account.php b/includes/admin/class-zvc-admin-connect-user-account.php index 440d3ba0..6d0de980 100644 --- a/includes/admin/class-zvc-admin-connect-user-account.php +++ b/includes/admin/class-zvc-admin-connect-user-account.php @@ -14,7 +14,8 @@ public function render() { $account_id = get_user_meta( get_current_user_id(), 'zoom_user_account_id', true ); $client_id = get_user_meta( get_current_user_id(), 'zoom_user_client_id', true ); $client_secret = get_user_meta( get_current_user_id(), 'zoom_user_client_secret', true ); - // Output the form + + // Output the form ?>

Users Server to Server Oauth Credentials

@@ -46,7 +47,6 @@ public function render() { echo '

Access token generated and saved successfully!

'; } } - public function save_api_credentials() { if ( isset( $_POST['save_user_credentials'] ) ) { $account_id = sanitize_text_field( $_POST['account_id'] ); diff --git a/includes/api/class-zvc-zoom-api-v2.php b/includes/api/class-zvc-zoom-api-v2.php index 7e5f8ed1..a4f2a095 100644 --- a/includes/api/class-zvc-zoom-api-v2.php +++ b/includes/api/class-zvc-zoom-api-v2.php @@ -235,8 +235,14 @@ public function logMessage( $responseBody, $responseCode, $request ) { private function getBearerToken() { //@todo this will need to be modified for each user scenario - $OauthData = get_option( 'vczapi_global_oauth_data' ); - if ( ! empty( $OauthData ) ) { + $OauthData = get_option( 'vczapi_global_oauth_data' ); + $userOauthData = get_user_meta( get_current_user_id(), 'zoom_user_access_token', true ); + $setting = get_option( '_vczapi_zoom_settings' ); + $enable_individual_zoom = $setting['enable_individual_zoom']; + + if (current_user_can( 'edit_posts' ) && $enable_individual_zoom == "on" && ! empty( $userOauthData ) ) { + return $userOauthData->access_token; + } elseif ( ! empty( $OauthData ) ) { return $OauthData->access_token; } else { return $this->generateJWTKey(); @@ -247,6 +253,7 @@ private function getBearerToken() { * Generate JWT key * * @return string + * @deprcated 4.2.2. */ private function generateJWTKey() { $key = $this->zoom_api_key; From 9148ebaeb7b05c8e1852185e9b8eaa735bb31af9 Mon Sep 17 00:00:00 2001 From: dipin-bajra Date: Mon, 26 Jun 2023 13:36:52 +0545 Subject: [PATCH 4/9] added token regeneration gor individual zoom user account --- includes/api/S2SOAuth.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/api/S2SOAuth.php b/includes/api/S2SOAuth.php index 8d19cafb..69ec3b47 100644 --- a/includes/api/S2SOAuth.php +++ b/includes/api/S2SOAuth.php @@ -97,10 +97,18 @@ public function generateAndSaveAccessToken( $account_id, $client_id, $client_sec * @return void */ public function regenerateAccessTokenAndSave() { - $account_id = get_option( 'vczapi_oauth_account_id' ); - $client_id = get_option( 'vczapi_oauth_client_id' ); - $client_secret = get_option( 'vczapi_oauth_client_secret' ); + $setting = get_option( '_vczapi_zoom_settings' ); + $enable_individual_zoom = $setting['enable_individual_zoom']; + if ( $enable_individual_zoom == "on" ) { + $account_id = get_user_meta( get_current_user_id(), 'zoom_user_account_id', true ); + $client_id = get_user_meta( get_current_user_id(), 'zoom_user_client_id', true ); + $client_secret = get_user_meta( get_current_user_id(), 'zoom_user_client_', true ); + } else { + $account_id = get_option( 'vczapi_oauth_account_id' ); + $client_id = get_option( 'vczapi_oauth_client_id' ); + $client_secret = get_option( 'vczapi_oauth_client_secret' ); + } $result = $this->generateAndSaveAccessToken( $account_id, $client_id, $client_secret ); if ( is_wp_error( $result ) ) { //@todo log error if regenerating access token unsuccessful From 62cc60b271b9c9e20e658519942833c517b39611 Mon Sep 17 00:00:00 2001 From: dipin-bajra Date: Wed, 5 Jul 2023 12:23:06 +0545 Subject: [PATCH 5/9] added new template when the enable individual acc is active , regenaration token issue solved --- includes/Data/Datastore.php | 16 +++++++++++ .../class-zvc-admin-connect-user-account.php | 7 ++++- includes/admin/class-zvc-admin-post-type.php | 8 +++++- includes/admin/class-zvc-admin-settings.php | 7 +++-- .../admin/class-zvc-admin-setup-wizard.php | 2 +- includes/api/S2SOAuth.php | 28 ++++++++----------- includes/api/class-zvc-zoom-api-v2.php | 6 ++-- includes/template-functions.php | 5 ++-- .../tpl-meeting-fields-view-only.php | 0 9 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 includes/views/post-type/tpl-meeting-fields-view-only.php diff --git a/includes/Data/Datastore.php b/includes/Data/Datastore.php index 5dcb687e..0cc641ae 100644 --- a/includes/Data/Datastore.php +++ b/includes/Data/Datastore.php @@ -96,4 +96,20 @@ public static function get_meetings( $args = false, $wp_query = true ) { return $result; } + + /** + * Retrives zoom setting options. + * + * @param $key + * + * @return false|mixed + */ + public static function get_vczapi_zoom_settings( $key = '' ) { + $setting = get_option( '_vczapi_zoom_settings' ); + if ( ! empty( $setting ) && ! empty( $key ) ) { + return ! empty( $setting[ $key ] ) ? $setting[ $key ] : false; + } + + return ! empty( $setting ) ? $setting : false; + } } \ No newline at end of file diff --git a/includes/admin/class-zvc-admin-connect-user-account.php b/includes/admin/class-zvc-admin-connect-user-account.php index 6d0de980..844a1a18 100644 --- a/includes/admin/class-zvc-admin-connect-user-account.php +++ b/includes/admin/class-zvc-admin-connect-user-account.php @@ -15,6 +15,11 @@ public function render() { $client_id = get_user_meta( get_current_user_id(), 'zoom_user_client_id', true ); $client_secret = get_user_meta( get_current_user_id(), 'zoom_user_client_secret', true ); + //saving the host id to the hostid meta + $list_user = json_decode(zoom_conference()->listUsers()); + $host_id = $list_user->users[0]->id; + update_user_meta(get_current_user_id(), 'user_zoom_hostid', $host_id); + // Output the form ?>
@@ -36,7 +41,7 @@ public function render() {
generateAndSaveAccessToken( $account_id, $client_id, $client_secret, true ); + $access_token = \Codemanas\VczApi\Api\S2SOAuth::get_instance()->generateAndSaveAccessToken( $account_id, $client_id, $client_secret, true ); if ( is_wp_error( $access_token ) ) { // Handle the error appropriately $error_message = $access_token->get_error_message(); diff --git a/includes/admin/class-zvc-admin-post-type.php b/includes/admin/class-zvc-admin-post-type.php index 76db7799..aeff1648 100644 --- a/includes/admin/class-zvc-admin-post-type.php +++ b/includes/admin/class-zvc-admin-post-type.php @@ -1,5 +1,7 @@ ID, '_meeting_fields', true ); + $is_individual_account = Datastore::get_vczapi_zoom_settings( 'enable_individual_zoom' ); + do_action( 'vczapi_before_fields_admin', $post ); //Get Template - require_once ZVC_PLUGIN_VIEWS_PATH . '/post-type/tpl-meeting-fields.php'; + $template = $is_individual_account ? '/post-type/tpl-meeting-fields-view-only.php' : '/post-type/tpl-meeting-fields.php'; + require_once ZVC_PLUGIN_VIEWS_PATH . $template; + } /** diff --git a/includes/admin/class-zvc-admin-settings.php b/includes/admin/class-zvc-admin-settings.php index 52af8585..a79ee4ad 100644 --- a/includes/admin/class-zvc-admin-settings.php +++ b/includes/admin/class-zvc-admin-settings.php @@ -1,6 +1,7 @@ generateAndSaveAccessToken( $vczapi_oauth_account_id, $vczapi_oauth_client_id, $vczapi_oauth_client_secret, ); + $OAuth_access_token = \Codemanas\VczApi\Api\S2SOAuth::get_instance()->generateAndSaveAccessToken( $vczapi_oauth_account_id, $vczapi_oauth_client_id, $vczapi_oauth_client_secret ); if ( is_wp_error( $OAuth_access_token ) ) { self::$message = sprintf( __( 'Zoom Oauth Error Code: "%s" - %s ', 'video-conferencing-with-zoom-api' ), $OAuth_access_token->get_error_code(), $OAuth_access_token->get_error_message() ); @@ -223,8 +224,8 @@ public function zoom_video_conference_menus() { 'Zoom_Video_Conferencing_Admin_Sync', 'render', ) ); - $setting = get_option( '_vczapi_zoom_settings' ); - $enable_individual_zoom = $setting['enable_individual_zoom']; + var_dump(Datastore::get_vczapi_zoom_settings()); + $enable_individual_zoom = Datastore::get_vczapi_zoom_settings('enable_individual_zoom'); //this condition only works on page refresh since data saved in same admin call if ( $enable_individual_zoom == 'on' ) { add_submenu_page( diff --git a/includes/admin/class-zvc-admin-setup-wizard.php b/includes/admin/class-zvc-admin-setup-wizard.php index 867d28bb..f32c50d2 100644 --- a/includes/admin/class-zvc-admin-setup-wizard.php +++ b/includes/admin/class-zvc-admin-setup-wizard.php @@ -40,7 +40,7 @@ public function save_oauth_credentials() { update_option( 'vczapi_oauth_client_id', $client_id ); update_option( 'vczapi_oauth_client_secret', $client_secret ); - $result = \vczapi\S2SOAuth::get_instance()->generateAndSaveAccessToken( $account_id, $client_id, $client_secret ); + $result = \Codemanas\VczApi\Api\S2SOAuth::get_instance()->generateAndSaveAccessToken( $account_id, $client_id, $client_secret ); if ( ! is_wp_error( $result ) ) { //this can't be a cached request $decoded_users = json_decode( zoom_conference()->listUsers() ); diff --git a/includes/api/S2SOAuth.php b/includes/api/S2SOAuth.php index 69ec3b47..db176ef9 100644 --- a/includes/api/S2SOAuth.php +++ b/includes/api/S2SOAuth.php @@ -1,16 +1,20 @@ enable_individual_zoom = Datastore::get_vczapi_zoom_settings('enable_individual_zoom'); } /** @@ -76,15 +80,8 @@ public function generateAndSaveAccessToken( $account_id, $client_id, $client_sec //@todo - implement a per person option to allow other users to add their own API Credentials and generate own access token if ( ! $save_to_user ) { update_option( 'vczapi_global_oauth_data', $result ); - } else { - //@todo check if allowed to use - //check current user capability minimum edit_posts - //check if global option is checked to allow user to add their own zoom account - $setting = get_option( '_vczapi_zoom_settings' ); - $enable_individual_zoom = $setting['enable_individual_zoom']; - if ( current_user_can( 'edit_posts' ) && $enable_individual_zoom == "on" ) { - update_user_meta( get_current_user_id(), 'zoom_user_access_token', $result ); - } + } else if ( current_user_can( 'edit_posts' ) && $this->enable_individual_zoom ) { + update_user_meta( get_current_user_id(), 'zoom_user_access_token', $result ); } } @@ -97,19 +94,16 @@ public function generateAndSaveAccessToken( $account_id, $client_id, $client_sec * @return void */ public function regenerateAccessTokenAndSave() { - $setting = get_option( '_vczapi_zoom_settings' ); - $enable_individual_zoom = $setting['enable_individual_zoom']; - - if ( $enable_individual_zoom == "on" ) { + if ( $this->enable_individual_zoom ) { $account_id = get_user_meta( get_current_user_id(), 'zoom_user_account_id', true ); $client_id = get_user_meta( get_current_user_id(), 'zoom_user_client_id', true ); - $client_secret = get_user_meta( get_current_user_id(), 'zoom_user_client_', true ); + $client_secret = get_user_meta( get_current_user_id(), 'zoom_user_client_secret', true ); } else { $account_id = get_option( 'vczapi_oauth_account_id' ); $client_id = get_option( 'vczapi_oauth_client_id' ); $client_secret = get_option( 'vczapi_oauth_client_secret' ); } - $result = $this->generateAndSaveAccessToken( $account_id, $client_id, $client_secret ); + $result = $this->generateAndSaveAccessToken( $account_id, $client_id, $client_secret, $this->enable_individual_zoom ); if ( is_wp_error( $result ) ) { //@todo log error if regenerating access token unsuccessful } diff --git a/includes/api/class-zvc-zoom-api-v2.php b/includes/api/class-zvc-zoom-api-v2.php index a4f2a095..ec1ab2c9 100644 --- a/includes/api/class-zvc-zoom-api-v2.php +++ b/includes/api/class-zvc-zoom-api-v2.php @@ -2,6 +2,7 @@ use \Firebase\JWT\JWT; use Codemanas\VczApi\Data\Logger; +use Codemanas\VczApi\Data\Datastore; /** * Class Connecting Zoom API V2 @@ -122,7 +123,7 @@ protected function sendRequest( $calledFunction, $data, $request = "GET" ) { if ( $responseCode == 401 && vczapi_is_oauth_active() ) { //only regenerate access token if it's already active; - \vczapi\S2SOAuth::get_instance()->regenerateAccessTokenAndSave(); + \Codemanas\VczApi\Api\S2SOAuth::get_instance()->regenerateAccessTokenAndSave(); //only retry twice; if ( self::$OAuth_revalidate_attempts <= 2 ) { self::$OAuth_revalidate_attempts ++; @@ -237,8 +238,7 @@ private function getBearerToken() { //@todo this will need to be modified for each user scenario $OauthData = get_option( 'vczapi_global_oauth_data' ); $userOauthData = get_user_meta( get_current_user_id(), 'zoom_user_access_token', true ); - $setting = get_option( '_vczapi_zoom_settings' ); - $enable_individual_zoom = $setting['enable_individual_zoom']; + $enable_individual_zoom = Datastore::get_vczapi_zoom_settings('enable_individual_zoom'); if (current_user_can( 'edit_posts' ) && $enable_individual_zoom == "on" && ! empty( $userOauthData ) ) { return $userOauthData->access_token; diff --git a/includes/template-functions.php b/includes/template-functions.php index a38f4e2d..ea66a3d1 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -1,4 +1,6 @@ first_name ) ? $current_user->first_name . ' ' . $current_user->last_name : $current_user->display_name; $pass = isset( $_GET['pak'] ) || empty( $zoom['password'] ) ? '' : ( ! empty( $zoom['password'] ) ? $zoom['password'] : '' ); - $setting = get_option('_vczapi_zoom_settings'); - $enable_direct_via_browser= $setting['enable_direct_join_via_browser']; + $enable_direct_via_browser= Datastore::get_vczapi_zoom_settings('enable_direct_join_via_browser'); $localize = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'zvc_security' => wp_create_nonce( "_nonce_zvc_security" ), diff --git a/includes/views/post-type/tpl-meeting-fields-view-only.php b/includes/views/post-type/tpl-meeting-fields-view-only.php new file mode 100644 index 00000000..e69de29b From 33842c701104e3eb50ba0908d7b225164ed7ff70 Mon Sep 17 00:00:00 2001 From: dipin-bajra Date: Wed, 5 Jul 2023 13:03:25 +0545 Subject: [PATCH 6/9] replaced helper function get_vczapi_zoom_setting with normal get_option --- includes/admin/class-zvc-admin-post-type.php | 3 +-- includes/admin/class-zvc-admin-settings.php | 4 ++-- includes/template-hooks.php | 7 ++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/admin/class-zvc-admin-post-type.php b/includes/admin/class-zvc-admin-post-type.php index aeff1648..2ebc876b 100644 --- a/includes/admin/class-zvc-admin-post-type.php +++ b/includes/admin/class-zvc-admin-post-type.php @@ -358,8 +358,7 @@ public function register_post_type() { 'not_found_in_trash' => __( 'No zoom events found in Trash.', 'video-conferencing-with-zoom-api' ), ) ); - $settings = get_option( '_vczapi_zoom_settings' ); - $settings = ! empty( $settings ) ? $settings : false; + Datastore::get_vczapi_zoom_settings(); $args = array( 'labels' => $labels, diff --git a/includes/admin/class-zvc-admin-settings.php b/includes/admin/class-zvc-admin-settings.php index a79ee4ad..2ae32dae 100644 --- a/includes/admin/class-zvc-admin-settings.php +++ b/includes/admin/class-zvc-admin-settings.php @@ -399,8 +399,8 @@ class="nav-tab Date: Wed, 12 Jul 2023 12:16:18 +0545 Subject: [PATCH 7/9] added the new template for the each user account connected and enabled only view mode --- includes/admin/class-zvc-admin-settings.php | 2 +- .../tpl-meeting-fields-view-only.php | 561 ++++++++++++++++++ 2 files changed, 562 insertions(+), 1 deletion(-) diff --git a/includes/admin/class-zvc-admin-settings.php b/includes/admin/class-zvc-admin-settings.php index 2ae32dae..cb30a947 100644 --- a/includes/admin/class-zvc-admin-settings.php +++ b/includes/admin/class-zvc-admin-settings.php @@ -224,7 +224,7 @@ public function zoom_video_conference_menus() { 'Zoom_Video_Conferencing_Admin_Sync', 'render', ) ); - var_dump(Datastore::get_vczapi_zoom_settings()); + $enable_individual_zoom = Datastore::get_vczapi_zoom_settings('enable_individual_zoom'); //this condition only works on page refresh since data saved in same admin call if ( $enable_individual_zoom == 'on' ) { diff --git a/includes/views/post-type/tpl-meeting-fields-view-only.php b/includes/views/post-type/tpl-meeting-fields-view-only.php index e69de29b..a962a95d 100644 --- a/includes/views/post-type/tpl-meeting-fields-view-only.php +++ b/includes/views/post-type/tpl-meeting-fields-view-only.php @@ -0,0 +1,561 @@ + + + + + ID, '_meeting_zoom_details', true); + $meeting_fields = !empty($meeting_fields) ? $meeting_fields : array(); + if (empty($meeting_fields['meeting_type'])) { + $meeting_fields['meeting_type'] = 1; + } + $current_user_id = get_current_user_id(); + $is_post_author = ($current_user_id == $post->post_author); + + if ($post->post_status == 'publish' && is_object($meeting_details) && isset($meeting_details->id)) { + ?> + + + + + id) && ($post->post_status === 'publish' || $post->post_status === 'draft' || $post->post_status === 'pending' || $post->post_status == 'private')) { + if ($is_post_author) {?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + > + + + + + + + + > + + + + + + + + > + + + + > + + + + > + + + + > + + + + + + + + + + + + + + + + + + + +
+ +

+ +

+
+ host_id)) { + $user = json_decode(zoom_conference()->getUserInfo($meeting_details->host_id)); + if (!empty($user)) { + if (!empty($user->code)) { + echo $user->message; + } else { + echo ''; + echo esc_html($user->first_name) . ' ( ' . esc_html($user->email) . ' )'; + } + } else { + _e('Please check your internet connection or API connection.', 'video-conferencing-with-zoom-api'); + } + } else { + printf(__('Did not find any hosts here ? Please %scheck here%s to verify your API keys are working correctly.', 'video-conferencing-with-zoom-api'), '', ''); + } ?> +

+
+

+

+ +
+ getUserInfo($host_id)); + if (!empty($user)) { + if (!empty($user->code)) { + echo $user->message; + } else { + echo ''; + echo esc_html($user->first_name) . ' ( ' . esc_html($user->email) . ' )'; + } + } else { + _e('Please check your internet connection or API connection.', 'video-conferencing-with-zoom-api'); + } + ?> +

+
+ + + first_name) . ' ( ' . esc_html($users[0]->email) . ' )'; ?> + + +

+

+ +

+ ', ''); + } ?> +
+ +

+ ?

+
+ +

+
+ + + +

+
+ + +

+
+ + + + + + +

+
+ + + + + +
+ +

+
+ password)): ?> + password); ?> + +

+
+ + +

+ + class="regular-text"> + + +

+
+

+ +

+ +

+
+ +

+ + class="regular-text"> +

+
+

+ +

+

+
+ +

+ + class="regular-text"> +

+
+

+ +

+
+

+
+ +

+ + class="regular-text"> +

+
+

+ +

+

+
+ +

+ + value="1" + class="regular-text"> +

+
+

+ +

+

+
+ + +

+ + class="regular-text"> +

+
+

+ +

+

+
+ + +

+ + class="regular-text"> +

+
+ + +

+ + class="regular-text"> +

+
+ + +

+ + class="regular-text"> +

+
+ + +

+ + class="regular-text"> +

+
+ + +

+
+ +

+
+ + + + ', ''); + } ?> +

+
\ No newline at end of file From fe0c7a5da1701d53820eaf9443d653938ad7b11b Mon Sep 17 00:00:00 2001 From: dipin-bajra Date: Mon, 17 Jul 2023 17:09:05 +0545 Subject: [PATCH 8/9] formatting --- .../tpl-meeting-fields-view-only.php | 89 +++++++++---------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/includes/views/post-type/tpl-meeting-fields-view-only.php b/includes/views/post-type/tpl-meeting-fields-view-only.php index a962a95d..13ca6cb8 100644 --- a/includes/views/post-type/tpl-meeting-fields-view-only.php +++ b/includes/views/post-type/tpl-meeting-fields-view-only.php @@ -38,32 +38,32 @@ id) && ($post->post_status === 'publish' || $post->post_status === 'draft' || $post->post_status === 'pending' || $post->post_status == 'private')) { - if ($is_post_author) {?> -
- host_id)) { - $user = json_decode(zoom_conference()->getUserInfo($meeting_details->host_id)); - if (!empty($user)) { - if (!empty($user->code)) { - echo $user->message; + if ($is_post_author) { ?> +
+ host_id)) { + $user = json_decode(zoom_conference()->getUserInfo($meeting_details->host_id)); + if (!empty($user)) { + if (!empty($user->code)) { + echo $user->message; + } else { + echo ''; + echo esc_html($user->first_name) . ' ( ' . esc_html($user->email) . ' )'; + } } else { - echo ''; - echo esc_html($user->first_name) . ' ( ' . esc_html($user->email) . ' )'; + _e('Please check your internet connection or API connection.', 'video-conferencing-with-zoom-api'); } } else { - _e('Please check your internet connection or API connection.', 'video-conferencing-with-zoom-api'); - } - } else { - printf(__('Did not find any hosts here ? Please %scheck here%s to verify your API keys are working correctly.', 'video-conferencing-with-zoom-api'), '', ''); - } ?> -

-
-

- - class="regular-text"> -

-
-

- + +

+

+ + class="regular-text"> +

+
+

+

-

-
- ID, '_meeting_zoom_details', true); - $meeting_fields = !empty($meeting_fields) ? $meeting_fields : array(); - if (empty($meeting_fields['meeting_type'])) { - $meeting_fields['meeting_type'] = 1; - } + ID, '_meeting_zoom_details', true ); + $meeting_fields = ! empty( $meeting_fields ) ? $meeting_fields : array(); + if ( empty( $meeting_fields['meeting_type'] ) ) { + $meeting_fields['meeting_type'] = 1; + } - if ($post->post_status == 'publish' && is_object($meeting_details) && isset($meeting_details->id)) { - ?> + if ( $post->post_status == 'publish' && is_object( $meeting_details ) && isset( $meeting_details->id ) ) { + ?> - id) && ($post->post_status === 'publish' || $post->post_status === 'draft' || $post->post_status === 'pending' || $post->post_status == 'private')) { - ?> + id ) && ( $post->post_status === 'publish' || $post->post_status === 'draft' || $post->post_status === 'pending' || $post->post_status == 'private' ) ) { + ?> + for="meeting_type"> - + + for="userId"> - + + for="userId"> - + + for="meeting_type"> - + + for="start_date"> - + - - + + - - + + - - + + - + - + - > + > - + - + - > + > - + - > + > - + > + > @@ -317,70 +317,49 @@ class="regular-text"> - > + > - + - - - - - -
@@ -29,263 +29,252 @@ value='[zoom_meeting_post post_id="ID; ?>" template="boxed"]' onclick="this.select(); document.execCommand('copy'); alert('Copied to clipboard');"/>

- +

-

-

- +

+
- getUserInfo($host_id)); - if (!empty($user)) { - if (!empty($user->code)) { - echo $user->message; - } else { - echo ''; - echo esc_html($user->first_name) . ' ( ' . esc_html($user->email) . ' )'; - } - } else { - _e('Please check your internet connection or API connection.', 'video-conferencing-with-zoom-api'); - } - ?> + getUserInfo( $host_id ) ); + if ( ! empty( $user ) ) { + if ( ! empty( $user->code ) ) { + echo $user->message; + } else { + echo ''; + echo esc_html( $user->first_name ) . ' ( ' . esc_html( $user->email ) . ' )'; + } + } else { + _e( 'Please check your internet connection or API connection.', 'video-conferencing-with-zoom-api' ); + } + ?>

+ id="userId-description">

- + - first_name) . ' ( ' . esc_html($users[0]->email) . ' )'; ?> - + first_name ) . ' ( ' . esc_html( $users[0]->email ) . ' )'; ?> +

+ class="vczapi-admin-hostID-manually-add">

- +

- ', ''); - } ?> + id="userId-description">

+ ', '' ); + } ?>

+ id="userId-description"> ?

- - - -

+ + +
- - - - - - -

-
+ + + + + + +
- - + +
- password)): ?> - password); ?> - -

-
+ password ) ): ?> + password ); ?> + +
- + -

- -

- -

-
+

+ +

+
+ for="meeting-authentication"> -

- -

-

-
+

+ +

+
+ for="join_before_host"> -

- -

-
-

-
+

+ +

+
+ for="option_host_video"> -

- -

-

-
+

+ +

+
+ for="option_participants_video"> -

- -

-

-
+

+ +

+
- + -

- -

-

-
+

+ +

+
@@ -293,21 +282,32 @@ class="vczapi-admin-hostID-manually-add">

- - class="regular-text"> +

- +

- - class="regular-text"> +

- - class="regular-text"> +

- +

- class="regular-text"> + value="1" + class="regular-text">

+ for="option_auto_recording"> - -

-
+ +
- - - - ', ''); - } ?> -

-
\ No newline at end of file