diff --git a/admin/class-bread-admin.php b/admin/class-bread-admin.php index 3c2d85d..4d090b5 100644 --- a/admin/class-bread-admin.php +++ b/admin/class-bread-admin.php @@ -378,8 +378,7 @@ function get($url, $cookies = array()) 'timeout' => '120', 'cookies' => $cookies, ); - if ( - isset($this->options['user_agent']) + if (isset($this->options['user_agent']) && $this->bread->getOption('user_agent') != 'None' ) { $args['headers'] = array( @@ -451,7 +450,7 @@ function pwsix_process_wizard() if (!$this->current_user_can_create()) { return; } - $layout = sanitize_url($_POST['wizard_layout']); + $layout = sanitize_text_field($_POST['wizard_layout']); $encode_options = file_get_contents(plugin_dir_path(__FILE__) . 'templates/' . $layout); while (0 === strpos(bin2hex($encode_options), 'efbbbf')) { $encode_options = substr($encode_options, 3); @@ -473,7 +472,7 @@ function pwsix_process_wizard() $settings['additional_list_format_key'] = '@Virtual@'; } $str = file_get_contents(plugin_dir_path(__FILE__) . 'templates/meeting_data_templates.json'); - $meeting_templates = json_decode($str); + $meeting_templates = json_decode($str, true); if ($vm_flag == '1') { $settings['custom_section_content'] = '
[additional_meetinglist]
' . $settings['custom_section_content']; - $settings['additional_list_template_content'] = $meeting_templates['Online Meeting Two Column']; + $settings['additional_list_template_content'] = join('', $meeting_templates['Online Meeting Two Column - Link in QR-Code']); } $settings['meeting_sort'] = sanitize_text_field($_POST['wizard_meeting_sort']); if ($settings['meeting_sort'] != 'day') { @@ -496,8 +495,19 @@ function pwsix_process_wizard() } } update_option($optionsName, $settings); - $this->bread->setAndSaveSetting($id, 'Setting ' . $id); + $setting_name = sanitize_title($_POST['wizard-setting-name']); + $setting_name = $setting_name == '' ? $setting_name : 'Setting ' . $id; + $this->bread->setAndSaveSetting($id, $setting_name); $this->bread->getMLOptions($id); + $this->bread->setRequestedSetting($id); + ignore_user_abort(true); + ob_clean(); + header('Content-Type: application/json; charset=utf-8'); + header("Expires: 0"); + $message = ['result' => ['setting' => $id]]; + $data = json_encode($message); + header('Content-Length: ' . strlen($data)); + file_put_contents('php://output', $data); } function pwsix_process_settings_admin() { @@ -505,7 +515,7 @@ function pwsix_process_settings_admin() return; } $this->bread->getMLOptions($this->bread->getRequestedSetting()); - if (isset($_POST['delete'])) { + if (isset($_POST['delete_settings'])) { if (!$this->current_user_can_modify()) { return; } diff --git a/admin/css/admin.css b/admin/css/admin.css index b77a480..675d693 100644 --- a/admin/css/admin.css +++ b/admin/css/admin.css @@ -509,3 +509,17 @@ select.service_body_select { .chosen-container-multi .chosen-choices li.search-field input[type=text] { font-family: "Open Sans",sans-serif !important; } +.step-description { + margin: 10px; + border: solid; + padding: 10px; + background-color: cornsilk; +} +.invalid-feedback { + color: red; + font-weight: bold; +} +.valid-feedback { + color: green; + font-weight: bold; +} diff --git a/admin/js/bread-wizard.js b/admin/js/bread-wizard.js index e3fe7f7..17cd883 100644 --- a/admin/js/bread-wizard.js +++ b/admin/js/bread-wizard.js @@ -18,15 +18,50 @@ jQuery(document).ready(function($){ return false; }) } + BreadWizard.prototype.ajax_submit = function() { + var myform = document.getElementById("wizard_form"); + + var formData = new FormData(myform); + + fetch(window.location.href, { + method: "POST", + body: formData, + }) + .then((response) => { + if (!response.ok) { + throw new Error("network returns error"); + } + return response.json(); + }) + .then((resp) => { + finalInstructions(resp); + }) + .catch((error) => { + // Handle error + console.log("error ", error); + }); + } + var href; + finalInstructions = function(response) { + $('#wizard-before-create').hide(); + $('#wizard-after-create').show(); + href = window.location.href.substring(0, window.location.href.indexOf('/wp-admin')); + href = href+"?current-meeting-list="+response.result.setting; + const tag = '<a href="'+href+'">'+href+''; + $('#wizard-show-link').html(tag); + } + BreadWizard.prototype.generate_meeting_list = function() { + window.open(href, '_blank').focus(); + } BreadWizard.prototype.test_root_server = function() { ask_bmlt("switcher=GetServerInfo", (info) => { - $('#wizard_root_server_result').removeClass('invalid-feedback') - .addClass('valid-feedback').html('BMLT Server version '+info[0]['version']); + $('#wizard_root_server_result').removeClass('invalid-feedback dashicons-dismiss') + .addClass('valid-feedback dashicons-before dashicons-yes-alt').html('Connected! - BMLT Server version '+info[0]['version']); }, (error) => { - $('#wizard_root_server_result').removeClass('valid-feedback') - .addClass('invalid-feedback').html('Could not connect: Check spelling and internet connection.'); + $('#wizard_root_server_result').removeClass('valid-feedback dashicons-yes-alt') + .addClass('invalid-feedback dashicons-before dashicons-dismiss').html('Could not connect: Check spelling and internet connection.'); }); } BreadWizard.prototype.root_server_keypress = function(event) { @@ -113,8 +148,10 @@ jQuery(document).ready(function($){ break; case 3: lang_options(); - case 3: + case 4: if ($("wizard_layout").val()=='') handle_error('Layout not defined'); + $('#wizard-before-create').show(); + $('#wizard-after-create').hide(); default: break; } diff --git a/admin/partials/_bmlt_server_setup.php b/admin/partials/_bmlt_server_setup.php index 3bc5e46..bf61405 100644 --- a/admin/partials/_bmlt_server_setup.php +++ b/admin/partials/_bmlt_server_setup.php @@ -29,7 +29,7 @@
- bread->emptyOption('root_server')) { echo "ERROR: Please enter a BMLT Server"; echo ''; @@ -51,7 +51,7 @@ bread->getOption('sslverify') ? 'checked' : ''; ?> />
-@@ -92,14 +92,15 @@