Skip to content

Firefly III: a personal finances manager

Change settings for expression engine.

James Cole147359646b40
diff --git a/app/Console/Commands/Upgrade/UpgradesRuleActions.php b/app/Console/Commands/Upgrade/UpgradesRuleActions.php
index 38d55c2156..b237f429f5 100644
--- a/app/Console/Commands/Upgrade/UpgradesRuleActions.php
+++ b/app/Console/Commands/Upgrade/UpgradesRuleActions.php
@@ -49,7 +49,7 @@ class UpgradesRuleActions extends Command
return 0;
}
- if (false === config('firefly.feature_flags.expression_engine')) {
+ if (false === AppConfiguration::get('enable_expression_engine', false)->data) {
$this->friendlyInfo('Expression engine is not enabled. Nothing to do.');
return 0;
diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php
index 22def0c26a..30a71af7fe 100644
--- a/app/Http/Controllers/Admin/ConfigurationController.php
+++ b/app/Http/Controllers/Admin/ConfigurationController.php
@@ -79,12 +79,14 @@ final class ConfigurationController extends Controller
$allowWebhooks = AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data;
$enableBatchProcessing = AppConfiguration::get('enable_batch_processing', true)->data;
$validUrlProtocols = AppConfiguration::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
+ $enableExpressionEngine = AppConfiguration::get('enable_expression_engine', false)->data;
return view('settings.configuration.index', [
'subTitle' => $subTitle,
'subTitleIcon' => $subTitleIcon,
'singleUserMode' => $singleUserMode,
'isDemoSite' => $isDemoSite,
+ 'enableExpressionEngine' => $enableExpressionEngine,
'siteOwner' => $siteOwner,
'enableExchangeRates' => $enableExchangeRates,
'useRunningBalance' => $useRunningBalance,
@@ -119,6 +121,7 @@ final class ConfigurationController extends Controller
AppConfiguration::set('valid_url_protocols', $data['valid_url_protocols']);
AppConfiguration::set('is_demo_site', $data['is_demo_site']);
+ AppConfiguration::set('enable_expression_engine', $data['enable_expression_engine']);
// flash message
session()->flash('success', (string) trans('firefly.configuration_updated'));
diff --git a/app/Http/Requests/ConfigurationRequest.php b/app/Http/Requests/ConfigurationRequest.php
index ab70eec2a9..df47d8cc89 100644
--- a/app/Http/Requests/ConfigurationRequest.php
+++ b/app/Http/Requests/ConfigurationRequest.php
@@ -52,6 +52,7 @@ class ConfigurationRequest extends FormRequest
'valid_url_protocols' => $this->string('valid_url_protocols'),
'is_demo_site' => $this->boolean('is_demo_site'),
'enable_batch_processing' => $this->boolean('enable_batch_processing'),
+ 'enable_expression_engine' => $this->boolean('enable_expression_engine'),
];
}
@@ -71,6 +72,7 @@ class ConfigurationRequest extends FormRequest
'enable_batch_processing' => ['min:0', 'max:1', 'numeric'],
'valid_url_protocols' => ['min:0', 'max:255'],
'is_demo_site' => ['min:0', 'max:1', 'numeric'],
+ 'enable_expression_engine' => ['min:0', 'max:1', 'numeric']
];
}
diff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.php
index 2929cd396b..4d5226e2f6 100644
--- a/app/Models/RuleAction.php
+++ b/app/Models/RuleAction.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use FireflyIII\Support\Facades\AppConfiguration;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use FireflyIII\TransactionRules\Expressions\ActionExpression;
use Illuminate\Database\Eloquent\Casts\Attribute;
@@ -39,12 +40,12 @@ class RuleAction extends Model
public function getValue(array $journal): string
{
- if (false === config('firefly.feature_flags.expression_engine')) {
+ if (false === AppConfiguration::get('enable_expression_engine', false)->data) {
Log::debug('Expression engine is disabled, returning action value as string.');
return (string) $this->action_value;
}
- if (true === config('firefly.feature_flags.expression_engine') && str_starts_with($this->action_value, '\=')) {
+ if (true === AppConfiguration::get('enable_expression_engine', false)->data && str_starts_with($this->action_value, '\=')) {
// return literal string.
return substr($this->action_value, 1);
}
diff --git a/app/Rules/IsValidActionExpression.php b/app/Rules/IsValidActionExpression.php
index ef6bc8ed48..1e3111c89d 100644
--- a/app/Rules/IsValidActionExpression.php
+++ b/app/Rules/IsValidActionExpression.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
namespace FireflyIII\Rules;
use Closure;
+use FireflyIII\Support\Facades\AppConfiguration;
use FireflyIII\TransactionRules\Expressions\ActionExpression;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Translation\PotentiallyTranslatedString;
@@ -41,7 +42,7 @@ class IsValidActionExpression implements ValidationRule
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
- if (false === config('firefly.feature_flags.expression_engine')) {
+ if (false === AppConfiguration::get('enable_expression_engine', false)->data) {
return;
}
$value ??= '';
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 0c22c0f5d6..79910ef1f2 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -37,6 +37,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Services\Password\Verifier;
+use FireflyIII\Support\Facades\AppConfiguration;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\Support\ParseDateString;
use FireflyIII\User;
@@ -334,7 +335,7 @@ class FireflyValidator extends Validator
}
// if value is an expression, assume valid
- if (true === config('firefly.feature_flags.expression_engine') && str_starts_with($value, '=') && strlen($value) > 1) {
+ if (true === AppConfiguration::get('enable_expression_engine', false)->data && str_starts_with($value, '=') && strlen($value) > 1) {
return true;
}
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index cc610ab0c5..1edff08ad5 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -2619,6 +2619,8 @@ return [
'setting_valid_url_protocols_explain' => 'Firefly III only allows urls to have standard protocols like https and ftp etc. If you\'re a techie you may want to allow others as well.',
'setting_enable_batch_processing' => 'Enable batch processing',
'setting_enable_batch_processing_explain' => 'Batch processing is a relatively new feature of Firefly III that allows a set of new transactions (aka a batch) be processed when the final transaction is submitted, and not during the submission of each individual entry. This makes data import faster, but also skips rules until the end. It is an experimental feature so disabled by default.',
+ 'setting_enable_expression_engine' => 'Enable expression engine',
+ 'setting_enable_expression_engine_explain' => 'The expression engine lets you write rule actions that are dynamic, using the data of the transaction to join text together or copy values. However, it also allows crafty users to run commands on the underlying server or Docker container. This is potentially very dangerous, so the feature is disabled by default. Only enable this when you TRUST ALL your users.',
'setting_single_user_mode' => 'Single user mode',
'setting_single_user_mode_explain' => 'By default, Firefly III only accepts one (1) registration: you. This is a security measure, preventing others from using your instance unless you allow them to. Future registrations are blocked. When you uncheck this box, others can use your instance as well, assuming they can reach it (when it is connected to the internet).',
diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php
index e8e16b2dcb..c7476b09df 100644
--- a/resources/lang/en_US/form.php
+++ b/resources/lang/en_US/form.php
@@ -48,6 +48,7 @@ return [
'auto_budget_currency_id' => 'Currency',
'external_ip' => 'Your server\'s external IP',
'attachments' => 'Attachments',
+ 'enable_expression_engine' => 'Enable expression engine',
'BIC' => 'BIC',
'verify_password' => 'Verify password security',
'source_account' => 'Source account',
diff --git a/resources/views/settings/configuration/index.blade.php b/resources/views/settings/configuration/index.blade.php
index 4bd854298f..885cfe590c 100644
--- a/resources/views/settings/configuration/index.blade.php
+++ b/resources/views/settings/configuration/index.blade.php
@@ -136,11 +136,20 @@ Technical stuff
{{ __('firefly.setting_is_demo_site_explain') }}
</p>
{!! ExpandedForm::checkbox('is_demo_site','1', $isDemoSite) !!}
+ <h4>
+ {{ __('firefly.setting_enable_expression_engine') }}
+ </h4>
+ <p>
+ {{ __('firefly.setting_enable_expression_engine_explain') }}
+ </p>
+ {!! ExpandedForm::checkbox('enable_expression_engine','1', $enableExpressionEngine) !!}
+
<p>
<button type="submit" class="btn btn-success">
{{ __('firefly.store_configuration') }}
</button>
</p>
+
</div>
</div>
</div>