Skip to content

Commit

Permalink
Merge branch 'master' into 38203-load-recaptcha-on-focus-only
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-eastgate authored Sep 11, 2023
2 parents 9ff570e + b77c0e6 commit 1a5d93a
Show file tree
Hide file tree
Showing 69 changed files with 1,005 additions and 124 deletions.
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 37 additions & 19 deletions js/onoffice-honeypot.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
var form = form || {};
form.type = form.type || '';
jQuery(document).ready(function ($) {
if (honeypot_enabled['honeypotValue'] == true && form.type !== '' && form.type !== 'applicantsearch') {
var messageTextarea = $('textarea[name="message"]');
var messageInput = $('input[name="message"]');
if(messageTextarea.length === 1){
messageTextarea.attr('name', 'tmpField');
} else if (messageInput.length === 1) {
messageInput.attr('name', 'tmpField');
}
var label = $('<label>').text('Message:').attr("class", "message");
var input = $('<input>').attr({
'type': 'text',
'name': 'message',
'class': 'message'
const formElements = getFormsBySpecialHtmlAttribute();

addHoneypotToForms(formElements);

function getFormsBySpecialHtmlAttribute() {
const formElements = [];
const forms = document.querySelectorAll('.oo-form, #onoffice-form');

forms.forEach(form => {
const dataAttr = form.getAttribute('data-applicant-form-id');
if (dataAttr === null) {
formElements.push(form);
}
});
$("#onoffice-form").prepend(input);
$("#onoffice-form").prepend(label);
var originalInput = $('input[name="message"]');
originalInput.before(label, input);

return formElements;
}

function addHoneypotToForms(formElements) {
formElements.forEach((formElement) => {
const messageTextarea = $(formElement).find('textarea[name="message"]');
const messageInput = $(formElement).find('input[name="message"]');
if (messageTextarea.length === 1) {
messageTextarea.attr('name', 'tmpField');
} else if (messageInput.length === 1) {
messageInput.attr('name', 'tmpField');
}
const label = $('<label>').text('Message:').attr("class", "message");
const input = $('<input>').attr({
'type': 'text',
'name': 'message',
'class': 'message'
});
$(formElement).prepend(input);
$(formElement).prepend(label);
const originalInput = $(formElement).find('input[name="message"]');
originalInput.before(label, input);
});
};
});
24 changes: 24 additions & 0 deletions js/onoffice-prevent-double-form-submission.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
jQuery(document).ready(function ($) {
const formElements = document.querySelectorAll('.oo-form, #onoffice-form');

handleFormSubmissions(formElements);

function handleFormSubmissions(formElements) {
formElements.forEach((formElement) => {
let submitted = false;
const submitButton = $(formElement).find('.submit_button');

$(formElement).on('submit', function (event) {
if (submitted) {
event.preventDefault();
} else {
submitted = true;
}
});

submitButton.on('click', function () {
submitButton.prop('disabled', true);
});
});
}
});
22 changes: 13 additions & 9 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Author: onOffice GmbH
Author URI: https://en.onoffice.com/
Description: Your connection to onOffice: This plugin enables you to have quick access to estates and formsno additional sync with the software is needed. Consult support@onoffice.de for source code.
Version: 4.11.1
Version: 4.14
License: AGPL 3+
License URI: https://www.gnu.org/licenses/agpl-3.0
Text Domain: onoffice-for-wp-websites
Expand Down Expand Up @@ -66,6 +66,8 @@
use onOffice\WPlugin\Utility\Redirector;
use onOffice\WPlugin\WP\WPQueryWrapper;

const DEFAULT_LIMIT_CHARACTER_TITLE = 60;

define('ONOFFICE_DI_CONFIG_PATH', implode(DIRECTORY_SEPARATOR, [ONOFFICE_PLUGIN_DIR, 'config', 'di-config.php']));

$pDIBuilder = new ContainerBuilder();
Expand Down Expand Up @@ -161,7 +163,16 @@
}, 1, 3);
} else {
add_filter('document_title_parts', function ($title) use ($pDI){
return $pDI->get(EstateViewDocumentTitleBuilder::class)->buildDocumentTitle($title);
$result = $pDI->get(EstateViewDocumentTitleBuilder::class)->buildDocumentTitle($title);
if (strlen($result['title']) > DEFAULT_LIMIT_CHARACTER_TITLE) {
$shortenedTitle = substr($result['title'], 0, DEFAULT_LIMIT_CHARACTER_TITLE);
if (substr($result['title'], DEFAULT_LIMIT_CHARACTER_TITLE, 1) != ' ') {
$shortenedTitle = substr($shortenedTitle, 0, strrpos($shortenedTitle, ' '));
}
$result['title'] = $shortenedTitle;
}

return $result;
}, 10, 2);
}

Expand Down Expand Up @@ -399,11 +410,4 @@ function update_status_close_action_button_option()
};
}, 500);

function do_extra_enqueue_honeypot() {
$honeypot_enabled = get_option('onoffice-settings-honeypot');
wp_localize_script( 'onoffice-honeypot', 'honeypot_enabled', array( 'honeypotValue' => $honeypot_enabled ) );
}

add_action( 'wp_enqueue_scripts', 'do_extra_enqueue_honeypot' );

return $pDI;
3 changes: 3 additions & 0 deletions plugin/AddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class AddressList
'emailprivate',
'emailbusiness',
'email',
'faxprivate',
'faxbusiness',
'fax',
];

const DEFAULT_FIELDS_REPLACE = [
Expand Down
15 changes: 15 additions & 0 deletions plugin/DataView/DataListView.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class DataListView
/** */
const SORT_BY_STANDARD_VALUES = 'sortby';

/** */
const SHOW_PRICE_ON_REQUEST = '1';

/** @var int */
private $_id = null;

Expand Down Expand Up @@ -145,9 +148,13 @@ class DataListView
/** @var string */
private $_showReferenceEstate = '0';

/** @var bool */
private $_showMap = false;

/** @var bool */
private $_showPriceOnRequest = false;


/**
*
* @param int $id
Expand Down Expand Up @@ -214,6 +221,14 @@ public function getExpose(): string
public function getAddressFields(): array
{ return $this->_addressFields; }

/** @return bool */
public function getShowMap(): bool
{ return (bool) $this->_showMap; }

/** @param bool $showMap */
public function setShowMap(bool $showMap)
{ $this->_showMap = $showMap; }

/** @param bool $random */
public function setRandom(bool $random)
{ $this->_random = $random; }
Expand Down
1 change: 1 addition & 0 deletions plugin/DataView/DataListViewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function createListViewByRow(array $row): DataViewFilterableFields
$pListView->setSortByUserDefinedDirection((int)$row['sortByUserDefinedDirection']);
$pListView->setSortByUserValues($row[DataListView::SORT_BY_USER_VALUES]);
$pListView->setShowReferenceStatus($row['show_reference_estate'] ?? 1);
$pListView->setShowMap($row['show_map']);
$pListView->setShowPriceOnRequest((bool)$row['show_price_on_request']);

$geoFieldsAll = [
Expand Down
3 changes: 3 additions & 0 deletions plugin/DataView/DataSimilarEstatesSettingsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,8 @@ private function configureDataSimilarEstatesSettings(DataViewSimilarEstates $pDa
$pDataViewSimilar->getCustomLabels());
$pDataViewSimilar->setShowPriceOnRequest
($row[DataViewSimilarEstates::FIELD_PRICE_ON_REQUEST] ?? false);
$pDataViewSimilar->setPictureTypes
($row[DataViewSimilarEstates::PICTURES] ??
$pDataViewSimilar->getPictureTypes());
}
}
3 changes: 3 additions & 0 deletions plugin/DataView/DataSimilarView.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class DataSimilarView
/** */
const ENABLE_SIMILAR_ESTATES = 'enablesimilarestates';

/** */
const PICTURES = 'pictures';

/** @var string[] */
private $_fields = [
'Id',
Expand Down
12 changes: 11 additions & 1 deletion plugin/DataView/DataViewSimilarEstates.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class DataViewSimilarEstates
/** */
const FIELD_SIMILAR_ESTATES_TEMPLATE = 'similar_estates_template';

/** */
const PICTURES = 'pictures';

/** */
const FIELD_PRICE_ON_REQUEST = 'show_price_on_request';

Expand Down Expand Up @@ -97,6 +100,9 @@ class DataViewSimilarEstates
/** @var array */
private $_customLabel = [];

/** @var string[] */
private $_pictureTypes = [];

/** @var bool */
private $_showPriceOnRequest = false;

Expand Down Expand Up @@ -162,7 +168,11 @@ public function getName(): string

/** @return array */
public function getPictureTypes(): array
{ return [ImageTypes::TITLE]; }
{ return $this->_pictureTypes; }

/** @param array $pictureTypes */
public function setPictureTypes(array $pictureTypes)
{ $this->_pictureTypes = $pictureTypes; }

/** @return string */
public function getTemplate(): string
Expand Down
Loading

0 comments on commit 1a5d93a

Please sign in to comment.