Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ stylelint.config.js
composer.json
package.json
phpcs.xml.dist
.DS_Store
7 changes: 7 additions & 0 deletions admin/class-bigbluebutton-admin-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) );
Expand All @@ -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;
}
Expand Down
4 changes: 0 additions & 4 deletions admin/class-bigbluebutton-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
99 changes: 99 additions & 0 deletions admin/class-bigbluebutton-register-custom-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down Expand Up @@ -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 = '<select name="bbb-room-guestPolicy">';
foreach ($policies as $key => $policy){
$selected = "";
if($policy == $value){
$selected = "selected";
}
$html .= "<option {$selected} value='{$policy}'>{$policy}</option>";
}
$html .= "</select>";

return $html;
}
}
4 changes: 4 additions & 0 deletions admin/css/bigbluebutton-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@
margin-top: 2em;
margin-bottom: 2em;
}

#bbb-room-extra-options .extra-options-item{
margin: 10px 0px;
}
10 changes: 10 additions & 0 deletions admin/partials/bigbluebutton-extra-options-metabox-display.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div id="duration" class="extra-options-item">
<label><?php echo $duration_label; ?></label>
<input name="bbb-room-duration" type="text" value="<?php echo $duration_value ? $duration_value: 0; ?>"><small> (<?php echo __( 'Duration Msg', 'bigbluebutton'); ?>)</small>
</div>

<div id="guestPolicy" class="extra-options-item">
<label><?php echo $guestPolicy_label; ?></label>
<?php echo $guestPolicy_select; ?>
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<label><?php echo $entry_max_participants_label; ?>: </label>
<?php if ( $existing_value != '' ) { ?>
<input name="<?php echo $entry_max_participants_name; ?>" type="text" value="<?php echo $existing_value; ?>"><small> (<?php echo $defaultMsg; ?>)</small>
<?php } else { ?>
<input name="<?php echo $entry_max_participants_name; ?>" type="text" value="<?php echo $default_max_participants; ?>"><small> (<?php echo $defaultMsg; ?>)</small>
<?php } ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<label><?php echo $entry_pre_upload_presentation_label; ?>: </label>
<?php if ( $existing_value != '' ) { ?>
<input name="<?php echo $entry_pre_upload_presentation_name; ?>" type="text" value="<?php echo $existing_value; ?>"><small> (<?php echo $defaultMsg; ?>)</small>
<?php } else { ?>
<input name="<?php echo $entry_pre_upload_presentation_name; ?>" type="text"><small> (<?php echo $defaultMsg; ?>)</small>
<?php } ?>
65 changes: 59 additions & 6 deletions includes/class-bigbluebutton-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand All @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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('<?xml version="1.0" encoding="UTF-8"?><modules/>');
$module = $xml->addChild('module');
$module->addAttribute('name', 'presentation');
$presentation = $module->addChild('document');
$presentation->addAttribute('url', $url);
return $xml->asXML();
}



/**
* Convert website response to XML Object.
*
Expand Down
3 changes: 3 additions & 0 deletions includes/class-bigbluebutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ private function define_admin_hooks() {
// Add room metadata hooks.
$this->loader->add_action( 'add_meta_boxes', $plugin_admin_register_custom_types, 'register_room_code_metaboxes' );
$this->loader->add_action( 'add_meta_boxes', $plugin_admin_register_custom_types, 'register_record_room_metabox' );
$this->loader->add_action( 'add_meta_boxes', $plugin_admin_register_custom_types, 'register_room_maxParticipants_metaboxes' );
$this->loader->add_action( 'add_meta_boxes', $plugin_admin_register_custom_types, 'register_wait_for_moderator_metabox' );
$this->loader->add_action( 'add_meta_boxes', $plugin_admin_register_custom_types, 'register_pre_upload_presentation_metabox' );
$this->loader->add_action( 'add_meta_boxes', $plugin_admin_register_custom_types, 'register_extra_options_metabox' );
$this->loader->add_action( 'save_post', $plugin_admin_api, 'save_room' );

// Show custom fields in rooms table.
Expand Down
Binary file modified languages/bigbluebutton-en_CA.mo
Binary file not shown.
27 changes: 27 additions & 0 deletions languages/bigbluebutton-en_CA.po
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,33 @@ msgstr "Moderator Code"
msgid "Viewer Code"
msgstr "Viewer Code"

msgid "Max Participants"
msgstr "Max Participants"

msgid "Max Participants Msg"
msgstr "-1 = unlimited"

msgid "Pre-upload presentation"
msgstr "Pre-upload presentation"

msgid "Presentation Link"
msgstr "Presentation Link"

msgid "Presentation Link Msg"
msgstr "example: https://mysite.com/presentation.pdf"

msgid "Extra Options"
msgstr "Extra Options"

msgid "Duration"
msgstr "Duration"

msgid "Duration Msg"
msgstr "In minutes. 0 = unlimited"

msgid "Guest Policy"
msgstr "Guest Policy"

msgid "Recordable"
msgstr "Recordable"

Expand Down
Binary file modified languages/bigbluebutton-en_US.mo
Binary file not shown.
27 changes: 27 additions & 0 deletions languages/bigbluebutton-en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,33 @@ msgstr "Moderator Code"
msgid "Viewer Code"
msgstr "Viewer Code"

msgid "Max Participants"
msgstr "Max Participants"

msgid "Max Participants Msg"
msgstr "-1 = unlimited"

msgid "Pre-upload presentation"
msgstr "Pre-upload presentation"

msgid "Presentation Link"
msgstr "Presentation Link"

msgid "Presentation Link Msg"
msgstr "example: https://mysite.com/presentation.pdf"

msgid "Extra Options"
msgstr "Extra Options"

msgid "Duration"
msgstr "Duration"

msgid "Duration Msg"
msgstr "In minutes. 0 = unlimited"

msgid "Guest Policy"
msgstr "Guest Policy"

msgid "Recordable"
msgstr "Recordable"

Expand Down
Loading