function wpsolr_admin_action_form_temporary_index(&$response_object) { // recaptcha response $g_recaptcha_response = isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : ''; // A recaptcha response must be set if (empty($g_recaptcha_response)) { return; } $form_data = WpSolrExtensions::extract_form_data(true, array('managed_solr_service_id' => array('default_value' => '', 'can_be_empty' => false))); $managed_solr_server = new OptionManagedSolrServer($form_data['managed_solr_service_id']['value']); $response_object = $managed_solr_server->call_rest_create_solr_index($g_recaptcha_response); if (isset($response_object) && OptionManagedSolrServer::is_response_ok($response_object)) { $option_indexes_object = new OptionIndexes(); $option_indexes_object->create_index($managed_solr_server->get_id(), OptionIndexes::STORED_INDEX_TYPE_MANAGED_TEMPORARY, OptionManagedSolrServer::get_response_result($response_object, 'urlCore'), 'Test index from ' . $managed_solr_server->get_label(), OptionManagedSolrServer::get_response_result($response_object, 'urlScheme'), OptionManagedSolrServer::get_response_result($response_object, 'urlDomain'), OptionManagedSolrServer::get_response_result($response_object, 'urlPort'), '/' . OptionManagedSolrServer::get_response_result($response_object, 'urlPath') . '/' . OptionManagedSolrServer::get_response_result($response_object, 'urlCore'), OptionManagedSolrServer::get_response_result($response_object, 'key'), OptionManagedSolrServer::get_response_result($response_object, 'secret')); // Redirect automatically to Solr options if it is the first solr index created if (count($option_indexes_object->get_indexes()) === 1) { $redirect_location = '?page=solr_settings&tab=solr_option'; header("Location: {$redirect_location}", true, 302); // wp_redirect() is not found exit; } } }
/** * Page listing all managed Solr account's indexes. */ ?> <div class="wdm-vertical-tabs-content"> <div class="wrapper"> <h4 class='head_div'>Select an index</h4> <?php // Add menu items for all the managed Solr account's indexes $subtabs = array(); $result_object = $managed_solr_server->call_rest_account_indexes($account_uuid); if (OptionManagedSolrServer::is_response_ok($result_object)) { foreach ($managed_solr_server->get_response_results($result_object) as $result) { $subtabs[$managed_solr_server->get_id() . ':' . $result->uuid . ':' . $result->uuid] = $result->label; } } // Display menu $subtab_composed = wpsolr_admin_sub_tabs($subtabs); // Display index detail if index appears in parameters $subtab_exploded = explode(':', $subtab_composed); if (count($subtab_exploded) >= 3) { $subtab = $subtab_exploded[2]; } ?> </div> </div>
$response_error = 'This temporary solr core has expired and was therefore deleted. You can remove it from your configuration'; // No more readonly therefore $is_index_type_temporary = false; $is_index_readonly = false; } else { $is_index_type_temporary_on_server = OptionManagedSolrServer::get_response_result($response_object, 'isTemporary'); if (!$is_index_type_temporary_on_server) { // Change the solr index type to managed $option_object->update_index_property($index_indice, OptionIndexes::INDEX_TYPE, OptionIndexes::STORED_INDEX_TYPE_MANAGED); // No more readonly therefore $is_index_type_temporary = false; $is_index_readonly = false; } } } else { $response_error = isset($response_object) && !OptionManagedSolrServer::is_response_ok($response_object) ? OptionManagedSolrServer::get_response_error_message($response_object) : ''; } } } ?> <div id="<?php echo $subtab != $index_indice ? $index_indice : "current_index_configuration_edited_id"; ?> " class="wrapper" <?php echo $subtab != $index_indice ? "style='display:none'" : ""; ?> >
/** * Ajax call to verify a license */ public static function ajax_verify_licence() { $option_licenses = new OptionLicenses(); $licenses = $option_licenses->get_licenses(); $license_package = isset($_POST['data']) && isset($_POST['data'][self::FIELD_LICENSE_PACKAGE]) ? $_POST['data'][self::FIELD_LICENSE_PACKAGE] : null; $license_activation_uuid = $option_licenses->get_license_activation_uuid($license_package); if (empty($license_activation_uuid)) { $licenses[$license_package] = array(self::FIELD_LICENSE_SUBSCRIPTION_NUMBER => $licenses[$license_package][self::FIELD_LICENSE_SUBSCRIPTION_NUMBER]); self::set_option_data(self::OPTION_LICENSES, $licenses); echo json_encode((object) array('status' => (object) array('state' => 'ERROR', 'message' => 'This license activation code is missing. Try to unactivate manually, by signin to your subscription account.'))); die; } $managed_solr_server = new OptionManagedSolrServer(); $response_object = $managed_solr_server->call_rest_verify_license(self::get_license_api_url(), $license_activation_uuid); if (isset($response_object) && OptionManagedSolrServer::is_response_ok($response_object)) { if (isset($licenses[$license_package])) { // Remove the license type activation $licenses = self::get_option_data(self::OPTION_LICENSES, array()); unset($licenses[$license_package][self::FIELD_NEEDS_VERIFICATION]); self::set_option_data(self::OPTION_LICENSES, $licenses); } } // Return the whole object echo json_encode($response_object); die; }