Skip to content

Commit

Permalink
v2.0.0-beta.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Feb 13, 2018
1 parent 1e7eec5 commit 626acd1
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Solspace Freeform Changelog

## 2.0.0-beta.7 - 2018-02-13
### Added
- Added Dutch translations.

### Changed
- Updated the install and uninstall process to be smarter (Lite vs Pro order, etc).

### Fixed
- Fixed a bug where Export CSV feature for Lite was not respecting the Remove Newlines setting.
- Fixed a bug with user / user group permissions.
- Fixed a bug where dashboard widgets' titles could not be overwritten.
- Fixed a bug where an error on install could sometimes occur.

## 2.0.0-beta.6 - 2018-02-02
### Added
- Added a 'Use Double Opt-in?' setting for MailChimp integrations.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "solspace/craft3-freeform",
"description": "The most intuitive and powerful form builder for Craft.",
"version": "2.0.0-beta.6",
"version": "2.0.0-beta.7",
"type": "craft-plugin",
"minimum-stability": "dev",
"authors": [
Expand Down
7 changes: 7 additions & 0 deletions src/Controllers/SubmissionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Solspace\Freeform\Freeform;
use Solspace\Freeform\Library\Composer\Components\Fields\Interfaces\MultipleValueInterface;
use Solspace\Freeform\Library\Composer\Components\Fields\Interfaces\NoStorageInterface;
use Solspace\Freeform\Library\Composer\Components\Fields\TextareaField;
use Solspace\Freeform\Library\DataExport\ExportDataCSV;
use Solspace\Freeform\Library\Exceptions\Composer\ComposerException;
use Solspace\Freeform\Library\Exceptions\FreeformException;
Expand Down Expand Up @@ -69,6 +70,8 @@ public function actionExport()
$this->requirePostRequest();
PermissionHelper::requirePermission(Freeform::PERMISSION_SUBMISSIONS_MANAGE);

$isRemoveNewlines = Freeform::getInstance()->settings->isRemoveNewlines();

$submissionIds = \Craft::$app->request->post('submissionIds');
$submissionIds = explode(',', $submissionIds);

Expand Down Expand Up @@ -112,6 +115,10 @@ public function actionExport()
}
}

if ($isRemoveNewlines && $field instanceof TextareaField) {
$value = trim(preg_replace('/\s+/', ' ', $value));
}

$rowData[] = $value;
}

Expand Down
36 changes: 35 additions & 1 deletion src/Freeform.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Freeform extends Plugin
const VERSION_PRO = 'pro';

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

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

$event->permissions[$this->name] = [
$permissions = [
self::PERMISSION_SUBMISSIONS_ACCESS => [
'label' => self::t('Access Submissions'),
'nested' => $submissionNestedPermissions,
Expand Down Expand Up @@ -248,6 +249,15 @@ function (RegisterUserPermissionsEvent $event) {
],
self::PERMISSION_SETTINGS_ACCESS => ['label' => self::t('Access Settings')],
];

if (!isset($event->permissions[self::PERMISSION_NAMESPACE])) {
$event->permissions[self::PERMISSION_NAMESPACE] = [];
}

$event->permissions[self::PERMISSION_NAMESPACE] = array_merge(
$event->permissions[self::PERMISSION_NAMESPACE],
$permissions
);
}
);
}
Expand Down Expand Up @@ -457,4 +467,28 @@ public function afterInstall()
$status->sortOrder = 3;
$status->save();
}

/**
* Uninstall only if Freeform Pro is not present
*
* @return bool
*/
protected function beforeUninstall(): bool
{
$isProInstalled = (bool) (new Query())
->select('id')
->from('{{%plugins}}')
->where(['handle' => 'freeform-pro'])
->one();

if ($isProInstalled) {
\Craft::$app->session->setNotice(
\Craft::t('app', 'You must uninstall Freeform Pro before you can uninstall Freeform Lite')
);

return false;
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Freeform for Craft
*
* @package Solspace:Freeform
* @author Solspace, Inc.
* @copyright Copyright (c) 2008-2016, Solspace, Inc.
* @link https://solspace.com/craft/freeform
* @license https://solspace.com/software/license-agreement
*/

namespace Solspace\Freeform\Library\Exceptions\Integrations;

use Solspace\Freeform\Library\Exceptions\FreeformException;

class IntegrationNotFoundException extends FreeformException
{
}
6 changes: 6 additions & 0 deletions src/Models/IntegrationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Solspace\Freeform\Freeform;
use Solspace\Freeform\Library\Configuration\CraftPluginConfiguration;
use Solspace\Freeform\Library\Exceptions\Integrations\IntegrationException;
use Solspace\Freeform\Library\Exceptions\Integrations\IntegrationNotFoundException;
use Solspace\Freeform\Library\Integrations\AbstractIntegration;
use Solspace\Freeform\Library\Integrations\CRM\AbstractCRMIntegration;
use Solspace\Freeform\Library\Integrations\IntegrationStorageInterface;
Expand Down Expand Up @@ -134,6 +135,7 @@ public function isOAuthConnection(): bool
/**
* @return AbstractIntegration|AbstractCRMIntegration|AbstractMailingListIntegration
* @throws IntegrationException
* @throws IntegrationNotFoundException
*/
public function getIntegrationObject()
{
Expand All @@ -154,6 +156,10 @@ public function getIntegrationObject()

$className = $this->class;

if (!class_exists($className)) {
throw new IntegrationNotFoundException(sprintf('"%s" class does not exist', $className));
}

/** @var AbstractIntegration $integration */
$integration = new $className(
$this->id,
Expand Down
4 changes: 4 additions & 0 deletions src/Models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class Settings extends Model
/** @var bool */
public $showTutorial;

/** @var bool */
public $removeNewlines;

/** @var bool */
public $defaultTemplates;

Expand Down Expand Up @@ -82,6 +85,7 @@ public function __construct(array $config = [])
$this->fieldDisplayOrder = Freeform::FIELD_DISPLAY_ORDER_NAME;
$this->showTutorial = true;
$this->defaultTemplates = true;
$this->removeNewlines = false;
$this->footerScripts = true;
$this->formSubmitDisable = true;

Expand Down
9 changes: 8 additions & 1 deletion src/Services/AbstractIntegrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Solspace\Freeform\Freeform;
use Solspace\Freeform\Library\Configuration\CraftPluginConfiguration;
use Solspace\Freeform\Library\Exceptions\Integrations\IntegrationException;
use Solspace\Freeform\Library\Exceptions\Integrations\IntegrationNotFoundException;
use Solspace\Freeform\Library\Integrations\AbstractIntegration;
use Solspace\Freeform\Library\Integrations\SettingBlueprint;
use Solspace\Freeform\Models\IntegrationModel;
Expand All @@ -38,7 +39,13 @@ public function getAllIntegrations(): array

$models = [];
foreach ($results as $result) {
$models[] = $this->createIntegrationModel($result);
$model = $this->createIntegrationModel($result);

try{
$model->getIntegrationObject();
$models[] = $model;
} catch (IntegrationNotFoundException $e) {
}
}

return $models;
Expand Down
8 changes: 8 additions & 0 deletions src/Services/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ public function isFormSubmitDisable(): bool
return (bool) $this->getSettingsModel()->formSubmitDisable;
}

/**
* @return bool
*/
public function isRemoveNewlines(): bool
{
return (bool) $this->getSettingsModel()->removeNewlines;
}

/**
* @return Settings
*/
Expand Down
8 changes: 8 additions & 0 deletions src/templates/settings/_general.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ <h2>{{ "General Settings"|t }}</h2>
errors: settings.errors("defaultTemplates"),
}) }}

{{ forms.lightswitchField({
label: "Remove Newlines from Textareas for Exporting"|t,
instructions: "Enable this to have newlines removed from Textarea fields in submissions when exporting."|t,
name: "settings[removeNewlines]",
on: settings.removeNewlines,
errors: settings.errors("removeNewlines"),
}) }}

{{ forms.lightswitchField({
label: "Disable submit button on form submit?"|t,
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,
Expand Down

0 comments on commit 626acd1

Please sign in to comment.