Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
v2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Sep 12, 2018
1 parent add65af commit 8447d20
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 174 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Solspace Freeform Changelog

## 2.3.0 - 2018-09-12
### Added
- Added ability to set Mailing List fields as hidden fields (automatically opting in users).

### Changed
- Updated for compatibility with future Freeform Payments add-on plugin.
- Updated CP single submission view to include a note for Mailing List fields that mentions data is not stored for this field type.
- Updated new field creation to error if maximum number of fields are reached.
- Updated Freeform's automatically inserted JS to no longer include `type="text/javascript"`.
- Updated reCAPTCHA settings to be stored in Freeform Lite rather than Pro.
- Updated Element Connections feature to only attempt to fire when it's properly set up (to eliminate form errors if accidentally partially added).
- Improved AJAX script in Demo Templates to better handle script loading and IE11 compatibility.

### Fixed
- Fixed a bug where Salesforce API connections were not holding for more than a day or so.
- Fixed a bug where the Freeform 1.x to 2.x (Craft 2.x to 3.x) migration path could error in some cases.
- Fixed a bug where deleting forms and fields were not returning proper AJAX return statuses.
- Fixed a bug where the Constant Contact integration was not correctly working.
- Fixed a bug where the Dynamic Recipients field as Checkbox OR Radio would default to the first option being checked IF none were selected and form reloaded after an error was triggered.
- Fixed a bug where required asterisks were out of position in CP submission view.
- Fixed a bug where permissions for Manage Export Profiles was not working correctly.

## 2.2.2 - 2018-08-02
### Changed
- Updated Element Connections feature to allow mapping Freeform File Upload fields to the User Photo field.
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "solspace/craft3-freeform-pro",
"description": "Adds API integrations, premium field types, advanced exporting and widgets to Freeform.",
"version": "2.2.2",
"version": "2.3.0",
"type": "craft-plugin",
"minimum-stability": "dev",
"authors": [
Expand All @@ -11,6 +11,7 @@
}
],
"require": {
"craftcms/cms": "^3.0.0",
"solspace/craft3-commons": "^1.0.8"
},
"autoload": {
Expand All @@ -19,7 +20,7 @@
}
},
"extra": {
"schemaVersion": "2.0.11",
"schemaVersion": "2.1.0",
"handle": "freeform-pro",
"class": "Solspace\\FreeformPro\\FreeformPro",
"name": "Freeform Pro",
Expand Down
11 changes: 8 additions & 3 deletions src/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function actionSaveSettings()
$this->requirePostRequest();
$postData = \Craft::$app->request->post('settings', []);

$plugin = FreeformPro::getInstance();
$plugin = Freeform::getInstance();
$plugin->setSettings($postData);

if (\Craft::$app->plugins->savePluginSettings($plugin, $postData)) {
Expand All @@ -38,6 +38,11 @@ public function actionSaveSettings()
);
}

/**
* @return Response
* @throws \yii\base\InvalidConfigException
* @throws \yii\web\ForbiddenHttpException
*/
public function actionProvideSetting(): Response
{
PermissionHelper::requirePermission(Freeform::PERMISSION_SETTINGS_ACCESS);
Expand All @@ -48,8 +53,8 @@ public function actionProvideSetting(): Response
return $this->renderTemplate(
'freeform-pro/_settings/' . (string) $template,
[
'settings' => FreeformPro::getInstance()->getSettings(),
'settings' => Freeform::getInstance()->getSettings(),
]
);
}
}
}
126 changes: 0 additions & 126 deletions src/Fields/NumberField.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Fields/RecaptchaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Solspace\FreeformPro\Fields;

use Solspace\Freeform\Freeform;
use Solspace\Freeform\Library\Composer\Components\AbstractField;
use Solspace\Freeform\Library\Composer\Components\Fields\Interfaces\InputOnlyInterface;
use Solspace\Freeform\Library\Composer\Components\Fields\Interfaces\NoStorageInterface;
use Solspace\Freeform\Library\Composer\Components\Fields\Interfaces\SingleValueInterface;
use Solspace\Freeform\Library\Composer\Components\Fields\Traits\SingleValueTrait;
use Solspace\FreeformPro\FreeformPro;

class RecaptchaField extends AbstractField implements NoStorageInterface, SingleValueInterface, InputOnlyInterface
{
Expand All @@ -34,7 +34,7 @@ public function getHandle()
*/
protected function getInputHtml(): string
{
$key = FreeformPro::getInstance()->getSettings()->recaptchaKey;
$key = Freeform::getInstance()->getSettings()->recaptchaKey;

$output = '<script src="https://www.google.com/recaptcha/api.js"></script>';
$output .= '<div class="g-recaptcha" data-sitekey="' . ($key ?: 'invalid') . '"></div>';
Expand Down
29 changes: 13 additions & 16 deletions src/Integrations/CRM/SalesforceLead.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,22 +259,19 @@ public function checkConnection(): bool
$client = new Client();
$endpoint = $this->getEndpoint('/');

try {
$response = $client->get(
$endpoint,
[
'headers' => [
'Authorization' => 'Bearer ' . $this->getAccessToken(),
'Content-Type' => 'application/json',
],
]
);
$json = json_decode((string) $response->getBody(), true);

return !empty($json);
} catch (RequestException $exception) {
throw new IntegrationException($exception->getMessage(), $exception->getCode(), $exception->getPrevious());
}
$response = $client->get(
$endpoint,
[
'headers' => [
'Authorization' => 'Bearer ' . $this->getAccessToken(),
'Content-Type' => 'application/json',
],
]
);

$json = json_decode((string) $response->getBody(), true);

return !empty($json);
}

/**
Expand Down
22 changes: 1 addition & 21 deletions src/Models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,4 @@

class Settings extends Model
{
/** @var bool */
public $recaptchaEnabled;

/** @var string */
public $recaptchaKey;

/** @var string */
public $recaptchaSecret;

/**
* @return array
*/
public function rules(): array
{
return [
[['recaptchaKey', 'recaptchaSecret'], 'required', 'when' => function (Settings $model) {
return (bool) $model->recaptchaEnabled;
}],
];
}
}
}
6 changes: 5 additions & 1 deletion src/Services/RecaptchaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
use craft\base\Component;
use GuzzleHttp\Client;
use Solspace\Freeform\Events\Fields\ValidateEvent;
use Solspace\Freeform\Freeform;
use Solspace\FreeformPro\Fields\RecaptchaField;
use Solspace\FreeformPro\FreeformPro;

class RecaptchaService extends Component
{
/**
* @param ValidateEvent $event
*/
public function validateRecaptcha(ValidateEvent $event)
{
$field = $event->getField();
Expand All @@ -19,7 +23,7 @@ public function validateRecaptcha(ValidateEvent $event)
if (!$response) {
$field->addError(FreeformPro::t('Please verify that you are not a robot.'));
} else {
$secret = FreeformPro::getInstance()->getSettings()->recaptchaSecret;
$secret = Freeform::getInstance()->getSettings()->recaptchaSecret;

$client = new Client();
$response = $client->post('https://www.google.com/recaptcha/api/siteverify', [
Expand Down
68 changes: 68 additions & 0 deletions src/migrations/m180829_100554_TransferRecaptchaSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace Solspace\FreeformPro\migrations;

use craft\db\Migration;
use craft\db\Query;

/**
* m180829_100554_TransferRecaptchaSettings migration.
*/
class m180829_100554_TransferRecaptchaSettings extends Migration
{
/**
* @inheritdoc
*/
public function safeUp()
{
$proSettings = (new Query())
->select('settings')
->from('{{%plugins}}')
->where(['handle' => 'freeform-pro'])
->scalar();

$liteSettings = (new Query())
->select('settings')
->from('{{%plugins}}')
->where(['handle' => 'freeform'])
->scalar();

if ($liteSettings) {
$liteSettings = json_decode($liteSettings, true);
} else {
$liteSettings = [];
}

if ($proSettings) {
$proSettings = json_decode($proSettings, true);
if (isset($proSettings['recaptchaEnabled'])) {
$liteSettings['recaptchaEnabled'] = 1;
$liteSettings['recaptchaKey'] = $proSettings['recaptchaKey'];
$liteSettings['recaptchaSecret'] = $proSettings['recaptchaSecret'];

$this->update(
'{{%plugins}}',
['settings' => json_encode($liteSettings)],
['handle' => 'freeform']
);

$this->update(
'{{%plugins}}',
['settings' => null],
['handle' => 'freeform-pro']
);
}
}

return true;
}

/**
* @inheritdoc
*/
public function safeDown()
{
echo "m180829_100554_TransferRecaptchaSettings cannot be reverted.\n";
return false;
}
}
Loading

0 comments on commit 8447d20

Please sign in to comment.