Skip to content

Commit 626acd1

Browse files
committed
v2.0.0-beta.7
1 parent 1e7eec5 commit 626acd1

File tree

10 files changed

+108
-3
lines changed

10 files changed

+108
-3
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Solspace Freeform Changelog
22

3+
## 2.0.0-beta.7 - 2018-02-13
4+
### Added
5+
- Added Dutch translations.
6+
7+
### Changed
8+
- Updated the install and uninstall process to be smarter (Lite vs Pro order, etc).
9+
10+
### Fixed
11+
- Fixed a bug where Export CSV feature for Lite was not respecting the Remove Newlines setting.
12+
- Fixed a bug with user / user group permissions.
13+
- Fixed a bug where dashboard widgets' titles could not be overwritten.
14+
- Fixed a bug where an error on install could sometimes occur.
15+
316
## 2.0.0-beta.6 - 2018-02-02
417
### Added
518
- Added a 'Use Double Opt-in?' setting for MailChimp integrations.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "solspace/craft3-freeform",
33
"description": "The most intuitive and powerful form builder for Craft.",
4-
"version": "2.0.0-beta.6",
4+
"version": "2.0.0-beta.7",
55
"type": "craft-plugin",
66
"minimum-stability": "dev",
77
"authors": [

src/Controllers/SubmissionsController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Solspace\Freeform\Freeform;
1717
use Solspace\Freeform\Library\Composer\Components\Fields\Interfaces\MultipleValueInterface;
1818
use Solspace\Freeform\Library\Composer\Components\Fields\Interfaces\NoStorageInterface;
19+
use Solspace\Freeform\Library\Composer\Components\Fields\TextareaField;
1920
use Solspace\Freeform\Library\DataExport\ExportDataCSV;
2021
use Solspace\Freeform\Library\Exceptions\Composer\ComposerException;
2122
use Solspace\Freeform\Library\Exceptions\FreeformException;
@@ -69,6 +70,8 @@ public function actionExport()
6970
$this->requirePostRequest();
7071
PermissionHelper::requirePermission(Freeform::PERMISSION_SUBMISSIONS_MANAGE);
7172

73+
$isRemoveNewlines = Freeform::getInstance()->settings->isRemoveNewlines();
74+
7275
$submissionIds = \Craft::$app->request->post('submissionIds');
7376
$submissionIds = explode(',', $submissionIds);
7477

@@ -112,6 +115,10 @@ public function actionExport()
112115
}
113116
}
114117

118+
if ($isRemoveNewlines && $field instanceof TextareaField) {
119+
$value = trim(preg_replace('/\s+/', ' ', $value));
120+
}
121+
115122
$rowData[] = $value;
116123
}
117124

src/Freeform.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class Freeform extends Plugin
8585
const VERSION_PRO = 'pro';
8686

8787
const PERMISSIONS_HELP_LINK = 'https://solspace.com/craft/freeform/docs/demo-templates';
88+
const PERMISSION_NAMESPACE = 'Freeform';
8889

8990
const VERSION_CACHE_KEY = 'freeform_version';
9091
const VERSION_CACHE_TIMESTAMP_KEY = 'freeform_version_timestamp';
@@ -219,7 +220,7 @@ function (RegisterUserPermissionsEvent $event) {
219220
$submissionNestedPermissions[$permissionName] = ['label' => 'For ' . $form->name];
220221
}
221222

222-
$event->permissions[$this->name] = [
223+
$permissions = [
223224
self::PERMISSION_SUBMISSIONS_ACCESS => [
224225
'label' => self::t('Access Submissions'),
225226
'nested' => $submissionNestedPermissions,
@@ -248,6 +249,15 @@ function (RegisterUserPermissionsEvent $event) {
248249
],
249250
self::PERMISSION_SETTINGS_ACCESS => ['label' => self::t('Access Settings')],
250251
];
252+
253+
if (!isset($event->permissions[self::PERMISSION_NAMESPACE])) {
254+
$event->permissions[self::PERMISSION_NAMESPACE] = [];
255+
}
256+
257+
$event->permissions[self::PERMISSION_NAMESPACE] = array_merge(
258+
$event->permissions[self::PERMISSION_NAMESPACE],
259+
$permissions
260+
);
251261
}
252262
);
253263
}
@@ -457,4 +467,28 @@ public function afterInstall()
457467
$status->sortOrder = 3;
458468
$status->save();
459469
}
470+
471+
/**
472+
* Uninstall only if Freeform Pro is not present
473+
*
474+
* @return bool
475+
*/
476+
protected function beforeUninstall(): bool
477+
{
478+
$isProInstalled = (bool) (new Query())
479+
->select('id')
480+
->from('{{%plugins}}')
481+
->where(['handle' => 'freeform-pro'])
482+
->one();
483+
484+
if ($isProInstalled) {
485+
\Craft::$app->session->setNotice(
486+
\Craft::t('app', 'You must uninstall Freeform Pro before you can uninstall Freeform Lite')
487+
);
488+
489+
return false;
490+
}
491+
492+
return true;
493+
}
460494
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Freeform for Craft
4+
*
5+
* @package Solspace:Freeform
6+
* @author Solspace, Inc.
7+
* @copyright Copyright (c) 2008-2016, Solspace, Inc.
8+
* @link https://solspace.com/craft/freeform
9+
* @license https://solspace.com/software/license-agreement
10+
*/
11+
12+
namespace Solspace\Freeform\Library\Exceptions\Integrations;
13+
14+
use Solspace\Freeform\Library\Exceptions\FreeformException;
15+
16+
class IntegrationNotFoundException extends FreeformException
17+
{
18+
}

src/Models/IntegrationModel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Solspace\Freeform\Freeform;
1616
use Solspace\Freeform\Library\Configuration\CraftPluginConfiguration;
1717
use Solspace\Freeform\Library\Exceptions\Integrations\IntegrationException;
18+
use Solspace\Freeform\Library\Exceptions\Integrations\IntegrationNotFoundException;
1819
use Solspace\Freeform\Library\Integrations\AbstractIntegration;
1920
use Solspace\Freeform\Library\Integrations\CRM\AbstractCRMIntegration;
2021
use Solspace\Freeform\Library\Integrations\IntegrationStorageInterface;
@@ -134,6 +135,7 @@ public function isOAuthConnection(): bool
134135
/**
135136
* @return AbstractIntegration|AbstractCRMIntegration|AbstractMailingListIntegration
136137
* @throws IntegrationException
138+
* @throws IntegrationNotFoundException
137139
*/
138140
public function getIntegrationObject()
139141
{
@@ -154,6 +156,10 @@ public function getIntegrationObject()
154156

155157
$className = $this->class;
156158

159+
if (!class_exists($className)) {
160+
throw new IntegrationNotFoundException(sprintf('"%s" class does not exist', $className));
161+
}
162+
157163
/** @var AbstractIntegration $integration */
158164
$integration = new $className(
159165
$this->id,

src/Models/Settings.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class Settings extends Model
4545
/** @var bool */
4646
public $showTutorial;
4747

48+
/** @var bool */
49+
public $removeNewlines;
50+
4851
/** @var bool */
4952
public $defaultTemplates;
5053

@@ -82,6 +85,7 @@ public function __construct(array $config = [])
8285
$this->fieldDisplayOrder = Freeform::FIELD_DISPLAY_ORDER_NAME;
8386
$this->showTutorial = true;
8487
$this->defaultTemplates = true;
88+
$this->removeNewlines = false;
8589
$this->footerScripts = true;
8690
$this->formSubmitDisable = true;
8791

src/Services/AbstractIntegrationService.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Solspace\Freeform\Freeform;
1717
use Solspace\Freeform\Library\Configuration\CraftPluginConfiguration;
1818
use Solspace\Freeform\Library\Exceptions\Integrations\IntegrationException;
19+
use Solspace\Freeform\Library\Exceptions\Integrations\IntegrationNotFoundException;
1920
use Solspace\Freeform\Library\Integrations\AbstractIntegration;
2021
use Solspace\Freeform\Library\Integrations\SettingBlueprint;
2122
use Solspace\Freeform\Models\IntegrationModel;
@@ -38,7 +39,13 @@ public function getAllIntegrations(): array
3839

3940
$models = [];
4041
foreach ($results as $result) {
41-
$models[] = $this->createIntegrationModel($result);
42+
$model = $this->createIntegrationModel($result);
43+
44+
try{
45+
$model->getIntegrationObject();
46+
$models[] = $model;
47+
} catch (IntegrationNotFoundException $e) {
48+
}
4249
}
4350

4451
return $models;

src/Services/SettingsService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ public function isFormSubmitDisable(): bool
136136
return (bool) $this->getSettingsModel()->formSubmitDisable;
137137
}
138138

139+
/**
140+
* @return bool
141+
*/
142+
public function isRemoveNewlines(): bool
143+
{
144+
return (bool) $this->getSettingsModel()->removeNewlines;
145+
}
146+
139147
/**
140148
* @return Settings
141149
*/

src/templates/settings/_general.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ <h2>{{ "General Settings"|t }}</h2>
7070
errors: settings.errors("defaultTemplates"),
7171
}) }}
7272

73+
{{ forms.lightswitchField({
74+
label: "Remove Newlines from Textareas for Exporting"|t,
75+
instructions: "Enable this to have newlines removed from Textarea fields in submissions when exporting."|t,
76+
name: "settings[removeNewlines]",
77+
on: settings.removeNewlines,
78+
errors: settings.errors("removeNewlines"),
79+
}) }}
80+
7381
{{ forms.lightswitchField({
7482
label: "Disable submit button on form submit?"|t,
7583
instructions: "Enable this to automatically disable the form's submit button when the form is submitted. This will prevent the form from double-submitting."|t,

0 commit comments

Comments
 (0)