diff --git a/.gitignore b/.gitignore index b748979..fc0e2e8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ stylelint.config.js composer.json package.json phpcs.xml.dist +.DS_Store diff --git a/admin/class-bigbluebutton-admin-api.php b/admin/class-bigbluebutton-admin-api.php index c290b09..21a4564 100644 --- a/admin/class-bigbluebutton-admin-api.php +++ b/admin/class-bigbluebutton-admin-api.php @@ -57,6 +57,7 @@ public function save_room( $post_id ) { // Add room codes to postmeta data. update_post_meta( $post_id, 'bbb-room-moderator-code', $moderator_code ); update_post_meta( $post_id, 'bbb-room-viewer-code', $viewer_code ); + update_post_meta( $post_id, 'bbb-room-maxParticipants', $_POST['bbb-maxParticipants'] ); if ( ! get_post_meta( $post_id, 'bbb-room-meeting-id', true ) ) { update_post_meta( $post_id, 'bbb-room-meeting-id', sha1( home_url() . Bigbluebutton_Admin_Helper::generate_random_code( 12 ) ) ); @@ -66,6 +67,12 @@ public function save_room( $post_id ) { update_post_meta( $post_id, 'bbb-room-recordable', ( $recordable ? 'true' : 'false' ) ); update_post_meta( $post_id, 'bbb-room-wait-for-moderator', ( $wait_for_mod ? 'true' : 'false' ) ); + if($_POST['bbb-pre-upload-presentation'] !== ""){ + update_post_meta( $post_id, 'bbb-room-pre-upload-presentation', $_POST['bbb-pre-upload-presentation'] ); + } + update_post_meta( $post_id, 'bbb-room-duration', $_POST['bbb-room-duration'] ); + update_post_meta( $post_id, 'bbb-room-guestPolicy', $_POST['bbb-room-guestPolicy'] ); + } else { return $post_id; } diff --git a/admin/class-bigbluebutton-admin.php b/admin/class-bigbluebutton-admin.php index 90dd709..cd0eb8d 100644 --- a/admin/class-bigbluebutton-admin.php +++ b/admin/class-bigbluebutton-admin.php @@ -292,10 +292,6 @@ private function room_server_settings_change() { return 3; } - if ( substr_compare( $bbb_url, 'bigbluebutton/', strlen( $bbb_url ) - 14 ) !== 0 ) { - return 2; - } - update_option( 'bigbluebutton_url', $bbb_url ); update_option( 'bigbluebutton_salt', $bbb_salt ); diff --git a/admin/class-bigbluebutton-register-custom-types.php b/admin/class-bigbluebutton-register-custom-types.php index a5b5885..b7635b4 100644 --- a/admin/class-bigbluebutton-register-custom-types.php +++ b/admin/class-bigbluebutton-register-custom-types.php @@ -103,6 +103,15 @@ public function register_room_code_metaboxes() { add_meta_box( 'bbb-viewer-code', __( 'Viewer Code', 'bigbluebutton' ), array( $this, 'display_viewer_code_metabox' ), 'bbb-room' ); } + /** + * Create Max Participants metaboxes on room creation and edit. + * + * @since 3.0.0 + */ + public function register_room_maxParticipants_metaboxes() { + add_meta_box( 'bbb-maxParticipants', __( 'Max Participants', 'bigbluebutton' ), array( $this, 'display_maxParticipants_metabox' ), 'bbb-room' ); + } + /** * Show recordable option in room creation to users who have the corresponding capability. * @@ -123,6 +132,24 @@ public function register_wait_for_moderator_metabox() { add_meta_box( 'bbb-room-wait-for-moderator', __( 'Wait for Moderator', 'bigbluebutton' ), array( $this, 'display_wait_for_mod_metabox' ), 'bbb-room' ); } + /** + * Show Pre-upload presentation metabox. + * + * @since 3.0.0 + */ + public function register_pre_upload_presentation_metabox() { + add_meta_box( 'bbb-room-pre-upload-presentation', __( 'Pre-upload presentation', 'bigbluebutton' ), array( $this, 'display_pre_upload_presentation' ), 'bbb-room' ); + } + + /** + * Show Extra Options metabox. + * + * @since 3.0.0 + */ + public function register_extra_options_metabox() { + add_meta_box( 'bbb-room-extra-options', __( 'Extra Options', 'bigbluebutton' ), array( $this, 'display_extra_options' ), 'bbb-room' ); + } + /** * Display moderator code metabox. * @@ -139,6 +166,23 @@ public function display_moderator_code_metabox( $object ) { require 'partials/bigbluebutton-room-code-metabox-display.php'; } + /** + * Display Max Participants metabox. + * + * @since 3.0.0 + * + * @param Object $object The object that has the room ID. + */ + public function display_maxParticipants_metabox( $object ) { + $default_max_participants = "-1"; + $entry_max_participants_label = __( 'Max Participants', 'bigbluebutton' ); + $defaultMsg = __( 'Max Participants Msg', 'bigbluebutton' ); + $entry_max_participants_name = 'bbb-maxParticipants'; + $existing_value = get_post_meta( $object->ID, 'bbb-room-maxParticipants', true ); + wp_nonce_field( 'bbb-room-maxParticipants-nonce', 'bbb-room-maxParticipants-nonce' ); + require 'partials/bigbluebutton-max-participants-metabox-display.php'; + } + /** * Display viewer code metabox. * @@ -181,4 +225,59 @@ public function display_allow_record_metabox( $object ) { wp_nonce_field( 'bbb-room-recordable-nonce', 'bbb-room-recordable-nonce' ); require 'partials/bigbluebutton-recordable-metabox-display.php'; } + + /** + * Display Pre-upload presentation metabox. + * + * @since 3.0.0 + * + * @param Object $object The object that has the room ID. + */ + public function display_pre_upload_presentation($object){ + $entry_pre_upload_presentation_label = __( 'Presentation Link', 'bigbluebutton' ); + $defaultMsg = __( 'Presentation Link Msg ', 'bigbluebutton' ); + $entry_pre_upload_presentation_name = 'bbb-pre-upload-presentation'; + $existing_value = get_post_meta( $object->ID, 'bbb-room-pre-upload-presentation', true ); + wp_nonce_field( 'bbb-room-pre-upload-presentation-nonce', 'bbb-room-pre-upload-presentation-nonce' ); + require 'partials/bigbluebutton-pre-upload-presentation-metabox-display.php'; + } + + /** + * Display Extra options metabox. + * + * @since 3.0.0 + * + * @param Object $object The object that has the room ID. + */ + public function display_extra_options($object){ + $duration_label = __( 'Duration', 'bigbluebutton' ); + $duration_value = get_post_meta( $object->ID, 'bbb-room-duration', true ); + + $guestPolicy_label = __( 'Guest Policy', 'bigbluebutton'); + $guestPolicy_value = get_post_meta( $object->ID, 'bbb-room-guestPolicy', true ); + $guestPolicy_select = $this->formatGuestPolicy($guestPolicy_value); + + wp_nonce_field( 'bbb-room-extra-options-nonce', 'bbb-room-extra-options-nonce' ); + require 'partials/bigbluebutton-extra-options-metabox-display.php'; + } + + /** + * Format Guest Policy options + * + */ + private function formatGuestPolicy($value = "ALWAYS_ACCEPT"){ + $policies = array("ALWAYS_ACCEPT", "ASK_MODERATOR", "ALWAYS_DENY"); + + $html = '"; + + return $html; + } } diff --git a/admin/css/bigbluebutton-admin.css b/admin/css/bigbluebutton-admin.css index 69a1357..efb4928 100644 --- a/admin/css/bigbluebutton-admin.css +++ b/admin/css/bigbluebutton-admin.css @@ -55,3 +55,7 @@ margin-top: 2em; margin-bottom: 2em; } + +#bbb-room-extra-options .extra-options-item{ + margin: 10px 0px; +} \ No newline at end of file diff --git a/admin/partials/bigbluebutton-extra-options-metabox-display.php b/admin/partials/bigbluebutton-extra-options-metabox-display.php new file mode 100644 index 0000000..e02b0d3 --- /dev/null +++ b/admin/partials/bigbluebutton-extra-options-metabox-display.php @@ -0,0 +1,10 @@ +
+ + + diff --git a/admin/partials/bigbluebutton-max-participants-metabox-display.php b/admin/partials/bigbluebutton-max-participants-metabox-display.php new file mode 100644 index 0000000..e7dd860 --- /dev/null +++ b/admin/partials/bigbluebutton-max-participants-metabox-display.php @@ -0,0 +1,6 @@ + + + () + + () + diff --git a/admin/partials/bigbluebutton-pre-upload-presentation-metabox-display.php b/admin/partials/bigbluebutton-pre-upload-presentation-metabox-display.php new file mode 100644 index 0000000..83a8ffc --- /dev/null +++ b/admin/partials/bigbluebutton-pre-upload-presentation-metabox-display.php @@ -0,0 +1,6 @@ + + + () + + () + diff --git a/includes/class-bigbluebutton-api.php b/includes/class-bigbluebutton-api.php index f44670e..3233952 100644 --- a/includes/class-bigbluebutton-api.php +++ b/includes/class-bigbluebutton-api.php @@ -43,6 +43,10 @@ public static function create_meeting( $room_id, $logout_url ) { $viewer_code = get_post_meta( $rid, 'bbb-room-viewer-code', true ); $recordable = get_post_meta( $rid, 'bbb-room-recordable', true ); $meeting_id = get_post_meta( $rid, 'bbb-room-meeting-id', true ); + $maxParticipants= get_post_meta( $rid, 'bbb-room-maxParticipants', true ); + $preUplaodPresentation = get_post_meta( $rid, 'bbb-room-pre-upload-presentation', true ); + $duration= get_post_meta( $rid, 'bbb-room-duration', true ); + $guestPolicy= get_post_meta( $rid, 'bbb-room-guestPolicy', true ); $arr_params = array( 'name' => esc_attr( $name ), 'meetingID' => rawurlencode( $meeting_id ), @@ -51,10 +55,22 @@ public static function create_meeting( $room_id, $logout_url ) { 'logoutURL' => esc_url( $logout_url ), 'record' => $recordable, ); + if($maxParticipants && $maxParticipants > 0){ + $arr_params['maxParticipants'] = $maxParticipants; + } + if($duration > 0){ + $arr_params['duration'] = $duration; + } + if($guestPolicy){ + $arr_params['guestPolicy'] = $guestPolicy; + } $url = self::build_url( 'create', $arr_params ); - - $full_response = self::get_response( $url ); + if($preUplaodPresentation !== ""){ + $full_response = self::get_response( $url, "post", $preUplaodPresentation); + }else{ + $full_response = self::get_response( $url ); + } if ( is_wp_error( $full_response ) ) { return 404; @@ -172,8 +188,8 @@ public static function get_recordings( $room_ids, $recording_state = 'published' substr_replace( $meeting_ids, '', -1 ); $arr_params = array( - 'meetingID' => $meeting_ids, - 'state' => $state, + 'meetingID' => rtrim($meeting_ids, ","), + 'state' => rtrim($state, ",") ); $url = self::build_url( 'getRecordings', $arr_params ); @@ -361,11 +377,48 @@ public static function test_bigbluebutton_server( $url, $salt ) { * @param String $url URL to get response from. * @return Array|WP_Error $response Server response in array format. */ - private static function get_response( $url ) { - $result = wp_remote_get( esc_url_raw( $url ) ); + private static function get_response( $url, $method = "get", $preUploadFileLink = null ) { + if($method == "post"){ + if($preUploadFileLink !== null){ + $payload = self::getPresentationsAsXML($preUploadFileLink); + $headers = array( + 'Content-type' => 'application/xml', + 'Content-length' => mb_strlen($payload) + ); + $result = wp_remote_post($url, array( + 'timeout' => 30, + 'method' => 'POST', + 'headers' => $headers, + 'body' => $payload + )); + } + }else{ + $result = wp_remote_get(esc_url_raw($url), array( + 'timeout' => 30, + )); + } return $result; } + /** + * format pre upload file. + * + * @since 3.0.0 + * + * @param String $url URL + * @return String xml xml format. + */ + private function getPresentationsAsXML($url){ + $xml = new SimpleXMLElement('